How to generate lightmap by using Ray Tracing technique

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

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 on other sites
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.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• Forum Statistics

• Total Topics
634092
• Total Posts
3015437
×