I’m unsure what the correct approach in three.js is to apply some global uniforms to many materials/objects.
I have these options:
- patch ShaderChunks to add code and related uniforms to them
- this will apply to all shaders using those chunks. How do I set their uniforms in a good way?
- use Material.onBeforeCompile
- requires access to invidual materials, which isn’t trivial when using e.g. GLTFLoader
- still not entirely clear how/when to set uniforms in a good way
One approach I would imagine would be to have a “global” per-material beforeRender callback of sorts where I can set/update some uniforms for every material based on some condition (e.g. set tonemapping-related uniforms when tonemapping is set to a specific option).