aboutsummaryrefslogtreecommitdiffstats
path: root/src/ru
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-12-23 13:51:30 +0100
committerSven Gothel <[email protected]>2012-12-23 13:51:30 +0100
commit4bd8df723573250f11afb7b67c7235f8dc8b631e (patch)
tree1e100d141262170fa28d70c34e9ca41018e184dd /src/ru
parent706bb89a6917f9231ae829a36a19142ed532fc11 (diff)
Block Shader: VP: Don't use sunColor (0); FP: Proper mixing for frontColor (meshColor).
Diffstat (limited to 'src/ru')
-rw-r--r--src/ru/olamedia/asset/shader/block.fp24
-rw-r--r--src/ru/olamedia/asset/shader/block.vp5
2 files changed, 13 insertions, 16 deletions
diff --git a/src/ru/olamedia/asset/shader/block.fp b/src/ru/olamedia/asset/shader/block.fp
index d082e16..3134183 100644
--- a/src/ru/olamedia/asset/shader/block.fp
+++ b/src/ru/olamedia/asset/shader/block.fp
@@ -1,28 +1,24 @@
varying vec2 texCoord;
-//vec4 frontColor;
+varying vec4 frontColor;
uniform sampler2D mesh_ActiveTexture;
-vec4 frontColor = vec4(1.0);
const vec4 texEnvColor = vec4(0.0);
const vec4 zerov4 = vec4(0.0);
const vec4 onev4 = vec4(1.0);
-vec4 calcTexColor(in vec4 color, in vec4 texColor) {
- color.rgb = mix(color.rgb, texEnvColor.rgb, texColor.rgb);
- color.a *= texColor.a;
- color = clamp(color, zerov4, onev4);
- return color;
-}
-
void main (void)
{
- vec4 texColor;
- texColor = texture2D(mesh_ActiveTexture, texCoord.st);
- if (texColor.a < 0.1f) discard;
- vec4 color = calcTexColor(frontColor, texColor);
- gl_FragColor = vec4(gl_FragColor.a) * gl_FragColor + vec4(1.0 - gl_FragColor.a) * texColor;
+ vec4 texColor = texture2D(mesh_ActiveTexture, texCoord.st);
+ if (texColor.a < 0.1) discard;
+
+ vec4 color;
+ // mix(x, y, a) == x * ( 1 - a ) + y * a
+ // color.rgb = mix(frontColor.rgb, texEnvColor.rgb, texColor.rgb);
+ color.rgb = mix(texEnvColor.rgb, frontColor.rgb, texColor.rgb);
+ color.a = frontColor.a * texColor.a;
+ gl_FragColor = clamp(color, zerov4, onev4);
} \ No newline at end of file
diff --git a/src/ru/olamedia/asset/shader/block.vp b/src/ru/olamedia/asset/shader/block.vp
index 4994769..4e160c2 100644
--- a/src/ru/olamedia/asset/shader/block.vp
+++ b/src/ru/olamedia/asset/shader/block.vp
@@ -10,8 +10,8 @@ attribute vec4 mesh_colors;
attribute vec2 mesh_texCoord;
varying out vec4 position;
-vec4 color;
varying out vec2 texCoord;
+varying out vec4 frontColor;
void main(void)
{
@@ -21,5 +21,6 @@ void main(void)
gl_Position = pmvMatrix[0] * position;
- color = mesh_colors * sunColor;
+ frontColor = mesh_colors;
+ // frontColor = mesh_colors * sunColor;
}