Skip to main content
GameDev.net gamedev.net
🔒 Locked

transparency problem

Started by niazware May 27, 2006 at 8:30 AM 1 replies 500+ views
Original Post
niazware
niazware
hi everybody I'm going to render a tree (using billboards), and also its shadow on a plane using a pre-rendered shadow map which is textured on a png file. I open photoshop, and make the shadow texture file transparent, but I can't see the plane under the shadow, I mean it is not transparent, what should I do? how should I use alpha testing and alpha blending? Currently I'm using alpha testing, and my reference value is 0x08, with GREATEREQUAL comparison, areas surrounding the shadow are visible, but the areas covered by the shadow are fully black (i.e. I can't see the ground under the shadow), what should I do now? should I change my codes (alpha blending?) or should I change my file format? please help me, thanks
jollyjeffers
jollyjeffers
Two important things:

1. The texture format that you load your file into - does it have an alpha channel (e.g. D3DFMT_A8R8G8B8). If not, you'll lose the alpha data from your file, thus you cant do any computations using it.

2. Are you aware that alpha blending is "draw order dependent" - and that you need to structure your rendering appropriately. Make sure you draw any semi-transparent textures/geometry LAST and in a back-to-front order.

The following basics should get you running:

D3DRS_ALPHABLENDENABLE = TRUE
D3DRS_SRCBLEND = D3DBLEND_SRCALPHA
D3DRS_DESTBLEND = D3DBLEND_INVSRCALPHA


Make sure you've read and followed Alpha Testing State from the SDK. In particular, note that it checks for hardware capabilities. The Alpha Blending State entry might also be of interest.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
ET3D
ET3D
For shadow, it makes sense to use a texture that contains only alpha. You can use the DirectX Texture Tool from the SDK to create such a texture. However, it seems like you already have an okay texture, since alpha testing works.

All you need is to turn on alpha blending (as Jack said) and to make your alpha less than 1, so that it blends some of the ground with the shadow colour. You don't have to change the actual texture, just multiply in the pixel shader of fixed function pipeline. This will allow you to play with the value easily, until you get the effect you're looking for.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.