The SaveRenderMesh shader allows you to capture the actual tesselated geometry that mental ray uses to produce the final render. This means that you can obtain geometry from the following sources:
- Sub-division surface geometry
- Displacement mapped geometry
- Particle instantiated geometry
- Hair instantiated geomety
- Geometry shader produced geometry
SaveRenderMesh is implemented as a lightmap shader that captures this geometry and saves it to a file of your choice in the standard Wavefront OBJ file format.
The output of the shader has these capabilities:
- Save render normals.
- Save render UV coordinates (interpolated if necessary).
- Save meshes out on each frame to different files.
- Save multiple objects to:
- a single mesh contained in a single file.
- individual meshes contained in a single file.
- individual meshes contained in multiple files.
Here, we have a simple torus with a fractal displacement map applied.
This is its render tree:
This produces a render that looks like this:
By adding the SaveRenderMesh lightmap shader into the rendertree (as shown in the diagram below), the next time we render, it will save the geometry into an OBJ file on disk. The “Lightmap_Color” node is provided automatically by XSI and you cannot delete it. You can safely ignore it however, since the lightmap shader does not write to this file.
Once we’ve rendered the torus, we can load the tesselated OBJ file back into XSI.
Note, there is actually no need to render the torus itself, since mental ray tesselates the geometry before the render itself takes place. This means that you can just drag a very small render region away from the torus, and you will still obtain the OBJ file.
Above you can see the original torus on the left with the loaded OBJ file containing the displaced geometry shown on the right. As you’d expect, there is no noticeable difference between the render geometry and the geometry we’ve just loaded in.
We are now able to edit the displaced geometry using the standard modelling tools.
Generally, it’s more efficient to let mental ray tesselate geometry at render time, however there are circumstances where it is extremely useful to have access to the tesselated render mesh. For example, if you have a displaced surface representing a terrain and you want to place rocks and vegetation onto it. In this situation, it’s very helpful to be able to see exactly where the surface is so that you can place your objects accurately.
On the next page, I’ll explain the various options available to you.