4

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

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131

2 Answers2

3

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.

Ferdi
  • 31
  • 2
3

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

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • 1
    Under Android there is no such constant named GL_PROGRAM_POINT_SIZE. But gl_PointSize can still be set in vertex shader and it works. – neoexpert Dec 26 '19 at 14:31
  • 1
    @neoexpert Yes, you are right. That's a difference between OpenGL ES and "desktop" OpenGL – Rabbid76 Dec 26 '19 at 15:06