Jump to content

  • Log In with Google      Sign In   
  • Create Account


Transparent shadows with DirectDraw (HELP)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Drki   Members   -  Reputation: 122

Like
Likes
Like

Posted 02 November 1999 - 01:37 AM

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.


Sponsor:

#2 Niels   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 October 1999 - 02:20 AM

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


#3 Drki   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 October 1999 - 03:27 AM

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)?

#4 Melo   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 October 1999 - 05:19 AM

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


#5 Sphet   Members   -  Reputation: 631

Like
Likes
Like

Posted 22 October 1999 - 06:06 AM

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?


#6 Clan Destiny   Members   -  Reputation: 122

Like
Likes
Like

Posted 29 October 1999 - 04:49 PM

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


#7 Niels   Members   -  Reputation: 122

Like
Likes
Like

Posted 30 October 1999 - 08:30 AM

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


#8 Niels   Members   -  Reputation: 122

Like
Likes
Like

Posted 30 October 1999 - 08:34 AM

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


#9 Drki   Members   -  Reputation: 122

Like
Likes
Like

Posted 02 November 1999 - 01:37 AM

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS