I'm not sure I understand opacity in OpenSCAD...

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

I'm not sure I understand opacity in OpenSCAD...

Dan Zuras 3D


        Folks,

        I made the following model in an attempt to understand
        how some connectors work.  I had the connection block
        rendered in blue & set the value of opaque to 0.5 so I
        could see things through it.

        But it renders funny.

        For one thing, one of the two blue blocks is lighter &
        more transparent than the other.  The darker solid one
        can be seen through the other one but not the other way
        around.  And 3 solid cubes placed around them cannot be
        seen through either block.

        Perhaps I am making some mistake here.  But the two
        different colors confuses me.

        Can someone tell me what I am doing wrong?

        Thanks,

                                Dan


module connectionBlock() color([0,0,1,0.5]) difference() {
        cube(size = [50,60,30], center = true);
        cube(size=[80,25,25],center=true);
        translate([0,-50,0]) cube(size = [100,100,100], center = true);
};

connectionBlock();
rotate([180,0,0]) connectionBlock();
cube(size = 20, center = true);
translate([0,0,30]) cube(size = 20, center = true);
translate([0,0,-30]) cube(size = 20, center = true);

Reply | Threaded
Open this post in threaded view
|

Re: I'm not sure I understand opacity in OpenSCAD...

Clifford Wolf
Hi,

On Sun, Jun 20, 2010 at 01:47:43AM -0700, Dan Zuras 3D wrote:
> I made the following model in an attempt to understand
> how some connectors work.  I had the connection block
> rendered in blue & set the value of opaque to 0.5 so I
> could see things through it.
>
> But it renders funny.

hmm.. looks like someone found out about the alpha component in the color()
statement and added it to the documentation...

this feature does not really work and so I never documented it and also did
not use it in the examples...

I recommend using the % modifier instead. Example given:

        --snip--
        module connectionBlock() color([0,0,1]) difference() {
                cube(size = [50,60,30], center = true);
                cube(size=[80,25,25],center=true);
                translate([0,-50,0]) cube(size = [100,100,100], center = true);
        };

        connectionBlock();
        %rotate([180,0,0]) connectionBlock();
        cube(size = 20, center = true);
        translate([0,0,30]) cube(size = 20, center = true);
        translate([0,0,-30]) cube(size = 20, center = true);
        --snap--

The problem with transparent elements is that the order in which surfaces
are drawn makes a big difference - unlike with opaque surfaces where the
order doesn't make any difference when a z-buffer is used.

this problem does not affect the % modifier because the % elements are
always drawn after the rest of the scene.

yours,
 - clifford

--
The number of the beast - vi vi vi.

Reply | Threaded
Open this post in threaded view
|

Re: I'm not sure I understand opacity in OpenSCAD...

Dan Zuras 3D
> Date: Sun, 20 Jun 2010 11:48:08 +0200
> From: Clifford Wolf <[hidden email]>
> To: Dan Zuras 3D <[hidden email]>, [hidden email]
> Subject: Re: [OpenSCAD] I'm not sure I understand opacity in OpenSCAD...
>
> Hi,
>
> On Sun, Jun 20, 2010 at 01:47:43AM -0700, Dan Zuras 3D wrote:
> > I made the following model in an attempt to understand
> > how some connectors work.  I had the connection block
> > rendered in blue & set the value of opaque to 0.5 so I
> > could see things through it.
> >
> > But it renders funny.
>
> hmm.. looks like someone found out about the alpha component
> in the color() statement and added it to the documentation...
>
> this feature does not really work and so I never documented it
> and also did not use it in the examples...
>
> I recommend using the % modifier instead. Example given:
>
> --snip--
> module connectionBlock() color([0,0,1]) difference() {
> cube(size = [50,60,30], center = true);
> cube(size=[80,25,25],center=true);
> translate([0,-50,0]) cube(size = [100,100,100], center = true);
> };
>
> connectionBlock();
> %rotate([180,0,0]) connectionBlock();
> cube(size = 20, center = true);
> translate([0,0,30]) cube(size = 20, center = true);
> translate([0,0,-30]) cube(size = 20, center = true);
> --snap--
>
> The problem with transparent elements is that the order in which
> surfaces are drawn makes a big difference - unlike with opaque
> surfaces where the order doesn't make any difference when a
> z-buffer is used.
>
> this problem does not affect the % modifier because the % elements
> are always drawn after the rest of the scene.
>
> yours,
>  - clifford
>
> --
> The number of the beast - vi vi vi.

        Thank you.  This mostly works.  If I put a percent in front
        of both instances of the connection block I can now see the
        other elements.  But they are different colors & only one
        is translucent to the other.

        No matter.  It works well enough for my application.

        Thanks again,

                                Dan