1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| let c = new THREE.Color('#09e7ea'); const material = new THREE.ShaderMaterial({ uniforms: { targetColor:{value:new THREE.Vector3(c.r,c.g,c.b)}, height: { value: 10}, }, side: THREE.DoubleSide, transparent:true, depthWrite:false, vertexShader: [ "varying vec3 modelPos;", "void main() {", " modelPos = position;", " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", "}" ].join("\n"), fragmentShader: [ "uniform vec3 targetColor;", "uniform float height;", "varying vec3 modelPos;",
"void main() {", " gl_FragColor = vec4(targetColor.xyz,(1.0 - modelPos.y/height)*(1.0 - modelPos.y/height));", "}" ].join("\n") });
|