Shadow Catcher, Matte in Solaris for Karma XPU and MaterialX in Houdini
Shadow Catcher, Matte in Solaris for Karma XPU and MaterialX
workflow using two renderings
this simple workflow creates two renderings, color and shadow which are then composed into a single image with transparency
in geo context
add geo node, name it: mainobject inside add some test geo add another geo node, name it: floor inside add grid add bend node bend the grid so that it covers all bg add material node assign white mat
in mat context
add standard surface node, name it white specular -> specular: 0 emission -> emission: 0.2
in stage context
add scene imports add env_light add camera and rotate it that the bended grid covers bg add 2 karma trees name them color and shadow set path on the 2 karma render settings nodes $HIP/render/file.$F4.exr $HIP/render/shadow/file.$F4.exr (use same files names, so it can be used in TOP net) add 2 render geometry settings nodes: (before the karma nodes) first render geo settings node (for color): primitives: /floor shading -> render visibility: invisible second render geo settings node (for shadow): primitives: /main_object shading -> render visibility: phantom
node graph
┌───────────────┐ │ scene import │ └────┬──────────┘ │ ┌────────────────┐ │ │ scene import m │ │ └────┬───────────┘ │ ┌───┘ ┌────────────────┐ │ │ │ camera1 │ │ │ └───────┬────────┘ │ │ ┌─────────┘ ┌────┴────┴────┴──┐ │ merge │ └────┬────────────┘ │ ┌───────────────┐ │ │ distant light │ │ └────┬──────────┘ │ ┌─────┘ ┌───────────────┐ │ │ │ dome light │ │ │ └──────┬────────┘ │ │ ┌──────────┘ ┌───┴───┴────┴─────┐ │ merge │ └────────┬─┬───────┘ ┌─┘ └─────────────────────────────────┐ ┌──┴───────────────────┐ ┌───────────┴──────────┐ │ render geo settings1 │ │ render geo settings2 │ └───┬──────────────────┘ └─────────────┬────────┘ └─────┐ │ ┌────────┴─────────────┐ ┌───────────┴────────┐ │ karma color │ │ karma shadow │ └─────────┬────────────┘ └─────────────┬──────┘ │ │ ┌─────────┴──────────────┐ ┌───────────┴──────┐ │ usd render rop │ │ usd render rop │ └────────────────────────┘ └──────────────────┘
rendering both passes
go to /out context add 2 USD render nodes name them color pass and shadow pass set valid frame range on both render delegate: Karma XPU LOP path: /stage/color (on first node) LOP path: /stage/shadow (on second node) check wait for render to complete add batch node below both add merge node and feed the batch nodes click render
node graph
┌──────────────────┐ ┌──────────────────┐ │ USD render │ │ USD render │ │ color │ │ shadow │ └─────────┬────────┘ └────────┬─────────┘ │ │ │ │ │ │ │ │ ┌────────┴────────┐ ┌──────┴───────┐ │ batch1 │ │ batch2 │ └────────┬────────┘ └──────┬───────┘ │ │ └──────────┐ ┌────────┘ │ │ ┌───┴───┴─────┐ │ merge │ └─────────────┘
compositing the two images into a transparent one
go to /img context, add img network add 2 file nodes, name the testgeo and shadow load the 2 images add extract node (feed the shadow) add invert node add color node, name it shadow-intensity (feed the invert node into 2nd input, also plug it shortly into 1st input and then remove again, so it takes the same image dimensions) color tab -> color: set to black_ mask tab -> effect amount: adjust this add over node 1st input: feed testgeo 2nd input: feed color node set display and render flag add rop file output node valid frame range: render current frame ouput picture: $HIP/comp/testgeo.png
node graph
┌─────────────┐ ┌─────────────┐ │ color pass │ │ shadow pass │ └──────┬──────┘ └───────┬─────┘ │ └──┐ │ ┌──────┴───────┐ │ │ extract │ │ └───────┬──────┘ │ └──┐ │ ┌──────┴───────┐ │ │ invert │ └───────────┐ └────────┬─────┘ │ ┌──┘ │ ┌────┴────┴─────┐ │ │ color │ │ └───────┬───────┘ │ ┌────────────┘ ┌────┴────┴──┴───┐ │ over │ └────────┬───────┘ | ┌────────┴───────┐ │ROP file output │ └────────────────┘
shadow catcher using background plate
This workflow renders out one image containing alpha and shadow, with the options to adjust the brightness of the shadow.
settings up the scene and rendering
in /obj context add some test geo, a grid, light and cam go to /stage context add lots of scene import nodes for: geo, grid, cam, materials (and merge them) add dome light (or other lights) add background plate node primitives: /grid1 (select the grid) add karma render settings node (feed the backgroundplate) output picture: $HIP/render/test.exr resolution mode: manual resolution: 1024 1024 rendering engine: XPU image output -> AOVs (render vars) -> check import render vars from second input extra render vars -> name: holdout format: color3h data type: color3f source name: holdout;C.*[LO] source type: LPE add usd render rop node click on render to disk (use render scheduler to see progress)
compositing the image into a transparent one
go to /img context, add img network add file node, name it: comp file: $HIP/render/test.exr add 3 extract nodes, name them: extract image, extract shadow, extract alpha extract image node -> plane: C rename plane: C extract shadow node -> plane: holdout_shadows rename plane: C extract alpha node -> plane: A rename plane: C add color node, name it: shadow_brightness mask tab -> effect amount: 0.5 (adjust this later) image tab -> override size: ch("../comp/size1") ch("../comp/size1") (reference file node image size) add multiply node, feed shadowbrightness and extractshadow nodes add screen node, feed multiply and extractalpha nodes add extract node, name it: extractalpha2 (feed screen node) plane: C rename plane: A add add node feed _extract image node and extractalpha2 node add rop file output node output picture: $HIP/comp/test.png click render
node graph
file (comp) ┬ ┌─────────────────────┴──────────────────┬───────────────────┐ │ │ │ │ │ │ extractimage shadowbrightness extractshadow extractalpha ┬ ┬ ┬ ┬ │ │ │ │ │ └────────┬────────┘ │ │ multiply │ │ ┬ │ │ │ │ │ └──────────────┬─────────────┘ │ screen │ ┬ │ │ │ extractalpha2 │ ┬ │ │ └───────────────────────┬──────────────────────┘ add ┬ │ ropfileoutput (the mtlx ambient occlusion node currently only works with Karma CPU, and there is no mtlx shadow catcher material) see tips for: mtlx ambient occlusion karma (materialX)
src
https://www.youtube.com/watch?v=p5sEhWI2Iwc https://www.youtube.com/watch?v=3xmYbiuiXsI