Customizing the Appearance of Our Points

You may have noticed that our points are being rendered as small squares, with the number of pixels on each side equal to the value of gl_PointSize. Using another special OpenGL variable, gl_PointCoord, we can actually customize the appearance of our points. For each point, when the fragment shader is run, we’ll get a two-dimensional gl_PointCoord coordinate with each component ranging from 0 to 1 on each axis, depending on which fragment in the point is currently being rendered.

To see how this works, we’ll first use gl_PointCoord to draw our fragments as circles instead of squares. How can we do this? Well, each point will be rendered with fragments that range from 0 to 1 on each axis relative to

Get OpenGL ES 2 for Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.