dds Alpha channel not working on mesh

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

Recommended Posts

I have a DXT3 dds image loaded in a LPDIRECT3DTEXTURE9. Drawing it as a sprite will make the "black pixels/alpha" transparent. However if I use it on a mesh it will show black edges along the texture where it should be transparent.

What should I do to make it transparent ( fixed pipeline atm ) ?

Share on other sites
I suppose you're referring to the D3DX sprite class. I've never used it so this post is mere speculation.
I suppose the sprite class internally sets up alpha blending and your code does not.
You need to enable [color=#000000][font=Consolas, Courier, monospace]

D3DRS_ALPHAFUNC[/font].

Share on other sites
Ok, I got the effect I wanted but with a bug.

Places like some corners or edges there are small specks of black being visible. This is not shown in the game I "borrow" the asset from.

What are tyical sources for corner and edges specks?

Share on other sites
That sounds like you've only got alpha test on, so the pixel is either opaque or transparant, and not actually blended properly. What render states are you setting?

Share on other sites
 SetRenderState(D3DRS_ZENABLE, TRUE); SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(50, 50, 50)); SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 

What else is needed?

Share on other sites
I have recoded this 4 times now and still no go. Tried even with just a pure vertex buffer, with and without indices.

Share on other sites
Another thing that is occuring is that if I have a sphere where a spot on the sphere surface is made transparent with alpha blending, the back/opposite side through the "spot hole" of the sphere also becomes transparent but is not supposed to.

It might be that my faces are two-sided. One interesting observation I have is that a strip of triangles are black on one side(alpha black) and have a texture on the other side, but with ALPHABLENDENABLE set to true both sides are invisble, while I want the other side visible.

So if the same "subset" is curled ontop of itself it like a sphere or ring, it will make invisible faces behind it that should not be.

Share on other sites
lol fixed it:
 SetRenderState(D3DRS_ALPHAREF , 0x80); SetRenderState(D3DRS_ALPHAFUNC , D3DCMP_GREATER); 

Share on other sites
What DireCt version and what compiler and windows version are you using? I have problem finding AlphaBlend myself

Share on other sites
Always a new bug to figure out for me

Now, if the Mesh is barely 5+ units away from the camera the mesh will have many faces start becoming fully transparent.

Turning off D3DRS_ALPHATESTENABLE corrects this but that messes up my textures... And it seems the further away my Mesh gets from the camera the darker it gets..

What is going on? I have messed around with these states without any results

 SetRenderState(D3DRS_LIGHTING, false); SetRenderState(D3DRS_ZENABLE, true); SetRenderState(D3DRS_ALPHAREF, 0x50); SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER); SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(50, 50, 50)); SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); SetRenderState(D3DRS_NORMALIZENORMALS, true); SetRenderState(D3DRS_ALPHABLENDENABLE, true); SetRenderState(D3DRS_ALPHATESTENABLE, true); SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 9
• 11
• 15
• 21
• 26