View Full Version : Blending 4 textures with splat map (WebGL)

12-26-2013, 06:06 AM
I'm trying to blend 4 textures with splat map. It works with red, blue and black colors, but it doen't with green.
Here's my code:

vec4 t0 = texture2D(splatter, vUv).rgba;
vec4 t1 = texture2D( map, vUv ).rgba;
vec4 t2 = texture2D( map2, vUv).rgba;
vec4 t3 = texture2D( map3, vUv ).rgba;
vec4 t4 = texture2D( map4, vUv ).rgba;

t1 = mix(t1, t2, t0.r);
t2 = mix(t2, t3, t0.g);
t3 = mix(t1, t3, t0.b);
gl_FragColor = mix(t4, t3, t0.a);
t0 is splat map. What am I doing wrong?