Results 1 to 6 of 6

Thread: Alpha behind transparent object

  1. #1
    Join Date
    Mar 2016
    Posts
    18

    Exclamation Alpha behind transparent object

    Hello LPE Gurus, hope somebody can help me out with this one.
    I need a proper alpha (LPE isolated) behind a glass object.

    Here is an example of a test scene. The beauty alpha looks fine, but i need only the red ball to color correct.
    The beauty_LPE_alpha is the result with the standard alpha LPE name:E([^'name'] .*)? L?

    Any suggestions?.

    thank`s in advanced
    Attached Thumbnails Attached Thumbnails red_beauty.jpg   red_beauty_alpha.jpg   red_beauty_LPE_alpha.jpg  

  2. #2
    Join Date
    Jul 2015
    Location
    Santa Clara
    Posts
    250

    Default

    Great question.

    Actually using alpha is not the best solution here. Instead we can leverage the power of LPE's and capture the lightpaths associated with the red sphere, even if they are reflected or refracted or even diffused.

    While using a camera tone mapper is good practice for rendering out a final image 'in camera', when compositing it should be turned off (so that color correction is only done once).

    I've duplicated your test scene but made life a little more difficult for myself by adding a shiny disk under the sphere and frosting the glass. A beauty pass LPE L .* E gives us this...

    Click image for larger version. 

Name:	beautyLPE.JPG 
Views:	26 
Size:	33.0 KB 
ID:	8977

    What we want to do is separate the image into 2 LPE's. Light paths that interact with the sphere and lightpaths that don't. First we need to tag the sphere with a handle so an LPE can identify it. Select the sphere and in the attribute editor find the iray section of the object shape node. In the handle field, name the sphere "red_sphere".

    Click image for larger version. 

Name:	attribute.JPG 
Views:	26 
Size:	33.6 KB 
ID:	8978

    Now we are ready to write some LPE's. For the red sphere, we just need all the light rays that are in the scene, interact at some point with this object and then eventually make it to the camera/eye. So the expression is:

    Light -> interactions -> sphere -> interactions -> camera

    L .* 'red_sphere' .* E

    (if the object wasn't obscured by the glass and you just wanted the object with a clean silhouette, you would use L .* 'red_sphere' E , where the light goes straight to the camera after hitting the object without any more interaction in the scene)

    We can give this expression a name by placing it at the front of the expression and ending in a colon... this is optional but we will use this label later.

    sphere: L .* 'red_sphere' .* Go to the Output tab of render settings, set the Radiance 2 canvas type to Light Path Expression and type the expression into the LPE field.

    The other expression, all the rays that don't interact with the sphere is much more tricky to figure out. But actually we don't need to, we've already done the work. All the rays that don't interact with the sphere are all the rays that are NOT used by the sphere LPE we just created. We can easily 'invert' an expression by using the carat symbol ^. So the opposite of the first expression is:

    ^(L .* 'red_sphere' .* E )

    But we already gave this expression a label, so we can use the label instead to make things clearer as well as add another label (again, an optional steps)... note the $ symbol used in front of the label "sphere".

    not_sphere: ^$sphere

    set the Radiance 3 canvas type to Light Path Expression and type the expression into the associated LPE field.

    Click image for larger version. 

Name:	LPE.JPG 
Views:	25 
Size:	41.7 KB 
ID:	8979

    Ok, so we now have both expressions we need. If we render we get 2 additional images...

    sphere: L .* 'red_sphere' .*
    Click image for larger version. 

Name:	sphere.JPG 
Views:	24 
Size:	21.4 KB 
ID:	8980

    not_sphere: ^$sphere
    Click image for larger version. 

Name:	not_sphere.JPG 
Views:	25 
Size:	31.4 KB 
ID:	8981

    Now, if you layer these 2 images additively you should get an image the same as the beauty pass. In Photoshop for instance, the blend type is color dodge (add). Here I've just used a simple hue shift on the sphere layer to change the color from red to green, without need for rerendering. The color change is picked up cleanly, even where the sphere is blurry through the glass.

    Hope this helps...

  3. #3
    Join Date
    Jul 2015
    Location
    Santa Clara
    Posts
    250

    Default

    The final composite- half original, half color shifted sphere...
    Click image for larger version. 

Name:	final.JPG 
Views:	26 
Size:	33.6 KB 
ID:	8982

    Source MAYA file...

    LPE_alpha.zip
    Last edited by rossh; March 7th, 2017 at 21:03. Reason: adding maya file

  4. #4
    Join Date
    Mar 2016
    Posts
    18

    Default

    Wow! That`s it! You guys are the best! Thank you very much rossh. Great support, fast and practicable.
    Will test it tomorrow.

  5. #5
    Join Date
    Jul 2015
    Location
    Santa Clara
    Posts
    250

    Default

    Oh, no problem at all. Your question was a great example as to why LPE's are worth learning. They are so much more powerful and customizable than normal render passes.

    Light passes are just as easy, by the way. Just tag a light with a handle ("light_handle" for instance) then just use this modified beauty expression to get a per light pass...

    <L'light_handle'> .* E

    Only exeption is the environment lights (Hosek or IBL) which are merged together by Iray into a single lightsource... doesn't need a handle, you just tell it to use a specific light type, environment, Le...

    Le .* E

  6. #6
    Join Date
    Mar 2016
    Posts
    18

    Default

    Thank`s for explanation. LPE`s are relay powerful. It would worth it to learn the syntax ..... one day .... if i had time
    Last edited by atomac; March 8th, 2017 at 20:45.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •