Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
In this reprinted <a href="http://altdevblogaday.com/">#altdevblogaday</a> in-depth piece, game programer Simon Yeung shares an overview on how to bake light maps of indirect lighting data by sampling from the photon map.
July 3, 2012
[In this reprinted #altdevblogaday in-depth piece, game programer Simon Yeung shares an overview on how to bake light maps of indirect lighting data by sampling from the photon map.] Continuing from my previous post, this article will describe how light maps are calculated from the photon map. My light map stores incoming radiance of indirect lighting on a surface which are projected into Spherical Harmonics (SH) basis. Four SH coefficients is used for each color channels. So three textures are used for RGB channels (total 12 coefficients).
To bake the light map, the scene must have a set of unique, non-overlapping texture coordinates (UV) that correspond to a unique world space position so that the incoming radiance at a world position can be represented. This set of UV can be generated inside a modeling package or using UVAtlas. In my simple case, this UV is mapped manually. To generate the light map, given a mesh with unique UV and the light map resolution, we need to rasterize the mesh (using scan-line or half-space rasterization) into the texture space with interpolated world space position across the triangles. So we can associate a world space position to a light map texel. Then for each texel, we can sample the photon map at the corresponding world space position by performing a final gather step just like in the previous post for offline rendering. So the incoming radiance at that world space position, hence the texel in the light map, can be calculated. Then the data is projected into SH coefficients, stored in three 16-bits floating point textures. Below is a light map that extracts the dominant light color from SH coefficients: The baked light map showing the dominant light color from SH coefficients
After baking the light map, during run-time, the direct lighting is rendering the usual way, a point light is used to approximate the area light in the ray traced version, and the difference is more noticeable at the shadow edges.
Then we sample the SH coefficients from the light map to calculate the indirect lighting:
Combining the direct and indirect lighting, the final result becomes:
As we store the light map in SH, we can apply a normal map to the mesh to change the reflected radiance.
We can also apply some tessellation, adding some ambient occlusion (AO) to make the result more interesting:
This post gives an overview on how to bake light maps of indirect lighting data by sampling from the photon map. I use SH to store the incoming radiance, but other data can be stored such as storing the reflected diffuse radiance of the surface, which can reduce texture storage and doesn't require floating point texture. Besides, the SH coefficients can be store per vertex in the static mesh instead of light map. Lastly, by sampling the photon map with final gather rays, light probe for dynamic objects can also be baked using similar methods.
March of the Froblins: http://developer.amd.com/samples/demos/pages/froblins.aspx
Lighting and Material of HALO 3: http://www.bungie.net/images/Inside/publications/presentations/lighting_material.zip
[This piece was reprinted from #AltDevBlogADay, a shared blog initiative started by @mike_acton devoted to giving game developers of all disciplines a place to motivate each other to write regularly about their personal game development passions.]
You May Also Like