setupMaterial() overrides a material's onBeforeCompile function if it already exists
Closed this issue · 1 comments
itsdouges commented
Heya! Currently setup material will overrides the function if it already exists which isn't ideal. The solution would be to compose it, something like:
if (material.onBeforeCompile) {
const previousOnBeforeCompile = material.onBeforeCompile;
const newOnBeforeCompile = (shader, renderer) => {
// csm logic
previousOnBeforeCompile(shader, renderer);
};
material.onBeforeCompile = newOnBeforeCompile;
}
For context this is set because I'm using https://github.com/FarazzShaikh/THREE-CustomShaderMaterial/ which sets it and allows you to re-use standard three materials with custom shaders.
StrandedKitty commented
Thank you. Fixed in v3.1.1.