Sign in to follow this  

How is it possible to make alpha blending texture to display correctly ?

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

Hi all. (C#) I'm having a problem with displaying an alpha-blended texture. Every non alpha-blended color on that texture is white!!! What should I do if i need to display a texture that has all the RGB pallete and only, 0% or 100%, visible pixels (or is that texels or voxels, i can't remember). By the way i'm trying to display that texture on rectangle (quad), is it the right way to display it on two triangles (the way i'm dooing it). And almost forgot. It seems like that texture not on it's place by 180 degrees. What should i do? Very much thank you!.

Share this post


Link to post
Share on other sites
put these somewhere (preferably not in your render loop)


device.SetRenderState(RenderStates.AlphaTestEnable, true);
device.SetRenderState(RenderStates.AlphaBlendEnable, true);
device.SetRenderState(RenderStates.SourceBlend, (int)Blend.SourceAlpha);
device.SetRenderState(RenderStates.DestinationBlend, (int)Blend.InvSourceAlpha);
device.SetTextureStageState(0, TextureStageStates.AlphaOperation, (int)TextureOperation.Modulate);

Share this post


Link to post
Share on other sites
Quote:
Original post by greenwire
put these somewhere (preferably not in your render loop)


device.SetRenderState(RenderStates.AlphaTestEnable, true);
device.SetRenderState(RenderStates.AlphaBlendEnable, true);
device.SetRenderState(RenderStates.SourceBlend, (int)Blend.SourceAlpha);
device.SetRenderState(RenderStates.DestinationBlend, (int)Blend.InvSourceAlpha);
device.SetTextureStageState(0, TextureStageStates.AlphaOperation, (int)TextureOperation.Modulate);


Allready tried. Actualy i've tried to pass a dozen of different parameters to the functions above.

Result: Every visible color is white.

Share this post


Link to post
Share on other sites
Does the texture colors render correctly if you draw without alpha blending?

Yes, you are right to use two triangles to form a quad when drawing. About your 180 degree problem, try experimenting with the order of the vertices of the triangles. If they are ordered the wrong way ou will end up with rotated or mirrored textures.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sr_Guapo
Are you using lighting? If so, are all you materials set up correctly?


As far as i remember i've turned the lightning off. Unfortunately can't say how, that line of code is on different computer. And cant say anything about materials, i think there should be none of them.

What am i doing:

0) BeginScene()
1) Locking the component surface area (BackBuffer)
2) Draw the stuff i need to display on screen
3) Unlocking the surface (BackBuffer)
4) Draw two textured triangles
5) EndScene()
6) Present()

Share this post


Link to post
Share on other sites

This topic is 4304 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this