View Full Version : Crisp rendering of horizontal & vertical lines?
01-14-2011, 01:57 PM
I have a problem rendering horizontal and vertical lines when multiple sample buffers are being used. The problem is that even when I specify a line width of 1 and colour of black, these lines are drawn thicker and greyer than I had hoped for i.e. they are not crisp, thin lines but fuzz, greyish lines. If I disable multi-sampling then these lines are rendered as I want but then angled lines are rendered with a very jagged appearance (also undesirable).
Is there a way to render horizontal and vertical lines crisply and with a fine, dark appearance and angled lines with minimal jaggies in the same context at the same time? Perhaps there is a way to disable multi-sampling for horizontal/vertical ines but enable it for angled lines? Some other technique perhaps?
01-14-2011, 02:00 PM
I should mention that I am referring only to 2D lines in 2D space as in vector graphics rendering.
01-14-2011, 02:32 PM
Have you tried offsetting slightly the line positions, ie +0.5 pixel ?
May not work for all AA modes however.
01-14-2011, 05:46 PM
glDisable(GL_MULTISAMPLE) should produce single-sample rendering in a multisample buffer, so you could do that when you know the lines are exactly horizontal or vertical. However this is known not to work on some older hardware.
01-14-2011, 07:57 PM
Thanks guys, it does appear to be somewhat position dependent as alluded to by ZbuffeR but it seems glDisable(GL_MULTISAMPLE) does the trick nicely!
01-14-2011, 08:13 PM
GL_LINE_SMOOTH may give you more control and quality than FSAA can.
01-14-2011, 08:54 PM
I tried GL_LINE_SMOOTH but the results were not what I wanted in that the horizontal and vertical lines are rendered thicker than desired although their colour looks better (i.e. darker when appropriate).
The only way I can see to draw crisp, thin horizontal and vertical lines is to disable multisampling and line smoothing.
01-15-2011, 01:30 AM
You need to ensure that your lines fall on whole pixels. If they fall between two pixels, antialiasing will (correctly) smooth the line and make it appear thicker.
In short, enable FSAA or GL_LINE_SMOOTH and align the ends of your lines to the pixel grid before rendering.
01-15-2011, 01:57 AM
OK, sounds good but being a newbie at this, how do I "align the ends of your lines to the pixel grid"? I don't really like the idea of enabling/disabilg FSAA on-the-fly so a better solution would be ideal.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.