Iray canvas, shadows, and LPEs

I would like to render a figure sitting on a bed in an indoors setting in such a way that I can separate background and foreground into different layers.

Background layer should contain everything except the figure, its shadows, and reflections. That's easy to do -- render scene without the figure in it.

Foreground layer should contain figure, its shadows, and reflections rendered to an otherwise transparent background.

Merging those two layers should produce identical (or as nearly identical as possible) result to rendering a full scene.

I know how to get just the figure to render on a transparent background so the biggest problem is capturing its shadows and reflections without also capturing background objects they fall onto.

In theory it should be possible for Iray canvases and Light Path Expressions together with Iray Matte to be used to accomplish this, but I am not sure how.

Any advice would be much appreciated.


  • TheKDTheKD Posts: 2,523

    Damn, I think it was sickleyield that used to have a badass video tutorial that showed you how to use matte for catching shadows. Can't seem to find it though.

  • ebergerlyebergerly Posts: 3,160

    Some random thoughts that hopefully might help...

    It's been a few years since I spent time with LPE's and Iray matte advanced node stuff and canvases, but here's what I recall:

    - Well, this first one is new...your post got me interested in going back and looking at advanced Iray nodes and mattes and stuff, and it seems that my D|S 4.15 is crashing fairly regularly when I have an advanced iray node applied to an object. Four times so far in the last few hours. Maybe if I get some spare time I'll try to reproduce.

    - I spent a lot of time trying to figure out LPE's a few years ago, and at the end of the day I came to realize that with the limited documentation available, and apparent failure of some of the LPE's to work or be implemented, LPE's only gave me about the same functionality as the built-in Iray canvases in D|S. And their LPE "language" in the Iray manual is enough to make your brain explode. And I even had trouble trying to reproduce the complete render using LPE's. They didn't seem to work as expected in some cases. 

    - You can use the Iray advanced node and enable an Iray matte (on the bed object in your case) to get your character plus shadows, however, from what I recall, the results depended upon what light source was lighting your scene. If you use the standard D|S light sources (distant, point, etc.) the result was the character plus shadows, but if you use a mesh object/primitive with an emissive surface to light the scene (which I generally use) the resulting image included shandows and light reflections off the Iray matte/advanced node surface (in your case, the bed would be somewhat visible in the render). And my recollection was it was pretty useless.  

    - You can use the Environment/Draw Ground feature in the Iray Render settings to get your character plus shadows on a transparent background, and you can tweak the ground height, but that probably won't help much with your character on a bed (especially if the bed surface isn't totally flat). When it comes to character plus shadows, that's what I use most often to put a character over an HDR or background image.  

    - I recall there isn't, unfortunately, a simple "shadow pass" (canvas) as with other 3D apps, though I recall there was something in the LPE documentation that mentioned a shadow pass, but I don't think it's available in the D|S implmentation. 

    - You mention the character plus shadows AND reflections, but the reflections are a whole world of complexity. Keep in mind every light ray you see is a reflection off of some surface (many people seem to think only the sparkly stuff is reflections), so capturing those is, as I recall, one area where LPE's might help, since you can extract specular, diffuse, and glossy reflections, and even specify how many bounces, but like I say, that's a whole world of complexity.

    - One other thing to consider is that when you're working with canvases they are output in EXR format, and they're not normalized to 0-1. So you probably have to tweak them first when you're compositing. 

    Anyway, after a whole bunch of investigating years ago, I finally came to the conclusion that the most useful output from Iray is the built-in canvases, which allow you to adjust individual light contributions (to me one of the most useful features), depth of field, color grading, etc. I pretty much gave up on needing to separate out the shadows and reflections. But then I don't do animations, so I don't need a fixed background and character plus shadows/reflections on top. 


  • Thanks for your thoughtful response.

    As for Iray LPE syntax, it is modeled on Perl regular expression syntax, and it should even support substitution (i.e. render from one canvas used as source for the next by name).

    As for reflections, they shouldn't be hard to capture separately.

    As for shadows, the lights I use are mix of emissive (room lightbulb for example), and environment light. AFAIK, you can capture emissive light with LPE.

    What I wonder is what is the "Shadows (Interactive only)" canvas?

    Also, to capture the standard Beauty you just write L.*E (or E.*L) in LPE.

    Here is LPE syntax from Iray manual:
    Light path expressions

  • ebergerlyebergerly Posts: 3,160

    Yes, I'm familiar with REGEX from C# programming. I hate it. Drives me crazy. As do the NIVIDIA LPE expressions. 

    As I said, I spent a lot of time going thru the NVIDIA Iray manual you referenced, years ago. And I found that what is written in the manual, in many cases, doesn't seem to work in D|S. I can give a whole list of stuff written in that manual that produces nothing in D|S. So yeah, it seems it should be easy but in practice I've found it to be anything but. 

    But it sounds like you've got it pretty much figured out, so I wish you luck. 

  • ebergerlyebergerly Posts: 3,160

    By the way, here's a list I made years ago as a result of my LPE testing in D|S. And it includes (at the end) a list of LPE expressions listed in the NVIDIA Iray manual that don't seem to work in D|S. And I recall some LPE expressions that seem to work in D|S aren't the same as what's shown in the Iray manual.

    As I mentioned before, most of the LPE's that seem to work are already available as standard canvases. For example, you can just render a canvas with only the light contribution of a single light source by selecting that light as a node and do a beauty pass associated with that node. 

    So for me, the whole LPE thing was a big pain that I never use. 

    Also, attached are two images I had developed long ago to show that the Iray matte works differently when lighting the scene with a standard light vs. an emissive. The first image is with the ground mesh assigned to an Iray advanced node/matte, and lit by an emissive plane. The second is when the identical scene is lit by a distant light. Completely different results, for  emissive lighting pretty much useless. 

    Light Type Contributions:

    Area Lights:     E.*La

    Environment Lights    E.*Le                            

    Point Lights:    E.*Lp                         


    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                       

    Don't Work:

    E.*L                        Any Light

    E.*                          Beauty

    E<RD>A                 Albedo



    1305 x 805 - 80K
    1150 x 780 - 30K
  • johndoe_36eb90b0johndoe_36eb90b0 Posts: 56
    edited April 10

    Interesting, the right picture is close to what I am after (except it should be transparent), can you tell me:

    1. Which formula you used in the right picture and which one in the left?
    2. Was Alpha checked or not in either of them?
    3. Was this Iray photoreal or Iray interactive?
    4. What shaders were used on surfaces?

    As for some LPEs not working in DAZ Studio, it is possible there was a bug.

    Post edited by johndoe_36eb90b0 on
  • ebergerlyebergerly Posts: 3,160

    I encourage you to try all of this for yourself. Honestly, I spent a lot of time investigating this in the past and have little interest in going down that rabbit hole again. I've provided more than enough info to assist anyone who wants to investigate further. Yes, I'm sure that in the last few years they've made improvements in the canvas/LPE implementations (hopefully, they fixed the need to enter LPE expressions from right to left rather than left to right...), but honestly, based on the lack of LPE/canvas-based discussions here over the years, I doubt few users really care.  

  • johndoe_36eb90b0johndoe_36eb90b0 Posts: 56
    edited April 10

    ebergerly said:

    I encourage you to try all of this for yourself. Honestly, I spent a lot of time investigating this in the past and have little interest in going down that rabbit hole again. I've provided more than enough info to assist anyone who wants to investigate further. Yes, I'm sure that in the last few years they've made improvements in the canvas/LPE implementations (hopefully, they fixed the need to enter LPE expressions from right to left rather than left to right...), but honestly, based on the lack of LPE/canvas-based discussions here over the years, I doubt few users really care.  

    Ok thanks.

    I forgot to point out one thing regardarding emissive lights -- I think that if you were expecting to get the same shadows from emissive light that expectation was not realistic, because most emissive lights I have seen so far do not have an emission profile configured. In other words, they emit very diffuse light which results in rather soft, low contrast shadows compared to say DistantLight.

    Another point you made is about EXR output. You can set tonemapper to be linear (crush blacks 0, crush whites 1, gamma 1), then set exposure and later do HDR toning in say Photoshop when compositing layers.

    I think it is a shame not many people know how to use this workflow and it would be cool if DAZ posted a detailed tutorial.

    Post edited by johndoe_36eb90b0 on
  • TheKDTheKD Posts: 2,523
    edited April 10

    Why would you wanna crush whites?

    Post edited by TheKD on
  • ebergerlyebergerly Posts: 3,160

    Wow, johndoe, not sure if you were aware of this, but when I saw your comments on emission profiles relative to softness of shadows, I thought you were mistaken, as emission profiles (assuming you mean the industry standard IES profiles) merely define the non-uniform lighting pattern of real world lights, due to filaments and bulbs and stuff. So I thought you were mistakenly equating IES profiles with shadow softness, which are generally unrelated.

    However, you got me thinking. Since IES profiles are merely text files that define, for each angle emitting from the light source, how much visible energy is being sent out, I wondered whether you can actually tweak an IES file to cause the emitting surface (a flat plane in my case) to send light only in one direction, normal to the plane surface. Unlike the typical emissive, which sends light in all directions. 

    And surprisingly it's very easy to do. I just opened an IES file I had, and changed all the candela values at all angles to 0, except at 90 degrees. Below are the results of the non-IES emissive which sends light in all directions, and the 90-degree only emissive. 

    Though I'm not sure how any of that is really relevant to the discussion, since the Iray matte surface won't work with emissives no matter what the IES profile, and as I mentioned the uniform and totally unrealistic directional lights are, IMO, pretty much unusable unless someone is willing to sacrifice realism in order to get a harsh shadow and some reflections (as shown in my second image above). 

    Cool, thanks. Now I can make my own IES files.... 


    1166 x 872 - 57K
    971 x 808 - 61K
  • ebergerlyebergerly Posts: 3,160

    By the way, regarding the workflow for stuff like this. Like I say, personally I just use the wonderful canvases that D|S provides, and pretty much ignore the LPE's and Iray matte nodes. Though occasionally I'll use the Environment/Draw Ground to put a character plus shadows over an HDR. I use a free, professional postwork software called Nuke, and it allows me to do incredible things. Like vary the individual light contributions in real time, just by sliding a slider. Rather than have to waste time re-rendering. And also do depth of field in real time rather than take forever to re-render. And on and on...

    Below is a screenshot of part of my main template I use in Nuke, and all I do is drag 'n drop my EXR canvases out of D|S, hook them up, and I'm all set. It's all pre-configured to do depth of field, add volume rays, add vignettes, and so on. So for me at least, there's not really much tutorial needed for the D|S workflow, but rather knowing how to do all the postwork in Nuke. Yeah, it took a bit to figure that the Exposure node needs to crank the exposure of the DAZ EXR's down by about -13 stops or whatever, and that some of the outputs are already 0-1 and don't need Exposure adjustments, but anyway. 

    I imagine with Nuke you could figure out some way to get the shadow plus reflections with emissives (maybe just use a directional and fake-blur the shadows or something), but I'm happy with the standard Canvases.  

    1141 x 872 - 66K
  • @TheKD I apologize, it was supposed to say "burn highlights", we all know that crushing blacks is the only politically correct crushing. /s

    Joking aside, those settings should give you linear output when you render to a beauty canvas.

    @ebergerly Yes, I meant IES profiles, and yes, I meant that when you have a light that radiates in all directions from a large flat surface you get very diffuse light with soft shadows, kind of like softboxes for photography are used to diffuse light to accomplish the same thing. From what I noticed, emissive lights do work with Iray matte, but the shadow is faint and soft if there is no IES profile. Perhaps you could test what happens with your 90 degrees light now?

  • ebergerlyebergerly Posts: 3,160

    I'm not sure what you're trying to accomplish. Are you applying an IES profile to a flat emissive plane? If so, why? Perhaps you can post some examples. 

Sign In or Register to comment.