Gaffer: Displacement in Cycles [7/8] (Patreon)
Content
Cycles in Gaffer handles displacement as a separate material assignment. To set up displacement on our chess pieces, board border and edge, add eight new ShaderAssignment nodes and connect a cyclesDisplacement to each one.
Next, add cyclesImageTexture nodes, each pointed to the appropriate image texture, and connect either the R, G or B output channel to the Height input of each cyclesDisplacement. All our displacement materials will share the same Scale and Midlevel settings, so we can connect a shared cyclesValue to each. Set Midlevel to 0.5 since our height maps were created with 50% grey as the midpoint.
Finally, update the naming of nodes as desired for organization purposes and connect PathFilters to point to the appropriate objects. We can reuse a few PathFilters from higher up in the graph, but in the case of the pieces we'll need to create new filters since both black and white pieces share the same displacement. The final setup will look like this:
To enable displacement in our renders we'll need to add a couple of nodes down in the render settings section of our graph. Add a MeshType node and set it to Subdivision Surface. This will smooth out the lower poly models (which we want anyway) and allow us to get highly detailed displacement.
We only need to subdivide the geometry that has displacement (plus the backdrop), so this is a good opportunity to use a UnionFilter to combine all our displacement filters. Connect the filters using the UnionFilter, then connect the output to the MeshType filter input. To help keep things visually organized, right click on node connectors and add a Dot. This is an elbow that can be positioned to keep connectors from overlapping and creating a pile of spaghetti in the graph.
Next, add a CyclesAttributes and make a couple of changes: set Subdivision Max Level to a low-ish value, say around 5. This will prevent the scene from grinding to a halt or crashing as a result of attempting to subdivide the geometry excessively. Finally, set Shader Displacement Method to True. This enables real 3D displacement where the vertices of the geometry are moved. Setting it to Bump is much faster, but it's just an approximation and doesn't look good in closeup. Feel free to use this option for geo that will remain far from the camera; it could improve performance significantly.
That should do it! Fire up a new render in our catalogue to see how things are looking. Use cam_close (select it in our StandardOptions node) so we can see details clearly.
It's working, but a shared scale value of 0.5 is too much. Set it to around 0.03 for a nice look.
Follow a similar process to dial in the displacement on the board. After everything looks good, we're ready to make our final renders. Check that out in Part 8!