Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform sampler2D gameview; // "diffuse" texture
- uniform sampler2D lightmap;
- uniform vec4 nv_color;
- uniform float nv_intensity;
- uniform vec4 nv_desaturation_params;
- uniform vec4 nv_light_params;
- uniform float darkness;
- uniform float timer;
- uniform bool render_darkness;
- bool use_nightvision = nv_intensity > 0.0;
- void main()
- {
- vec2 uv = gl_TexCoord[0].xy;
- vec2 st = uv - vec2(0.5, 0.5);
- float angle = -0.5;
- float distance = 2.5;
- float f = 1 + sin(angle) / distance * st.y;
- st.x = st.x / f * 0.92;
- st.y = st.y * cos(angle) / f * 0.92;
- //st.x /= (1.15 - 0.3 * st.y);
- //st.y /= (1.15 - 0.3 * st.y);
- uv = st + vec2(0.5, 0.5);
- vec4 color = texture2D(gameview, uv);
- if (!render_darkness)
- {
- gl_FragColor = color;
- return;
- }
- vec4 light = texture2D(lightmap, uv);
- if (use_nightvision)
- {
- float luminance = dot(color.rgb, vec3(0.299, 0.587, 0.114));
- float lightLuminance = max(light.r, max(light.g, light.b));
- vec3 grayscale = vec3(luminance * nv_intensity); // * nv_color.a * nv_color.rgb;
- float lightIntensity = smoothstep(nv_desaturation_params.x, nv_desaturation_params.y, lightLuminance) * nv_desaturation_params.z + nv_desaturation_params.w;
- color.rgb = mix(grayscale, color.rgb, lightIntensity);
- lightIntensity = smoothstep(nv_light_params.x, nv_light_params.y, lightLuminance) * nv_light_params.z + nv_light_params.w;
- gl_FragColor = vec4(color.rgb * lightIntensity , color.a);
- }
- else
- {
- color.rgb = color.rgb * light.rgb;
- gl_FragColor = vec4(color.rgb, color.a);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement