]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix color equations in the standard shaders
authorMikko Rasa <tdb@tdb.fi>
Tue, 28 Aug 2012 08:30:30 +0000 (11:30 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 28 Aug 2012 08:30:30 +0000 (11:30 +0300)
The generated shader code assigned a scalar to a vec3 if lighting was
enabled without texture or material.  An unnecessary multiplication in
the alpha equation with texture but no material was removed.

Also fix texturing in the shader demo (Mesa does funny things with
uniforms).

demos/shaders.cpp
source/program.cpp

index 27538e4eb2e6a2c35e1bf5aa9e7fa4465a5b8bd8..1b9c64724f78bd394ab9051458bfcfe496136d63 100644 (file)
@@ -83,6 +83,7 @@ int main()
        }
 
        GL::ProgramData progdata;
+       progdata.uniform("texture", 0);
        progdata.uniform("normalmap", 1);
 
        GL::Lighting lighting;
index f11206677b94890ebe7d89dfdeefbc5af425e7f4..729018a1a4b1edc69438d426c32426e82b19b09b 100644 (file)
@@ -79,9 +79,10 @@ const char *standard_fragment_src[] =
        "e",   "\tvec4 reflection = textureCube(environment, n_normal*(dot(n_normal, v_eye_dir)*2.0)-v_eye_dir);\n",
        "t",   "\tvec4 tex_sample = texture2D(texture, v_texcoord);\n",
         0,    "\tgl_FragColor.rgb = ",
-       "!t!l!m", "vec3(1.0)",
+       "!t!m",  "vec3(1.0)",
        "t",     "tex_sample.rgb",
        "l|mt",  "*",
+       "l!m!t",  "*",
        "!lm",   "v_color.rgb",
        "l",     "((l_diffuse",
        "lm",    "*gl_FrontLightProduct[0].diffuse.rgb",
@@ -94,10 +95,11 @@ const char *standard_fragment_src[] =
        "e",     "+reflection.rgb*reflectivity",
         0,      ";\n",
         0,    "\tgl_FragColor.a = ",
-       "!m",    "1.0",
+       "!t!m",  "1.0",
+       "t",     "tex_sample.a",
+       "tm",    "*",
        "!lm",   "v_color.a",
        "lm",    "gl_FrontMaterial.diffuse.a",
-       "t",     "*tex_sample.a",
         0,      ";\n",
         0,    "}\n",
        0, 0