PDA

View Full Version : How to improve polygonal text quality?



sansan
07-21-2009, 08:55 AM
Dear all!

I use nVIDIA GeForce 8600 GT under Windows 2003 Professional 64-bit, ForceWare version is 158.27.
The 3D quality settings in nVIDIA control panel should be "application-controlled", this is mandatory.

In my application I render lots of text labels showing data values in an OpenGL scene. Each glyph is rendered as a set of small filled polygons.

The text quality is good when the scene is zoomed in and the characters are large enough. However, when the user zooms it out and the characters get smaller (polygon size becomes comparable with a single pixel), text quality becomes unsatisfactory, some pixels simply disappears:

http://picasaweb.google.com/lh/photo/CdE4nTJsKl206e8dVYCMFw?feat=directlink

Note the quality of text in the annotation block at the right bottom corner. This is texmapped text rendered using FTGL library, and though the text size is smaller, the characters are still readable. This is the target quality for the text lables showing data values. The text should remain readable even when the user zooms the scene out and the characters become small.

If I go to NVIDIA control panel and turn 3D quality settings to "Maximum quality", the text quality becomes better, but still needs some amendment (compare the data labels in cells with the annotation text):

http://picasaweb.google.com/lh/photo/TLdr5r_Iol2tGTGFCSTAjA?feat=directlink

I have tried turning GL_POLYGON_SMOOTH on and setting GL_POLYGON_SMOOTH_HINT to GL_NICEST, but the result is worse than the 2nd snapshot.

Can anybody give me an advice how to achieve at least the text quality shown on the 2nd snapshot using only OpenGL calls, without tweaking NVIDIA control panel parameters?

Is it possible at all for polygonal text to look so good as texmapped text in the annotation block at the right bottom corner on both snapshots? If it is, how to achieve this?

P.S. The same problem with small polygons is reproduced on different hardware and under Linux. Thus the solution should be cross-platform and based on OpenGL capabilities only.

P.P.S. I saw NeHe lesson related to MSAA, but it's Windows-oriented. If this is the thing that helps me, it would be nice to know how to use it under Linux.

Thanks in advance for help!

Sergey

Stephen A
07-21-2009, 12:43 PM
MSAA will improve quality significantly. How are you creating the OpenGL context? Your platform abstraction should support multisampled contexts (and if not, this is trivial to fix - as long as you have access to its source code). The code on linux is 1-1 equivalent to windows - the ARB_multisample (http://www.opengl.org/registry/specs/ARB/multisample.txt) spec contains everything you need to know.

If you cannot or do not want to mess with the platform abstraction, you can achieve the same results by rendering text to multisampled FBOs.

Note that texmapped text will always look significantly better than polygonal text for small point sizes. However, it *is* possible to have zoomable texmapped text. Check out this Siggraph paper: Improved Alpha-Tested Magnification for Vector Textures and Special Effects (http://www.gbuffer.net/vector-textures). It is quite simple to implement and results are very good (especially if your target hardware supports shaders).

sansan
07-22-2009, 06:35 AM
Stephen, thank you a lot for the exhaustive reply!

My application uses VTK 5.2.1 (http://www.vtk.org) as a visualization platform. AFAIU, it does not support MSAA so far. Dealing with OpenGL rendering contexts and OS-specific things (like Win32 pixel formats or X11 visuals) is hidden inside, I have no easy means to customize this to turn MSAA on. Moreover, my application might be used on notebooks with poor hardware acceleration of 3D graphics, and MSAA simply might not work on some machines. On the other hand, textures are supported everywhere.

After all, even hardware MSAA still produces text of lower quality than texmapped fonts, as you have already mentioned in your post.

Thus I am going to concentrate my efforts on implementing texture-based text rendering for data labels instead of polygonal method.