fake shadows

Started by raft, June 24, 2010, 05:46:58 PM

Previous topic - Next topic

raft

hi,

i'm working on a simple ball game. as the ball can jump, it's crucial to notify the user over which tile the ball is. a shadow is the most obvious way but it's not supported in android version. even if it is supported, i doubt it will perform good enough.

so what's the best way of faking simple shadows ? most simple solution will be to highlight the tile without any shadow. calculating where shadow will be and modifying tile's texture may be an option but it wont be easy and will not perform good because of continuous texture uploading. what else can i do ?

thanks,
r a f t

EgonOlsen

A quad with a transparent, dark spot as blob shadow? Just like in bloodridge for example: http://www.hayles.demon.co.uk/bloodridge/bloodridge.html

raft

that sounds as a good idea ;D what about the tiles on the side ? i need to trim that shadow to tile's borders

EgonOlsen

I don't quite understand that tile problem yet...maybe an illustration would help... ;)

raft

as in the screenshot below. when the ball is close to a border of tile, the shadow should be trimmed to border.

(taken from ballbox)

EgonOlsen

Some ideas:


  • ignore it
  • make the shadow small enough, so that ignoring the problems doesn't hurt much. May not work too well, if the shadow's size changes, which is most likely to illustrate the height...
  • create a kind of small border that surrounds the tiles and that is slightly higher then the tiles, so that the shadow is hidden by it when leaving the tile. It can be visible or invisible if the background color is fixed. I did this in Paradroidz to hide that the fog of war actually wasn't clipped at the levels' borders.
  • maybe its possible to do something with a border and some weird blending modes combined...but i'm not really sure about this...maybe that's just complete nonsense...
  • do something on the geometry level of a more detailed shadow plane (not just one quad)...might be slow and a pain in the a... to code.

raft

thank you, you are full of ideas ;D i will consider these in detail..

EgonOlsen

Another idea (untested...like the others): Attach an IRenderHook to the shadow, disable depthbuffer writes before rendering via gl, enable them afterwards. After drawing the game world, render the background as a seperate object/world. That way, the background will overwrite the overlapping parts of the shadow. This won't work with a blitted or unicolored background though. But with something like in ballbox, it actually should.

EgonOlsen

#8
Thinking about this, i'm not sure if transparent objects write into the depth buffer at all. I've changed this behaviour one or two times, so i'm not sure what the current state is. I'll check this later...if they don't, the renderhook-step can be left out.

EgonOlsen

I've checked it...transparent objects don't write into the depth buffer. So if you are playing around with the idea mentioned above, you can simply leave out the IRenderHook part.

raft

ok, thank you :) for now i just higlight the tile for quick development. later i will look into cosmetic opportunuties ;)

paulscode

Another idea, you could still use a quad but change the both the position and uv coordinates of the vertices so that they never extend past the edge of the "floor".  In other words, you would shrink the size of the quad as it gets closer to the edge while at the same time changing the u/v coordinates of those vertices so that the shadow texture, rather than shrinking, gets clipped instead.  Of course this would become a bit more complicated if you were also changing the scale of the quad based on the object's distance from the ground, but the basic concept could still be applied.

raft

thanks, that's a good idea too ;D but implementing it will not be easy i suppose.
i guess i will stick to higlighting the tile. there will also be some items over some tiles and simply placing the shadow below them will look absurd.