www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: raft on June 24, 2010, 05:46:58 pm

Title: fake shadows
Post by: raft on June 24, 2010, 05:46:58 pm
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
Title: Re: fake shadows
Post by: EgonOlsen on June 24, 2010, 06:04:31 pm
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 (http://www.hayles.demon.co.uk/bloodridge/bloodridge.html)
Title: Re: fake shadows
Post by: raft on June 24, 2010, 06:12:57 pm
that sounds as a good idea ;D what about the tiles on the side ? i need to trim that shadow to tile's borders
Title: Re: fake shadows
Post by: EgonOlsen on June 24, 2010, 06:15:08 pm
I don't quite understand that tile problem yet...maybe an illustration would help... ;)
Title: Re: fake shadows
Post by: raft on June 24, 2010, 06:21:59 pm
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 (http://ballbox.webcindario.com/))
(http://img704.imageshack.us/img704/8007/ballshadows.png)
Title: Re: fake shadows
Post by: EgonOlsen on June 24, 2010, 06:35:36 pm
Some ideas:

Title: Re: fake shadows
Post by: raft on June 24, 2010, 06:40:28 pm
thank you, you are full of ideas ;D i will consider these in detail..
Title: Re: fake shadows
Post by: EgonOlsen on June 24, 2010, 08:08:11 pm
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.
Title: Re: fake shadows
Post by: EgonOlsen on June 24, 2010, 08:23:39 pm
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.
Title: Re: fake shadows
Post by: EgonOlsen on June 24, 2010, 09:25:44 pm
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.
Title: Re: fake shadows
Post by: raft on June 24, 2010, 09:37:49 pm
ok, thank you :) for now i just higlight the tile for quick development. later i will look into cosmetic opportunuties ;)
Title: Re: fake shadows
Post by: paulscode on June 26, 2010, 04:40:51 am
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.
Title: Re: fake shadows
Post by: raft on June 26, 2010, 02:05:37 pm
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.