Jump to content
  • Advertisement
Sign in to follow this  
bsh_aoa

How to generate lightmap by using Ray Tracing technique

This topic is 3776 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

when i read the book "An Introduction To Ray Tracing", i learn something about how to create a realistic image of my scene. But how to generate a lightmap (or 3 lightmaps) for each object in my scene? Current 3D game engine(e.g. UnrealEngine) used ray tracing to generate 3 lightmaps each object, and used these lightmap in shader to modulate diffuse color/texture. Is there any paper to read? thanks.

Share this post


Link to post
Share on other sites
Advertisement
I don't know of any paper about that (though I'm sure there are plenty of them out there). As far as I know, you must first build a basic raytracer. Then from every surface you shot n rays (where n is the resolution you want the lightmaps to be, and considering only point lights), and shot them towards each light source. If a ray hits another surface closer than the light, its contribute to the final lightmap pixel is zero. Otherwise it is a value that depends upon the number (and intensity ) of the light sources, the distance of the current light (if you want to take it into account here instead than during runtime light calculations) and so on. If no light source is visible from that pixel, the pixel is black. If all the lighs are visible, the pixel is white (or of the sum of the colors of the light sources).
Notes:
-If you want to use area lights, you will need to shot more than one ray from each texel to achieve penumbras.
-Color lights and light distances could be computed at runtime, but then you will need to store one lightmap for each light that affect a given surface. You can reduce this by just using lightmaps for the sun, and using other methods for dynamic lights.
-If you want to take into account Global illumination effect (in particular, indirect illumination from near surfaces), you need more sofisticate algorithms, i.e. radiosity. This is what was done for quake 2 and half life 1 and 2 (with HL2 being my favourite use of this technique).
-Today the games tend to move toward fully dynamic lighting and shadowing. Consider this before starting with a non trivial task as writing a light mapper.

Anyway, I've seen many threads about this topic here on gamedev. Try using the search tool, you should get many of them.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!