How to make line visible inside transparent 3dShape

edited June 2014 in How To...

It looks like that lines and borders of 3dshapes aren't visible inside transparent 3dShapes. Is there any solution for this? I would like to see line inside the sphere. I used fill with alpha to make sphere transparent.

Tagged:

Answers

  • To enforce this you can draw a 3D shape with fill and no stroke, then call hint(DISABLE_DEPTH_TEST), then draw the same shape will noFill and stroke, then enable depth test again for further drawing in 3D.

  • edited June 2014

    It's quite useful, but what about line starts inside a 3D shape. For example:

    size(400, 400, P3D);
    pushMatrix();
    translate(100, 200, 0);
    rotateY(-0.5);
    fill(200,0,0,150);
    noStroke();
    box(80);
    hint(DISABLE_DEPTH_TEST);
    stroke(0);
    noFill();
    box(80);
    strokeWeight(4);
    line (0,0,0,100,0,0);
    hint(ENABLE_DEPTH_TEST);
    popMatrix();
    
    pushMatrix();
    strokeWeight(1);
    translate(250, 200, 0);
    rotateY(-0.5);
    fill(200,0,0,150);
    noStroke();
    box(80);
    hint(DISABLE_DEPTH_TEST);
    stroke(0);
    noFill();
    box(80);
    hint(ENABLE_DEPTH_TEST);
    strokeWeight(4);
    line (0,0,0,100,0,0);
    popMatrix();
    

    boxes

    I'm trying to get line which starts in the box and ends outside. Without deep_test the line is drew in front of (or behind) the box and you couldn't see that it starts inside the box. With deep_test a part inside the box is removed.

  • edited June 2014

    With deep_test a part inside the box is removed.

    Actually nothing is removed. Just draw a longer line if you want it to continue...

  • Deep_test is enabled during drawing second line (right box). According to the code line starts in the middle of the box, but it's not visible.

  • Yes, of course. That was the original question. Hence the provided solution. Indeed, if you don't use the solution, it won't work.

    Perhaps we should broaden the discussion a bit, so maybe it becomes clearer if you understand why this happens. Because actually this is a common problem related to opengl not processing. The problem is related to things like z-depth, transparency, depth sorting. Check out this link for an explanation and possible solutions: http://www.sjbaker.org/steve/omniv/alpha_sorting.html

Sign In or Register to comment.