I am working on a particle system, and of course I would like my point sprites to be smaller if they are farther away from the camera.


This works well if I use the fixed pipeline, but if I use a GLSL shader, it doesn’t. All point sprites are the same size.

There is not a lot of info on the net about this, the only thing I could find was to enable GL_VERTEX_PROGRAM_POINT_SIZE. But it did not change anything, size is still constant. Can someone tell me how to achieve this in a shader?


When you enable GL_VERTEX_PROGRAM_POINT_SIZE you can use the glsl command gl_PointSize in the shader to affect the size of the points emitted.

To do attenuation you need to duplicate the maths that the fixed function pipeline normally does in your shader and feed that into gl_PointSize.


I should have known that I also have to do the calculation in the shader. Thanks once again.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.