Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Dynamic Shadows, possible with gosu?
- By ? Date 2008-12-28 00:57
How would I go about implementing a dynamic shadow system like this in a ruby/gosu application, would I have to do it directly with C/openGL?
http://www.gamedev.net/reference/articles/article2032.asp

I'm working on an adventure platformer, my implementation would be considerably simpler because I only have rectangular bounding rectangles, rather than convex husks
- By jlnr (dev) Date 2009-01-01 20:09
The math for calculating shadows etc. seems logical. I've dreamed about adding something like this to my (C++) platformer too, so it's nice to see how it would look if done right.

I see two problems though if one would try to do it with gl blocks: first that the tutorial uses OpenGL's depth testing for Z ordering which Gosu doesn't. Also, there is no supported way to affect how Gosu will render its objects (e.g. modulated by the shadow in the alpha buffer).

All the complicated building of the alpha channel only happens so overlapping shadows don't darken the same area twice. This makes me wonder whether it wouldn't be cool if Gosu had support for the stencil buffer, given that the functionality used by clip_to seems to be very slow. Without modifying Gosu or finding a more complicated algorithm, I don't think you can avoid drawing on the same areas twice :(
- By ? Date 2009-01-01 22:55
A modified or different algorithm is not impossible, this is just a feature I would like to implement and I was wondering about the feasibility.
- By ? Date 2009-01-01 22:58
I'm not exactly going for realism, simply choosing the brightest or darkest one would probably look good enough, I don't really need it to be multicolored either, so the algorithm I'm looking at would be relatively simple with that and only using squares, etc.  I was unaware of GL blocks until I came to this forum recently, time to go fool around with them for a while :D
- By jlnr (dev) Date 2009-01-02 00:31
Well you could first try implementing the math and draw the shadow parts using Image#draw_as_quad or Window#draw_quad/draw_triangle. As far as I can see the only problem would be that if there are two obstacles in one line from the light, the overlap of their shadows would be darker than a normal shadow.
- By seand Date 2009-01-04 09:30
if you're running a sprite-based game it may be easier to squash and deform your sprite graphics and treat them as a flat black mask with a transparency. It'd require some hacking to bind them to only draw over a limited number of layers, but I don't think it would be that tough.
Up Topic Gosu / Gosu Exchange / Dynamic Shadows, possible with gosu?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill