Hello~
I’m currently trying to figure out the best way to have custom attributes for instanced meshes to be used in a shader. Unfortuantely I don’t have much to share in the form of code yet, since I’m still not sure about the right way to go here. And there are so many possibilities.
I stumbled across this thread on the forums and it seems similar enough to what I want to do:
Looking at the PBRCustomMaterial it seems like a great way to use the custom attributes once in place.
But I’m unsure on how to push it to the mesh. I was looking at the _renderWithInstances function of mesh.ts to see how the matrix world0-world3 is handled and that is where I’m currently stuck.
Just like aWeirdo did it in his overlay example, it would be awesome to have the attributes added to the mesh somehow. Like when the matrix gets added to the Buffer.
mesh.setFloatAttribute(instancesBuffer.createFloatBuffer(“customfloat”));
Would something like this even be possible without creating a new mesh type?
I have been looking at this problem since Babylon 3.x and always dreaded the copying of a lot of Shaderparts to make a potential pbr variant. But with the new PBRCustomMaterial it seems closer than ever. So I wanted to give it another shot.
Maybe someone can nudge me in the right direction of the right way to go, I would really love to get this working.
There might also be a couple of people coming from Unity that could be looking for this too.
Over there it is called per instance data: Unity - Manual: GPU instancing
Thank you!