PDA

View Full Version : Small objects are partially not drawn



AstroBistro
05-11-2010, 05:51 AM
I have a rendering problem. Small cylinders (3 axes of a 3D coordinate system) are partially not drawn if they are at a certain distance from the viewer. This is not a problem of clipping at the far plane. Other objects which are even further away are visible.
The cylinders are 8-sided quad-strips w/o normal vectors, because I don't want shading here.
The problem is clearly visible if multisampling is off. The higher the MS, the further the object must be from the view to be visible. The problem appears on all graphics cards that I have checked, ATI, Nvidia, old and new ones.
Any ideas?

View down the blue axis:
http://www.imagebanana.com/img/ozw366lj/InvisibleZDown.JPG

Slightly rotated: blue axis up:
http://www.imagebanana.com/img/xcev5mv/InvisibleZUp.JPG

The axes are small cylinders, screenshot shows it cut at the near-plane:
http://www.imagebanana.com/img/q42vqc48/AxisCut.JPG

Although red, green and blue axis have the same geometry, only rotated, red and green do not show this problem in the same way. In the screenshot below I have rotated the green axis in a similar position as the blue axis before, but instead of vanishing, it is just drawn as a thin line:
http://www.imagebanana.com/img/6r950wz/NotInvisibleY.JPG

If the axes are moved further away from the viewer, red and green axes vanish too, but as periodic interuptions:
http://www.imagebanana.com/img/kzqoo3fi/InterruptedXY.JPG

Rosario Leonardi
05-11-2010, 06:14 AM
Your problem happend cause the polygon is less then a fragment wide and in some part are not drawn at all. That's why the problem is mitigated with multisampling.

You can apply a sort of LOD and when the axis is far from the camera draw them as GL_LINES.

Lines don't suffer this problem.

AstroBistro
05-11-2010, 06:58 AM
Your problem happend cause the polygon is less then a fragment wide and in some part are not drawn at all. That's why the problem is mitigated with multisampling.

You can apply a sort of LOD and when the axis is far from the camera draw them as GL_LINES.
That sounds like a lot of work. Is this really the standard way of dealing with this sort of problem? Is there no GL parameter that instructs the rasterizer: "if a polygon is smaller than a fragment - but greater that 0, draw it as 1 fragment"?

Yomboprime
05-11-2010, 09:29 AM
You could draw always the cylinder and the line. This way you don't have to make LOD, and if the camera is near the axis it will draw correctly the nearer part and the farther part (if the camera had perspective. If it's orthogonal this doesn't matter).

dorbie
05-11-2010, 01:38 PM
OpenGL will always draw an object correctly w.r.t. rasterization even if it has very small polygons. Even with sub pixel position rounding and many degenerates SOME polygon in a contiguous set will produce a fragment. The only problem is therefore that your cylinder once projected is less than a pixel wide.

With a cylinder that projects to a size less than a pixel you are not guaranteed all fragments will be hit producing a contiguous line. In fact you can be assured that it will not in many circumstances.

GL_LINES is the correct way to draw something like this as stated earlier, alternatively make your axis cylinder thicker.