Rotating GL_POINT_SPRITE_ARB

I am very new to programming in Opengl and have quite a problem in my entirely point based rendering engine. I am currently using point sprites to render vertices, but I am unhappy with the results. I am trying to figure out a way to create rotated sprites, so the result would be something like lower image:

Any ideas on what approach I should take? I do not know if it is possible to rotate a point sprite, since it is made of only one vertex - I presume that new vertices are not generated for vertex shading stage.

Point sprites can not be rotated.
Intead a solution could be to send, for each ‘sprite’ center, 4 vertices for a quad, along with normal/tangent/binormal. Then the vertex shader can expand the 4 vertices to form the sprite quad lying on the surface. Make it look round with an alpha texture.

You also can simply apply an alpha texture on the point sprites.

Or, of if you can use geometry shaders, send only one vertex per point along with normal and tangent(stuff it in the texture coordinates), then in the geometry shader you extract the binormal using the normal and tangent, finally just create new vertics using the tangent and binormal.

To make the sprites look round, yes.
But the OP seem to want the make sprites tangent to the surface.

the way to draw non-rotated circular sprites is:
varying vec3 center2D; // in screen-space
varying float radius;
void main(){
float dist = distance(gl_FragCoord.xy,center2D.xy/center2D.w);
if(radius<dist)discard; // hit-tests a circle
gl_FragColor = vec4(0.5,0.5,0.5,1);
}

For a “rotated” sprite, you’ll need to hit-test a rotated ellipse. This will involve the normal-vector somehow. (I can’t help with the maths there)
Maybe it’ll be easiest to do raycasting?

Geometry shaders make the geometric approach eazy, but it’ll cost you the price of a new card (who cares!).

A potential downside of pointsprites is that they are clipped like points, meaning your quads will likely disappear before they slide off the screen completely.

Ah, SM4. Instancing and geometry shaders are beautiful things. :slight_smile:

this is just for some school project so I wont be buying any modern cards right now :slight_smile:

I actually managed to get circle point sprites using alpha texture, but optimal for me would be to get rotated circles using just one vertex. Optimal approach would be to hit-test 3D rotated circle. I should do that in pixel shader right? is vertex that is draw on that pixel passed to pixel shader? and can i pass circle radius from vertex shader to pixel shader?

sorry if my questions are stupid, it’s my first experience programming for GPU

If you’re targeting SM3 cards, then maybe the fastest way will be to generate 4 vertices out of 1… by rendering to a vertex-array. (Render to several RGBA32f textures at once, then copy those textures onto PBOs, which you then use as VBOs). This way you do all the work on the gpu.

A bit on the topic, are GL_QUADS actually internally supported on SM3/SM4 cards? (i.e you generate the VBOs and send quads, but the driver never needs to chop them into triangles).

now I have another problem, this time it’s concerning math behind it. I have center point and four vectors pointing at the edges. I have to rotate them at an angle that is difference between normal vector of the vertex and vector from center point to the eye.

How do I do this?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.