[test-shader] Fix some of the shaders to use premultiplied colors

Texture data is now in premultiplied format and the shader should
output a premultiplied color if the default blend mode is being
used. Shaders that directly manipulate the rgb values now
unpremultiply and premultiply again afterwards.
This commit is contained in:
Neil Roberts 2009-06-24 12:04:55 +01:00
parent e9d277609d
commit 20f3c173fe

View File

@ -69,8 +69,10 @@ static ShaderSource shaders[]=
FRAGMENT_SHADER_VARS
"uniform float brightness, contrast;"
FRAGMENT_SHADER_BEGIN
" color.rgb /= color.a;"
" color.rgb = (color.rgb - vec3(0.5, 0.5, 0.5)) * contrast + "
"vec3 (brightness + 0.5, brightness + 0.5, brightness + 0.5);"
" color.rgb *= color.a;"
FRAGMENT_SHADER_END
},
@ -118,7 +120,9 @@ static ShaderSource shaders[]=
{"invert",
FRAGMENT_SHADER_VARS
FRAGMENT_SHADER_BEGIN
" color.rgb /= color.a;"
" color.rgb = vec3(1.0, 1.0, 1.0) - color.rgb;\n"
" color.rgb *= color.a;"
FRAGMENT_SHADER_END
},
@ -127,9 +131,11 @@ static ShaderSource shaders[]=
"uniform float brightness;"
"uniform float contrast;"
FRAGMENT_SHADER_BEGIN
" color.rgb /= color.a;"
" color.r = (color.r - 0.5) * contrast + brightness + 0.5;"
" color.g = (color.g - 0.5) * contrast + brightness + 0.5;"
" color.b = (color.b - 0.5) * contrast + brightness + 0.5;"
" color.rgb *= color.a;"
FRAGMENT_SHADER_END
},