Alpha values not blending in RenderTexture

[16236-screen+shot+2013-10-07+at+10.28.32+copy+copy+copy.png|16236]The problem I’m having is that when I draw a new texture into the RenderTexture, instead of blending with the texture that’s already there (the render texture is set to clear “depth only” - though same thing happens with “don’t clear”) … the alpha value of the new texture REPLACES instead of blending with the texture that’s already there…

the texture that’s already there has not been drawn this frame - it’s only still there because the RenderTexture is set to don’t clear, which is as I need it.

The images i’ve added are -

A) what i see on screen

B) the renderTexture Alpha layer

C) the renderTexrture setup

D) the shader i’m currently using to draw the input texture…

Not sure if it’s relevant but i’m also using a depthmask so that only pixels within the shape can be renderer to… (but i’ve turned it off and same behaviour… so…)

grateful for any leads here :slight_smile:
ta…
![alt text][2]

It’s not replacing something that’s already there, but it’s rendering it back to front, and the ZTest argument is causing it to ignore everything behind the semi-transparent pixels, meaning it’s not drawn at all. Try removing the ZTest call in the shader.

Say you draw a solid cube to the render texture, alpha=1 everywhere. Then you draw an alpha=0.5ish smoke texture over it. That smoke should blend with the cube, but the final alpha should be 1 (the smoke didn’t make the cube become transparent.) If any of the smoke went off the edge of the cube, that would have a 0.5 alpha.

Then, using “don’t clear” to keep the previous frame (really, all previous frames,) the render texture blends in. The solid aplha=1 cube overwrites, extra 0.5 smoke blends in.

The problem is, a normal “alpha blend with background” (I think) will set the background/destination alpha the same as it sets colors – to the weighted average. Your solid cube is being turned into a 0.75 alpha by the smoke. No one usually cares, since you never look at background alpha anyway – you always use src, oneMinusSrc. Or, for render-textures, you just slam it on the screen as the final step. As Hoeloe notes, surface shaders are easier to test (like displaying alpha as grey scale, so you can check it.)

I think, on the initial blend, alpha should be set to Max(src,dest) (if that’s even a setting.)

But, always blending with the previous frame seems wrong to me. I’m thinking that whatever effect you’re trying to get is going to come some other way. Like a second camera … .