roguelike-game/resources/scanlines.fs

26 lines
737 B
GLSL
Executable File

#version 330 core
out vec4 FragColor;
in vec2 TexCoords;
uniform sampler2D screenTexture;
uniform vec3 screenSize;
uniform bool screenBurn;
void main()
{
vec3 col = texture(screenTexture, TexCoords).rgb;
float scanLine = mod(gl_FragCoord.y, 2.0) * 0.25;
vec3 scanColor = col.rgb - scanLine;
if (col.r < 0.1f && col.g < 0.1f && col.b < 0.1f) {
if (screenBurn) {
float dist = (1.0 - distance(vec2(gl_FragCoord.x / screenSize.x, gl_FragCoord.y / screenSize.y), vec2(0.5,0.5))) * 0.2;
FragColor = vec4(0.0, dist, dist, 1.0);
} else {
FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}
} else {
FragColor = vec4(scanColor, 1.0);
}
}