0

不知道这是否可能,但是在three.js中使用ShaderToon.js,有没有让uBaseColor值透明???并使 uLineColor 值不透明?

function createShaderMaterial( id, light, ambientLight ) {
        var shader = THREE.ShaderToon[ id ];
        var u = THREE.UniformsUtils.clone( shader.uniforms );
        var vs = shader.vertexShader;
        var fs = shader.fragmentShader;
        var material = new THREE.ShaderMaterial( { uniforms: u, vertexShader: vs, fragmentShader: fs } );
        material.uniforms.uDirLightPos.value = light.position;
        material.uniforms.uDirLightColor.value = light.color;
        material.uniforms.uAmbientLightColor.value = ambientLight.color;
        return material;
}

geometry = new THREE.TorusKnotGeometry(106.68, 200, 12, 2, 8.44, 5.4, 1);
material = createShaderMaterial( "dotted", directionalLight, ambientLight );
material.uniforms.uBaseColor.value.setHex( 0xffffff ); // want this to be transparent
material.uniforms.uLineColor1.value.setHex( 0x0000 );
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
4

1 回答 1

1

ShaderToon是示例的一部分,因此您可以根据自己的喜好随意修改它。

例如,您可以这样做:

"gl_FragColor = vec4( uBaseColor, 0.5 );",

在您的createShaderMaterial()功能中,您还必须设置

material.transparent = true;

三.js r.59

于 2013-07-21T21:19:31.283 回答