raylib/shaders/glsl330/cross_hatching.fs

48 lines
1.1 KiB
Forth
Raw Normal View History

#version 330
2016-05-18 13:04:27 +03:00
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
2016-05-18 13:04:27 +03:00
in vec4 fragColor;
2016-05-18 13:04:27 +03:00
// Input uniform values
uniform sampler2D texture0;
2016-01-13 19:13:28 +03:00
uniform vec4 fragTintColor;
2016-05-18 13:04:27 +03:00
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables
float hatchOffsetY = 5.0;
float lumThreshold01 = 0.9;
float lumThreshold02 = 0.7;
float lumThreshold03 = 0.5;
float lumThreshold04 = 0.3;
void main()
{
vec3 tc = vec3(1.0, 1.0, 1.0);
float lum = length(texture(texture0, fragTexCoord).rgb);
if (lum < lumThreshold01)
{
if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
if (lum < lumThreshold02)
{
2016-05-18 13:04:27 +03:00
if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
if (lum < lumThreshold03)
{
2016-05-18 13:04:27 +03:00
if (mod(gl_FragCoord.x + gl_FragCoord.y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
if (lum < lumThreshold04)
{
2016-05-18 13:04:27 +03:00
if (mod(gl_FragCoord.x - gl_FragCoord.y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0);
}
2016-05-18 13:04:27 +03:00
finalColor = vec4(tc, 1.0);
}