alpha blend error

Started by
5 comments, last by phil_t 7 years, 11 months ago

firstly, I use dx9.

when using alpha blend, I set the src alpha factor to D3DSRCALPHA,

dest alpha factor to D3DINVSRCALPHA,

the blend operator to D3DBLEND_ADD.

I use a bright pass to set the alpha value of the texture where is black , to 0.

I first draw the scene, then blend the texture to the scene .

but the black part of the texture are still black , it can't become transparent.

[attachment=32183:360??20160608213853386.jpg]

Advertisement

I use a bright pass to set the alpha value of the texture where is black , to 0.

Are you doing this on the CPU and updating the texture? Are you doing it in some pre-processing step in your import pipeline? Are you rendering your texture to a render target and then drawing that render target instead of the texture?

I use a bright pass to set the alpha value of the texture where is black , to 0.

Are you doing this on the CPU and updating the texture? Are you doing it in some pre-processing step in your import pipeline? Are you rendering your texture to a render target and then drawing that render target instead of the texture?

first use a bright-pass shader render a texture to a rendertarget, making the above picture , and sample the rendertarget in second pass,

and find that the alpha is always be 1.0.....

Your rendertarget needs an alpha component.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

If you're using shaders you don't even need to do a separate brightpass stage. Instead you could do something like:

float4 color = tex2D (mySampler, ps_in.TexCoord);

color.a = step (0.00392f, color.r + color.g + color.b);

That will work in a single pass - read the texture, set alpha to 0 if it's black, 1 otherwise.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

If you're using shaders you don't even need to do a separate brightpass stage. Instead you could do something like:

float4 color = tex2D (mySampler, ps_in.TexCoord);

color.a = step (0.00392f, color.r + color.g + color.b);

That will work in a single pass - read the texture, set alpha to 0 if it's black, 1 otherwise.

I do the brightpass like you, and set the alpha to 0 when it's black. the problem is after I draw the result to rendertarget, the alpha of the rendertarget is always be 1.0......

and the texture format has been a8r8g8b8...

- Show the code where you create the render target to which your brightpass draws.

- Show the code where you set the alpha blend parameters before your bright pass
- Show the code where you set the alpha blend parameters before you draw your render target to the final output.

Otherwise, people can only guess at what your problem might be.

This topic is closed to new replies.

Advertisement