Jump to content
  • Advertisement
Sign in to follow this  
ramy

Alpha blending error

This topic is 4829 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

Hello guys, ?I have been fiddling arround with lens flares, and actually implemented one. the lens flare requires an alpha blend so the black in texture to be removed, i understand that. the problem is, it also requires the skybox to have an alpha value so it appears through it, and i can c it when im inside the skybox. the problem is, then i enable alpha for skybox, it turns to bluish color, and terrain inside the akybox turns to lite greenish. here is a screenshot of this happening. not that i set the AlphablendEnable to false before rendering the Terrain. http://img37.echo.cx/my.php?image=alphaproblem9cb.jpg Anybody has an idea why Skybox turns to bluish, and Terrain as well :s thx in advanced.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ramy
the problem is, it also requires the skybox to have an alpha value so it appears through it, and i can c it when im inside the skybox.


not with additive blending (which is what you want in this case). You simply set the destination (sky) set to D3DBLEND_ONE, that is, leave it unchanged and simply add the lens flare color on top.

it's really hard to believe that you're setting the alpha blending to false before rendering the terrain. The only thing I can guess is that a huge green lens flare is covering the entire screen because it looks as if they turn from reddish to greenish as they descend.

Share this post


Link to post
Share on other sites
I would like to add the folowing information about the alpha i am using.

the lens flare i declare the following the Renderstates:

dev.SetRenderState(RenderStates.Lighting, false);
dev.SetRenderState(RenderStates.AlphaBlendEnable, true);
dev.SetRenderState(RenderStates.BlendOperation, (int)BlendOperation.Add);
dev.SetRenderState(RenderStates.SourceBlend, (int)Blend.One);
dev.SetRenderState(RenderStates.DestinationBlend, (int)Blend.One);
dev.SetRenderState(RenderStates.ShadeMode, (int)ShadeMode.Flat);
dev.SetRenderState(RenderStates.ZEnable, false);
dev.SetRenderState(RenderStates.ZBufferWriteEnable, false);

and after rendering them, i set AlphaBlendEnable to false.



then in the Skybox i do following:

dev.SetRenderState(RenderStates.AlphaBlendEnable, true);
dev.SetRenderState(RenderStates.SourceBlend, (int)Blend.SourceAlpha);
dev.SetRenderState(RenderStates.BlendOperationAlpha, (int)BlendOperation.Add);
dev.SetRenderState(RenderStates.DestinationBlend, (int)Blend.One);

and after rendering the skybox, i set AlphaBlendEnable to false.


then in Terrain rendering i disable the AlphaBlendEnable in Render states to false, before rendering and after rendering.

any clues?

Share this post


Link to post
Share on other sites
you render the skybox first without alpha blending blending, you don't need it. Then you render the lens flares with alpha blending. Your clear color must be blue by the way.

Share this post


Link to post
Share on other sites
Quote:
Original post by ramy
then in Terrain rendering i disable the AlphaBlendEnable in Render states to false, before rendering and after rendering.


this is tedious. Drawing something will not suddenly enable blending, it is remembered until the d3d device is lost (ctrl alt del) or released.

Share this post


Link to post
Share on other sites
Almost there,

i render the skybox first, then render the lens flare, and i disbled the alpha blending before and after rendering the lens flare. the result was, Terrain had correct color, and Lens flare were turned to something else :p

http://img199.echo.cx/img199/3816/alphaproblem9nn.jpg

Share this post


Link to post
Share on other sites
I fixed the thing, thx alot for ur help Lee_.

i disabled Alpha for Terrain and Skybox, and rendered the lens flae the last, and it works fine now.

thx again

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!