softening 2d shadows

Member
Posts: 194
Joined: 2009.02
Post: #1
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?
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #2
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.
Quote this message in a reply
Member
Posts: 268
Joined: 2005.04
Post: #3
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.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #4
http://www.gamedev.net/reference/program...oftshadow/

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.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #5
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?
Quote this message in a reply
Member
Posts: 749
Joined: 2003.01
Post: #6
How about you calculate the lighting-color per vertex of the grid (not per square) and then use glShadeModel (GL_SMOOTH)?

©h€ck øut µy stuƒƒ åt ragdollsoft.com
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Window drop shadows NelsonMandella 9 4,997 Mar 21, 2010 02:34 PM
Last Post: NelsonMandella
  Making 2D Stencil Shadows Soft metacollin 16 14,050 Jul 22, 2009 01:59 PM
Last Post: NelsonMandella
  Real-Time Soft Shadows MarkJ 6 4,896 Feb 17, 2007 03:10 PM
Last Post: MarkJ
  Rendering 2D Shadows for Convex Shapes Nick 16 9,312 Nov 28, 2006 11:50 AM
Last Post: memon
  Stencil shadows meant to look like this? ia3n_g 2 3,525 Nov 23, 2006 06:57 PM
Last Post: akb825