I'm trying to animate the color transition for ShaderMaterial. I want to have 5 colors, and switch them every few seconds for a whole object (wave of particles).
Here is my JS code
var material = new THREE.ShaderMaterial( {
uniforms: {
color: { value: new THREE.Color('violet') },
},
vertexShader: document.getElementById( 'vertexshader' ).textContent,
fragmentShader: document.getElementById( 'fragmentshader' ).textContent
});
And fragment shader part:
uniform vec3 color;
void main() {
if ( length( gl_PointCoord - vec2( 0.5, 0.5 ) ) > 0.475 ) discard;
gl_FragColor = vec4(color, 1.0 );
}
I have just a little idea of how three.js works. Any suggestions highly appreciated! :)
All code is here: codepen.io/agrhff/pen/MWKEqQy