D3D9 Colour Key Transparencies
hello all,
I''m having a bit of (code)writers block.. This is something I''ve done 10x before in previous versions of Direct3D - but for some reason I really can''t crack it tonight
I have a simple 2D tile game, magenta colour key (that is, where a tile has a magenta pixel it shouldn''t be drawn).. I''m sure it was just a case of doing the following:
1. Creating the texture with the colour key AND with a D3DFMT that has at least 1bit alpha (I''m using A8R8G8B8).
2. Set the 3 render states:
- D3DRS_SRCBLEND = D3DBLEND_SRCALPHA
- D3DRS_DESTBLEND = D3DBLEND_INVSRCALPHA
- D3DRS_ALPHABLENDENABLE = TRUE
3. Render!
Is there anything else to it? I''m sure its one little thing I''ve missed... and its really bugging me
any chance you can give me a hand?
cheers,
Jack
DirectX 4 VB: All you need for multimedia programming in Visual Basic
Formula 1 Championship Manager, My Game Project.
Verify the renderstates using some texture file with already-defined alpha channel.
If that works, try to verify that the magenta is really converted to transparent.
-Nik
If that works, try to verify that the magenta is really converted to transparent.
-Nik
hmm, will look into those...
but I''m sure its a simple renderstate/settings thing - I suppose I''ll just dig through all my old source code until I find the answer
Jack
but I''m sure its a simple renderstate/settings thing - I suppose I''ll just dig through all my old source code until I find the answer
Jack
The renderstates you mentioned are correct, that''s why i recommended verifying the data itself. However, the problem might also be in texture stage states (where does the device get the alpha from?).
-Nik
-Nik
are you using 0xffff00ff or 0x00ff00ff for the colorkey?
I just did this yesterday, and it works fine for me, so if you want I could look at my code and see what I did
I just did this yesterday, and it works fine for me, so if you want I could look at my code and see what I did
Make sure that you have the following renderstates set
Device->SetRenderState(D3DRS_ALPHAREF,255);
Device->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_GREATEREQUAL);
[edited by - RhoneRanger on October 13, 2003 4:17:57 PM]
Device->SetRenderState(D3DRS_ALPHAREF,255);
Device->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_GREATEREQUAL);
[edited by - RhoneRanger on October 13, 2003 4:17:57 PM]
cheers for the tips... I''ll have a crack at it after lunch
I also found an old(er) piece of D3D9 code that uses transparent textures, so if the above doesn''t work, I''ll just compare the two projects line for line till it works...!
cheers
Jack
DirectX 4 VB: All you need for multimedia programming in Visual Basic
Formula 1 Championship Manager, My Game Project.
I also found an old(er) piece of D3D9 code that uses transparent textures, so if the above doesn''t work, I''ll just compare the two projects line for line till it works...!
cheers
Jack
DirectX 4 VB: All you need for multimedia programming in Visual Basic
Formula 1 Championship Manager, My Game Project.
doubt anyone cares right now... but just for future reference (or if anyone searches with similar problems in the future!) I solved the problem by using 32bit DDS textures authored using DXTex...
Seems like D3DX really didn''t want to load my bitmap correctly!
Jack
DirectX 4 VB: All you need for multimedia programming in Visual Basic
Formula 1 Championship Manager, My Game Project.
Seems like D3DX really didn''t want to load my bitmap correctly!
Jack
DirectX 4 VB: All you need for multimedia programming in Visual Basic
Formula 1 Championship Manager, My Game Project.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement