View Full Version : Line width less than 1 pixel
03-08-2007, 11:03 PM
I have an application that involves some lines, and I would like to draw realistic 3d line widths. Trouble is, OpenGL only seems to support drawing lines a minumum of 1 pixel wide. Any smaller, and they stay at 1 pixel. If I set my hardware to oversampling, I can get smaller, but there's still a minimum limitation, and I would prefer not to have to oversample every rendering.
Is there an easy way to draw OpenGL lines smaller than one pixel? Or should I just change my code to draw them as cylinders (with no lighting because I want flat coloured lines) so that they will have their correct display, with a slight performance overhead for rendering the cylinders.
03-09-2007, 01:23 AM
1. If line is thiner than 1 pixel, draw 1-pixel line but use alpha blending to make it partially visible.
-problems with z-buffering (you'll have to sort lines)
2. Draw a GL_QUAD instead of line - you'll have to compute 4 vertex coordinates yourself - in application or using vertex shader.
+thin line properly drawn using subpixel accuracy
-line can appear 'dashed' because of fragments fitting 'between' two pixels on the screen and thus not being drawn.
03-09-2007, 01:49 AM
Thanks for the reply. Yes, these were the 2 workaround solutions I was considering. I'll probably have to try both and see which gives the best results. With solution 1, I don't think I'll bother with z-sorting. It's a fully rotating model, and I've never worked out an easy logical way to do the z-sorting in an efficient way for fast refresh.
Anyway, thanks for confirming my thoughts.
03-12-2007, 03:52 PM
A caveat about opting #2:
remember that clipping must be done in clip coordinate system, before the perspective divide (i.e. before getting to normalized screen coordinate system). Therefore, you must either do your computation in CCS, or clip against the near frustum yourself before doing your computation in NSCS.
Consider the case where a line segment's endpoint is exactly at the camera's origin.
This is a good reference:
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.