Could someone explain to me how one would go about doing shadow casting in a rogue-like grid-based game?
example:
I've managed to recreate the effect with a trace function, where it traces from the light source and goes around 360 and scans for tiles to light up. Which is very inefficient.
Any ideas? (code examples would be nice )
PS. couldn't find any older threads about this.
Rogue-like shadow casting
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Rogue-like shadow casting
A fast way to do this is to make an array indexed by the relative position between the light source and the wall cell.
Each array entry contains a shadow mask that shows which cells are in the shadow of the wall celll.
This array only needs to be made once at game startup.
A light map is made by scanning the lit area for wall cells and combining the shadow masks with the current light map.
The number of array entries can be reduced by a factor of 8 by using symmetry considerations.
My only code for this is in c, but would be even easier to implement in lua.
Each array entry contains a shadow mask that shows which cells are in the shadow of the wall celll.
This array only needs to be made once at game startup.
A light map is made by scanning the lit area for wall cells and combining the shadow masks with the current light map.
The number of array entries can be reduced by a factor of 8 by using symmetry considerations.
My only code for this is in c, but would be even easier to implement in lua.
- ghostwriter
- Prole
- Posts: 38
- Joined: Sat Dec 11, 2010 11:08 pm
Re: Rogue-like shadow casting
Mmm well I implemented the method described in this paper a couple years ago with nice results, but until LÖVE gets shader support it probably wouldn't be appropriate to implement it this way.
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Rogue-like shadow casting
A bit overboard, but:
http://love2d.org/forums/viewtopic.php?f=5&t=1871
http://love2d.org/forums/viewtopic.php?f=5&t=1871
Who is online
Users browsing this forum: No registered users and 7 guests