Replicating MeshLambertMaterial Using ShaderMaterial ignores textures

≯℡__Kan透↙ 提交于 2019-11-26 22:47:25

three.js was designed to be easy to use, not easy to modify. This may change in the future...

You need to set the material.defines like so:

var defines = {};

defines[ "USE_MAP" ] = "";. 

Then specify defines in the material constructor.

var material =  new THREE.ShaderMaterial({
   name: "TerrainShader",
   defines     : defines,
   uniforms    : shaderUniforms,
   vertexShader: THREE.MyShader.vertexShader,
   fragmentShader: THREE.MyShader.fragmentShader,
   fog:false,
   lights:true
});

Regarding the texture repetitions, you need to add the repeat to your uniforms:

shaderUniforms[ "offsetRepeat" ].value.set( 0, 0, 2, 2 );

three.js r.66

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!