Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If you are not familiar with using Light Path Expressions (LPEs), this page is a good place to start. The sections below will try to explain what LPEs are, visually represent their how they work and expand on what are the possible use cases.What are

UI Text Box
typetip

The Advanced Light Path Expressions article goes into greater detail about complex LPE usage and concepts.

 

 

What are LPEs?

...

Light Path Expressions are a special type of render element with advanced capabilities. They use They use regular expression patterns to record selected events of light contribution along the path of a ray.

This can be used for very fine control in compositing by allowing you to change for example only tweak, for example, the GI coming from lights, the environment or self-illuminating objects separately, or each separate GI bounce, or the self-reflections of an object or the way SSS is seen behind refraction without re-rendering. The possible applications are practically endless.

 

 

Light Paths

...

Section
 Leave the Light Select set empty for contributions from all scene lights, the environment or emissive objects. Add lights to Light Select set if you want to filter only their contribution.

: camera -> event -> light source.

Column
width60%

Generally speaking, in ray tracing we shoot rays from a virtual camera. Those rays hit different surfaces in the scene and bounce between objects until they are finally terminated at a light source.

Light Path Expressions follow the path of a ray and allow us to ask specific ray hits (which we call events) to be recorded. A ray, and the way an expression is built, always starts from the camera and ends at a light source. The different ray hit events in between is what we capture with LPEs.


To understand how this works, let’s look at the different symbols that make up an expression.

  1. Starting from the camera, we use the C symbol to designate it.
  2. When the ray hits a surface and starts bouncing in the scene, we record these ray hit events. In the first series of

Since Light Path Expressions record selected events, we need to look at how a ray travels along a path and what events occur on that path.

The path always starts from the camera, which we label with the C symbol in the expressions.

We can capture the many different events on that ray path. In the first
  1. simple examples, we will not look at the events themselves
.The path always ends
  1. . We will look at the ray hit events in the next section , where we explain Ray Spawn events and Ray Scatting types.
  2. Finally, the ray path is always terminated at a light source, which can be a light (L), a self-illuminating object (O) or the background (B) and is designated with these 3 symbols at the end of the expression.

  or an emissive object, or the environment. We label the light sources with the L symbol, emissive objects with O and the environment with the B symbol.

In a simple example, the path or a ray can be represented in this way.

UI Text Box
typetip
Column
width5%

 

Column
width35%

Image Modified

A single event example - the ray start from the camera, an event (hit) occurs and the ray is terminated at a light source

Section
Column
width60%
UI Text Box
typetip

Leave the Light Select set empty for contributions from all scene lights, the environment or emissive objects.

Add lights to Light Select set if you want to filter only their contribution.

 

In a more realistic scenario, multiple events can occur on a ray path. We can select which one ones to record, or we can record the accumulation of subsequent events along a path.

For example, we can capture the diffuse reflection (GI) starting from the camera and ending at a light. Or we can record a path that goes through a number of refraction hits, then reflects off another object and ends at a light.

Column
width5%

 

Column
width35%

Image Modified

Multiple events example - the ray starts from the camera, makes multiple hits and ends at a light source

...

Ray Spawn Events and Scattering Types

...

Section
Column
width60%

When a ray hits a surface, it can reflect, refract (transmit), or pass through a volume. These are the ray spawn events which we can record with LPE symbols.

We use the R symbol for reflection, T for refraction and sub-surface scattering, and finally V for volumes.

They can be used directly, Three types of events can be recorded along the path of a ray - reflection, refraction and volume. We mark them with R for reflection, T for refraction or transmission and V for volume or sub-surface scattering. Thеy can be used directly e.g. R captures reflections of any scattering type and is also equivalent to <R.>.

 

We can To further specify the kind of hit we want to trace , we can combine them by combining combine R, T and V with one or more scattering types - diffuse (D), glossy (G), singular (S) or straight (s). If we don’t specify that, all scattering types are assumed for our R, T or V events.

This . That allows us to filter the results only from diffuse reflection, for example with <RD> or combine glossy and singular reflection - <R[GS]> . We label the scattering types with D for diffuse, G for glossy, S for singular and s for straight or no scattering.

 

By using Using these ray spawn events and scattering types, we can recreate some familiar render elements or create custom single or multiple event expressions.

UI Text Box
typetip

Right click in the expression field to access a list of the available expression letters symbols and some presets that can be used as a starting point.

Note that the equivalent examples are there only for reference and it will be faster and more efficient to use the already available render elements if no modifications to them are needed

to get you started.

Column
width5%

 

Column
width35%
Image slider
Panel


Direct Diffuse Light select equals a A single diffuse reflection hit.

C<RD>L (Lighting)

Panel

Specular

RE is the combination of singular and glossy reflectionA single hit for glossy and singular reflection.

C<R[GS]>L (Direct Specular)

Panel

Refraction RE is the combination of specular and glossy refractionGlossy and specular refraction.

C<T[GS]>.+L (Refraction)

Panel

Multiple events - : Glossy and specular and glossy refraction followed by diffuse reflection.

 C<T[SG]><RD>L

Panel

Atmosphere RE can be represented by a A single volumetric event.

 CV.* (Atmosphere)

Modifiers

and the Arbitrary ray spawn and scattering type?

 

Object or material select

LPEs can be modified to work as object or materials selects just by adding a label.

For example since C.* will give us the Beauty or Full light select equivalent, C.'m1'.* can be used to separate only the RGB for materials with material label "1". To do so, we must first add an extra attribute called Light path expression label to the materials we want to use. The label can take numeric or text values and needs to be preceded by m and enclosed in single quotes when added to an expression.

Similarly C.'1'.* will filter the RGB only for objects with added VRay User attribute lpe_label=1 and C.'cube'.* will be the RGB for objects with VRay User attribute lpe_label=cube. Note that Maya attributes cannot be used in the same way.

Material and object labels can be added to any valid light path expression and thus are very useful in tricky cases like for example self reflection  C<R[GS]'m1'>.'m1'+L or ?

Boolean operations

here

Examples

SSS:

Fancy Bullets
typecircle
  • SSS from objects directly visible to the camera C<TD>.+L
  • SSS directly visibly OR occluded (behind reflections and refractions) C<[RT][SG]>*<TD>.+L
  • SSS only from occluded objects C<[RT][SG]>+<TD>.+L

Self-reflections by material ID 1

Fancy Bullets
typecircle
  • C<R[GS]'m1'>.'m1'+L

 

Emissive

Fancy Bullets
typecircle
  • Emissive (self-illuminating) objects only - direct camera rays CO
  • The GI coming from emissive objects C<RD>.*O
  • The union of GI, coming from emissive object and the directly visible to camera emissive objects (C<RD>.*O)|(CO)

GI



Section
Column
width30%

 

Column
width10%

 

Column
width20%
UI Text Box
sizemedium
Align
aligncenter

Read next

The Advanced Light Path Expressions article goes into greater detail about complex LPE usage and concepts.

Column
width10%

 

Column
width30%

 

Fancy Bullets
typecircle
  • Full GI C<RD>(.+L|.*[OB])
  • GI from the environment only C<RD>.*B
  • GI minus GI from environment C<RD>(.+L|.*[OB])-(C<RD>.*B)