I have my own ShaderMaterial which currently has flat shading. I would like to apply the same shading as the one THREE’s MeshLamberMaterial uses on top of my custom shader.
What is the simplest way to achieve this? I did some search on SO and the provided “solutions” seem too complicated or not robust enough for me to try in my own setting.
If there is a way to simply “plug-n-play” lamber shading on top of a custom shader, please let me know!!
Thank you
Edit 1:
I am currently initializing my ShaderMaterial
like below
const myVertexShader = `
// some vertex shader code
`;
const myFragShader = `
// some frag shader code
`;
const myUniforms = THREE.UniformUtils.merge([
THREE.UniformsLib['lights'], // does this include lambert shading..?
{
// some custom uniforms
},
]);
const myAwesomeMaterial = new THREE.ShaderMaterial({
vertexShader: myVertexShader,
fragmentShader: myFragShader,
uniforms: myUniforms,
lights: true,
});