View Full Version : Bad 2D glyphs rendering using point sprites

07-29-2008, 12:22 AM

I have a problem with textured point sprites. In my current application, I use extensively 2D 9x9 markers over photographs. Well, I though that the best way to render them could be using textured point sprites. This means only send one vertex per marker and let GL compute correct texture coordinates. Then I placed an ortho2d view and translated it by 0.375 in horz. and vert. (as MSDN and GL FAQ says, to ensure an exact match between texels and pixels, but this dont work as expected. Sometimes makers apperas shrinked in one dimension or stretched, like if texcoords were displaced a bit. Here is an example of a good and a bad marker:

Marker #470 is perfectly drawn, but #311 don't.
This effect happens randomly, when I pan or zoom my scene, and not all markers are affected, only few.
This looks like a floating point round error, but I ran out of ideas.

I disabled in NV control panel anisotropic filtering and antialising, but it had no effect.

P.D: my graphic card is an NV 8500 GT with driver version 158.22 (later I'll try with newest drivers, but this issue is happening since some driver versions and I really dont thing that could be a driver issue, but I'll it)

P.D: for drawing I'm using the simplest fragment shader ever:
uniform sampler2D texture;
void main()
gl_FragColor = texture2D(texture, gl_TexCoord[0].xy) * gl_Color;

and in the VS, texcoords are simply passed to the FS:
gl_TexCoord[0] = gl_MultiTexCoord0;
as well as point size:
gl_PointSize = gl_Point.size;

If anyone is experienced with 2d glyphs drawing using point sprites, I really apreciatte his advises


07-29-2008, 09:17 AM
Translate by 0.5.

Points need to be drawn on exact pixel centers.

07-29-2008, 11:55 PM
I already tried that, but didn't solved the problem :p

07-30-2008, 08:30 AM
Just to verify - what if you submit them as quads (or even tri's), do they still render bad? (for your case, it seems performance issue isn't in the ns range for this :-) )

07-30-2008, 10:54 AM
With quads I do not have any problem, in fact texts are drawn with quads (texcoords for text are a little tricky for point sprites) but performance matters because I'm drawing a huge number of glyphs, some projects can show around 7000 glyphs or more, depending on project settings number of options to show, number of displayed photos, etc