discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Shadows and stripes with difference()

M
mikeonenine@web.de
Sun, Dec 7, 2025 5:02 PM

I thought I would tidy up a section of code by replacing a unioned and differenced collection of cylinders and a ring with a single rotate-extruded polygon. But it takes exception to the ports, producing odd shadows and streaks, and it doesn’t render properly. If the ports are edited out, it’s fine. A liberal sprinkling of convexity=5 usually helps in such cases, but not here.

Version 2021.01 works slightly better (no streaks), but previews more slowly than Version 2025.05.30.

The code:

x = -1 or 1;

color([0.7, 0.7, 0.6], 0.4)

render()

difference()

{

rotate_extrude(angle=360)

translate([18, 0])

polygon([

[0, 69],

[2, 69],

[2, 15],

for(i=[270 : -5 : 180])

[2+1.5*sin(i)+1.5, 15+3*cos(i)+1.25+1.5],

[3.5, 15-0.25],

[3.5, 0],

[0, 0],

]);

translate([0, 0, 51])

for(i = [1 : 5])

rotate(i * 360/5)

translate([0, 20.3])

rotate([90,0,0])

linear_extrude(4)

offset(3)

polygon

([

[-3*x,2],

[-2*x,10],

[-1*x,10],

[4*x,2]

]);

}

What’s going on?

I thought I would tidy up a section of code by replacing a unioned and differenced collection of cylinders and a ring with a single rotate-extruded polygon. But it takes exception to the ports, producing odd shadows and streaks, and it doesn’t render properly. If the ports are edited out, it’s fine. A liberal sprinkling of convexity=5 usually helps in such cases, but not here. Version 2021.01 works slightly better (no streaks), but previews more slowly than Version 2025.05.30. The code: `x = -1 or 1; ` `color([0.7, 0.7, 0.6], 0.4)` `render()` `difference()` `{` `rotate_extrude(angle=360)` `translate([18, 0])` `polygon([` `[0, 69],` `[2, 69],` `[2, 15],` `for(i=[270 : -5 : 180])` `[2+1.5*sin(i)+1.5, 15+3*cos(i)+1.25+1.5],` `[3.5, 15-0.25],` `[3.5, 0],` `[0, 0],` `]);` `translate([0, 0, 51])` `for(i = [1 : 5])` `rotate(i * 360/5)` `translate([0, 20.3])` `rotate([90,0,0])` `linear_extrude(4)` `offset(3)` `polygon` `([` `[-3*x,2], ` `[-2*x,10], ` `[-1*x,10], ` `[4*x,2] ` `]);` `}` What’s going on?
NH
nop head
Sun, Dec 7, 2025 5:35 PM

I think it is just a weakness of transparency rendering. It needs to sort
the facets by depth before rendering them.

On Sun, 7 Dec 2025 at 17:02, Caddiy via Discuss discuss@lists.openscad.org
wrote:

I thought I would tidy up a section of code by replacing a unioned and
differenced collection of cylinders and a ring with a single
rotate-extruded polygon. But it takes exception to the ports, producing odd
shadows and streaks, and it doesn’t render properly. If the ports are
edited out, it’s fine. A liberal sprinkling of convexity=5 usually helps in
such cases, but not here.

Version 2021.01 works slightly better (no streaks), but previews more
slowly than Version 2025.05.30.

The code:

x = -1 or 1;

color([0.7, 0.7, 0.6], 0.4)

render()

difference()

{

rotate_extrude(angle=360)

translate([18, 0])

polygon([

[0, 69],

[2, 69],

[2, 15],

for(i=[270 : -5 : 180])

[2+1.5sin(i)+1.5, 15+3cos(i)+1.25+1.5],

[3.5, 15-0.25],

[3.5, 0],

[0, 0],

]);

translate([0, 0, 51])

for(i = [1 : 5])

rotate(i * 360/5)

translate([0, 20.3])

rotate([90,0,0])

linear_extrude(4)

offset(3)

polygon

([

[-3*x,2],

[-2*x,10],

[-1*x,10],

[4*x,2]

]);

}

What’s going on?


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

