iDevGames Forums
softening 2d shadows - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: softening 2d shadows (/thread-1278.html)



softening 2d shadows - NelsonMandella - May 18, 2009 03:24 PM

I'm trying to soften the jagged edges on the shadows in my 2d game, but I'm having some difficulty in figuring out how to do so. Here are some images of the jagged hard shadows to illustrate my problem,

[Image: shadow2.png]
[Image: Picture5.png]
[Image: Picture3-1.png]
[Image: Picture6-1.png]


I subdivide all tiles into a number of smaller tiles and then cast rays towards light sources to determine wether to light them. I guess that softening them would just require averaging the "brightness" value of the subdivided quads with that of their neighbors, but my problem is that I do not store and keep track of the subdivided quads- I generate them on the fly as needed when rendering a given tile. Is there any way to soften shadows without keeping track of every single subdivided quad for every tile in the game?


softening 2d shadows - Oddity007 - May 18, 2009 04:25 PM

Your problem is because of your resolution of per-tile is too low. Do it per-pixel instead, for a game like yours it shouldn't be too expensive.


softening 2d shadows - Bachus - May 18, 2009 04:39 PM

NelsonMandella Wrote:I subdivide all tiles into a number of smaller tiles and then cast rays towards light sources to determine wether to light them. I guess that softening them would just require averaging the "brightness" value of the subdivided quads with that of their neighbors, but my problem is that I do not store and keep track of the subdivided quads- I generate them on the fly as needed when rendering a given tile. Is there any way to soften shadows without keeping track of every single subdivided quad for every tile in the game?

Offhandedly I can not think of a way (without keeping track of tiles). If this was shadow mapping then the easiest way would be to use percentage closer filtering. The technique should still be valid here. It works exactly like your idea. You take samples from each pixel's/quadrant's neighbor, and average the result.

Alternatively, you can subdivide to smaller quadrants and maintain your dynamic system. Try em both and make the faster/better one an option for beefier computers.


softening 2d shadows - Skorche - May 18, 2009 05:59 PM

http://www.gamedev.net/reference/programming/features/2dsoftshadow/

Render that to a texture and apply the texture use it as a lightmap when drawing your other tiles. That's what I'd do.

Looks pretty cool though. I would never have thought to do lighting like that in an isometric game. I do vaguely recall Diablo (which I've played for all of an hour) did something similar.


softening 2d shadows - NelsonMandella - May 19, 2009 01:07 AM

Oddity007 Wrote:Do it per-pixel instead, for a game like yours it shouldn't be too expensive.

Since I'm not using any kind of shader, any per-pixel operations would be impossibly expensive. As it stands I'm getting 30-75 fps on a 2.3ghz core 2 duo.


Bachus Wrote:Alternatively, you can subdivide to smaller quadrants and maintain your dynamic system. Try em both and make the faster/better one an option for beefier computers.

I fooled around with this method a bit and it looks promising- though the inability to average sub divided quads along the edges of the original parent tile still produces a somewhat, though more subtle, jagged effect, even with the blending. Still a work in progress though.

Thanks for the article skorche, still reading it over.

Also what is a reasonable machine spec to target for a casual dungeon crawler like the one I'm working on?


softening 2d shadows - Najdorf - May 19, 2009 04:19 AM

How about you calculate the lighting-color per vertex of the grid (not per square) and then use glShadeModel (GL_SMOOTH)?