Overview
Now that we've looked at how LPEs work and know the basics, let's look at some advanced concepts and more ways to use LPEs.
Operations
Light path expressions may also include the modifiers placed after event symbols:
? for 0 or one repetitions (or an optional event)
+ for 1 or more repetitions (or indirect). See the example below.
* for 0 or more repetitions (any)
These can be used in combination with the . symbol. It can signify an arbitrary ray spawn event or an arbitrary scattering type, simply put it stands for any symbol.
Look at the table to the right to see how using these modifiers change the expressions.
Symbols in an expression can be grouped.
[] groups event, scatterings and labels
<> groups event, scatterings and labels
[^] inverts events, scatterings and labels
'' labels for masking objects or materials are placed inside single quotations.
| OR (pipe symbol)
() groups symbols.
Expression | Equivalent (Description) | Captured ray paths |
---|---|---|
C.*L | Full light select | camera (C) → any event (.) that repeats zero or more times (*) → light (L) |
CRL
| Direct light select | camera → diffuse reflection → light |
CR.+L | Indirect light select | camera → any event (.) that repeats one or more times (+) → light |
CR?L | ? | camera → diffuse reflection → light |
C<RD>L
| Lighting (Direct diffuse reflections) | camera → diffuse reflection → light |
C<R[GS]>L
| Specular (Direct glossy and singular reflections) | camera → glossy reflection → light camera → singular reflection → light |
C<RD'1'>L
| Lighting for object label 1 | camera → diffuse reflection for object with label 1 → light |
C<RD[^'1']>L
| Lighting for all objects other than object label 1 | camera → diffuse reflection for objects that don't have label 1 → light |
C<RD>(.+L|.*[OB])
| GI (Indirect diffuse reflections) | camera → diffuse reflection → any event (.) that repeats one or more times (+) → light camera → diffuse reflection → any event (.) that repeats zero or more times (*) → emission camera → diffuse reflection → any event (.) that repeats zero or more times (*) → background |
Shadow Mode Prefix
The shadow; prefix in LPE collects and returns shadow information.
It causes the light to accumulate the shadowed contribution out of the light contribution on the last bounce of the ray. It can be used to capture the diffuse or/and specular shadows in the render elements.
Expression | Description |
---|---|
shadow;CDL | Extracts shadow from all lights. |
shadow;CGL | Extracts shadow from the reflection occlusion of all lights. |
shadow;C.'objectLabel'.*L | Extracts shadows that fall over or are reflected in a specific object that is tagged. You can also use it with a material label. |
shadow;CD<L.'lightLabel'> | Extracts shadows resulting from a specific labeled light. |
shadow;CG<L.'lightLabel'> | Extracts shadows resulting from a specific labeled light in the reflection occlusion. |
Capture objects, materials or lights
LPEs can be modified to record information for only specific objects, materials or lights by adding a label.
LPE labels for objects
If we take C.* as an example, which gives us the Beauty, C.'1'.* will filter the Beauty only for objects with LPE label 1.
C.'cube'.* will be the Beauty only for objects with LPE label cube.
LPE labels to objects are added with V-Ray User Attributes, added from the extra V-Ray attributes menu. The user attribute name needs to be lpe_label and its value can be text or numbers: for instance
lpe_label=1 or lpe_label=cube.LPE labels can be anything. You can label an object or material 1, or 2, or testObject, or myMaterial.
When used in expressions, labels need to be placed inside single quotes: C.'cube'.*
Note that Maya attributes cannot be used as LPE labels.
Adding a Light Path Expression label to geometry
LPE labels for materials
Similarly, C.'m1'.* can be used to separate the Beauty only for materials with material label 1.
C.'mmyMaterial'.* will be the Beauty only for materials with LPE label myMaterial.
LPE labels are added to materials with the Light Path Expression Label attribute from the extra V-Ray attributes menu. The label can take numeric or text values and when used in an expression it needs to be preceded by m and placed inside in single quotes.
LPE labels can be anything. You can label an object or material 1, or 2, or testObject, or myMaterial.
When used in expressions, material labels require prefixing the label with m and placing the label inside single quotes: C.'m1' or C.'mmyMaterial'.
Adding a Light Path Expression label to materials
LPE labels for lights
In Maya you can add light path expression labels to lights.
This is useful for Houdini to Maya workflows as light selects in Houdini are managed through LPE labels for lights. It can also be used for convenience when working with many Maya lights. For example, you can add the same label to all the desired lights and use it in expressions as opposed to adding the lights to a light select every time.
How to add LPE labels to lights
- Select the desired light and go under the Shape node in the Attribute Editor.
- Then go to Attributes menu > VRay > Light Path Expression Label.
- An Extra VRay Attribute rollout appears with a text box.
- Add the label.
Syntax
The correct way of using LPE labels for lights in a LPE is:
<L.'light_LPE_label'>
where light_LPE_label is the label given to a light.
Examples
C.*<L.'1'> will filter the light contribution of lights with LPE label 1. It works the same way as a light select.
C.*<L.'topLight'> will be the light contribution from lights with LPE label topLight.
Another more advanced example is C<RD>.+<L.'1'>, which isolates the GI of a specific light with LPE label 1.
(C<RD>(.+L|.*[OB]))-(C<RD>.+<L.'1'>) filters the GI of all lights in the scene except for the lights with LPE label 1.
You can also use wildcards in the Light path expression. For example, if you have three Rectangle lights in the scene all with LPE labels corresponding to rect1, rect2, rect3, all of them will be encompassed in C.*<L.'rect*'>
Inverting LPE labels
Labels can be easily inverted in expressions by adding ^ in front of them and then placing the inversion symbol and the label inside square brackets [ ].
For example, C.[^'m1'].* will give us the Beauty for all materials that do not have material label 1.
We can invert multiple labels at the same time, for example CR[^'1''2'].+L filters the indirect illumination for all object that do not have the labels 1 and 2.
Reserved labels: coat and sheen
The material labels coat and sheen are reserved for the additional VRayMtl Coat and Sheen layers.
You cannot add a custom Light Path Expression Label with values coat or sheen.
You can use mcoat and msheen directly in expressions to capture the reserved labels.
Boolean operations between expressions can be used along with the reserved coat or sheen labels to extract those layers exclusively for specified materials or objects.
Example: (C.*)-(C.'mcoat'.*) captures the Beauty without the contribution of the VRayMtl Coat layer.
You can read more about boolean operations in the next section.
Boolean operations
Boolean operations allow us to combine expressions. We can complement (^), intersect (&) or unite (|) expressions, or we can subtract (-) one expression from another.
Let's look at some examples.
GI can be broken down to different types of light sources: lights, self-illuminating objects and the environment. If we need to control each of these separately in compositing, we can use the built-in presets, respectively: C<RD>.+L, C<RD>.*O and C<RD>.*B. The combination of these in compositing (with a plus) replaces the GI channel in a back-to-beauty composite. However, if we only need to grade the GI from Lights, we can render a GI render element and C<RD>.+L. Then, we subtract C<RD>.+L from the GI in compositing, grade C<RD>.+L and add it back to the composite.
Alternatively we can render GI and an LPE for GI minus C<RD>.+L. In this way, we'll only need to add the graded C<RD>.+L channel to the GI in compositing, saving us some compositing complexity.
For the purpose of this example, we can do a union of the GI coming from all three types of light sources to get the GI using the pipe symbol for union: (C<RD>.+L)|(C<RD>.*O)|(C<RD>.*B)
Boolean operations can also be very useful when using LPEs with object or material labels.
Let's look at a simple example with direct lighting. V-Ray already has a render element for this (Lighting) and the equivalent expression is C<RD>L. If we additionally want to capture direct lighting falling onto object(s) labeled cube, we need to render an LPE for C<RD'cube'>L. We can then subtract C<RD'cube'>L from the Lighting channel in compositing, grade it and add it back in.
Alternatively, we can render the C<RD'cube'>L expression and a second one that does the subtraction right in the renderer: (C<RD>L)-(C<RD'cube'>L). We then grade each channel as needed and add them with a plus in the composite.
Additional examples
SSS
- 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 label 1
- C<R[GS]'m1'>.'m1'+L
Emissive
- 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
- 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)
VRayMtl Sheen and Coat
Coat Specular C<R[GS]'mcoat'>L
Coat Reflection C<R[GS]'mcoat'>.+L
Sheen Specular C<R[GS]'msheen'>L
Sheen Reflection C<R[GS]'msheen'>.+L