Custom instance buffer trouble

Hello forum,

I have trouble using the registerInstancedBuffer feature. (How to pass custom attributes of each instance to the shader).

For example: Babylon.js Playground (babylonjs.com)

Thanks for any help!

See this PG with the fix: https://playground.babylonjs.com/#YPABS1#181

First, you cannot directly declare attribute in fragment shader. I pass the value of attribute test to fragment shader by using a varying vTest. And set vTest to be the value from attribute test.

    box.material.Vertex_MainEnd(`\
        vTest = test;
    `);

You also need to declare the custom attribute before using it.

box.material.AddAttribute("test")

2 Likes

Beautiful, thank you!