Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Deckards

Lights in a tile based map

This topic is 5400 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to add a position light for each tile in tile based map, how could i achieve that? The problem is that i'd have too many opengl lights and i think multutexturing is only used for torch and that kind of light. [edited by - Deckards on March 1, 2004 4:43:59 AM]

Share this post


Link to post
Share on other sites
Advertisement
You could consider performing very simple lighting calculations in software, building a colormap to use when drawing your tiles. In Golem, I maintain a list of light data including position, color, and attenuation range for each light, and perform a simple calculation for every sub-tile (1 tile=4x4 subtiles) in the drawn view. I don''t go with a full lighting calculation; rather I simply calculate the distance squared and scale intensity from 0 (at d^2=Range^2) to 1 (at d^2=0) using Inten=(RangeSquared-DistanceSquared)/RangeSquared clamped to [0,1] then multiply by each color component to generate the RGB color value for that subtile and for each light, building a colormap of subtile colors as I go. These are used as glColor() attributes to provide tile lighting, and I can interpolate between values to obtain the brightness and light color of any given world coordinate value, for the purpose of lighting/color objects occupying the world.

Since I use DistanceSquared and RangeSquared, I save on sqrt() calls and get a nice-looking quadratic fall-of rather than linear as a bonus. It''s a bit of a hack, but so are many things in 2D tilebased games. Also, for lights which are guaranteed not to move, or for large area lighting effects (lava pools, etc.) I maintain a static light array with an RGB entry for every subtile vertex in the map. Static lighting calls add color to this map, which is used in the final vertex lighting calculation. You can check out the screen-shots page for Golem (see link in sig) to see how this lighting system looks in action.


Golem
Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!