Jump to content
  • Advertisement
Sign in to follow this  
poigwym

alpha blend error

This topic is 921 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Edited by poigwym

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

 

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.....

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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...

Edited by poigwym

Share this post


Link to post
Share on other sites

- 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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!