I want to repeat wrapping texture in THREE.js shader.
The original texture image is:
I want it to repeat 4x4 times which will looks like:
But with the following code, it turns out to be:
Vertex shader:
varying vec2 vUv; uniform float textRepeat; void main() { // passing texture to fragment shader vUv = uv * textRepeat; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }
Fragment shader:
varying vec2 vUv; uniform sampler2D texture; void main() { // add origianl texture gl_FragColor = texture2D(texture, vUv); }
uniforms
in a JavaScript file, in which textureRepeat
gives the times need to be repeated:
uniforms: { texture: { type: 't', value: THREE.ImageUtils.loadTexture('image/box.jpg') }, textRepeat: { type: 'f', value: 8 } }
Could anyone tell me what's going wrong here?