Controlling shader visibility with Cycles Light Path Node

Software:
Blender 2.79

The Cycles ‘Input > Light Path’ node is useful for creating shaders with a selective optical participation.
A simple example of that would be a bright light material that is ‘seen’ by the camera and through reflection / refraction but isn’t actually lighting the scene.

Basic Ray Visibility can be set at the object level via the object’s Cycles setting:

Ray_Vis

But when we need to set per shader, and more specific Ray Visibility, we can set it up using a ‘Light Path’ node within the cycles shader:

Light_Path

The ”Is ________ Ray” outputs will give a 0 / 1 value indicating if the sampled ray is of a certain type,
The Ray Length output will give a float value representing the ray’s real world length,
And the ‘_______ Depth’ outputs  will give an integer representing the number of light bounces that were computed until the sampled ray.

In this simple example we see how to use the Light path node to create a light shader that only affects reflections / refraction but not producing any diffuse light.

A Mix Shader is used to mix between a Transparent Shader and an Emission Shader.

The ‘Converter > Math’ ‘Maximum’ node is used as a logical ‘OR’ operator to produce a value of 1 for the mix factor if the ray type is either a Camera Ray or a Glossy Ray or a Singular Ray, and cause the Emission shader to be active.
For other ray types the mix value will be 0 and the Transparent shader will be active.

Basic Emission Shader:
Ray_A

Restricted Emission Shader:
Ray_B.jpg

* At the time of writing this post the ‘Is Diffuse Ray’ output of the ‘Light Path’ node didn’t produce expected results so I couldn’t create a light material that creates diffuse lighting but doesn’t  appear in reflections and refractions.

 

From the Cycles documentation:

Ray types can be divided into four categories:

  • Camera: the ray comes straight from the camera.
  • Reflection: the ray is generated by a reflection off a surface.
  • Transmission: the ray is generated by a transmission through a surface.
  • Shadow: the ray is used for (transparent) shadows.

Reflection and transmission rays can further have these properties:

  • Diffuse: the ray is generated by a diffuse reflection or transmission (translucency).
  • Glossy: the ray is generated by a glossy specular reflection or transmission.
  • Singular: the ray is generated by a perfectly sharp reflection or transmission.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s