Mesh baking - Smashing-Tech/Smash-Hit-Blender-Tools GitHub Wiki
See also: LitMesh on the Smashing Tech Wiki
Note: This page is a technical document discussing how and why bake_mesh.py
works. If you don't care to know the exact details about mesh files, then you don't need to read this page, though you may be able to understand some of the limits of modding better if you do.
Introduction
Mesh baking is the process of creating a .mesh
file from a segment's .xml
file. A mesh file or LitMesh is a precomputed mesh that will be fed directly to OpenGL as raw triangle data. The goal of mesh baking is to compute this triangle data from a description of how the boxes should look from the segment .xml
file.
Lighting
Normally, lighting a LitMesh occurs in LitMesh::getLight( ... )
and LitMesh::shade( ... )
by using raycasts and checking the facing ratio to see how much light is being missed at a point.
Unfortunately, this is quite slow, so we instead accumulate the total amount of volume that a box near the point has intersecting with other, nearby boxes. This has a similar effect to preforming many ray casts.