© Square Enix © Goodbye Kansas


Table of Contents

This workflow guide shows how to bake a height/displacement map with the V-Ray BakerTool.


Overview


Displacement map baking with V-Ray in Houdini is possible through the V-Ray BakerTool. 

The creation process is done in two render steps: first, we create a render element that contains information about the position of each point of the lowRes object in space. Then, we make a render element with information about the normals of the lowRes object.

As a final step, we render the HighRes object displacement map onto the LowRes object. 

The geometry creation process is not a subject to this tutorial. 

You can download an example scene from the download button below.


Download Scene


lowPoly
highPoly



Step 1: First Render


Let's start with the first render settings.

Connect the LowRes object node to the left input of the V-Ray BakerTool node.

 For this purpose, the lowRes object needs to have UVs and normals. The V-Ray BakerTool needs to be in Baking mode "Maps Baking". 



Render Element


Go to the V-Ray BakerTool node.

In the Output tab, enable the World Position option.

Enable a Custom Operator as well and make sure that both of those options are saved in 32-bit format.

The render Output has to be saved in an .exr format.





The Custom Operator is a V-Ray Color texture with input tied to the normal output of a V-Ray TexSampler.



Render Settings


In the Renderer tab of the V-Ray Baker Tool, set the Sampler to Bucket.

Make sure that the Noise Threshold is set to 0.005 and the Max Subdivs to 24 - these are the default values.

Once done, click the Bake Now button.

Wait for the map to be exported.



Step 2: Second Render


For the second render, connect the LowRes object to the left input of the V-Ray BakerTool and the HighRes object to the right input of the V-Ray Baker Tool.



Baking Settings


Set the Baking Mode to Projection Baking as we did for the first render.

Select the Closest Mode and set the Normals to Geometry.



Render Settings


Go to the Render tab and select the Bucket Sampler with the same parameters values as those for the first render:

Noise Threshold = 0.005

Max Subdivs = 24



Render Element


Here we need only one render element. Keep the Output in an .exr format.

In the World Position we need to place information about the coordinates of the HighRes projection points onto the LowRes object.

Click the Bake Now button and wait for the map to bake.



Step 3: Displacement


Now that we have all of the need information baked into .exr images, we can use a COP node to get the displacement map.

Go into /img/calculateHeightMap and in the three File nodes load the respective render elements:

  • InitialPosition - load the world position from Step 1;
  • InitialNormals - load the custom operator from Step 1;
  • ProjectedPositions - load the world position from Step 2.




The GenerateHeight node is a custom node that takes care of the following settings:

  • Extend Range - The value here should be higher than the biggest expected distance between the two meshes at any given point.
  • Clear_artifacts - This remap's purpose is to clear the closest places between the meshes, but because of the difference in the density, that will create an edgy effect. So let's leave the two most distal points (that's 0 and 1) and create a new point with Position 0.01. Set its Value to 0.


If the Position is bigger than 0.01, the displacement map will be badly clamped.  





The Blur node clears other unwanted artifacts from the displacement caused by the difference of point density between the two meshes.

Move the slider to compare the renders with and without blur and Clear_artifacts.


No blur and no Clear Artifacts

No blur, Clear Artifacts enabled

Blur enabled, Clear Artifacts enabled