Skip to content

Commit

Permalink
feat: add black-and-white shader
Browse files Browse the repository at this point in the history
  • Loading branch information
Silverlan committed Nov 3, 2024
1 parent 97865a1 commit 4527929
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions assets/addons/bw_shader/lua/autorun/client/cl_bw_shader.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--[[
Copyright (C) 2024 Silverlan
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
]]

include("/shaders/bw/shader.lua")
16 changes: 16 additions & 0 deletions assets/addons/bw_shader/lua/shaders/bw/shader.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--[[
Copyright (C) 2024 Silverlan
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
]]

local Shader = util.register_class("shader.BwShader", shader.BasePbr)

Shader.FragmentShader = "programs/scene/bw"
Shader.VertexShader = "programs/scene/textured"
function Shader:InitializePipeline(pipelineInfo, pipelineIdx)
shader.BasePbr.InitializePipeline(self, pipelineInfo, pipelineIdx)
end
shader.register("bw", Shader)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c_bw = "Black and White"
17 changes: 17 additions & 0 deletions assets/addons/bw_shader/shaders/programs/scene/bw.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#version 440

#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

#include "/programs/scene/pbr/fs_core.glsl"

void main()
{
vec2 uv = get_uv_coordinates();
vec4 albedoColor = fetch_albedo_map(uv, get_instance_color());
fs_color = calc_pbr(albedoColor, uv, u_pushConstants.debugMode);
float luminance = calc_luminance(fs_color.rgb);
fs_color.rgb = vec3(luminance, luminance, luminance);
if(CSPEC_BLOOM_OUTPUT_ENABLED == 1)
extract_bright_color(fs_color, u_renderer.bloomThreshold);
}

0 comments on commit 4527929

Please sign in to comment.