mental ray supports light mapping. This is a two-stage process that runs on certain objects (whose materials contain a lightmap shader) to compute illumination or other information, and write the result into a texture or elsewhere. The first stage calls the lightmap shader in vertex mode once for every vertex of the object, and collects the returned information. The second stage calls the lightmap shader in output mode to use the collected information to paint a texture or other output data by looping over all triangles of the object.
The lightmap shaders in the base shader library collect direct and indirect illumination, and create a writable texture map from it. Although mental ray knows only about one lightmap shader, the base lightmap shader is split into the main shader that handles the output stage, and a separate shader for the vertex stage that is called by the main shader. This makes it easier to substitute only one stage with another user-written shader.
The lightmap illumination sampling shader is a simple color shader that samples the surface light influx density. It gathers direct illumination and optionally indirect illumination. It should not be used in a material; instead, it should be assigned to the input parameter of the mib_lightmap_write shader.
color "mib_lightmap_sample" ( boolean "indirect", integer "flip", array light "lights" )
The lightmap generation shader is the main lightmap shader. It gathers geometric information and texture coordinates on the triangle vertices and then writes a triangular region of texture for each triangle. For each pixel of the texture that the triangle covers, a sampling function is called and the results are written to the shader. The lightmap shader is attached to a material using the lightmap keyword.
struct { vector "point", vector "normal", vector "tex" } "mib_lightmap_write" ( color texture "texture", vector texture "coord", color texture "input", integer "fg_mode" )
-1 | off |
0 | force FG point on every vertex (of the tessellated geometry) |
1 | force FG point on every texture pixel (texel) |
2 | ... every second texel |
3 | ... every third texel (default) |
n (n > 3) | ... every n-th texel |
Copyright (©) 1986-2009 by mental images GmbH