[test-shader] Fix some of the shaders to use premultiplied colors
authorNeil Roberts <neil@linux.intel.com>
Wed, 24 Jun 2009 11:04:55 +0000 (12:04 +0100)
committerNeil Roberts <neil@linux.intel.com>
Wed, 24 Jun 2009 11:05:19 +0000 (12:05 +0100)
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.

tests/interactive/test-shader.c

index ecb8d22..3c59861 100644 (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
     },