Skip to content

How to use Raycast shader node

Tugcga edited this page Aug 15, 2026 · 1 revision

In this small tutorial, we will create a displacement map for a sphere that turns it into a dodecahedron.

Okay, let's take a sphere and a dodecahedron.

img_001

To make the dodecahedron invisible, add a CyclesMesh property and disable all visibility flags except Raycast. This will make the dodecahedron invisible in the render but visible to raycasting.

img_002

Assign an emissive shader to the sphere and start creating the shader tree.

Start by adding Geometry and Raycast nodes, and connect Position to Position and Normal to Direction. This pair of nodes will measure the positive shift (along the normal) for displacement.

img_003

For the negative direction, create a vector (-1, -1, -1), multiply it by the Normal vector from the Geometry node, and connect the result to Direction on the second Raycast node. Also connect Position to Position. This node will measure the distance along the direction opposite to the normal.

img_004

Multiply the outputs IsHit and HitDistance for both Raycast nodes.

img_005

Negate the result of the negative Raycast, and combine the obtained values by taking a simple sum.

img_006

Finally, add 0.5 to the result. This will shift all negative values into a positive interval. Connect it to the Emission color.

img_007

Render.

img_008

Unwrap the sphere.

img_009

Add a CyclesBake property to the sphere and define an EXR output file.

img_010

Bake the map; you should obtain something like this.

img_011

Solidify the boundary (using Photoshop, for example).

img_012

Okay, now apply this map as a displacement map. Create a copy of the sphere (or a new one, but it should have the same UVs). Assign a simple diffuse material. Add an Image texture, set the mode to Non-Color Data, and connect it to the Displacement node.

img_013

Add a subdivision.

img_014

Render. It's a sphere.

img_015

Clone this wiki locally