gl_PointSize OpenGLES clarification

4.1k Views Asked by At

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

2

There are 2 best solutions below

2
Rabbid76 On BEST ANSWER

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).

0
Ferdi On

gl_PointSize determines the size of a point.

You can draw in triangles, lines and points. If you'll draw for example a triangle in points, then 3 points will appear on the screen. There size can be changed with gl_PointSize parameter. If you set for example gl_PointSize = 10.0; , then points on screen will be quite big.

What is this for? Gives more possibilities. Also a texture can be bound to a point - wherever you draw a point there'll be a texture. Cool, hah? And the size of this texture in this case is determined by gl_PointSize;

Not much sure in what range it can be changed. I guess it depends a bit. Just try (1.0, 4.0, 10.0 for example) and you'll quickly see the difference.