I'm trying to use a code I found here to create a gradient shader on a cube, based on coordinates. But the position in my vertex shader doesn't seem to vary. It goes from 0 to 1 without any steps in between:
What am I doing wrong? https://codesandbox.io/s/modest-silence-xzg1c?file=/src/App.js
Here is my fragment and vertex shader:
const vertexShader = `
varying vec2 vUv;
void main() {
vUv.y = position.y;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`
const fragmentShader = `
uniform vec3 colors[2];
varying vec2 vUv;
void main() {
gl_FragColor = vec4(mix(colors[0], colors[1], vUv.y), 1.0);
}
`
const uniforms = {
colors: {
type: 'v3v',
value: [new Color('#ff0000'), new Color('#0000ff')]
}
}