Archived

This topic is now archived and is closed to further replies.

alpha transparency

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

I would like to know whether transparency like water can be achieved as shown in games... I m basically making an engine for a strategy game and I m having problems with transparency of water.... When I apply a transparent texture to a poly, it pixellates the water...Plz advice.

Share this post


Link to post
Share on other sites
You need to do alpha blending (semi transparent).
How to do that depends on which API you are using.

EDIT:
Forgot this is a DirectX forum
I don't have any reference with me right now, so can't help you much. You can google "alpha blending tutorials" to find tuts in the Internet. I recommend that you go to Articles & Resources (the link above), and search there.


Current project: 2D in Direct3D engine.
% completed: ~20%


[edited by - alnite on March 25, 2003 2:11:13 AM]

Share this post


Link to post
Share on other sites
In my alphablending engine these states are set to enable transparency.


  
vidw_Device->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
vidw_Device->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPH);
vidw_Device->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCAPHA);


Vikke Matikainen

Share this post


Link to post
Share on other sites
my code looks something like this :

g_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
g_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_pD3DDevice->SetRenderState(D3DRS_DESTBLEND,BLEND_INVSRCALPHA);
g_pD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
g_pD3DDevice->SetRenderState(D3DRS_ALPHAREF, 0x30);
g_pD3DDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_GREATEREQUAL);

so I''ve enabled the alpha transparancy...
The problem is :
When I apply (say) transpararent trees to a poly....it works fine..the reason for that being : the alpha values are in terms of black and white.... but with water that is not possible as the alpha values have to be in different shades of grey....
that is why it pixellates the water creating holes in the texture when i try to do it this way.

I''m also looking at the alpha blending functions...but not much help....
But will continue to look at alpha blending.

Share this post


Link to post
Share on other sites
The problem lies in your texture file. Don''t store alpha channel in your texture files as black and white, but grayscale. Make sure your texture file supports alpha channel (.tga and .dds formats are ones of them). When creating a texture surface, use D3DFMT_A8R8G8B8 format (so that alpha channel varies from 0 to 255, a number in between will give you a semi transparent texture).


Current project: 2D in Direct3D engine.
% completed: ~20%

Share this post


Link to post
Share on other sites
The texture I''m using is in grayscale.....
that is i have used 50 percent greyscale in photoshop...
But still the pixellating occurs...
In other images that I have loaded there is no problem with pixellating as they are not alpha images....
So i think the problem is not with the texture...but with the way i m using the alpha channel in DirectX....
I m able to get tree alpha to show trees, etc in my program....
but the problem persists with semi-transparent i images...

What I do is I apply my materials to an object in 3D Studio Max and then convert them to .X file format....
So when I m using alpha on trees etc...I get very good results...
but when I use semi-transparent images...like the water texture alpha channel is 50 percent gray , I get the pixellation....

I m loading all the files and image formats correctely...so there is no problem with that too...I m using TGA file format only....
Plz advice

Share this post


Link to post
Share on other sites