Light Path Expressions Iray
Seems like there is virtually no info on DAZ's implementation of the Iray LPE (Light Path Expressions), aside from a thread or two back in 2015 as far as I can tell.
From what I've seen about LPE's from the NVIDIA perspective it's a great way to define the specific passes/canvases you get in your renders, and you can extract an incredible amount of info from your renders. But unlike the standard passes, you select LPE and then you have to define what you want by entering some very cryptic expressions?
I tried to do something simple, but it seems like DAZ hasn't fixed the implementation, since even when you type in an expression it types backwards. I guessing it was never really implemented, and since nobody seems to care they didn't pursue it?
Has anybody succeeded with LPE, or are you limited to the standard canvases?
Thanks.
Comments
They work as far as I can tell. I've used my own LPEs and gotten results. In my opinion, they're just hard to completely understand and figure out. It took me probably close to 12 hours of experiementing with them before I was finally able to start getting the results I was trying to.
To get around the very strange text box behavior inside Daz Studio, I type them somewhere else first then copy and paste them in.
Cool Thanks.
So basically you just find in the NVIDIA documentation the correct LPE code and copy/paste? I assume DAZ is using the NIVDIA code directly?
Yeah, that's pretty much it. I guess if you're familiar with RegEx it's supposed to help, but I wouldn't really know.
Oh yeah I forgot to mention, you can write them forward or backwards, from the light to the eye (camera) or from the eye to the light, but I'm pretty sure the order of the event type, scattering mode and handle need to be in the proper order.
Have you found a good reference for LPE expressions? I found this at the SolidAngle site, but it looks like they use "C" instead of "E" for camera view. I'm trying to replace those with E's and see if they work.
https://support.solidangle.com/display/A5ARNTUT/Introduction+to+Light+Path+Expressions
Wow, I'm starting to love this LPE thing
I'm starting to build a list of LPE's that seem to work in Studio Iray:
Environment Lighting: E.*Le
Indirect Lighting, more than 1 bounce: L.{2,}E
Specular: E<RS.>.*L
Diffuse: E<RD.>.*L
Area Lighting: E.*La
Scene illuminated by "plane 2" emissive only: <L'plane 2'>.*E
The last one is the awesome-est. You can make a render pass that is JUST the scene illuminated by selected lights in your scene. Then you can take that into your compositor and adjust the scene as if you varied the light in your initial render. Cool. In this case I had an emissive plane called "plane 2" in my scene, and I isolated its effect.
By the way, it seems like the Iray for 3DS Max LPE's work in Studio Iray, while the ones for Arnold renderer (?) don't.
Those look similar forsure. Not sure if they'll work or not. I would imagine there's a high probability they will, worse case with a few minor adjustments.
Here are the resources I worked from:
https://forum.nvidia-arc.com/showthread.php?13658-Light-Path-Expressions
http://blog.irayrender.com/post/76948894710/compositing-with-light-path-expressions
http://blog.irayrender.com/post/37260056351/instant-relighting-nonphysical-effects
http://blog.irayrender.com/post/77365439434/get-a-grip-2-instant-color-change
http://blog.irayrender.com/post/78094420163/get-a-grip-3-more-complex-color-changes
Yeah I already tried them and they seem to work fine.
The ones that don't seem to work are:
Beauty: E.*
Albedo: E<RD>A
They just give me a black image/canvas
Okay so after some testing I've compiled the following list of LPE's that seem to work. To verify they work I added the "Light Type Contributions" canvases together in Nuke and they reproduce the Beauty pass. I did the same for the Reflections canvases:
Light Type Contributions:
Area Lights (ie, emissives): E.*La
Environment Lights E.*Le
Point Lights (not sure if this includes spotlights, etc.): E.*Lp
Reflections:
Specular: L.*<RS>E
Diffuse: L.*<RD>E
Glossy: L.*<RG>E
Specific Scene Light Contributions:
Scene illuminated by "SpotLight 1" emissive only: <L'SpotLight 1'>.*E
Indirect Lighting, more than 1 bounce: L.{2,}E
It seems like the LPE seems to shine when you want to isolate one or more light sources and manipulate them in post. Or if you want to manipulate the reflections (diffuse, specular, etc.). So far I haven't found where you can access stuff like shadows, distance, and albedo, but I think maybe if you mix the LPE canvases with the regular Iray canvases in Studio you can get most of what you need.
By the way, you have't lived until you've manipulated the color and intensity of individual scene lights in your compositing program. It's pretty incredible. Saves a ton of time having to go back and re-render. Just move a slider and the light gets brighter and darker. Like magic.
Oh, and for those who worry about needing tons of CPU power for professional 3D apps, the compositing program I started playing with is called Nuke, and it was used in Iron Man and a bunch of others. And it uses the GPU (if available). So I just set it for my 1080t and it runs fine. And fast. Like when it's doing depth of field and tons of canvases and stuff.
Here's a simple scene with 3 lights:
Here's a GIF showing when I brought the final render into Nuke, and used an LPE to control only the Environment light. Using a simple Exposure node slider I can adjust the Environment intensity (and color if I want) in realtime in post. Pretty cool.
That's neat. Another software toy for me to get, I suppose.
For anyone interested in this LPE thing, I found a few more tidbits...
First, the built-in Specular, Diffuse, and Glossy are vastly different from the LPE versions I referenced above. In fact, the built-in versions don't add up to the Beauty pass, so I *think* there's something wrong with them. But I haven't figured out exactly what they are. Other than weird. For example, the built-in Diffuse looks nothing like a Diffuse. So I'll probably ignore them from now on and use the LPE versions.
Also, the EXR files generated as Canvases are not the normal 0 to 1 RGBA values, they're 0 to over 10,000 or something. Apparently DAZ didn't do the internal tone mapping that should be done (if I read previous posts right about DAZ's response), so you'll need to do your own with each EXR. The way I do it is to add an Exposure node in Nuke and set the Stops to -13.6 or thereabouts.
Also, the best reference I've found is the Iray Programmers Manual:
https://www.migenius.com//doc/realityserver/latest/resources/general/iray/manual/index.html#/concept/light_path_expressions.html
In fact that link has tons of great info on Iray in general. And if you want to make your own Iray renderer it even has sample C++ code showing you how to load a scene and render it in Iray. That may be on my list of fun things to try in the near future...
BTW, below is a comparison of the LPE version of a Diffuse canvas (on the left) and the built-in version on the right. Weird. Clearly the one on the left is a Diffuse pass and the one on the right isn't.
Do you have tone mapping enabled? I believe having it on can cause canvases to show up differently than what you would expect. Also some compositors may need to be told to set the gamma to 2.2 for some .exr files (I know I had to do this with Blackmagic Design's Fusion).
Really weird. Thanks for the manual link.
Thanks. Yeah if you look at the Diffuse from the non-LPE on the right you can see that it's not a matter of just cranking the gamma up (ie, the mid-tones). If you compare with the correct one on the left, you can see the torus has zero diffuse (it's black), but on the right it's clearly reflecting, not diffuse like it should. So as far as I can tell it's just wrong. Not quite sure what it is, but it sure ain't diffuse.
Anyone happen to know a LPE formula to get a proper materialID pass? Whatever the preset is doing, it's not a materialID pass I expect(a different solid color for each material set). It's a very useful thing to have for creating quick masks.
Has anyone got or know of a walkthrough for plebs like me on how to use and set up LPE?
1) go to advanced tab of render settings.
2) go to canvases and check it on
3) click the plus button to add a canvas
4) click on the type drop down with the new canvas selected and select LPE
5) type the "equation thingie" in the box called expression.
6) optional add nodes needed
Thanks but
5) Is what I am having trouble with. How do I use Material Colour ID and the "equation thingie"? It is all geek to me this side of things. LOL
Oh I have the same problem when it comes to those expressions lol. In the dropdown there is one called materialid in the presets, but I have never gotten it to work for me correctly. For a quick example, I get this render, with this materialid pass. Not what I am looking for at all lol. Where it is white looking, is all totally transparent in the PNG it spits out.