From b1a90a7f915e7779aad975a70b503788b0a1b228 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Wed, 2 Sep 2015 02:44:16 +0200 Subject: Added some useful postprocessing shaders Shaders come in two flavours: - shaders/gl330: OpenGL 3.3+ (Windows, Linux, OSX) - shaders/gles100: OpenGL ES 2.0 (Android, RPI, HTML5) --- shaders/gles100/cross_hatching.fs | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 shaders/gles100/cross_hatching.fs (limited to 'shaders/gles100/cross_hatching.fs') diff --git a/shaders/gles100/cross_hatching.fs b/shaders/gles100/cross_hatching.fs new file mode 100644 index 00000000..c308acb6 --- /dev/null +++ b/shaders/gles100/cross_hatching.fs @@ -0,0 +1,44 @@ +# version 100 + +precision mediump float; + +varying vec2 fragTexCoord; + +uniform sampler2D texture0; +uniform vec4 tintColor; + +// NOTE: Add here your custom variables + +float hatchOffsetY = 5.0f; +float lumThreshold01 = 0.9f; +float lumThreshold02 = 0.7f; +float lumThreshold03 = 0.5f; +float lumThreshold04 = 0.3f; + +void main() +{ + vec3 tc = vec3(1.0, 1.0, 1.0); + float lum = length(texture2D(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) + { + if (mod(gl_FragCoord .x - gl_FragCoord .y, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); + } + + if (lum < lumThreshold03) + { + if (mod(gl_FragCoord .x + gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); + } + + if (lum < lumThreshold04) + { + if (mod(gl_FragCoord .x - gl_FragCoord .y - hatchOffsetY, 10.0) == 0.0) tc = vec3(0.0, 0.0, 0.0); + } + + gl_FragColor = vec4(tc, 1.0); +} \ No newline at end of file -- cgit v1.2.3