March 2013
Intermediate to advanced
984 pages
26h 18m
English
By using gl_PointCoord to lookup texels in a texture in the fragment shader, simple point sprites can be generated. Each point sprite simply shows the texture as a square. Example 6.27 is the vertex shader used in the example. Notice that we’re writing to gl_PointSize in the vertex shader. This is to control the size of the point sprites—they’re scaled relative to their distance from the near plane. Here we’ve used a simple linear mapping, but more complex logarithmic mappings can be used.
Example 6.27. Simple Point Sprite Vertex Shader
uniform mat4 model_matrix;uniform mat4 projection_matrix;layout (location = 0) in vec4 position;void main(void){ vec4 pos = projection_matrix * (model_matrix ...