Overwrite PhysicalMaterial´s color fragment include

Hi!
What’s written there: three.js/color_fragment.glsl.js at 0c5b9b7e4caffa17765e242f4dacfd191f58cb3d · mrdoob/three.js · GitHub (the other shader chunks are in the same folder).
How to overwrite:

material.onBeforeCompile = shader => {
    shader.fragmentShader = shader.fragmentShader.replace(
        `#include <color_fragment>`,
        ` _your_shader_code_here_ `
    );
}

Also, a very useful addon: Chainable onBeforeCompile + Uniforms per Mesh

1 Like