Using displacement and normal maps
with Renderman



This place is dedicated to the use of the baked normal and displacement maps generated by rayDisplace in a Renderman type renderer. I made a small shader template that shows how to displace the surface then use a baked normals map to « force » normals instead of the usual « N = calculatenormal( P) » method generally associated with displacement.

You can download the displacementshader here (.sl) : normalmap_displace.zip

This shader can work like a usual displacement shader, however there are a number of additionnal parameters :

Km_pos and Km_neg : if you only specify Km as the displacement multiplier as usual the shader expect a one channel displacement map where the 0-0.5 color range means negative displacement and the 0.5-1.0 range positive displacement. In case you want to directly use the dual channel (red for positive, green for negative) displacement maps like the ones I used to bake, you can set a non zero Km_pos or Km_neg and the shader will consider the map as such. The interest is that Km_pos and Km_neg can be different, allowing for better use of the color range (especially important for 8bit files, not so crucial for higher depths).

normal_map : if this parameter isn't left to a empty string, then the shader will try to load a normal map of that name and apply it after the displacement. If it is left to an empty string, then the shader will recalculate the normal in the usual way.

normal_map_space : to specify in which geometric space the normals in the map are supposed to be expressed. You can use the predeclared Renderman geometric spaces, or one that you declared previously in your RIB file. In one exemple you'll see it is set to « world » as we're loading a map of world normals. You can also set it to « point », « pointU » or « pointV » to convert back normals from point space, using the same convention as the spaceChange utility, that is keeping the surface derivatives as they are, rebuilding tgV from tgU and N, or rebuilding tgU from tgV and N. The « flexing arm » exemple uses that mode.

I prepared 3 example files, one for each type of surface (polygon, nurbs and subdivision), all ready to render!


polyTorso.zip


Flexarm.zip


subdTorso.zip

And the maps you will need :

dualChannelDisplace.zipworldNormalsTorso.zipmrArmDisplace.zipflexingArmPointNormals.zipunifiedDisplacementTorso16bit.zip

pointNormalsTorso.zip - polyTorsoPointNormals.zip

As you can see, due to the specific way displacement is handled by Renderman compatible renderers, it's much less of a hassle to modify a normal after a displacement, especially when using point space normals as pre_displaced surface information is still available!

Note : I still have difficulties recovering the correct tgU and tgV for surfaces that are not continuous in u and v like the subdivision surface. I'll be working on that, if you're a Renderman guru your help will be appreciated! Drop me a mail and tell me what I'm doing wrong please :)

To be continued...

Olivier Renouard

olivier AT drone DOT org