Re:Tiled Shadow Maps
by JasonSage on Monday July 23, 2012 @03:23PM
(#4282621)
I assume you mean for generating the shadow map before it is scaled and pixelized? I'm not familiar with techniques for doing such a thing. You could probably step through each object and draw lines from the corners based on the angle between the player tile and the object. The approach I listed would actually save you from testing every single object—as soon as a black pixel is detected in an algorthm, it moves to the next line, meaning that the number of objects that may exist in that direction at a greater distance is completely irrelevant.
[ Parent
| on HN ]
I guess I was thinking something like this:
http://roguebasin.roguelikedevelopment.org/index.php/Eliglos...
(the second example, "raycasting"). You'd work on the "native tile resolution".
I.e. you just "swipe" lines starting at the player position to the edge of the map, in a circle; as soon as you hit an obstacle tile, you stop marking the tiles ("pixels") on the line as lightened. No need to do any per-object iteration (as long as the tile map contains object references in tile positions)
This works, but gives you no indication of whether the tile is partially visible or not, much less how visible. An accurate indication of this would require many more rays and a lot of processing.