Use instance ID in material?

   4335   5   1
User Avatar
Member
292 posts
Joined: 12月 2007
オフライン
Good Day.

Can anyone suggest in LOPs how I might use an instance ID in a material. I'm trying to get material variation on each instance of a mesh.

Thank you for any ideas.

lor
Edited by lor - 2021年5月4日 13:35:17
User Avatar
Member
112 posts
Joined: 10月 2011
オフライン
Using the materialvariation node set to point instances and the instances parameter to something like /myinstancerprim1[*], you could create a new primvar based on the index variable:
toggle use snippet and set the wrangle to:
value=index

.. which will give you the instanceid as a primvar, so it can be read in your material.

Though probably better for material variation would be to create a color3f primvar already with the desired variation color and just read that directly in your material.

To read primvars in Karma, you can just use a parameter node.
Edited by simon_o - 2021年5月5日 03:07:39
Pipeline @ RISE Visual Effects Studios
User Avatar
スタッフ
1470 posts
Joined: 7月 2005
オフライン
Like Simon said. Here is an example.

P.S. For Karma, you should use Bind VOP rather than Parameter VOP, because inside Mat Lib LOP the semantics of a Parameter VOP is to create an input attribute on the material primitive, while Bind VOP is translated to the standard USD Primvar reader.
Edited by rafal - 2021年5月5日 11:03:00

Attachments:
pt_instance_variation.hip (137.8 KB)

User Avatar
Member
238 posts
Joined: 12月 2016
オフライン
These are fully red even though the foo variable seems to be correctly set.

also using usdglobal elemnum into random should logically work but doesn't.
Edited by NicTanghe - 2025年8月26日 08:01:27
User Avatar
Member
209 posts
Joined: 11月 2013
オフライン
Couple of threads here for more info, but I've also attached an example file.
https://www.sidefx.com/forum/topic/76074/ [www.sidefx.com]
https://www.sidefx.com/forum/topic/79855/ [www.sidefx.com]
Edited by Hamilton Meathouse - 2025年8月29日 12:43:15

Attachments:
material_variation.hipnc (174.6 KB)

User Avatar
Member
209 posts
Joined: 11月 2013
オフライン
Example file above has PointInstancer and InstanceableReference examples
  • Quick Links