Special mix required in xna 4.0

I have 2 dynamic textures and you want to add a second texture color to the first texture color. But only where the first color of the alpha texture is not 0, something like a reverse transparent, I will add two pic links to show that my average is:

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

only part of the collisions should add two colors of texture textures

ty for your help

+4
source share
2 answers

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

+1
source

Perhaps using BlendState.Additive will be enough for you.

or maybe this can be achieved using custom BlendState .. but I have no experience with this ...

or you can make a shader, you should notice that you have a quatrain:

  • A square with a rag doll. (CRF)
  • Square with a circle. (Qc)

you draw Qc over Qrd ...

so you need to get the texture coordinates that you get in the pixel shader that Qc belongs to in order to texture the coordinates in the Qrd space ...

then you select a color from the Qrd texture, and if the alpha is almost zero, you pinch the pixel ... otherwise you return a sample from the Qrc texture

+1
source

All Articles