[Algorithms] applying precomputed and/or sampled lighting to dynamic objects
Brought to you by:
vexxed72
From: Charles B. <cb...@cb...> - 2001-01-12 23:10:32
|
The basic idea here is an old one : encoding the specular and diffuse lighting incident in a point in an environment map. To light an object near that point, you use the reflection vector to look up the specular map and the normal to look up the diffuse map. The final color is then : Out = (1 - Gloss) * Diffuse(normal) * Texture + Gloss * Specular(reflection) * (BRDF Texture) (the Gloss map may just be a function of position, or it may also be a function of angle (eg. the Fresnel term)). The (BRDF Texture) could be 1 in the simplest case. The normal and reflection vector might come from the vertices, or from a normal map (you need EMBM for the reflection vector to come from the normal map). All of this can be done with vertex + pixel shaders. This can produce very high quality lighting by including radiosity contributions in the environment map. The problem is that only a single environment map is used, and the lighting environment is actually location dependent. To address this, I propose that you lay down several environment map sample points (you create a new map as a preprocess when you detect that the old one is a bad approximation there). All the environment map points are joined by a tetrahedral net (simplicial complex). At run time, the center of the object is used to find its environment maps. That center point selects a tetrahedron, which in turn selects four environment maps. You can find "barycentric" coordinates in the tetrahedron by using volumes of sub-tetrahedra just the same way you use areas of triangles. You use a "virtual" environment map by alpha-blending together the four maps at the corners of the tetrahedron using their barycentric coordinates as alpha values. Thus the Diffuse and Specular terms in the above lighting equation are replaced with four alpha-blended terms. This can be done with 7 passes using two-multitexture hardware. First precompute a "Specular Response" texture as BRDF * Gloss. 1) render two diffuse environment maps 2) alpha blend in two more diffuse environment maps 3) multiply by (1-Gloss) * Texture 4 - 7) add on Specular(i) * (Specular Response) for i = 1 to 4 To use normal maps requires three-simultaneous texture hardware, I believe. I don't think there's any way to use fewer environment maps without severe transitioning artifacts. If your game has strongly constrained environments, then you can use the walls of the game as boundaries of the graph of environment maps, so that few (or no) tetrahedrons are created (for example, you could have just a linear set of nodes down a hallway). Very cool little BRDF note I just learned : almost all materials reflect more strongly at glancing angles (this is obvious for glass and chrome and whatnot) - it's even true for paper! Hold a piece of paper at a very glancing angle to a light source, and you will observe a strong specular reflection!! Whether or not this affects the typical illumination of paper at all is another question... -------------------------------------- Charles Bloom www.cbloom.com |