How to get user Cryptomatte or custom Cryptomatte in Vray for Houdini?

To get user cryptomatte in arnold we use attribwrangle
run over: primitives
VEXpression: s@crypto = ‘torus’; (as example)

or with attribcreate:
name: crypto
class: primitives
type: string
string: torus (as example)

How can I achieve the same thing with vray?

Hey @elrachyd ,

I’ve attached an example here: https://drive.google.com/file/d/1sA6…ew?usp=sharing

Also added some notes in the file, I’m copying here for anyone who may stumble upon this post at a later point.

Custom string attributes for Cryptomatte in “User Attribute” mode is supported only for packed primitives/fragments, or entire Geometry nodes. Assigning the attribute to regular (not packed) poly meshes won’t work.
You can either use:

1. a custom string point attribute on the packed primitive, in which case you need to tell V-Ray to always export the attribute under either the Object Properties → Main → Forced Attributes list, or the Renderer ROP → Objects → Forced Attributes list. If an attribute is not used in the shading network, we discard it to speed up export times and reduce the VRScene size (each vector attribute is essentially the same as an additional point so you can imagine 1 million points with position + 9 extra vector attributes is the same as 10 million points as far as raw data export is concerned).
2. the User Attributes field on the Geometry node → V-Ray Object Properties → Main tab, e.g. cryptomatteName=‘vray’

Hope that helps!

Thank you for the scene example, I really appreciate, but I’m so confused with this setup!
1- why the custom attributes is running over the class Point, rather than primitive?
2- for objectProperties you defined, all object get the same color!
as you can see in the image

eachPackedPrim look fine

with 02 separated objects (Sphere & Cube)
for the Cube I put the same data you provided in your example
User Attributes:cryptomatteName=‘vray’
except for Forced Attributes:crypto( just attr name!)
and nothing in torus object
and here is the result different color
First image is your example
here is hip file



cryptoUserAttributes_v1.zip (47.5 KB)

There are 2 Cryptomatte elements in the file.

The first one is using a User Attribute defined on the entire Geometry node using the V-Ray Object Properties - cryptomatteName=‘vray’. Then, in the Cryptomatte VOP node, in User Attribute mode, the attribute specified is ‘cryptomatteName’. So, it’s checking for this attribute, finds it on both the Box and the Torus, and gives them the same color.

The second one is using a string attribute defined on each packed object. The attribute is called ‘myAttr’, it has different values for the box and the torus. On the second Cryptomatte VOP node, it’s specified as ‘myAttr’ so when V-Ray starts rendering, it finds the different values for this attribute on the box and the torus, thus giving you different colors.

I hope that makes sense ?

One thing that may clarify what happens -- packed objects are treated as individual nodes themselves when we start exporting. So, essentially, when you pack the box and torus and place the string attribute on them, it’s essentially the same as if you were to Object Merge them in separate Geometry nodes, add V-Ray Object Properties to those geometry nodes, and define the attribute there.

1- why the custom attributes is running over the class Point, rather than primitive?
I doubt it would make any difference from our point of view - any particular reason you would prefer them to be on the packed primitives rather than the points storing them ?

Best regards!

packed objects are treated as individual nodes themselves when we start exporting. So, essentially, when you pack the box and torus and place the string attribute on them, it’s essentially the same as if you were to Object Merge them in separate Geometry nodes, add V-Ray Object Properties to those geometry nodes, and define the attribute there.
Then why are rendered with the same color??

The first one is using a User Attribute defined on the entire Geometry node using the V-Ray Object Properties - cryptomatteName=‘vray’. Then, in the Cryptomatte VOP node, in User Attribute mode, the attribute specified is ‘cryptomatteName’. So, it’s checking for this attribute, finds it on both the Box and the Torus, and gives them the same color.
Why in my example with the same setup gives different color?? just look at my scene!
Thanks

Yes, the reason for this is exactly the same, and why I mentioned it won’t work with regular poly geometry but will work just fine with packed primitives. Here’s the relevant part from the previous post:

Packed objects are treated as individual nodes themselves when we start exporting. So, essentially, when you pack the box and torus and place the string attribute on them, it’s essentially the same as if you were to Object Merge them in separate Geometry nodes, add V-Ray Object Properties to those geometry nodes, and define the attribute there.

With alembics, that is pretty much the same - if there is no partitioning going on, we export a single Node, and the Cryptomatte attribute can be queried from a Node only, not the actual mesh data. If you partition the alembic file (e.g. by @path), we’ll export a separate Node for each @path value.

Here’s an example: https://drive.google.com/file/d/1OVWz5y2lzzJ1LB4kLp2\_A7qK9c3yNZjR/view?usp=sharing

The only thing that comes to mind is to partition the object above using the connectivity attribute when exporting the alembic, if that’s a possibility.

Hope that helps!

Why in my example with the same setup gives different color?? just look at my scene!

I did - it’s looking as expected on my end.

What Houdini and V-Ray builds are you using - might be a fixed issue although I don’t recall anything like this not working during the last few months.

really confused, I’ve never seen this issue with cryptomatte for Arnold
OK why myAttr look the same as eachPackedPrim ? it seem like duplicated ! is not?
Also there is no alembic file in your scene!

@bdancer thanks for the scene
The confusion is why myAttr look the same as eachPackedPrim what’s the point to have 02 custom cryptomatte with the identical color? that’s the confusion for me!

> The confusion is why myAttr look the same as eachPackedPrim what’s the point to have 02 custom cryptomatte with the identical color? that’s the confusion for me!

Sorry, I don’t understand that… could u post a screenshot of what does that mean? Which identical color? I’ve posted a screenshot with the different color per-packed…

Sorry, I don’t understand again… What is the confusion here?
"myAttr look the same as eachPackedPrim" - because both use the same attribute and attribute value? so same attribute value results in the same “color”?

I can’t explain more with my boring English but take a look at this scene with HtoA cryptomatte
I want to achieve the same thing with Vray, can you reproduce this please?
Thank you
here is the hip file
htoaCryptomatte.zip (105 KB)

Cryptomatte in V-Ray doesn’t support user attributes per-polygon, only for object or packed. Scene attached.
vray_htoaCryptomatte.zip (79.3 KB)


really helpful thank you

It seems that none of these workflows works on the GPU+CPU. I do not get the same results at all. If that is the case, are you guys planning to support this on the GPU+CPU?

Any word on this?

> Any word on this?

We are working on this.

Got it, Thanks!

hsz,This should work in the recent nightly, could u pls test?

Great, I’ll test it and let you know!