2015-11-07 96 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圖片通道預期工作。