我正在寻找创建一个与MeshStandardMaterial相同的three.js的材质。 我想这样做是因为我需要它的所有功能,除了对GLSL代码进行少量更改。
我尝试使用ShaderMaterial重新创建MeshStandardMaterial。
WAFFLE.StandardMaterial = function( parameters ) {
parameters.uniforms = THREE.UniformsUtils.merge( [
THREE.UniformsLib.common,
THREE.UniformsLib.aomap,
THREE.UniformsLib.lightmap,
THREE.UniformsLib.emissivemap,
THREE.UniformsLib.bumpmap,
THREE.UniformsLib.normalmap,
THREE.UniformsLib.displacementmap,
THREE.UniformsLib.roughnessmap,
THREE.UniformsLib.metalnessmap,
THREE.UniformsLib.fog,
THREE.UniformsLib.lights,
{
emissive: { value: new THREE.Color( 0x000000 ) },
roughness: { value: 0.5 },
metalness: { value: 0 },
envMapIntensity: { value: 1 } // temporary
}
] );
parameters.vertexShader = THREE.ShaderChunk.meshphysical_vert;
parameters.fragmentShader = THREE.ShaderChunk.meshphysical_frag;
THREE.ShaderMaterial.call( this, parameters );
}
WAFFLE.StandardMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype );
WAFFLE.StandardMaterial.prototype.constructor = WAFFLE.StandardMaterial;
到目前为止,我还没有成功。
如何重新创建MeshStandardMaterial?