From 208b41573cc0cafb8428705cb997247a50b5553d Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 20 May 2010 22:28:22 +0200 Subject: Updated color calculation in shader. --- bullet_fragment.glsl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bullet_fragment.glsl b/bullet_fragment.glsl index 66f53a4..5e8becd 100644 --- a/bullet_fragment.glsl +++ b/bullet_fragment.glsl @@ -7,6 +7,9 @@ void main() { l_uv -= l_offset; l_uv = vec2(v_tex_rot * vec4(l_uv, 0.0, 1.0)); l_uv += l_offset; - gl_FragColor = vec4(texture2D(tex, l_uv)); - gl_FragColor.xyz += gl_Color.xyz - gl_Color.xyz * gl_FragColor.x; + gl_FragColor = texture2D(tex, l_uv); + float M = max(max(gl_FragColor.x, gl_FragColor.y), gl_FragColor.z); + float C = M - min(min(gl_FragColor.x, gl_FragColor.y), gl_FragColor.z); + float S = C > 0.0 ? C / M : 0.0; + gl_FragColor.xyz = M * mix(vec3(1.0, 1.0, 1.0), gl_Color.xyz, S); } -- cgit v1.2.3