mX64
mX64

Reputation: 388

special blend needed in xna 4.0

i got 2 dynamic texture ,and want add second texture color to first texture color But just where first texture color alpha is not 0 something like inverse transparncey i add two pic link to show what is my mean:

http://img.7setare.com/images/k5znp5efpn1szfvwka.png TO http://img.7setare.com/images/vs4p0qx81zxxrfh1v8d5.png

just collisions part must add two texture pixel color

ty for your help

Upvotes: 4

Views: 190

Answers (2)

mX64
mX64

Reputation: 388

just did it , works great

sampler circleSampler : register(s1);
sampler playerSampler : register(s0);

float4 main(float4 color : COLOR0 ,float2 texCoord : TEXCOORD0):COLOR0
{
float4 output = float4(1,1,1,1);
float4 CircColor = tex2D(circleSampler,texCoord);
float4 playerColor = tex2D(playerSampler,texCoord);
if (CircColor.a ==0)
{
output = playerColor;
}
else
{
output = CircColor* playerColor;
}
output.a = playerColor.a;
return output;
}

technique Technique1
{
    pass Pass1
    {

        PixelShader = compile ps_2_0 main();
    }
}

anyway ty for ur time

Upvotes: 1

Blau
Blau

Reputation: 5762

Maybe using BlendState.Additive wil be enough for you.

or maybe it can be achieved with a custom BlendState.. but I have not experience with this...

or you can make a shader, you should note that you have to quads:

  1. Quad with a rag doll. (Qrd)
  2. Quad with a circle. (Qc)

you draw Qc over Qrd...

so you have to traduce the texture coordinates that you get in the pixel shader that owns to Qc to texture cordinates at Qrd space...

then you sample the color from Qrd texture, and if alpha is near zero you clip the pixel... else you return the sample from Qrc texture

Upvotes: 1

Related Questions