I think it is just a weakness of transparency rendering. It needs to sort the facets by depth before rendering them. On Sun, 7 Dec 2025 at 17:02, Caddiy via Discuss <discuss@lists.openscad.org> wrote: > I thought I would tidy up a section of code by replacing a unioned and > differenced collection of cylinders and a ring with a single > rotate-extruded polygon. But it takes exception to the ports, producing odd > shadows and streaks, and it doesn’t render properly. If the ports are > edited out, it’s fine. A liberal sprinkling of convexity=5 usually helps in > such cases, but not here. > > Version 2021.01 works slightly better (no streaks), but previews more > slowly than Version 2025.05.30. > > The code: > > x = -1 or 1; > > color([0.7, 0.7, 0.6], 0.4) > > render() > > difference() > > { > > rotate_extrude(angle=360) > > translate([18, 0]) > > polygon([ > > [0, 69], > > [2, 69], > > [2, 15], > > for(i=[270 : -5 : 180]) > > [2+1.5*sin(i)+1.5, 15+3*cos(i)+1.25+1.5], > > [3.5, 15-0.25], > > [3.5, 0], > > [0, 0], > > ]); > > translate([0, 0, 51]) > > for(i = [1 : 5]) > > rotate(i * 360/5) > > translate([0, 20.3]) > > rotate([90,0,0]) > > linear_extrude(4) > > offset(3) > > polygon > > ([ > > [-3*x,2], > > [-2*x,10], > > [-1*x,10], > > [4*x,2] > > ]); > > } > > What’s going on? > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
LM
Leonard Martin Struttmann
Sun, Dec 7, 2025 6:23 PM

I agree.  Just removing the color() line made it look much better.

On Sun, Dec 7, 2025 at 11:36 AM nop head via Discuss <
discuss@lists.openscad.org> wrote:

I think it is just a weakness of transparency rendering. It needs to sort
the facets by depth before rendering them.

On Sun, 7 Dec 2025 at 17:02, Caddiy via Discuss <
discuss@lists.openscad.org> wrote:

I thought I would tidy up a section of code by replacing a unioned and
differenced collection of cylinders and a ring with a single
rotate-extruded polygon. But it takes exception to the ports, producing odd
shadows and streaks, and it doesn’t render properly. If the ports are
edited out, it’s fine. A liberal sprinkling of convexity=5 usually helps in
such cases, but not here.

Version 2021.01 works slightly better (no streaks), but previews more
slowly than Version 2025.05.30.

The code:

x = -1 or 1;

color([0.7, 0.7, 0.6], 0.4)

render()

difference()

{

rotate_extrude(angle=360)

translate([18, 0])

polygon([

[0, 69],

[2, 69],

[2, 15],

for(i=[270 : -5 : 180])

[2+1.5sin(i)+1.5, 15+3cos(i)+1.25+1.5],

[3.5, 15-0.25],

[3.5, 0],

[0, 0],

]);

translate([0, 0, 51])

for(i = [1 : 5])

rotate(i * 360/5)

translate([0, 20.3])

rotate([90,0,0])

linear_extrude(4)

offset(3)

polygon

([

[-3*x,2],

[-2*x,10],

[-1*x,10],

[4*x,2]

]);

}

What’s going on?


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


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

I agree. Just removing the color() line made it look much better. On Sun, Dec 7, 2025 at 11:36 AM nop head via Discuss < discuss@lists.openscad.org> wrote: > I think it is just a weakness of transparency rendering. It needs to sort > the facets by depth before rendering them. > > On Sun, 7 Dec 2025 at 17:02, Caddiy via Discuss < > discuss@lists.openscad.org> wrote: > >> I thought I would tidy up a section of code by replacing a unioned and >> differenced collection of cylinders and a ring with a single >> rotate-extruded polygon. But it takes exception to the ports, producing odd >> shadows and streaks, and it doesn’t render properly. If the ports are >> edited out, it’s fine. A liberal sprinkling of convexity=5 usually helps in >> such cases, but not here. >> >> Version 2021.01 works slightly better (no streaks), but previews more >> slowly than Version 2025.05.30. >> >> The code: >> >> x = -1 or 1; >> >> color([0.7, 0.7, 0.6], 0.4) >> >> render() >> >> difference() >> >> { >> >> rotate_extrude(angle=360) >> >> translate([18, 0]) >> >> polygon([ >> >> [0, 69], >> >> [2, 69], >> >> [2, 15], >> >> for(i=[270 : -5 : 180]) >> >> [2+1.5*sin(i)+1.5, 15+3*cos(i)+1.25+1.5], >> >> [3.5, 15-0.25], >> >> [3.5, 0], >> >> [0, 0], >> >> ]); >> >> translate([0, 0, 51]) >> >> for(i = [1 : 5]) >> >> rotate(i * 360/5) >> >> translate([0, 20.3]) >> >> rotate([90,0,0]) >> >> linear_extrude(4) >> >> offset(3) >> >> polygon >> >> ([ >> >> [-3*x,2], >> >> [-2*x,10], >> >> [-1*x,10], >> >> [4*x,2] >> >> ]); >> >> } >> >> What’s going on? >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
M
mikeonenine@web.de
Sun, Dec 7, 2025 7:04 PM

