• Register
Post news RSS Shadow and Light Part II

The completion of the discussion about the shadow and lighting in the dungeon. Includes a video of the shadows in action.

Posted by on

At the end of part I we had the shadows moving with the player, and more or less conforming to the space and shape of the walls, but as the player moved toward the end of the screen, the shadows would completely disappear.

The problem turned out to be with how I was determining the area to select from. I was using the basic code in the existing pick area method of the composite sprite, and tweaking until I got the correct values. The basic algorithm is:

1. Convert the AABB of the current scene render state to an OOBB

2. Calculate the inverse of that OOBB using the batch transform of the composite sprite object that is the shadow map.

3. Convert that inverse OOBB to an AABB.

4. Perform a query area on the composite sprite using the AABB, that does NOT target the OOBB of the individual sprites.

The last part, not targeting the OOBB of the individual sprites, was the key to getting the pick are to always return the proper objects based on the position of the player, which the map tracks as the player moves.

Here is a video that shows the shadowing in action. This video includes the dynamic light radius that is in the game also. In the video, the light radius is the minimum and would represent going into a dungeon with no torch or other light means. Equipping a torch gives you a larger view radius and you can use certain objects to change the light color. this can have an effect, positive or negative, on certain monsters.

We have added video on our blog, or on You Tube.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.