Bug 200 : internal lines of shapes are visible with smooth() and P3D or OPENGL
Last modified: 2009-07-22 14:00




Status:
ASSIGNED
Resolution:
-
Priority:
P1
Severity:
normal

 

Reporter:
fry
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2005-11-04 05:00
most basic case, with smooth turned on a rect sometimes has a diagonal line
through it.

need to keep track of what edge vertices are internal, and not smooth them.
perhaps the opengl tessellator even does this on its own?
Additional Comment #1 From fry 2005-11-04 05:02
this is a general problem with 3D rendering, and may be a bit difficult to fix.
Additional Comment #2 From Ricard 2005-11-28 17:06
(In reply to comment #1)
>
>
>
> Additional Comment #1 From
> fry
> 2005-11-04 05:02
>
> <!--
> addReplyLink(1); //-->[reply]
>
>
>
>
> this is a general problem with 3D rendering, and may be a bit
difficult to fix.
>
>

Have additional information on this. Try this code and you'll see what I mean:

import processing.opengl.*;

float t = 0;

void setup(){
size(500,500,OPENGL);
framerate(24);
background(255);
smooth();
fill(0);
stroke(0);
}

void draw(){
translate(width/2,height/2);
background(255);

rotateX(PI/54*t); // COMMENTING REMOVES CONTOURS' FLICKERING EFFECT
t++;

noSmooth();
noStroke();
beginShape(TRIANGLE_STRIP);
vertex(20,20);
vertex(100,20);
vertex(20,100);
vertex(200,100);
endShape();

beginShape(TRIANGLE_STRIP);
vertex(200,100);
vertex(100,20);
vertex(200,20);
vertex(150,0);
endShape();

smooth(); // COMMENTING REMOVES LINES INSIDE AND BETWEEN STRIPS
stroke(255,0,0);
beginShape(LINE_STRIP);
vertex(20,20);
vertex(20,100);
vertex(200,100);
vertex(200,20);
vertex(150,0);
vertex(100,20);
vertex(20,20);
endShape();
}

I use code similar to this one in order to avoid such effect in Linux. It
sounds weird but in Linux this effect is less visible, althought still
there when rotating any of the axis (mostly when rotating around X and Y).

The basic idea is to turn off smoothing when drawing meshes and turn it
back on to draw the contour. Well, it appears to be a problem when turning
smoothing off and back on during one same frame. The result is that only
the last call of smooth is taken into account for everything.

This seems normal if we don't keep any information about smoothing on the
vertices themselves and they are not drawn until the end of the frame (in
order to take into account Z-ordering and maybe other stuff, I don't know).

Should the information about smoothing be kept on the vertices and
triangles, the same way as light, colour,...? is this already done?
(haven't dived into the code, to check myself).


A second problem (don't know if it's a separate bug or not, so I keep it
here just in case) is about the flickering of the contour, when rotating
the polygon around the x axis. Has this something to do with this bug?

Does this help or is this just a bunch of more questions?? jeje

well, it's a quite nasty bug for my library. So I'll keep looking into it
once I get some time (won't be before mid december, though).
Additional Comment #3 From fry 2005-11-28 17:26
> This seems normal if we don't keep any information about smoothing on the
> vertices themselves and they are not drawn until the end of the frame (in
> order to take into account Z-ordering and maybe other stuff, I don't know).

yes, generally this is how it would work, it just takes time to rework the renderer to make it
happen.
Additional Comment #4 From njetti 2005-12-01 20:34

I think OpenGL can't even draw a rect properly:

import processing.opengl.*;
void setup(){
size(400,400, OPENGL);
for(int i=0; i < 10; i++){
rect(random(width), random(height), random(10, 30),random(10,30));
}
}
Additional Comment #5 From fry 2007-02-03 09:08
this is on the list for the 1.0 release.
Additional Comment #6 From fry 2007-07-27 19:33
*** Bug 602 has been marked as a duplicate of this bug. ***
Additional Comment #7 From Eric F. 2008-08-11 13:28
workaround: use hint(ENABLE_OPENGL_4X_SMOOTH) in conjunction with global
noSmooth().

although seemingly illogical, perhaps the reason it works may help track down source
of problem? i'm not really qualified to say...


Additional Comment #8 From fry 2008-08-11 18:10
The cause of the problem is known (we need to shut off anti-aliasing on
internal lines), it's just a good bit of work to handle the implementation
(+ across each of the renderers). This is slated for 1.0, meaning that it
should be done before the fall.
Additional Comment #9 From fry 2008-11-20 07:29
*** Bug 1027 has been marked as a duplicate of this bug. ***
Additional Comment #10 From Cedric 2009-03-21 16:35
its still not solved, right ?
Additional Comment #11 From dlp 2009-07-21 21:59
Yeah, I'm still seeing this with P3D on 1.0.1, OS 1.5.7. I thought this was
supposed to be fixed by now? Is there any workaround?
Additional Comment #12 From fry 2009-07-22 14:00
No, the bug is not fixed yet. When fixed, the status will be marked as
"fixed", and it will be noted in the changes document with a new release.

I've not had time to fix it, and nobody else has taken the time to do it
themselves.