iosopengl-esopengl-es-2.0vertex-shaderpixel-shading

gl_PointSize OpenGLES clarification


What does setting gl_PointSize = 1.0 in vertex shader means or achieve? Does that mean the vertex itself is a pixel?


Solution

  • What does setting gl_PointSize = 1.0 in vertex shader means or achieve? Does that mean the vertex itself is a pixel?

    Yes, it does.


    See gl_PointSize:

    The variable gl_PointSize is intended for a vertex shader to write the size of the point to be rasterized. It is measured in pixels.

    See OpenGL ES Specification - Khronos OpenGL ES Registry, 3.3 Points, page 51:

    Point size is taken from the shader builtin gl_PointSize and clamped to the implementation-dependent point size range. If the value written to gl_PointSize is less than or equal to zero, results are undefined. The range is determined by the ALIASED_POINT_SIZE_RANGE and may be queried as described in chapter 6. The maximum point size supported must be at least one.
    Point rasterization produces a fragment for each framebuffer pixel whose center lies inside a square centered at the point’s (xw, yw ), with side length equal to the point size.


    This means, if you define gl_PointSize = 1.0, then this specifies a square with a side lenght of 1 fragment. The fragment whos center point is in this square is affected.

    In compare to "desktop" OpenGL, in program point size has not to be enabled. (In desktop OpenGL gl_PointSize only has a meaning, if GL_PROGRAM_POINT_SIZE is enabled).