Leonard Martin Struttmann wrote:

I agree.  Just removing the color() line made it look much better.

Well maybe, but it has to be transparent grey!

Linear_extrude works. Why does rotate_extrude produce a shadow (with or without render)?

Unfortunately, it is not possible to obtain a step with linear_extrude.

$fn=100;

color([0.7, 0.7, 0.7], 0.4)

{

translate([-40, 0, 0])

rotate_extrude()

translate([20, 0])

square([2, 60]);

translate([40, 0, 0])

linear_extrude(60)

difference()

{

circle(22);

circle(20);

}}

Leonard Martin Struttmann wrote: > I agree. Just removing the color() line made it look much better. Well maybe, but it has to be transparent grey! Linear_extrude works. Why does rotate_extrude produce a shadow (with or without render)? Unfortunately, it is not possible to obtain a step with linear_extrude. `$fn=100;` `color([0.7, 0.7, 0.7], 0.4)` `{` `translate([-40, 0, 0])` `rotate_extrude()` `translate([20, 0])` `square([2, 60]);` `translate([40, 0, 0])` `linear_extrude(60)` `difference()` `{` `circle(22);` `circle(20);` `}}`
M
mikeonenine@web.de
Sun, Dec 7, 2025 7:30 PM

Subtle differences:

L > R: Rotate_extrude, linear_extrude, difference of 2 cylinders.

Subtle differences: L > R: Rotate_extrude, linear_extrude, difference of 2 cylinders.
M
mikeonenine@web.de
Sun, Dec 7, 2025 7:31 PM

Subtle differences:

L > R: Rotate_extrude, linear_extrude, difference of 2 cylinders.

Subtle differences: L > R: Rotate_extrude, linear_extrude, difference of 2 cylinders.
NH
nop head
Sun, Dec 7, 2025 7:41 PM

My guess would be that rotate_extrude produces a polygon with the faces in
a different order so that some of the front faces are rendered before the
faces behind.

On Sun, 7 Dec 2025 at 19:31, Caddiy via Discuss discuss@lists.openscad.org
wrote:

Subtle differences:

L > R: Rotate_extrude, linear_extrude, difference of 2 cylinders.


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

My guess would be that rotate_extrude produces a polygon with the faces in a different order so that some of the front faces are rendered before the faces behind. On Sun, 7 Dec 2025 at 19:31, Caddiy via Discuss <discuss@lists.openscad.org> wrote: > Subtle differences: > > L > R: Rotate_extrude, linear_extrude, difference of 2 cylinders. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
M
mikeonenine@web.de
Sun, Dec 7, 2025 8:32 PM

nop head wrote:

My guess would be that rotate_extrude produces a polygon with the faces in
a different order so that some of the front faces are rendered before the
faces behind.

Strange behaviour:

translate([-80, 0, 0])

rotate([0, 0, $t*360])

rotate_extrude(angle=330)

translate([20, 0])

square([2, 60]);

You could be right!

nop head wrote: > My guess would be that rotate_extrude produces a polygon with the faces in > a different order so that some of the front faces are rendered before the > faces behind. Strange behaviour: `translate([-80, 0, 0])` `rotate([0, 0, $t*360])` `rotate_extrude(angle=330)` `translate([20, 0])` `square([2, 60]);` You could be right!