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

Transparent shadows

Started by JaZsT Aug 16, 2001 at 3:48 AM 4 replies 300+ views
Original Post
JaZsT
JaZsT
Hello !! Here''s another lame question from me....but f*** it : In my 2D iso game I want to use "half" transparent shadows. I am using DirectX7(DDraw), and the only thing I can do is full transparency using surface color key (DDBLT_KEYSRC). So, how do i manage "half" transparency ???? I heard smth about alpha channel....I''d appreciate any kind of help !! Thanx !! Life lived unexplored is life not worth living !
Life lived unexplored is life not worth living !
Kylotan
Kylotan
Bear in mind that I think many drivers don''t support alpha blending under DirectDraw.
JaZsT
JaZsT
Hmm, so what''s the other way to do it if not with alpha blending ?? Any tricks, or just "don''t do it" ?

Thanx !
Life lived unexplored is life not worth living !
JackNathan
JackNathan
You could do a checkerboard pattern of transparent and black pixels for a rough approximation of 50% alpha.


Jack
TANSTAAFL
TANSTAAFL
Purely academic note: the word you are looking for is "translucent".

Translucency is achieved, as others have pointed out, by alpha support. DirectDraw has none. This leaves you with several options:

1) don''t use directdraw. move it to d3d or opengl. or, if you use ddraw7, you can do a sort of "hybridization" of dd7 and d3d7, just for the alpha effect.
2) implement alpha yourself in software. Its not impossible to do, many commercial games have done this.
3) use "fake" translucency, such as dithering.

if you go the hybridization route, you can achieve "true" alpha blending in directdraw. here''s a rough outline on how to do it:

1) you''ll need to initialize some d3d7 objects, namely an IDirect3D7, and an IDirect3DDevice7 object. You should have the IDirect3DDevice7 render onto some offscreen surface.
2) you''ll need some textures, one which you grab from the current scene, and one with the "shadow" image, along with the shadow''s alpha information (i.e. outside of the shadow will have an alpha of 0.0, and the inside of the shadow will have an alpha of 0.5 or whatever value you assign for this).
3) when doing a shadow (and you have to do this before you render the character, not after), copy the portion of the back buffer affected by the shadow over to the rendering target surface.
4) draw two triangles (to form a rectangle) that contain this area and are applying the shadowed texture.
5) blit the section back onto the back buffer.
6) do other drawing.

I know I went through this sort of fast, and this "trick" does add a bit of work (two extra Blt calls and a call to DrawPrimitive), but you will achieve the effects you desire.
Get off my lawn!
Buster
Buster
DirectDraw does not do alpha blitting. You have 2 choices. First, you can twiddle the pixels yourself. Second, move to DirectGraphics (DX8).

Topic Locked

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

Sign in to reply to this topic.