PDA

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



Ffelagund
07-29-2008, 01:22 AM
Hello,

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:
http://www.typhoonlabs.com/badMarker.png

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

Jacobo.

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

Points need to be drawn on exact pixel centers.

Ffelagund
07-30-2008, 12:55 AM
I already tried that, but didn't solved the problem :p

tamlin
07-30-2008, 09: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 :-) )

Ffelagund
07-30-2008, 11: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