Defines vs customProgramCacheKey

What’s the benefit to either approach? I had assumed defines could only be set once ( and again maybe with material.needsUpdate? ). I guess with the customProgramCacheKey approach you could go over the uniform limit depending on the “branch”. Just thinking out loud.

That is right.

Not sure what you mean by that.

You need customProgramCacheKey() only when using onBeforeCompile() for the special case when you patch internal shaders based on conditions. Meaning onBeforeCompile() produces different permutations of a shader. customProgramCacheKey() can be used to identify each shader which is important for correct caching. More information in the documentation.

Well, uniforms get removed by the shader compiler if they are unused right? I had for some reason though that defines approach would not also go through this process, and thus have a potentially smaller uniform limit than the onBeforeCompile approach.