---
title: "Light Path Expressions"
canonical: "https://documentation.chaos.com/space/VMAYA/111739516/Light%20Path%20Expressions"
format: markdown
---
This page provides information about Light Path Expressions.

 

## **Overview**

---


## <span style="color: #000000">**Scene Setup**</span>

---

<span style="color: #333333">The scene setup is similar to the Light Select workflow. As LPEs are a mode of the Light Select render element, the expression will capture contributions of the light(s) added to the Light Select set. If the Light Select is empty, the expression will capture contributions for all scene lights.</span>

<span style="color: #333333">LPEs also allow extracting information from the environment, for example, capturing the GI that comes from the environment only. This does not require adding lights to the Light Select set.</span>


## <span style="color: #000000">**Syntax**</span>

---

<span style="color: #333333">The LPE syntax is based on regular expressions.</span>

<span style="color: #333333">Expressions describe a light path that starts from the camera and traces all light bounces to a light source.</span>

<span style="color: #333333">Essentially, the syntax follows the direction in which a ray travels in the scene and captures information along the ray path.</span>

<span style="color: #333333">Keep this information in mind, as light in the scene travels from the light source to the camera, but the expression is in reverse, following the path of the rays shot from the camera.</span>

<span style="color: #333333">For example, if you need to capture GI bounced off </span>one object onto another, light will travel from the light source onto the object that casts GI, then onto the object that receives GI, and finally <span style="color: #333333">end at the camera. </span>However, in LPEs, just like in ray tracing, the expression will be in reverse, starting from the camera, asking for which object receives GI, then which object casts the GI, and ending<span style="color: #333333"> at the light source.</span>

 

## <span style="color: #000000">**  LPE Symbols  **</span>

---

<span style="color: #333333">The LPE alphabet consists of the symbols representing a ray event/type and additional regular expression symbols (“.”, “+”, “*”, “<”, “>”, “[“, “]”, “|”, “?”, “^”, and additional label strings). </span>

<span style="color: #333333">A valid expression starts from the camera (</span><span style="color: #333333">**C**</span><span style="color: #333333">), captures ray spawn and scattering events, and ends at the light (</span><span style="color: #333333">**L**</span><span style="color: #333333">), emissive object (</span><span style="color: #333333">**O**</span><span style="color: #333333">), or the environment (</span><span style="color: #333333">**B**</span><span style="color: #333333">).</span>


<span style="color: #333333">Ray spawn events other than </span><span style="color: #333333">**C**</span><span style="color: #333333"> or V can be combined with scattering types (e.g. </span><span style="color: #333333">**<RD>**</span><span style="color: #333333"> - capture only diffuse reflection) to get a more specific ray event, or they can be used directly (e.g. </span><span style="color: #333333">**R**</span><span style="color: #333333"> - capture reflections of any scattering type. This is also equivalent to </span><span style="color: #333333">**<R.>**</span><span style="color: #333333">)</span>

<span style="color: #333333">Ray termination events can also be combined with each other when you want to capture the contribution of a light together with emissive objects, e.g., </span><span style="color: #333333">**C<RD>.*[LO]**</span><span style="color: #333333"> will capture the GI coming from lights or emissive objects.</span>

<span style="color: #333333">See a complete list of LPE Symbols below:</span>

LPE Symbols

|  |  |  |
| --- | --- | --- |
| Symbol | Description | Type |
| **  Initial ray spawn event  ** |
| C | Camera ray | Initial ray spawn event |
| **Ray spawn events** |
| R | Reflection ray | Ray spawn event |
| T | Transmission ray | Ray spawn event |
| V | Volume ray | Ray spawn event |
| **  Scattering types  ** |
| D | Diffuse scattering | Scattering type |
| G | Glossy scattering | Scattering type |
| S | Singular scattering | Scattering type |
| s | Straight (no) scattering | Scattering type |
| **  Ray termination (final) events  ** |
| L | Light hit | Ray intersection event |
| O | Emitting object hit | Ray intersection event |
| B | Background hit | Ray intersection event |
| [V-Ray 7 Beta] **Optional Modifier/Mode Prefix** |
| shadow; | Shadow instead of real lighting | Contribution modifier |

