Updated shaders with comments

This commit is contained in:
raysan5
2016-05-18 12:04:27 +02:00
parent 0e29aa2951
commit bc08271da3
34 changed files with 294 additions and 158 deletions

View File

@ -2,8 +2,11 @@
precision mediump float;
// Input vertex attributes (from vertex shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 fragTintColor;
@ -11,10 +14,12 @@ uniform vec4 fragTintColor;
void main()
{
vec4 base = texture2D(texture0, fragTexCoord)*fragTintColor;
// Texel color fetching from texture sampler
vec4 texelColor = texture(texture0, fragTexCoord)*fragTintColor*fragColor;
// Convert to grayscale using NTSC conversion weights
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
// Convert texel color to grayscale using NTSC conversion weights
float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
gl_FragColor = vec4(gray, gray, gray, fragTintColor.a);
// Calculate final fragment color
gl_FragColor = vec4(gray, gray, gray, texelColor.a);
}