Skip to main content
gamedev.net
🔒 Locked

2D sprite shadow problem

Started by warp X Sep 19, 2005 at 6:03 PM 3 replies 1.2k views
Original Post
warp X
warp X
I'm developing with vs2003 vc7. I use Haaf's Game Engine, which uses DirectX 8.0. The problem: I use a duplicate of a sprite as a sprites shadow. The duplicate is black and transparent. The backround is seen through the shadow a little bit. This is definitely what I want. When two shadows collide, the area of collision, or intersection, gets rendered with a darker color than the rest of the shadow. This isn't very realistic, when there is supposedly only one light source, usually the sun, in my game. That's my problem. The technical stuff: -The color mode is 32-bit ARGB, with the first byte being the alpha channel. -A sprite is rendered as a quad with a texure on it. -A blending color can be set for a vertex for the following operations: Texture's texel colors can be either: added to the vertex color, resulting in texture lightening. The vertex color 0xXX000000 makes no effect. multiplied by the vertex color, resulting in texture darkening. The vertex color 0xXXFFFFFF makes no effect. -Using the alpha channel: The alpha channel represents transparency. The less the value, the more the effect. Zero alpha = invisibility. Alpha blending can be used to blend an object's pixel colors with the pixels already on the screen when rendering. This is used for usual objects rendering. With alpha addition the object's pixel colors are added to the pixels already on the screen when rendering. This is used to create lighting effects. Now, I'm pretty sure somebody here knows about this kind of stuff, right? The problem together with the technical stuff: I'm using color multiplication with black vertex blending color. The result is a totally black character. I'm also using alpha blending so that I can see the background. With this alpha blending, when two shadows collide, they are also blended, so that the resulting color in the collision area, due to the dark color of the shadow, is darker than the original shadow. I think that in the colliding area the colors of the shadows are added togehter, is this correct? Or are they multiplied, I don't know. How does the blending operation work? Questions: Are there solutions to this problem, or is this a permanent issue, when using this kind of "sticked together with a chewing gum" feature? Is this even a real problem or am I just being nitpicky about things or exaggerating?
"I got stuck between levels 4 and 5 and got into this strange place: warp X..."
warp X
warp X
Got it working by using z-buffer.
"I got stuck between levels 4 and 5 and got into this strange place: warp X..."
Captain Nuss
Captain Nuss
Quote:
Original post by warp X
When two shadows collide, the area of collision, or intersection, gets rendered with a darker color than the rest of the shadow. This isn't very realistic, when there is supposedly only one light source, usually the sun, in my game.

That's not correct. This behaviour is indeed realistic.

Ps: I was looking for an image explaining the behaviour, but couldn't find one that quickly.
warp X
warp X
Let me disagree. If one goes behind a tree to hide from the sun, his shadow disappears, doesn't it? I need to see an image you were talking about to change my opinion.
"I got stuck between levels 4 and 5 and got into this strange place: warp X..."
Captain Nuss
Captain Nuss
In the real world, there is not just the direct light from the sun to be taken into account. If it was, the shadow would be completely black. Instead, the environment reflects some of the light coming from the sun. This light casts further shadows, even when you're standing behind the tree. It isn't the same, clearly defined shadow as would have been cast by the light of the sun, though, as the light reflected by the environment is made up from a bunch of light rays coming from totally different directions, resulting in a very fuzzy kind of shadow. But you're right in so far as you probably wouldn't take that into account in a game. :)

Topic Locked

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

Sign in to reply to this topic.