• Advertisement

Archived

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

Transparent shadows with DirectDraw (HELP)

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

A Wild guess is that they are not blitting the color at all, but simply using it as a mask to tell what pixels to cast shadow on. A really rough shadow (which is what they have in starcraft) can be made by simply down-shifting the color value of pixels within the shadow mask.

/Niels

Share this post


Link to post
Share on other sites
Advertisement
Thanks but there is a small problem with down-shifting the color value of pixels within the shadow mask.
I dont know how to do this. Can you give me little more info (source would be nice)?

Share this post


Link to post
Share on other sites
Hello...

You should read the "MMX enhanced alpha blending" article. It shows how to access the Vram of the surface and reading data from it.

Bye

Share this post


Link to post
Share on other sites
Starcraft is 8 bit mode, isn't it? They must have some special lookup table that determines the correct colour to shift by.. it looks up the source colour and then knows which colour to draw the shadow in..

.. or is Starcraft 16 bit?

Share this post


Link to post
Share on other sites
What's the resolution you're working with? If it's high enough, you may be able to get by SIMULATING the shadow by using alternating BLACK and TRANSPARENT pixels for the shadow, thus giving a decent appearance of shadow. (Since every other pixel in the shadow area will be black, it will let some of the background through, and black out the other parts. Logically making the background about 50% dimmer than it was.)

One of the benefits of this (if it will work for your articular application) is that the shadow data can be a part of the sprite itself, so you can save time by only blitting one surface per sprite.

Of course, that's just one way to work the issue.

-Marc

------------------
-Marc
Clan Destiny
www.mp3.com/clandestiny

Share this post


Link to post
Share on other sites
True alpha blending is definately the way to go, but if performance is a problem (I.e. you're targeting low-end HW), there are tricks you can play, such as 50/50 blends or dithering.

Reg. how to do it, I too recommend reading that article. The "downshifting" I was talking about is this:

Asuming you have a "mask" that tells which pixels should be covered by the shadow (E.g. a black/blue picture of the shadow). You check each pixel in the mask, if it is "blue", you get the color of the corresponding destination pixel and divide each color channel (Red, green and blue) by 2, by right shifting the value, and store it again. If the mask pixel is "black" you do nothing. (Preferably the mask is a 1-bit picture to save memory, but thats a different story).

If you are running 8-bit mode, you need a mapping table that maps each of the 256 colors to its best 50% representation.

/Niels

Share this post


Link to post
Share on other sites
Oh, just read the original question again: SRCAND doesn't work (It didn't in DX5, and I don't believe they've changed that, or?). In fact, nothing in DirectDraw works, besides blit, colorkeying and surface pointers.

(This IS quite sufficient, just pretty annoying that they can't tell the truth in the documentation, but rather see us waste precious time finding out for ourselves ... Doh! )

/Niels

Share this post


Link to post
Share on other sites
Well, thing is like this.
In Starcraft to blit a unit Blizzard have two surfaces. One is a unit and the other one is shadow of that unit (which is represent in blue color - dont know why?).
I have done the same thing in my game.
I blt the blue shadow with SRCAND ( to get transparent shadow ) but thing aint working.
For example when unit is on white part of screen the shadow is normaly blue.
I have try other shadow color but it just isnt working.

Any idea what should I do or just know what I am doing wrong plese replay or mail me.

Share this post


Link to post
Share on other sites
I understand that I have to downshift pixes that are blue in the mask I just dont know how to access a pixel in surface.

Could it be done with palletes cos I am using 8 bpp, but then I dont know how to use pallete on a single surface.
I have succeeded attaching pallete only on primary surface. Thanks

Share this post


Link to post
Share on other sites

  • Advertisement