diff options
Diffstat (limited to 'shaders/glsl100/grayscale.fs')
| -rw-r--r-- | shaders/glsl100/grayscale.fs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/shaders/glsl100/grayscale.fs b/shaders/glsl100/grayscale.fs index e55545e2..f92ec335 100644 --- a/shaders/glsl100/grayscale.fs +++ b/shaders/glsl100/grayscale.fs @@ -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); }
\ No newline at end of file |
