Overlapping lines

Hi All,

Here is my latest question:

I have a 3D shaded cube made by 6 faces drawn one by one with GL_QUADS and GL_LINE_LOOP for edges, I use:


gl.Enable(gl.POLYGON_OFFSET_FILL);
gl.PolygonOffset(1.0f, 1.0f);

to have Hidden Lines (edges) Removal.

In this way I see the shaded blue cube and the black edges drawn perfectly.

The problem arises when I select a cube face. I need to draw in yellow the shaded face and its boundary edge. When I do it and rotate the cube the edge change color unplesantly from black to yellow very frequently.

Is there a way to avoid this? To draw the yellow wire edges slightly closer to the user?

Thanks,

Alberto

If there is flicker on the edges, it means you are drawing them more than once. A cube has only 12 edges, no need to drawn four edges aroung each face, it would mean 4 * 6 = 24 edges, with flickering.

I know ZbuffeR, the cube is an example, in reality we work with 3D surface based models. Each surface has a fill and an outline and all around overlap with others.

Thanks,

Alberto

Maybe some other values for factor and units will do the trick?

N.

As far as I know, glPolygonOffset() helps to separate wireframe from polygons not wireframe from wireframe.

Alberto

But you can offset with a higher value just for selected wire.

ZbuffeR,

Aren’t only polygons affected by glPolygonOffset()? In my case I need to separate two lines.

Thanks,

Alberto

devdept, glPolygonOffset explained.

A line is in fact usually a polygon; a quad (that’s deconstructed into two triangles).

This is the first time I heard that a line is a polygon, do you all agree?

I will try to see what happen to apply again the glPolygonOffset() on lines.

Apply the normal offset to the whole wire, then increase the offset, then render only the selected wire.

Hi ZBuffeR,

We are following the RedBook Chapter 14 that says to apply glPolygonOffset on filled polygons not on wires. Can we do the opposite and use glPolygonOffset on wires with different factor for selected wires?

Thanks,

Alberto

You can always fake the polygonoffset by changing your projection matrix.

e.g.

  1. draw the polygon with gluPerspective(…,near,far)
  2. draw set of lines with gluPerspective(…,near+offset1,far+offset1)
  3. draw set of lines with gluPerspective(…,near+offset2,far+offset2)
    etc.

N.

ZbuffeR,

I tryed to do what you suggested but using the glPolygonOffset on wires instead of polygons it pushes the polygons in front of wires even with negative factors.

NiCo,

Unfortuately in our Rendering engine we are not allowed to give different projection to different entities.

I am sure that a smarter solution exists.

Think about two overlapping lines: how would you make one always visible over the other?

Thanks,

Alberto

You are right, I mixed up polygons and wire. So polygon offset is out.

NiCo,
Unfortuately in our Rendering engine we are not allowed to give different projection to different entities.
I am sure that a smarter solution exists.

Too bad, sometimes that is very useful. It is not smart enough for you ?

Think about two overlapping lines: how would you make one always visible over the other?

1)Change projection as said nico
2)disable depth test, or maybe use “or equal” tests, and draw selected wire last. If your vertex coordinates and drawing commands are exactly the same (only color changes), it should work without glitches.
3)use a custom vertex shader to do 1)

If you don’t want to change the projection matrix you can always change the modelview matrix to get the same effect. After all, the actual projection is only defined by projection*modelview…

N.

Thanks guys.

I will try again.