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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Juan C.Cilleruelo

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Problems, or maybe not, with transparencies. Some kind of magic!

nophead
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org