This is the documentation for Enlighten.
Vertex baking
Introduction
In some cases it may be beneficial to use vertex baking. Instead of creating a texture and UV map, this bakes out the lighting for each vertex in the model and interpolates between them. If the model is tessellated finely enough then the lighting will be indistinguishable from the standard texture output. One benefit is that objects using vertex baking do not need a lightmap UV unwrapping, but models with large triangles are not suited for this type of output.
HLBS scene markup
The baking paramset should have the outputType
parameter set to vertex
like this:
scene_default.bp
<bakeParams name="128x128_vertex" resolution="128 128" outputType="vertex"/>
When using vertex baked output there are some scene configurations involving intersecting objects that may cause aliasing in the AO output.
Output UVs
The BakeUVStream
output from the baking step will identify the location of the vertex output in the output lightmaps such that appropriate vertex buffers can be set up for rendering. Since the pixels are packed densely care must be taken to lookup the pixels correctly. The UVs are using the DirectX UV convention (http://msdn.microsoft.com/en-us/library/windows/desktop/bb147229%28v=vs.85%29.aspx) where the floating-point texture coordinates ranging from [ 0.0, 1.0 ]
(inclusive) are mapped to an integer texel space value ranging from [ - 0.5, n - 0.5]
, where n
is the number of texels in a given dimension on the texture. The UVs for the texture coordinates are referencing the "middle" of the pixel in order to avoid ambiguities due to floating-point precision. The mapping of a floating-point UV to an integer is:
int u = int(floor(uv.U*resolutionU)); int v = int(floor(uv.V*resolutionV));
Sample vertex baking scene
In this scene the two spheres on the left are texture baked, while the two spheres on the right are vertex baked.
Scene description
The scene specifies two pairs of spheres, each with a unique lightmap (four lightmaps in total).
uboxVertex.scene
<?xml version="1.0" encoding="utf-8"?> <scene name="uboxVertex" version="1"> <instance name="sphere_vertex_A" systemId="1" paramSet="Interior" geometry="regular_whitesphere" type="Static Set Dressing" lmName="VERTEX_A" lmType="128x128_vertex" position="-780.912 310.003 150.0" rotation="0.0 0.0 0.0 1.0" /> <instance name="sphere_vertex_B" systemId="1" paramSet="Interior" geometry="regular_whitesphere" type="Static Set Dressing" lmName="VERTEX_B" lmType="128x128_vertex" position="-780.912 310.003 410.0" rotation="0.0 0.0 0.0 1.0" /> <instance name="sphere_texture_A" systemId="1" paramSet="Interior" geometry="regular_whitesphere" type="Static Set Dressing" lmName="TEXTURE_A" lmType="128x128_texture" position="-1082.912 310.003 150.0" rotation="0.0 0.0 0.0 1.0" /> <instance name="sphere_texture_B" systemId="1" paramSet="Interior" geometry="regular_whitesphere" type="Static Set Dressing" lmName="TEXTURE_B" lmType="128x128_texture" position="-1082.912 310.003 410.0" rotation="0.0 0.0 0.0 1.0" /> <instance name="ubox_left" systemId="2" paramSet="Interior" geometry="ubox_left" type="Radiosity" lmName="B" lmType="512x512" position="-1000.0 0.0 0.0" rotation="0.0 0.0 0.0 1.0" /> <instance name="ubox_right" systemId="1" paramSet="Interior" geometry="ubox_right" type="Radiosity" lmName="A" lmType="512x512" position="1000.0 0.0 0.0" rotation="0.0 0.0 0.0 1.0" /> <instance name="Box" systemId="1" paramSet="Interior" geometry="Box" type="Static Set Dressing" lmName="SSD" lmType="128x128_pack" position="1084.85 -384.894 35.3984" rotation="0.0 0.0 0.0 1.0" /> <volume name="Probes" probesParamSet="Cull_L1"> <resolution x="15" y="10" z="5" /> <size x="3400.0" y="2400.0" z="1000.0" /> <position x="-1700.0" y="-1200.0" z="5.0" /> <basis> <U x="1.0" y="0.0" z="0.0" /> <V x="0.0" y="1.0" z="0.0" /> <N x="0.0" y="0.0" z="1.0" /> </basis> </volume> </scene>
Bake parameters
The bake parameters specify texture
baking for two of the spheres and vertex
baking for the other two.
uboxVertex_default.bp
<?xml version="1.0" encoding="utf-8"?> <bakeParamsList version="1"> <bakeParams name="128x128_texture" resolution="128 128" packUVs="true" outputType="texture"> <direct maxAASamples="8" maxLightSamples="256"/> </bakeParams> <bakeParams name="128x128_vertex" resolution="128 128" packUVs="true" outputType="vertex"> <direct maxAASamples="8" maxLightSamples="256"/> </bakeParams> <bakeParams name="128x128_pack" resolution="128 128" packUVs="true" outputType="texture"> <direct maxAASamples="8" maxLightSamples="256"/> </bakeParams> <bakeParams name="512x512" resolution="512 512" packUVs="false"> <direct maxAASamples="8" maxLightSamples="256"/> </bakeParams> </bakeParamsList>
Vertex baking and final gather
Due to a limitation of the implementation, vertex baking does not work in conjunction with final gather. You should disable final gather for all objects that have visibility of a vertex baked object.