Rogue-like shadow casting

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Chief
Party member
Posts: 101
Joined: Fri Mar 12, 2010 7:57 am
Location: Norway, 67° north

Rogue-like shadow casting

Post by Chief »

Could someone explain to me how one would go about doing shadow casting in a rogue-like grid-based game?

example:
Image

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. :cry:

Any ideas? (code examples would be nice :crazy:)

PS. couldn't find any older threads about this.
User avatar
subrime
Citizen
Posts: 76
Joined: Thu Nov 13, 2008 6:18 pm
Location: Australia

Re: Rogue-like shadow casting

Post by subrime »

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.
User avatar
ghostwriter
Prole
Posts: 38
Joined: Sat Dec 11, 2010 11:08 pm

Re: Rogue-like shadow casting

Post by ghostwriter »

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.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Rogue-like shadow casting

Post by TechnoCat »

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 72 guests