I’m not completely sure it’s possible as far as my knowledge with THREE.Points goes, but maybe someone else can offer insight?
My goal is that when I’m far away from the system, the sprites retain the same size in world-space as they do when close by.
THREE.PointsMaterial provides a property in order to activate/deactivate size attenuation. I have not studied your code in detail but I guess you could use a similar approach like the built-in material.
Aaah I knew of Size Attenuation from PointsMaterial, not sure why I didn’t think of copying that.
I presume that mvPosition in the shader can be substituted for cameraPosition? Because otherwise, mvPosition is not a property in the shader/program.
However, I just tried this and it seems to make the particles super small, and changing the scale or even multiplying scale by a constant, doesn’t seem to change the size at all.
I tried commenting out any other shadercode that changes gl_PointSize, too.
Ah okay, thanks! Still a bit new to shaders
I just tried this and it works partially! The size no longer acts weird depending on camera distance, however it now acts weird depending on a mix of camera distance and viewing angle
there a scale variable. Where does it come from?
I tried to look in ShaderChunk ‘begin_vertex’ and ‘project_vertex’ but can’t find it there.
I am digging the topic as i’d like to learn how to calculate sizeAttenuation in custom ShaderMaterial, where each vertex has own size (as attribute with BufferGeometry). Points are equally distanced from camera z position, but there is ‘zoom’ behaviour that uses both camera z and camera fov. I would like to keep the points sizes ‘proportionally’ scaled depending on zoom. Many thanks for a hint.