I am currently researching how instancing is done in hydra/HdSt. I already understood how you can setup transforms per instance and do one instanced draw call for n instances instead of n standard drawcalls. Now I want to map shader parameters to instanced data. As I looked at the hydra code and shaders, I think it is not supported in a way how transforms per instance are supported. It looks like you can add additional instance primvars, but they are not used with the PreviewShader.
I thought that possibly there is some kind of connection paradigm in how to setup a material network, so that you can plug custom primvars per instance into a specific shader parameter like it is done with UVTexture, but I didn’t find anything. It looks like I have to write my own shader or modification of the preview shader to read my custom primvars per instance (like diffuse colour per instance).
So my question is:
Did I miss something and it is possible to achieve colour per instance without touching shader code? How would that be done? Or is it like I thought and I have to modify or write my own instanced shader?
Hey Robert,
as long as the shader can have specific input, you can provide per-instance primvars that the shader can read, for example, most renderers today read primvars:displayColor, and you can provide them per-instance with a “instance-interpolation”.
I have some example files for Karma and Storm if you want.
This is, assuming you are talking about PointInstancer.
There is another way of doing instancing in USD which is called NativeInstancing or SceneGraph instancing, and it translates to Hydra into HdInstancer again, as PointInstancers do.
Cheers
and I’ve made a simple python node to read an image and create “one cube per pixel” in a RGBLed mode or as “3 cubes per pixel” as in a RGBLedIPS mode.
Hey Paolo,
thank you for your quick answer! I obviously missed the most obvious thing. It can be so easy :D. I just also tested emissive color per instance and it works like a charm, thank you! I am using a custom scene index without USD functionality by the way. So I am constructing the material network, instancer and prim datasources by myself. This is something which often isn’t obvious to me, because the USD adapters and the appropriate scene indices are often my only documentation on what exactly is expected in the data sources by the renderers.