Sir, one doubt uniform name means any variable name or something else
Uniform name just means some name that you could use for a variable. i.e. no spaces, no numbers at the beginning, no special characters.
Actually Idk the fragment shader coding I am bit confused how to declare a variable and where I need to paste this in a traverse function or somewhere else.
Ok…
So, the onbeforecompile function goes in a traversal loop that runs only once, and make absolutely certain that it runs before the first render frame, but after the gltf loads (because you are traversing the gltf scene)
If you know C, then GLSL (what WebGL shaders are written in) is very similar. I would do something like this
shader.fragmentShader = 'uniform int [uniform name];' + shader.fragmentShader + [conditionals from above];
Wait… that will fail…
shader.fragmentShader = 'uniform int [uniform name;\n' + shader.fragmentShader.replace(/}$/, [conditionals from above] + "}");
That would go in the onbeforecompile function
Can I text you personally here on three js?