[OpenSCAD] Problems, or maybe not, with transparencies. Some kind of magic!

nop head nop.head at gmail.com
Tue Jul 30 15:15:22 EDT 2019


The be able to see something behind a transparent object it has to be drawn
first. For normal objects they are drawn in the order your code is. I think
when % is used they are drawn later than all the normal objects. Does this
explain your observations?

OpensSCAD should really sort the objects by depth because it changes with
viewing angle, so you can't always have the order correct, but it currently
doesn't.

On Tue, 30 Jul 2019 at 20:07, Juan C.Cilleruelo <juanc.cilleruelo at gmail.com>
wrote:

> I know, basically, two forms of make pieces transparent: applying alpha to
> color -> "color("green", 0.3)" and using the modifier "%". First I define a
> cube with six sides and empty in his interior. By another hand, I define a
> little solid cube positioned exactly at the centre of the first one.
>
> And finally, by now, I make the big cube transparent with the color
> method.
>
> translate([25, 25, 25]) cube([50, 50, 50]);
>
> *color("green", 0.3)*
>
> union(){
>
> cube([10, 100, 100]);
>
> cube([100, 10, 100]);
>
> cube([100,100, 10]);
>
> translate([ 90, 0, 0]) cube([10, 100, 100]);
>
> translate([ 0, 90, 0]) cube([100, 10, 100]);
>
> translate([ 0, 0, 90]) cube([100,100, 10]);
>
> }
>
> Our first alternative is to change the order of the drawing objects:
>
> color("green", 0.3)
>
> union(){
>
> cube([10, 100, 100]);
>
> cube([100, 10, 100]);
>
> cube([100,100, 10]);
>
> translate([ 90, 0, 0]) cube([10, 100, 100]);
>
> translate([ 0, 90, 0]) cube([100, 10, 100]);
>
> translate([ 0, 0, 90]) cube([100,100, 10]);
>
> }
>
> *translate([25, 25, 25]) cube([50, 50, 50]);*
>
> Curiously the inner cube disappears, although the external cube is
> transparent.
>
> Now I try the other form of transparency.
>
> *//color("green", 0.3)*
>
> *%union(){*
>
> cube([10, 100, 100]);
>
> cube([100, 10, 100]);
>
> cube([100,100, 10]);
>
> translate([ 90, 0, 0]) cube([10, 100, 100]);
>
> translate([ 0, 90, 0]) cube([100, 10, 100]);
>
> translate([ 0, 0, 90]) cube([100,100, 10]);
>
> }
>
> translate([25, 25, 25]) cube([50, 50, 50]);
>
> I lost the colour, but the result is more correct for transparencies.
>
> But, like I need colour, I try a merge of both things:
>
> *color("green", 0.3)*
>
> *%union(){*
>
> cube([10, 100, 100]);
>
> cube([100, 10, 100]);
>
> cube([100,100, 10]);
>
> translate([ 90, 0, 0]) cube([10, 100, 100]);
>
> translate([ 0, 90, 0]) cube([100, 10, 100]);
>
> translate([ 0, 0, 90]) cube([100,100, 10]);
>
> }
>
> translate([25, 25, 25]) cube([50, 50, 50]);
>
> All seems to be ok now. The order does not alternate the result.
>
> And now the magic. I decide to make only one side transparent with
> modifier %, but all of them transparent with the colour.
>
> *color("green", 0.3)*
>
> union(){
>
> cube([10, 100, 100]);
>
> *%cube([100, 10, 100]);*
>
> cube([100,100, 10]);
>
> translate([ 90, 0, 0]) cube([10, 100, 100]);
>
> translate([ 0, 90, 0]) cube([100, 10, 100]);
>
> translate([ 0, 0, 90]) cube([100,100, 10]);
>
> }
>
> translate([25, 25, 25]) cube([50, 50, 50]);
>
> Copy the text and try it!!!
>
> It's very curious seeing how the cube inside is only visible through the
> side we make transparent with % modifier!
>
> I don't know if this is a bug, a not possible capability, or a wrong
> functionality. But, *sure all of you can agree that this is a
> curiosity!!!! *
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190730/0f72cca9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bmipkpddpnagdccf.png
Type: image/png
Size: 21170 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190730/0f72cca9/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plkpdjheiopdhhkk.png
Type: image/png
Size: 21220 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190730/0f72cca9/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dhlajkldbdkbjdkn.png
Type: image/png
Size: 21279 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190730/0f72cca9/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fbbkbfnjjaohmkio.png
Type: image/png
Size: 15747 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190730/0f72cca9/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ghhbffpdopohhbnh.png
Type: image/png
Size: 14133 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190730/0f72cca9/attachment-0004.png>


More information about the Discuss mailing list