I wanted to use PointsMaterial to render some smoke particles but it doesn’t support per particle rotation, so created a custom shader to do this. Problemn is that I don’t know how to handle the size of the particles in a way that even when resizing the screen they keep in the right size…
this is the error I’m noticing, look the particle size when I resize the browser:
Making screen smaller:
See how the size of the point relative to the world has make it look giant now…
This is the vertex shader:
attribute float rotation;
attribute float scale;
attribute float alpha;
varying float vAlpha;
varying float vRotation;
varying float vScale;
void main() {
vAlpha = alpha;
vRotation = rotation;
vScale = scale;
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
gl_PointSize = size * ( vScale / -mvPosition.z );
//gl_PointSize = size * vScale * (500.0 / -mvPosition.z);
}
The PointsMaterial alone works perfect, the only problem is I can’t rotate each individual particle… Will I need to add the camera’s FOV or canvas size into the shader’s uniforms and add them to the formula somehow??