Shading different GeometryInstances in one Primitive

There’s a simple exmaple to shade geometry instances in one primitive with same material but different color.

You might have doubt that why I don’t create 5 primitives and add 5 different appearances? Because its material are approximately the same but the color. And in some situation, I need to render a large number of geometries and I found I could add them to one Primitive's geometryInstances to get high performance.

As you see in my code, I make it come ture but there’s still some problems and it’s important. In my shader code, I have four compoent values: color, speed, thin and alpha(See line 137), I find that I can pass color by adding an attribute when create GeometryIsntace, but can’t pass others in the same way.

After reading some source codes, I notice there is a vertexFormat property which seems to specify which attribute is supported. But it is a very simple object which just has some string values. There must be some more low-level codes controlling it, but I do not know how to start with.

All in all. my questions are here:

  1. Is really vertexFormat property limit my passing attributes?
  2. If so, how to extend?
  3. If not, Is there any other ways to pass other attribues?

Thanks a lot.

1 Like

After some attempts, I finally find a solution here:

As you can see, This demo not only support shading different geometries but also support change their materials via passing a new color attribute. I think I should stop here for now, I’ve tired of searching in source code hardly.

But also, my questions above are still there. I’m welcome to hear any suggestions or information about that.

@sam.rothstein Hi, Sam, remember to come back for a visit after your holiday. :grin:

Hi @Gu-Miao,

Thank you for your descriptive community forum post. It seems like there have been a lot of questions about VertexFormat in our community forum recently!

First of all, I am glad to see that you were able to find a solution to your issue. I suspect that the properties provided by Geometry are limited to the specifications of our API. I currently do not know of a way to pass in additional attributes. I am not seeing anything in the Geometry documentation that suggests that this is possible.

Best,
Sam