From: Mikko Rasa Date: Sun, 19 Aug 2012 00:34:22 +0000 (+0300) Subject: Lighting affecting the alpha value of a surface makes no sense X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=101b961cbdcc3a2459bb7c12e3d8e6e5c320b94b Lighting affecting the alpha value of a surface makes no sense Use lighting only for RGB components, and take alpha directly from color or material. This should prevent problems caused by alpha>1. --- diff --git a/source/program.cpp b/source/program.cpp index 587a3fb0..7598bf15 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -73,20 +73,27 @@ const char *standard_fragment_src[] = /* XXX This is incorrect with normal mapping, since the vectors are in TBN space but environment map is expected to be in eye space */ "e", "\tvec4 reflection = textureCube(environment, n_normal*(dot(n_normal, v_eye_dir)*2.0)-v_eye_dir);\n", - 0, "\tgl_FragColor = ", - "!t!l!m", "vec4(1.0, 1.0, 1.0, 1.0)", - "t", "texture2D(texture, v_texcoord)", + "t", "\tvec4 tex_sample = texture2D(texture, v_texcoord);\n", + 0, "\tgl_FragColor.rgb = ", + "!t!l!m", "vec3(1.0)", + "t", "tex_sample.rgb", "l|mt", "*", - "!lm", "v_color", + "!lm", "v_color.rgb", "l", "((l_diffuse", - "lm", "*gl_FrontLightProduct[0].diffuse", + "lm", "*gl_FrontLightProduct[0].diffuse.rgb", "p", "+l_specular", - "pm", "*gl_FrontLightProduct[0].specular", + "pm", "*gl_FrontLightProduct[0].specular.rgb", "l", ")", "s", "*l_shadow", - "lm", "+gl_FrontLightModelProduct.sceneColor", + "lm", "+gl_FrontLightModelProduct.sceneColor.rgb", "l", ")", - "e", "+reflection*reflectivity", + "e", "+reflection.rgb*reflectivity", + 0, ";\n", + 0, "\tgl_FragColor.a = ", + "!m", "1.0", + "!lm", "v_color.a", + "lm", "gl_FrontMaterial.diffuse.a", + "t", "*tex_sample.a", 0, ";\n", 0, "}\n", 0, 0