Jump to content

How to distinguish/identify objects in EXR output


Recommended Posts

Hi,

I am new to both Houdini Mantra and Nuke, so bare with me :) In summary, I have a scene with 2 objects: Box_A and Box_B. Now I want to configure Mantra to render them such that I'll be able somehow to distinguish them as EXR layers, i.e. I want to produce a layer (RGBA) for Box_A and another layer (RGBA) for Box_B such that when I select Box_A layer I get RGBA for Box_A and same for Box_B. My goal is to color grade them independently in Nuke.

One last note, I've tried to Node_ID and Primitive_ID layers in Mantra but when I've read them in Nuke, I got the same identical images !? i.e. both layers "seem" to have the same data, maybe I am reading them incorrectly in Nuke, but I am also new to Nuke...

Thanks,

Link to comment
Share on other sites

Just an update... when I enabled Node ID (op_id) as extra image plan, I got unique rgb for each object. However, the rgb values are not clamped to [0,1] so I am getting large RGB pairs like (1234,1234,1234) and I could find an easy way in Nuke to select specific objects (or create a masks) based on the op_id (for those who are interested, I've tried to use keylight and other keyer, but they did not work because the RGB values were so high and out of [0,1] range)

I will look for a way to produce something like an alpha channel (to act as a mask) for each object automatically. The other solution is to render each object alone but that would be tooo much rendering...

Another idea is to manually export some parameters on shaders to extra image plan, i.e. define a variable X and on the shaders used by object A and set its value to 1 and use it extra layer (such that only shaders that use object A will set X to 1 hence producing its matte...however this is too much work and it will get messy as shaders are shared between objects...)

Edited by catchyid
Link to comment
Share on other sites

if you want 0-1 values for object matte you can generate an attribute at SOP level and render that.

put a point wrangle SOP inside each of your objects in the scene, with this code:

v@obj_id = set(random(@numpt * 0.1), random(@numpt * 0.2), random(@numpt * 0.3));

this will generate random color based on how many points that particular object is made of. i'm sure there are another ways, this one seems to be the most obvious though.

  • Like 1
Link to comment
Share on other sites

Alright, I followed your idea (even a simpler one, f@my_id=1 and exported that in the shader), and I've noticed that my_id is as excepted equals 1.0 at the majority of the object screen space, however at the borders it goes from 1.0 to 0.0, I think this has to do with antialiasing and taking multiple samples and averaging the value of my_id. 

So, due to antialiasing, any shader variables will range from 0 to its maximum value (i.e 1.0 in my case), and  this would make isolating objects using one variable is "impossible" (because all of them will have share a small range near 0). The solution I did is to create a unique ID for each objects that I want to isolate, sort of their matte plate, so instead of having id, I've created id_1, ide_2, ....It's not the most flexible solution but I guess on a small scale shot, it should work...

Thanks David :)

Edited by catchyid
Link to comment
Share on other sites

You can try to use filter "minmax edge" or "minmax idcover" (not sure which one would work best) for that pass only. that way it won't smooth the edges of the object. That is I believe the way mantra does unpremultiply.

Edited by sasho78
  • Like 1
Link to comment
Share on other sites

Thanks Alexander :) "minmax idcover" created what I wanted, however when I tested it I realized I still need an alpha channel to "smoothly" blend/isolate objects, meaning with sharp edges (as I wanted to have initially, compositing did not work well because I lost the alpha channel created by the default filter), pls see attached. So, I ended up creating a channel for each set of objects to act like a mask and an alpha channel.

Once more, thanks for your help :)

smooth.png

sharp.png

Link to comment
Share on other sites

3 hours ago, catchyid said:

...at the borders it goes from 1.0 to 0.0, I think this has to do with antialiasing and taking multiple samples and averaging the value of my_id. 

this is odd. I'm using this quite frequently without any issue. can you post the pic?

Link to comment
Share on other sites

I will produce an example image and post it David  :)

Just one last question: what is the "right" workflow for isolating volumes (e.g. pyro smoke)? The above method works nicely with surfaces (ie a regular meshes), however when I used the above idea with a smoke/fire volume, the the extra plan produced was incorrect in two ways : (1) it covered more screen space than the original pyro smoke object, and (2) the channel values produced were always higher than 1 (i.e. I defined in SOP my_id =1 so it should max one in the extra image plan)? I've tried "Full Opacity" in Mantra extra plan description , also changed it to "Fog" in the shader but did not work?!

Sorry to keep asking questions :)

Link to comment
Share on other sites

you can't use this for volumes as volumes has no points. for volumes you have to render actual density as a matte. just be careful about manipulating the density in the shader as that will not propagate to the matte (I mean you always have to render the volume with shader density 1 to get the correct result. if you want to alter the density you have to do that in volume VOP)

  • Like 1
Link to comment
Share on other sites

Okay, I found in pyro shader two vex variables: smoke_mask, and fire_mask --> when I exported them in Mantra extra image plane I got correct result. Is this what you suggested David by "render actual density as a matte"? 

Thanks...

Link to comment
Share on other sites

well yeah, i guess... if it gives you want you want :) just take a look how it's wired inside the pyro shader and you'll see what's going on. you can probably steal it from there and use for any other volumes to render a matte. pyro shader is just a preset compound from a more basic nodes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...