mickey
15-12-2008 14:03:19
Hi
I have a question regarding the pixel shader used to blend multiple texture and coverage maps.
I have my own pixel shader code which I use to blend multiple textures and it looks something like this:
Basically I have the additional inverse computation which is used to clamp the color values.
Currently I have this pixel shader and its limited to only blending 4 textures, so I searched the net looking for a pixel shader that can handle more than 4 textures - and I saw the pixel shader code that comes with the sample source code:
I was wondering if I could get any explanation or explain the difference to me or how I can tweak my pixel shader code so that it can also handle up to 4 coverage maps to a total of 12 - 16 texture blends.
Thanks!
I have a question regarding the pixel shader used to blend multiple texture and coverage maps.
I have my own pixel shader code which I use to blend multiple textures and it looks something like this:
float4 a = tex2D(alpha, alphaUV);
float4 c1 = tex2D(texture1, colorUV);
float4 c2 = tex2D(texture2, colorUV);
float4 c3 = tex2D(texture3, colorUV);
float4 c4 = tex2D(texture4, colorUV);
float inverse = 1.0f / (a.r + a.g + a.b + a.a);
// Multiply with alpha texture
c1 *= a.b * inverse;
c2 *= a.g * inverse;
c3 *= a.r * inverse;
c4 *= a.a * inverse;
float4 texColor = (c1 + c2 + c3 + c4) * shade * l;
Basically I have the additional inverse computation which is used to clamp the color values.
Currently I have this pixel shader and its limited to only blending 4 textures, so I searched the net looking for a pixel shader that can handle more than 4 textures - and I saw the pixel shader code that comes with the sample source code:
{
float3 cov1 = tex2D(covMap1, iTexCoord0).rgb;
float3 cov2 = tex2D(covMap2, iTexCoord0).rgb;
iTexCoord0.x *= splatScaleX;
iTexCoord0.y *= splatScaleZ;
oColor = tex2D(splat1, iTexCoord0) * cov1.x
+ tex2D(splat2, iTexCoord0) * cov1.y
+ tex2D(splat3, iTexCoord0) * cov1.z
+ tex2D(splat4, iTexCoord0) * cov2.x
+ tex2D(splat5, iTexCoord0) * cov2.y
+ tex2D(splat6, iTexCoord0) * cov2.z;
I was wondering if I could get any explanation or explain the difference to me or how I can tweak my pixel shader code so that it can also handle up to 4 coverage maps to a total of 12 - 16 texture blends.
Thanks!