HOME | DD

linvanoak — Iray Light Path Expressions in DAZ Studio
Published: 2018-03-16 19:45:01 +0000 UTC; Views: 9145; Favourites: 8; Downloads: 0
Redirect to original
Description body div#devskin0 hr { }

Light Path Expressions can be used to split the rendered information based on their light path into specific sub images.
The individual images can be exported as .exr files that allow for advanced compositing techniques in photoshop.
That way the look of the final image can be changed without the need to rerender.

This video released by Nvidia in October 2017 provides an overview:



The idea of this post is to give just one example how Iray "Light Path Expressions" can be used together with "Iray Handles" in DAZ Studio.

It is recommended that you first have a look at the official Iray dev blog entry:

blog.irayrender.com/post/76948…

- - -
- - -

Iray Handles & Light Path Expressions used to "Compositing per light"

​In DAZ Studio you use the "Iray handles" under the "Advanced Iray Node Properties" to set up Light Path Expressions.
In this example the idea is to separate the interaction of each light with objects in the scene into its own image.
In photoshop you can then adjust the strenght of each image in postproduction.

Step 01​

Set up a test scene with three lights:





You can find version 1004 of the test scene in its basic state as .zip file with size 83.2KB here:

LPE Light v1004


This version of the scene has the materials set up but the Light Path Expressions are not yet set so you can follow along.

- - -

Step 02

Before any work with canvases and Light Path Expressions open the Iray Render settings and make sure the tone mapping parameters are adjusted to be "linear"

Burn Highlights: 1.0
Crush Blacks: 0.0
White point: 1.0, 1.0, 1.0
Vignetting: 0.0
Saturation: 1.0
Gamma: 1.0



Adust the Exposure setting in the Tone Mapping so that most parts of the image are visible in the preview viewport.
Some details may look too bright, others too dark.

That is caused by the linear setttings of the Tone Mapping.
But don't worry you will be able to fine tune the individual lights in postproduction.

- - -

Step 03

Select your first emissive light object in the scene and apply the script to

Create Advanced Iray Node Properties




Edited:
The preview image of the Default Resources has been updated and now looks different.

- - -

Step 04

Now open the Parameters tab - Rendering - Iray and give your light a name in the box "Iray Handle"

light_front





light_left





light_right





- - -

Step 05


Now that you have set up the handles you can set up the Light Path Expressions LPE in the Iray Render Settings - Advanced - Canvases

.*E
.*E
.*E


To get a basic idea how those expressions are put together

L = light emitted that bounces from any type of surface any number of times
E = then hits the eye (E)
. = the dot character matches any interaction
* = the star operator means “repeat any number of times"

You just add the Iray handle after "L" into the brackets to indicate which light should be considered







Create a canvas with a Light Path Expression for each light in the scene.

- - -

The .zip file of Version 1005 of the test scene has everything set up and is ready to render:

LPE Light v1005


- - -

Step 06
​​When your goal is to export to .exr files then you do not need to worry which canvas is active.
You can just render out any canvas as .png




Depending on your scene the lights in the png you just rendered may not look good at all.
Again, this is caused by the linear tone mapping settings.

When you do this the first time it may seem odd to render out an image in a state where the lights seem off.
After you are familiar with the whole workflow you may get used to adjusting the Tone Mapping as a last step before rendering.

When you save the .png all the other canvases are automatically written to a folder as .exr.









- - -

Now it is time to put the rendered out .exr together in photoshop.

Step 7

Create a new 32 bit image with the same dimensions as your rendered images.






If there is no black solid background create one and leave its blending mode at normal.
This background layer should remain the lowest layer.


- Use File - Place Embedded to import your first .exr.






In this example the first image placed was light_front

Do not worry that your image may look either very bright or very dark.


- Change the blending mode to Linear Dodge (Add)






- place an Exposure adjustment layer
Adjustment layers by default affect all layers below them.
While setting this up the idea is to have the same exposure values affect all the images in the different layers.






Now you can change the exposure to a level in which the image of the front light looks about right to you.

- embed the .exr of your next light and also set it to blend mode "Linear Dodge - Add"
Place this layer below the already set adjustment layer but above the black solid background.




Those two layers combined show the result of light_front and light_left​.

- Now add the .exr of your third light and also set it to blend mode "Linear Dodge - Add"






At this stage you have added all the indiviudal light layers that combine to the original image.
The photoshop document should now look excactly the same as if you would have rendered out a single .png without any canvases from DAZ Studio.

The benefit of this workflow is that you can adjust the strenght of each light in postproduction without having to rerender the whole image.

You can fine tune the lights by adjusting each individual layer.
Instead of one adjustment layer affecting all images you may want to work with individual adjustment layers that just affect one layer and not the others.

In this example another Exposure Adjustment Layer was applied to just the "right_light" layer.





By changing the offset value the right red light is now stronger.

If after rendering you deceide that you actually do not want to use one of the lights at all you do not have to rerender the whole image.
You could just hide the photoshop layer of the corresponding image.
You could just tint one light by applying further adjustment layers.
You could also apply masks to specific areas of individual layers...

Try experimenting further with Iray Light Path Expressions to get some ideas of your own how you could use them in your workflow.

- - -

Troubleshooting:

- The exposure of a rendered .exr does not seem to have any effect and the layer remains completely black:

    Check if you made a typo in the light pass expression. If you do not enter a valid Iray Handle in the expression the layer will render black.

- When should I adjust the Tone Mapping?

    While you are still working on your scene you may want to keep the Tone Mapping at default values to get a more accurate view how the individual lights will look like.
    Change the Tone Mapping to a "linear" setup just before rendering out the final version of the image.
    The idea of the linear Tone Mapping setting is to get a maximum range of dark and bright areas in the scene.

- I tried to switch to 8Bits / Channel or 16Bits / Channel image mode and Photoshop asked me to merge layers. Why is that?

    When you work with 32Bit .exr images you have a huge amount of additional  color and brightness values to your disposal.
    When you want to switch to a 8Bit or 16Bit workflow a lot of that information will be lost.
    Make sure to finalize all brightness and color adjustments before merging the layers.


- - -

Updated 2023 July 23:

This workflow is still available in Daz Studio 4.21.

On Instagram you can find an additional example of light layers used for a character portrait:

www.instagram.com/p/Cu…

- - -

Related content
Comments: 2

thrwm [2022-03-25 08:35:35 +0000 UTC]

👍: 0 ⏩: 0

kittenwylde [2018-03-18 02:37:52 +0000 UTC]

Wow, thanks for this! I had no idea this was possible with Iray.

👍: 0 ⏩: 0