"fake" soft shadows?

Started by
21 comments, last by davepermen 15 years, 8 months ago
I've got a 2d sprite running around on a 3d terrain and I'd like to put a fake shadow under it; kind of like a soft circular shadow. I guess it would require projecting a 2d circle onto the floor/terrain with alpha blending somehow, but im not quite sure how i would do this... If you need an example of what I mean, I guess its how games in the '95-'00 era would fake shadowing. Something like this: http://www.armchairempire.com/images/feature-articles/ps2-ff7/final-fantasy-vii-2.jpg http://i151.photobucket.com/albums/s146/Chaoticgamer/star_ocean_first_departure-2_qjprev.jpg http://psp.absolute-playstation.com/pspimages/final-fantasy-tactics-war-of-the-lions-psp-l3.jpg
Advertisement
This seems so easy I may be missing your question...

But...if your sprite chracter moves on the terrain I assume you have some kind of collision algorithm available...all you need then is the ability to find the normal of the polygon directly underneath your character.

Then you:
1) make a shadow sprite
2) place it at the ground level at the center of the characters feet
3) rotate it to match the normal of the polygon (offset it bit from the terain to prevent z-fighting)
4) use alpha blending

Remember --always update the position of the shadow as the last thing in the frame, after the character has been moved and so on.
ah, it does potentially seem easy, but then the terrain isnt necessarily flat! so a flat shadow wont work in every case. Even if you take the normal, if you're at a bend in the terrain, you'll get part of the sprite cutoff. I don't *think* disabling the z buffer would make it look right in this kind of case either.
Quote:Original post by sqpat
ah, it does potentially seem easy, but then the terrain isnt necessarily flat! so a flat shadow wont work in every case.

Then you're no longer looking for a "fake" shadow, you're looking for a real one! I don't think any of the screenshots you've posted have interaction with the terrain, do they? What kind of terrain are you dealing with? Are you looking for a method that involves subdividing a textured quad and then displacing it based on the terrain somehow?

You could always just make the shadow part of the sprite.
i cant make it part of the sprite because of jumping, etc that would place it off the size of the sprite texture/graphic. Also because of other dynamic effects i want to have with these shadows.

also i thought it was fake because i was dealing with shadows of 'sprites'? anyways, breaking up a textured quad onto the terrain might work i suppose... hm. I'll think about the normal suggestion some more, i suppose.
http://sqpat.com/project/mysample31-buggyshadows.PNG

hmm... im not too happy with this, even before making a decent graphic, and before adding the normal checks. I guess im still happy because i implemented the backbone of the animation framework, but... does anyone know of a good way to fake this soft shadowing thing so that it deals with terrain better? maybe placing a directional light above four little circles that'll only show on the terrain... i dunno. i dont have a great understanding of lights and keeping them from affecting everything in the scene.
You can just grab the polgons underneath the character and draw a textured alpha blended circle onto it which then will conform to the terrain. Since most terrain engines will give u collision points upon request, there isn't any need to try and traverse the terrain's geometry just sample it using a regualr grid and apply the texture onto that grid, to avoid zbuffer artifacts either offset it or draw with some sort of zordering bias, or u can just render it after the terraain but before any characters without any zbuffing at all.

Good Luck!

-ddn
hmmm.... I wrote the terrain engine myself. I think I get what you're saying, but it'd be hard to just 'draw' a circle onto the terrain. Did you mean perhaps to grab several spots instead of just one, then I can draw like 9 little circles to approximate one big circle? That might work, I suppose.


EDIT: okay, even I if I do a ton of samples there'll probably be noticable jagged mini-shadows sticking up over the bends of the terrain. And if I chose to set a custom texture stage over the terrain... because its done indexed and it has a special algorithm to cut down on draw calls, it'd just not be feasible.

I thought it would be easy to project a circle onto a surface without using an actual light, but maybe I think I'll be using an actual light. Perhaps a vertical directional light and I'll render some transparent circles and not write them to the z buffer... then maybe this way it'll shadow onto the terrain? Does this sound right? I'm not sure. Man, time to hit up a tutorial

[Edited by - sqpat on August 17, 2008 2:22:53 AM]
no, i think what he means is this:

- you grab all the triangles below your object from the terrain. may be just one, may be several.

- you bind a shadow-circle texture with projective texturing from top

- you draw those grabbed triangles again, but without the grass, and the shadow-circle texture instead. you use alpha-blending to fit it on the grass
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

This topic is closed to new replies.

Advertisement