Well, I'm back!
I'm now trying to combine three textures into one while alpha blending it all together. I have one texture, my base texture, that I want everything else added onto(always visible). Then I have another texture that I'm going to edit via direct memory access(aka memblocks) that's going to have its own alpha. The last texture is a scroll texture(the same as last time) that also has its own alpha. I have everything down except that the base layer and the changing layer aren't adding their colors like they should(despite my math saying they should...).
Here's the relevant piece of code:
float4 BlendPS( ps_in input,
uniform float4 diffuse,
uniform float blend,
uniform sampler2D texture1 : register(s0),
uniform sampler2D texture2 : register(s1),
uniform sampler2D texture3 : register(s2)) : COLOR
{
/*
return diffuse * ( tex2D( texture1, input.uv )*(1.0-blend) + tex2D( texture2, input.uv1 )*blend );
*/
//tex1 is the scroll layer
//tex2 is the base layer
//tex3 is the dynamic layer
//don't ask me why the base layer is in the middle, it just has to //be there
blend = saturate( blend );
float4 tex1 = tex2D(texture1,input.uv);
float4 tex2 = tex2D(texture2,input.uv1);
float4 tex3 = tex2D(texture3,input.uv2);
float4 texCombined = (tex3 + tex2 + tex1*blend);
return diffuse * (texCombined);
}
And here's the whole shader file:
string Description = "This shader takes two textures and blends them by the blend factor, then tints the output with a diffuse color";
string Thumbnail = "BlendShader.png";
struct vs_out
{
float4 pos : POSITION;
float2 uv : TEXCOORD0;
float2 uv1 : TEXCOORD1;
float2 uv2 : TEXCOORD2;
};
struct ps_in
{
float2 uv : TEXCOORD0;
float2 uv1 : TEXCOORD1;
float2 uv2 : TEXCOORD2;
};
vs_out BlendVS( float4 pos : POSITION,
float2 uv : TEXCOORD0,
uniform float4x4 worldViewProj_m,
uniform float inctime,
uniform float directionX,
uniform float directionY)
{
vs_out OUT;
OUT.pos = mul(worldViewProj_m , pos);
OUT.uv = uv + float2(directionX,directionY)*inctime;
OUT.uv1 = uv;
OUT.uv2 = uv;
return OUT;
}
float4 BlendPS( ps_in input,
uniform float4 diffuse,
uniform float blend,
uniform sampler2D texture1 : register(s0),
uniform sampler2D texture2 : register(s1),
uniform sampler2D texture3 : register(s2)) : COLOR
{
/*
return diffuse * ( tex2D( texture1, input.uv )*(1.0-blend) + tex2D( texture2, input.uv1 )*blend );
*/
blend = saturate( blend );
float4 tex1 = tex2D(texture1,input.uv);
float4 tex2 = tex2D(texture2,input.uv1);
float4 tex3 = tex2D(texture3,input.uv2);
float4 texCombined = (tex3 + tex2 + tex1*blend);
return diffuse * (texCombined);
}
/*
technique MyShader
{
pass p0
{
VertexShader = compile vs_1_1 BlendVS( );
PixelShader = compile ps_2_0 BlendPS( );
}
}*/
Again, thanks for any help!
EDIT:screenie of the issue