diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-05-20 22:28:22 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-05-20 22:28:22 +0200 |
commit | 208b41573cc0cafb8428705cb997247a50b5553d (patch) | |
tree | b717ebc448f87c0916af964bb67c84d0de5ec1e9 /bullet_fragment.glsl | |
parent | 2b6e774ce7eab4c9e5052c757fe240bc95b86f55 (diff) |
Updated color calculation in shader.
Diffstat (limited to 'bullet_fragment.glsl')
-rw-r--r-- | bullet_fragment.glsl | 7 |
1 files 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); } |