Polynomial Texture Maps (PTM)
Project files: ptmtutorial.zip
In this tutorial we will learn how PTMs are used in Turtle and how to bake our own PTMs from existing models. We will start off by baking a PTM.
PTM Baking
Open the ptmbake.mb scene. The scene has been set up for a normal surface transfer. We are going to make the changes needed to output a PTM instead. Open the render settings window (
). First of all, we need to change File Format to OpenEXR MultiLayer.
Baking a PTM is computationally expensive, so we will keep the resolution of the output file low for this example. Set width and height to a value of 256.
Next, disable the Normals check box in the Outputs rollout and enable Ptm instead. Select Full Shading as ptm output. This will give us three different passes; one color pass and two passes for the coefficients data. If we don't need the color pass we can choose Illumination instead. This is normally the case, since the color pass is mostly usesful for subsurface scattering effects, but we'll use full shading anyway in this tutorial.
The number of shadow rays controls the quality of the self shadowing captured by the PTM. Higher number of shadow rays yields better results, less banded shadows and less noise. Enable Capture Shadows and set the number of Shadow Rays to 100.

Finally, hit the render button to make Turtle bake the PTM. As mentioned above the PTM will be generated in three render passes. One or two of the passes may output an entirely black image to the render window. This is perfectly normal, the generated PTM data may have very small and even negative values.



Using the baked PTM (ilrPtmShader)
We will now apply our newly baked PTM to a polygon plane. Open the ptmshade.mb scene. Make sure the polygon plane ptmPlane is selected and hit the PTM button (
) in the Turtle shelf. This will apply an ilrPtmShader to the object and automatically create a ilrPtmFile node with all necessary connections. To make the connections manually, create an ilrPtmFile node and make the following connections from the ilrPtmFile node to the ilrPtmShader in the Hypershade editor: outColor to color, outLightABC to lightABC and outLightDEF to lightDEF. Open the settings for the newly created PTM shader. The shader attributes will look as follows:

Hit any of the three link buttons (
) in the Ptm Data rollout to go to the PTM File node:

Change the PTM file by clicking on the folder button (
) to the right of the PTM File Name field and select the PTM file we just baked (located in the surface transfer output directory). Next we need to choose which layers in the OpenEXR file to use. As Color Layer , choose the layer starting with ptmCOL. Similarly, choose layers starting with ptmABC and ptmDEF for Light ABC Layer and Light DEF Layer respectively:

Now hit the render button to see the results.

The PTM shader contains a few unique attributes which deserves some attention:
Diffuse Gain controls the luminance fall off from the direction of maximum luminance. Increasing this value causes the light intensity of the current sample to decrease more rapidly as the direction of the incoming light moves away from the 'PTM normal' (the direction of maximum light intensity).
Since PTMs only model surface response to light directions from the hemisphere in the positive normal direction, you may get an abrupt transition on a surface when the light moves out of range. This can be avoided by applying a gradual transition function. Back Face Transition controls how early to start the transition (larger value yields earlier start).
Enabling Extract normal from ptm forces Turtle to recreate the surface normal from the PTM by analyzing the luminance function in the current sample. If this check box is disabled, the surface normal of the base mesh will be used instead.
Return to Tutorial index