discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Another rendering artifact: something about transparency vs difference

JB
Jordan Brown
Sat, Jul 23, 2022 5:55 AM

Has anybody seen this one?

color("white", 0.2) {
difference() {
cube([10,1,10]);
translate([1,-1,1]) cube([3,3,5]);
}
translate([10,0,0]) cube([10,1,10]);
}

yields this:

Look at the left block.  Note that the top and back, and the bottom of
the opening, are all missing.  Which sides are missing depend on the
view angle.

The right block does not participate in that part of the artifact, but
note the difference in shade.  The working block, on the right, is
significantly darker than the one that isn't working right.  I suspect
that the difference is that the one on the right has two faces stacked,
while the one on the left, for whatever reason, has only a single face
stacked.

Slapping a render() around the difference fixes the problem.

Has anybody seen this one? color("white", 0.2) { difference() { cube([10,1,10]); translate([1,-1,1]) cube([3,3,5]); } translate([10,0,0]) cube([10,1,10]); } yields this: Look at the left block.  Note that the top and back, and the bottom of the opening, are all missing.  Which sides are missing depend on the view angle. The right block does not participate in that part of the artifact, but note the difference in shade.  The working block, on the right, is significantly darker than the one that isn't working right.  I suspect that the difference is that the one on the right has two faces stacked, while the one on the left, for whatever reason, has only a single face stacked. Slapping a render() around the difference fixes the problem.
M
mikeonenine@web.de
Sat, Jul 23, 2022 11:34 AM

I think it is more that one can’t see the sides than that they are missing, because, as you say, when you change the viewing angle, you can see them. You can also see them if you use a stronger colour.

I have noticed the change in lightness when difference is used. Unfortunately render reveals the cutout shapes.

A similar deficit is that the ports at the back of a semi-transparent cylinder are not visible.

The base of a cylinder is not visible if it is made by subtracting one cylinder from another, but it is visible if a ring (circle minus circle) is linear_extruded. However, the ports at the back are still hidden.

I tried the render trick on the cylinder below but it didn’t help. Is there perhaps another way?

I think it is more that one can’t see the sides than that they are missing, because, as you say, when you change the viewing angle, you can see them. You can also see them if you use a stronger colour. I have noticed the change in lightness when difference is used. Unfortunately render reveals the cutout shapes. A similar deficit is that the ports at the back of a semi-transparent cylinder are not visible. The base of a cylinder is not visible if it is made by subtracting one cylinder from another, but it is visible if a ring (circle minus circle) is linear_extruded. However, the ports at the back are still hidden. I tried the render trick on the cylinder below but it didn’t help. Is there perhaps another way?
NH
nop head
Sat, Jul 23, 2022 12:06 PM

The problem is each face needs to be drawn in an order sorted by depth
depending on the viewing direction. OpenSCAD doesn't do that.

On Sat, 23 Jul 2022 at 12:34, mikeonenine@web.de wrote:

I think it is more that one can’t see the sides than that they are
missing, because, as you say, when you change the viewing angle, you can
see them. You can also see them if you use a stronger colour.

I have noticed the change in lightness when difference is used.
Unfortunately render reveals the cutout shapes.

A similar deficit is that the ports at the back of a semi-transparent
cylinder are not visible.

The base of a cylinder is not visible if it is made by subtracting one
cylinder from another, but it is visible if a ring (circle minus circle) is
linear_extruded. However, the ports at the back are still hidden.

I tried the render trick on the cylinder below but it didn’t help. Is
there perhaps another way?


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

The problem is each face needs to be drawn in an order sorted by depth depending on the viewing direction. OpenSCAD doesn't do that. On Sat, 23 Jul 2022 at 12:34, <mikeonenine@web.de> wrote: > I think it is more that one can’t see the sides than that they are > missing, because, as you say, when you change the viewing angle, you can > see them. You can also see them if you use a stronger colour. > > I have noticed the change in lightness when difference is used. > Unfortunately render reveals the cutout shapes. > > A similar deficit is that the ports at the back of a semi-transparent > cylinder are not visible. > > The base of a cylinder is not visible if it is made by subtracting one > cylinder from another, but it is visible if a ring (circle minus circle) is > linear_extruded. However, the ports at the back are still hidden. > > I tried the render trick on the cylinder below but it didn’t help. Is > there perhaps another way? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Sun, Jul 24, 2022 12:53 AM

On 7/23/2022 4:34 AM, mikeonenine@web.de wrote:

I think it is more that one can’t see the sides than that they are
missing, because, as you say, when you change the viewing angle, you
can see them. You can also see them if you use a stronger colour.

Oooh, interesting.  Yes.

color("red", 0.5) {
    difference() {
        cube([10,1,10]);
        translate([1,-1,1]) cube([3,3,5]);
    }
    translate([10,0,0]) cube([10,1,10]);
}

A similar deficit is that the ports at the back of a semi-transparent
cylinder are not visible.

I don't know for sure - I don't really understand the previewer - but I
don't think so.  I suspect that's not "color is wrong" but rather "the
objects aren't stacked in the right order to let OpenGL give you the
right answer".

The base of a cylinder is not visible if it is made by subtracting one
cylinder from another, but it is visible if a ring (circle minus
circle) is linear_extruded. However, the ports at the back are still
hidden.

But render() difference() { cylinder(); cylinder() } does make it visible.

I tried the render trick on the cylinder below but it didn’t help. Is
there perhaps another way?

Don't know, but if you give me source I'm happy to experiment.

The previewer is ... magic.  I've looked at it a little, and while I
more or less understood how unions work, and maybe differences, I did
not understand intersections at all.  It throws a bunch of triangles at
OpenGL, with various modes, and somehow OpenGL makes something that's
usually right.

Transparency seems like one of its key weaknesses.

On 7/23/2022 4:34 AM, mikeonenine@web.de wrote: > > I think it is more that one can’t see the sides than that they are > missing, because, as you say, when you change the viewing angle, you > can see them. You can also see them if you use a stronger colour. > Oooh, interesting.  Yes. color("red", 0.5) { difference() { cube([10,1,10]); translate([1,-1,1]) cube([3,3,5]); } translate([10,0,0]) cube([10,1,10]); } > A similar deficit is that the ports at the back of a semi-transparent > cylinder are not visible. > I don't know for sure - I don't really understand the previewer - but I don't think so.  I suspect that's not "color is wrong" but rather "the objects aren't stacked in the right order to let OpenGL give you the right answer". > The base of a cylinder is not visible if it is made by subtracting one > cylinder from another, but it is visible if a ring (circle minus > circle) is linear_extruded. However, the ports at the back are still > hidden. > But render() difference() { cylinder(); cylinder() } does make it visible. > I tried the render trick on the cylinder below but it didn’t help. Is > there perhaps another way? > Don't know, but if you give me source I'm happy to experiment. The previewer is ... magic.  I've looked at it a little, and while I more or less understood how unions work, and maybe differences, I did not understand intersections at all.  It throws a bunch of triangles at OpenGL, with various modes, and somehow OpenGL makes something that's usually right. Transparency seems like one of its key weaknesses.
M
mikeonenine@web.de
Sun, Jul 24, 2022 2:39 AM

Hey, it DOES work!

I had misunderstood “Slapping a render() around the difference fixes the problem.”

Now I can see those ports at the back that were previously hidden.

Satisfies my optical algorithms!

Hey, it DOES work! I had misunderstood “Slapping a render() **around** the difference fixes the problem.” Now I can see those ports at the back that were previously hidden. Satisfies my optical algorithms!