From da68e190f69651b68b28d27de3e92fe0125e106a Mon Sep 17 00:00:00 2001 From: Ghost581 <85649313+Ghost581X@users.noreply.github.com> Date: Fri, 10 Jan 2025 19:25:34 +0100 Subject: [PATCH] heretic update 4 Signed-off-by: Ghost581 <85649313+Ghost581X@users.noreply.github.com> --- Resources/Textures/Shaders/nightvision.swsl | 76 ++++++++++----------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/Resources/Textures/Shaders/nightvision.swsl b/Resources/Textures/Shaders/nightvision.swsl index 8a3e7706ada..c00b260344e 100644 --- a/Resources/Textures/Shaders/nightvision.swsl +++ b/Resources/Textures/Shaders/nightvision.swsl @@ -1,38 +1,38 @@ -light_mode unshaded; - -uniform sampler2D SCREEN_TEXTURE; -uniform highp vec3 tint; // Colour of the tint -uniform highp float luminance_threshold; // number between 0 and 1 -uniform highp float noise_amount; // number between 0 and 1 - -lowp float rand (lowp vec2 n) { - return 0.5 + 0.5 * fract (sin (dot (n.xy, vec2 (12.9898, 78.233)))* 43758.5453); -} - -void fragment() { - - highp vec4 color = zTextureSpec(SCREEN_TEXTURE, FRAGCOORD.xy * SCREEN_PIXEL_SIZE); - - // convert color to grayscale using luminance - highp float grey = dot(color.rgb, vec3(0.298, 0.5882, 0.1137)); - - // calculate local threshold - highp float threshold = grey * luminance_threshold; - - // amplify low luminance parts - if (grey < threshold) { - grey += (threshold - grey) * 0.5; - if (grey > 1.0) { - grey = 1.0; - } - } - - // apply night vision color tint - color.rgb = mix(color.rgb, tint, grey); - - // add some noise for realism - lowp float noise = rand(FRAGCOORD.xy + TIME) * noise_amount / 10.0; - color.rgb += noise; - - COLOR = color; -} +light_mode unshaded; + +uniform sampler2D SCREEN_TEXTURE; +uniform highp vec3 tint; // Colour of the tint +uniform highp float luminance_threshold; // number between 0 and 1 +uniform highp float noise_amount; // number between 0 and 1 + +lowp float rand (lowp vec2 n) { + return 0.5 + 0.5 * fract (sin (dot (n.xy, vec2 (12.9898, 78.233)))* 43758.5453); +} + +void fragment() { + + highp vec4 color = zTextureSpec(SCREEN_TEXTURE, FRAGCOORD.xy * SCREEN_PIXEL_SIZE); + + // convert color to grayscale using luminance + highp float grey = dot(color.rgb, vec3(0.298, 0.5882, 0.1137)); + + // calculate local threshold + highp float threshold = grey * luminance_threshold; + + // amplify low luminance parts + if (grey < threshold) { + grey += (threshold - grey) * 0.5; + if (grey > 1.0) { + grey = 1.0; + } + } + + // apply night vision color tint + color.rgb = mix(color.rgb, tint, grey); + + // add some noise for realism + lowp float noise = rand(FRAGCOORD.xy + TIME) * noise_amount / 10.0; + color.rgb += noise; + + COLOR = color; +} \ No newline at end of file