Hey there!
I’m extending / updating an existing material (MeshStandard one) using the onBeforeCompile method.
So far so good, done plenty of times but now i’m using uniformsGroup and apparently i cannot bind them onBeforeCompile for some reasons?
I’ve used uniformsGroup a lot in shader materials, never on existing ones.
[.WebGL-0x138005baf00] GL_INVALID_OPERATION: It is undefined behaviour to have a used but unbound uniform buffer.
Nothing really helpful
The issue apparently might be not the binding itself but definition in the shader because if i remove the ${globalUBO} string it doesn’t throw an error (but clearly doesn’t work)
I tried to write it manually too instead of using a variable but still the same issue
Instead of using onBeforeCompile and modifying this shader at render time, you can just inject whatever you want then and there, when first loading this string into memory.
that’s interesting and this might work actually.
Although i remember i tried in the past and it requires some effort on the fact it requires to enable manually to trigger the right DEFINES and stuff.
Maybe tricking that setting manually “isMeshStandardMaterial=true” instead.. something might be interesting to try eheh.
I’ll give a try as soon as i can, thanks for the idea sir.
Correct. The defines may be the only thing that could require some care. The good news is that it’s not impossible, you don’t want to be changing those defines often if ever, so once you figure out what you need that’s it, you have a ShaderMaterial acting as a standard material.
The idea was to see if its feasible to remove all mentions of “built in” materials from the renderer and just use ShaderMaterial beause, why not? The maintainers even liked it, but because this proposal came fairly late and all focus is on WebGPU and node materials, it hasn’t been explored further.