Replicating MeshLambertMaterial Using ShaderMaterial ignores textures

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

Leave a Comment