From 01d2500733766710f4a11f49216a5b3dcc75a4a3 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 28 Aug 2012 11:30:30 +0300 Subject: [PATCH] Fix color equations in the standard shaders 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 | 1 + source/program.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/demos/shaders.cpp b/demos/shaders.cpp index 27538e4e..1b9c6472 100644 --- a/demos/shaders.cpp +++ b/demos/shaders.cpp @@ -83,6 +83,7 @@ int main() } GL::ProgramData progdata; + progdata.uniform("texture", 0); progdata.uniform("normalmap", 1); GL::Lighting lighting; diff --git a/source/program.cpp b/source/program.cpp index f1120667..729018a1 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -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 -- 2.43.0