![image](media://488a6fba-b540-45d7-a211-70cb5ba9af9e)


## **Presets**

---

<span style="color: #333333">A number of presets are available for Light Path Expressions.</span>

<span style="color: #333333">There are preset equivalents to already available render elements (</span>such as Beauty, Lighting, GI, and Light Select types, etc.<span style="color: #333333">).</span>

<span style="color: #333333">The Misc and masking presets are useful in common use cases.</span>

<span style="color: #333333">Any preset can be used as a starting point for building other expressions, and like any LPE, they can be combined with</span><span style="color: #000000"> </span><span style="color: #000000">[boolean operations](https://docs-chaos.atlassian.net/wiki/spaces/VMAYA/pages/111739516/Light+Path+Expressions#Booleanoperations)</span><span style="color: #000000">.</span>

LPE Presets: Render Elements equivalents

|  |  |
| --- | --- |
| Preset | Light path expression |
| **Render elements** |
| RGB | C.* |
| Self-illumination | C[OL] |
| Background | CB |
| Lighting | C<RD>L |
| Specular | C<R[GS]>L |
| GI | C<RD>(.+L|.*[OB]) |
| SSS | C<TD>(.+L|.*[OB]) |
| Reflection | C<R[GS]>(.+L|.*[OB]) |
| Refraction | C<Т[GS]>(.+L|.*[OB]) |
| Atmosphere | CV.* |

![image](media://dbac3a21-139a-4e0e-bb28-18137d26a53d)


> ✅ It will be faster and more efficient to use the already available render elements instead of their LPE equivalents in the presets, of course - the examples are there as a point of reference.


LPE Presets: Light Select equivalents

|  |  |
| --- | --- |
| Preset | Light path expression |
| **Light selects** |
| Direct Illumination | CRL |
| Direct Diffuse | C<RD>L |
| Direct Specular | C<R[GS]>L |
| Full | C.*L |
| Indirect | CR.+L |
| Indirect Diffuse | C<RD>.+L |
| Indirect Specular | C<R[GS]>.+L |

![image](media://d2de0e7f-c44f-41fc-81b7-8c36dbedf5f4)


LPE Presets: Misc

|  |  |
| --- | --- |
| Preset | Light path expression |
| **Misc** |
| Self-illumination, no lights | CO |
| GI from self-illumination | C<RD>.*O |
| GI from environment | C<RD>.*B |

![image](media://a5df210b-d491-440b-9576-41df3e1d7971)


LPE Presets: Object and Material Select

|  |  |
| --- | --- |
| Preset | Light path expression |
| **Object/Material select** |
| Indirect for object label 1 | CR'1'.+L |
| Indirect for all object labels but 1 and 2 | CR[^'1''2'].+L |
| RGB for material label 1 | C.'m1'.* |

> ✅ To use object labels, add V-Ray User Attributes to your object, where the attribute name is **lpe_label** and equals your custom label. For example, **lpe_label=testLabel**.
> ✅ 
> ✅ To use material labels, add Extra V-Ray Attributes > Light Path Expression Label to your material. When used in expressions, material labels require the **m** prefix.
> ✅ 
> ✅ Refer to the examples below for guidance on setting up object and material labels.

![image](media://848fecbc-a9fe-49d0-9165-ae632f69a360)


---



## **Boolean operations**

---

<span style="color: #333333">Boolean operations allow us to combine expressions. We can complement (</span><span style="color: #333333">**^**</span><span style="color: #333333">), intersect (</span><span style="color: #333333">**&**</span><span style="color: #333333">), or unite (</span><span style="color: #333333">**|**</span><span style="color: #333333">) expressions, or we can subtract (</span><span style="color: #333333">**-**</span><span style="color: #333333">) one expression from another.</span>

<span style="color: #333333">Boolean operations can also be very useful in various scenarios to simplify the compositing workflow.</span>

> ✅ The [Advanced Light Path Expressions article](https://docs-chaos.atlassian.net/wiki/spaces/VMAYA/pages/111739227) provides in-depth details about complex LPE usage and concepts.


Boolean operation symbols

|  |  |
| --- | --- |
| Boolean operation | Symbol |
| **Expression operators** |
| Complement | ^ |
| Intersection | & |
| Union | | |
| Subtraction | - |


![image](media://af93b9d4-c670-4a6c-8cf2-d47f671e244b)


**Example**: **^(C<RD>L)** - Returns everything except the direct diffuse lighting. For more examples, see the [Advanced Light Path Expressions](https://docs-chaos.atlassian.net/wiki/spaces/VMAYA/pages/111739227/Advanced+Light+Path+Expressions#Boolean) page.


---