Bug 11956 - swrast: drawing a line 2.0px in width has incorrect offset
Summary: swrast: drawing a line 2.0px in width has incorrect offset
Status: RESOLVED MOVED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/swrast (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-12 01:46 UTC by Campbell Barton
Modified: 2019-09-18 18:44 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Campbell Barton 2007-08-12 01:46:45 UTC
Hi, when using blender3d with Mesa's libGL.so I notice a display problem that isnt present with NVidia's or ATI's drivers.

http://members.optusnet.com.au/cjbarton/mesabug.png

This looks to be a bug in Mesa's line drawing function since blender uses it to draw the outline.

Note that mesa has done this for a long time, and older versions had this problem also.

The example below uses  glLineWidth(2.0) and glDepthMask(0) and I assume line drawing with glLineWidth(2.0) to be the problem.

is the function in blender that draws the outline around the mesh - drawobject.c:1938

/* Mesh drawing routines */

static void draw_mesh_object_outline(Object *ob, DerivedMesh *dm)
{
	
	if(G.vd->transp==0) {	// not when we draw the transparent pass
		glLineWidth(2.0);
		glDepthMask(0);
		
		/* if transparent, we cannot draw the edges for solid select... edges have no material info.
		   drawFacesSolid() doesn't draw the transparent faces */
		if(ob->dtx & OB_DRAWTRANSP) {
			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
			dm->drawFacesSolid(dm, set_gl_material);
			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		}
		else {
			dm->drawEdges(dm, 0);
		}
					
		glLineWidth(1.0);
		glDepthMask(1);
	}
}
Comment 1 khaqq 2007-08-12 07:52:38 UTC
glLineWidth(2.0);

I have the impression that NVIDIA drivers do not draw a 2 pixel wide line in this case... But Mesa does it.

However, Mesa's output is not really good looking in this case.
Comment 2 Campbell Barton 2007-08-12 19:49:21 UTC
The image shows a 1px line around a 3d object, but this only works because the line drawn is 2px wide, and half of it is masked out by the 3d cube.

Also, this works for ATI cards as well, which makes me think its not an nvidia quirk.

A default install of blenders will show this problem if you want to test. Is there any other way to validate the OpenGL drawing?

Here are some screenshots of opengl outlines rendering correctly.
http://www.zeronave.it/zn/wp-content/uploads/2007/04/blender1.png
http://www.lordfreedom.com/Pagine/Grafica/Download/Immagini/Blender.jpg
http://upload.wikimedia.org/wikibooks/en/0/03/Screenshot-5.png
http://www.siteduzero.com/uploads/fr/files/8001_9000/8249.png - with mesa only the top and right lines show.
http://www.webalice.it/fulvio.peruggi/public/Pegasos&MorphOS/Articles/06_MorphOS_TLOS/Blender.jpg
Comment 3 Campbell Barton 2007-08-12 21:21:56 UTC
Note, the bug is not that the line drawn by mesa is not 2.0px, I expect both NVidia drivers and Mesa do this, the bug is that Mesa draws the Offset of that line differently. you can see that the line is offset to the top right of the model.

Open blender with teh default scen and middle ckick drag in the 3d view to reproduce this.
Comment 4 Brian Paul 2007-08-13 02:56:59 UTC
I think the root problem is Mesa uses a different rasterization method for lines and polygon edges that hits different pixels.  So, things don't match up exactly.  Note that Mesa's lines and polygon egdes are conformant so nothing's really incorrect.  With some work, Mesa's lines could be drawn differently.

One experiment to try would be to enable GL_LINE_SMOOTH and see what happens since AA lines are drawn in a manner very similar to polygon edges.
Comment 5 Campbell Barton 2007-08-13 06:08:11 UTC
enabled GL_LINE_SMOOTH and GL_BLEND and in this case Mesa gives very similar results to NVidea

http://members.optusnet.com.au/cjbarton/mesa_bug.png
Comment 6 Campbell Barton 2008-07-04 18:22:14 UTC
Is it hard to change this? - It seems that offsetting the line would not be a big change.
Comment 7 Marek Olšák 2011-03-01 13:59:28 UTC
This is specific to swrast and the issue is still present. Hardware drivers render the lines correctly.
Comment 8 GitLab Migration User 2019-09-18 18:44:00 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/289.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.