I'm currently working with THREE.js version 73 and attempting to create a particle system by utilizing THREE.BufferGeometry
for the vertices and THREE.ShaderMaterial
to enhance their functionality. However, I am encountering an error that is perplexing me. The issue arises at the following line in the fragment shader:
gl_FragColor = gl_FragColor * texture2D( texture, gl_PointCoord );
this.particleSystem = new THREE.PointCloud(
this.particles,
new THREE.ShaderMaterial({
uniforms: {
texture: wTex
},
vertexShader: `
attribute vec3 color;
attribute float size;
varying vec3 vColor;
varying vec2 vUv;
void main() {
vUv = uv;
vColor = color;
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) );
gl_Position = projectionMatrix * mvPosition;
}
`,
fragmentShader: `
uniform sampler2D texture;
varying vec3 vColor;
varying vec2 vUv;
void main() {
gl_FragColor = vec4( vColor, 1.0 );
gl_FragColor = gl_FragColor * texture2D( texture, gl_PointCoord );
}
`
})
);
I adapted this code from various online sources, but I believe I grasp its workings.