Skip to content

Commit

Permalink
heretic update 4
Browse files Browse the repository at this point in the history
Signed-off-by: Ghost581 <[email protected]>
  • Loading branch information
Ghost581X authored Jan 10, 2025
1 parent 6642a91 commit da68e19
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions Resources/Textures/Shaders/nightvision.swsl
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit da68e19

Please sign in to comment.