Nodematerial vs custom material

hi all ! I’m trying to convert the VAT generator in this pg: Babylon.js Playground to one that uses custom material: https://www.babylonjs-playground.com/#T2QE5X#1

I’m getting weird errors. uv2 is needed to read the VAT, I should not have to define it manually. How can I enable uv2 such that the shader will automatically access the mesh’s vertexBuffer.UV2Kind data ?
The error in Chrome console is: Error: VERTEX SHADER ERROR: 0:197: ‘uv2’ : undeclared identifier

If I do declare uv2 explciity in Vertex_Begin, I’m not getting any movement in the instances. Or am I going about this wrong, customMaterial and nodeMaterial are not 1:1 compatible ?

https://www.babylonjs-playground.com/#T2QE5X#2

sb_mat.AddAttribute('uv');
sb_mat.AddAttribute('uv2');

sb_mat.Vertex_Definitions(
     'attribute vec2 uv;'
    +'attribute vec2 uv2;'
)
2 Likes

Thank you ! I knew I was missing something obvious…

fyi: the perf at 60hz looks better than the nodeMaterial’s at 60hz…

1 Like