Currently, I am utilizing a cell shading script to shade a Lambert material on a model. However, I am facing challenges when trying to apply the same script to a custom Shader Material. Is there a way to convert the custom material into a Lambert material? I have searched for solutions but haven't found anything yet. Your assistance would be greatly appreciated. The code I have written so far includes the three_lamberton script, which is used for applying an image to an object. The scripts at the beginning are for layering images and setting up the custom shader material. Please disregard the repetition of some images being loaded into the material more than once, as they are just placeholders for now. My goal is to be able to apply the three_lamberton script to the shader material named material_shh.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Web GL test 2</title>
</head>
<body style="overflow: hidden; background: black;">
<div id="container">
</div>
<script src="three.min.js"></script>
<script src="OBJLoader.js"></script>
<script src="three_lambertoon_c.js"></script>
<script id="fragment_shh" type="x-shader/x-fragment">
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D tOne;
uniform sampler2D tSec;
uniform sampler2D tThree;
uniform sampler2D tFour;
uniform sampler2D tFive;
uniform sampler2D tSix;
varying vec2 vUv;
void main(void)
{
vec3 c;
vec4 Ca = texture2D(tOne, vUv);
vec4 Cb = texture2D(tSec, vUv);
vec4 Cc = texture2D(tThree, vUv);
vec4 Cd = texture2D(tFour, vUv);
vec4 Ce = texture2D(tFive, vUv);
vec4 Cf = texture2D(tSix, vUv);
c = Ca.rgb * Ca.a + Cb.rgb * Cb.a + Cc.rgb * Cc.a + Cd.rgb * Cd.a
+ Ce.rgb * Ce.a + Cf.rgb * Cf.a * (1.0 - Ca.a - Cb.a - Cc.a - Cd.a - Ce.a);
gl_FragColor= vec4(c, 1.0);
}
</script>
<script id="vertex_shh" type="x-shader/x-vertex">
varying vec2 vUv;
void main()
{
vUv = uv;
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
gl_Position = projectionMatrix * mvPosition;
}
</script>