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

Started by
4 comments, last by _Tank_ 18 years, 1 month ago
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!.
Advertisement
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);

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.
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.
Hack my projects! Oh Yeah! Use an SVN client to check them out.BlockStacker
Are you using lighting? If so, are all you materials set up correctly?
Sean Henley [C++ Tutor]Rensselaer Polytechnic Institute
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()

This topic is closed to new replies.

Advertisement