Author Topic: fake shadows  (Read 3247 times)

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
fake shadows
« 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: fake shadows
« Reply #1 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

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: fake shadows
« Reply #2 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: fake shadows
« Reply #3 on: June 24, 2010, 06:15:08 pm »
I don't quite understand that tile problem yet...maybe an illustration would help... ;)

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: fake shadows
« Reply #4 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)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: fake shadows
« Reply #5 on: June 24, 2010, 06:35:36 pm »
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.

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: fake shadows
« Reply #6 on: June 24, 2010, 06:40:28 pm »
thank you, you are full of ideas ;D i will consider these in detail..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: fake shadows
« Reply #7 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: fake shadows
« Reply #8 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.
« Last Edit: June 24, 2010, 08:25:21 pm by EgonOlsen »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: fake shadows
« Reply #9 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.

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: fake shadows
« Reply #10 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 ;)

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: fake shadows
« Reply #11 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.

Offline raft

  • quad
  • ******
  • Posts: 1972
    • View Profile
    • http://www.aptalkarga.com
Re: fake shadows
« Reply #12 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.