2015-11-07 98 views
1

只需划分一个PNG图像的信道来表示具有不与每个other.Below共混纹理泼洒是表达什么我试图实现为简单代码的示例:webgl的着色器 - 分通道RGBA

uniform sampler2D my-alpha-png; 
uniform sampler2D texture1; 
uniform sampler2D texture2; 
uniform sampler2D texture3; 

vec4 alpha = texture2D(my-alpha-png, vUV).rgba; 
vec4 tex0 = texture2D(texture1, vUV *10.0).rgba; 
vec4 tex1 = texture2D(texture2, vUV *10.0).rgba; 
vec4 tex2 = texture2D(texture3, vUV *10.0).rgba; 

vec4 colornone = alpha.a; // i want this channel to be blank; 
vec4 color1 = alpha.r; // this is texture1 
vec4 color2 = alpha.g; // this is texture2 
vec4 color3 = alpha.b; // this is texture3 

gl_FragColor = // ???? 

我已经尝试了许多变化我只能设法让两个纹理沃金,但阿尔法总是以及下方的纹理图像阿尔法PNG:

enter image description here

我更感兴趣的是分裂渠道代表在输出上,只需要四个通道r,g,b,一个不需要计算黑白...

谢谢。

回答

0

我打得周围,一个解决方案提出了:

vec4 final = (alpha.r * tex0) + (alpha.g *tex1) + (alpha.b * tex2) ; 

它似乎只能用绿色,红色,蓝色阿尔法 - 映射png图片通道预期工作。