When is gl_PointSize used in WebGL / OpenGL?
1 answer
gl_PointSize , like glPointSize used to indicate the size of a point ( GL_POINTS ). The only difference between them is that gl_PointSize used through a shader (shader), and glPointSize is used directly through OpenGL.
Now in which case what to use. A good example for a shader (and, accordingly, gl_PointSize ) is a fountain of particles.
That is, it is such a system of particles in which the points can be of different sizes. Since we cannot use glPointSize for each point individually, this can be achieved using a shader.
An example of the simplest vertex shader:
void main(){ gl_Position = ... gl_PointSize = pointSize; } In this case, if the variable pointSize constant for all points, then all points will be the same size. Often, pointSize is encoded through one of the color channels (for example, the alpha channel), and then removed in the shader - in this case, each point will have a different size.
