Jump to content
kumpa

How To Render Prim_id And Oo_id

Recommended Posts

hi !

how do i render Prim_Id and Op_Id in deep raster ? I tried just typeing Prim_Id into deepraster page but doesnt work. For test purposes, i saved image from IPR, but i also dont know what is the best way to isolate desired color value. What i am trying to achieve is to change color of an object in post production.

tnxalot

kumpa

Share this post


Link to post
Share on other sites

Two things are required here, first deep rasters render out point attribute information so you need to turn prim/obj ids into point attributes.

To do this you can use an attribute create sop with type set to prims and put $PR in the value field. You then need an attribute promote sop to change from prim to point attributes. The only problem is if you are talking about ids of individual polygons rather than entire primitive surfaces like a nurbs sphere. The only way around this is to unique points on all the edges of the bits you want to have ids for. So if you need the id of every polygon you'd need to unique all points with a facet sop. You may however be able to get away with just cusping them, same facet sop. Depends what you are ultimately trying to achieve. Of course bear in mind that uniquing or cusping them will also change the look of the shader that is used for the main beauty pass.

Once you have your id attributes you need to get the deep raster to pick them up, to do that you need a shader with a parameter in it that has the same name as your id attribute. This means your point attributes can "override" the parameter value for every point rendered.

Just set the deep raster tab to the same name and make sure the parameter you create for the shader is set to export - easy enough in vops, there is a check box for it.

You could do much the same thing for object ids but AFAIK there is no accessable obj id by default so you would have to manually assign one for each object.

Hope this helps, if not it's easy to put a simple file together that shows how to do it.

Share this post


Link to post
Share on other sites

hi sibarrick !

I am really thankful for this, i tried and it works perfectly ! From now on i will probably render out white frames and do the rest in halo. After 15 years of using various run-of-the-mill 3d apps, i still fail to understand why houdini with its apparent superiority isnt as popular as should be.

thanks again

kumpa

Share this post


Link to post
Share on other sites
You could do much the same thing for object ids but AFAIK there is no accessable obj id by default so you would have to manually assign one for each object.

However this is already implemented, at least in the IPR viewer. When you render an image inside the IPR viewer, you have available the Obj_ID and Prim_ID channels in the plane menu.

But are they readily available in normal renders or there is the need for a special set-up like you suggested?

Dragos

Share this post


Link to post
Share on other sites

They may have implimented Obj ids recently, last time I asked it wasn't accessible. It's annoying because it was there back in PRISMs days, maybe they have brought it back. If you find it I'd be interested it's very useful.

Share this post


Link to post
Share on other sites

Yes, the Op_Id and Prim_Id are automatically added to IPR renders, but you can also access these values in normal renders by adding them to the deep raster exports. To do this, add a new export variable and set the following:

- Variable name: Op_Id (or Prim_Id)

- File/Plane name: Op_Id (or Prim_Id)

- Channel depth & Variable type: floating point

- Sample filter: closest surface

- Pixel filter: minmax idcover (special filtering mode for id channels)

The values will take on the integer primitive or operator id values +1 (so that a value of 0 means no surface under that pixel).

Andrew

Share this post


Link to post
Share on other sites
Yes, the Op_Id and Prim_Id are automatically added to IPR renders, but you can also access these values in normal renders by adding them to the deep raster exports.  To do this, add a new export variable and set the following:

- Variable name: Op_Id (or Prim_Id)

- File/Plane name: Op_Id (or Prim_Id)

- Channel depth & Variable type: floating point

- Sample filter: closest surface

- Pixel filter: minmax idcover (special filtering mode for id channels)

The values will take on the integer primitive or operator id values +1 (so that a value of 0 means no surface under that pixel).

Andrew

24324[/snapback]

Note that there is most likely a correspondence between primitive id and the actual primitive number of the geometry. However, there's no guaranteed mapping between Op_Id and any identification of objects in Houdini.

If you render as an IPR file, you can use the expression function iprquerys() to decode the OP_Id's. See the scripts in houdini/ipr for examples (i.e. dragdrop.cmd and pickpixel.cmd). The iprquery() functions only work when the output driver had IPR turned on though.

I think it might also be a bad thing to try to add multiple planes with the same name...

Share this post


Link to post
Share on other sites
- Variable name: Op_Id (or Prim_Id)

- File/Plane name: Op_Id (or Prim_Id)

- Channel depth & Variable type: floating point

- Sample filter: closest surface

- Pixel filter: minmax idcover (special filtering mode for id channels)

The values will take on the integer primitive or operator id values +1 (so that a value of 0 means no surface under that pixel).

24324[/snapback]

Thank you, this is absolutely great. It would be even greater if it would be available in the online help.

Dragos

Share this post


Link to post
Share on other sites
Thank you, this is absolutely great. It would be even greater if it would be available in the online help.

Dragos

24334[/snapback]

It would be good to add as a user note. At least until they add it properly.

Share this post


Link to post
Share on other sites

hi!

i followed sibbarick advice and actually got Prim_ID and Obj_Id instead of saving ipr image. But i am still looking for a suitable way to extract desired primitives in halo. Is it common to normalise image range and divide result with nr. of primitives to get "step" for keyer to key them out ? It is only way i managed to do it.

tnx

kumpa

Share this post


Link to post
Share on other sites
But i am still looking for a suitable way to extract desired primitives in halo.

24338[/snapback]

I'm sure a VEX or VOP operator can be made, which allows you to specify the Obj /Prim ID (or better yet, sample it from the COP viewer) and generate a mask for that Object / primitive. The problem is I cannot figure out how to do it.

Dragos

Share this post


Link to post
Share on other sites

Try a lumakey COP with the Key plane set to Op_id or Prim_id, turn off 'Discard keyed region" and set the lower/upper limits set to just below/above the object id you want (ie, 4-0.01, 4+0.01). You can turn the supersampling down to 1x1 to speed up the operation. This would make a good basis for an asset.

Share this post


Link to post
Share on other sites

I did use lumakey, but problem is that it only works in range between 0 and 1. Therefore i had to normalise image range from 0-421 (number of primitives) to 0-1. Then i divided 1 by number of primitives to get range each primitive is covering. I am sure vex is the answer, but i dont think i am ready to do that. Besides i dont know how to access other planes in vex.

kumpa

Share this post


Link to post
Share on other sites

Here's a VEX fragment to fetch the id from Op_id into a VEX variable (in the first input).

int pindex, input_num;
float id;

input_num = 0;    // first input
pindex = iplaneindex(input_num, "Op_id");
if(pindex >= 0)
    id = cinput(input_num, pindex, 0, 0, IX, IY);
else
    id = 0;

However, the Lumakey COP should work outside 0-1 as long as the data format is 16 or 32 bit float; I would suggest changing the luma function from "Luminance" to "Max Component" as well.

Share this post


Link to post
Share on other sites

hi!

thank you malexander, i am sure this will be very very helpful !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×