Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Cutting half of the scene off

Discussion in 'General Graphics' started by btschumy, Jun 18, 2021.

  1. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    I have a Galaxy visualization app that allows you to pan around the Galaxy and see where various deep sky objects are located in it.

    I'm thinking of an enhancement where I show only the part of the Galaxy that is currently visible in the sky based upon your location and time/date.

    I've tried just drawing a translucent plane that intersects the Sun's location. Things on one side are visible and things on the other side are not (they are below the horizon). This doesn't really have the correct feel to it.

    What I'd like to do is specify the plane and only draw that part of the scene that is on the "visible" side of it. I suspect this is possible, but I don't know how to do it. I'd appreciate any ideas.
     
  2. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    I've gotten no responses to this. Let me try to explain a different way...

    In 2D graphics you can generally define a clipping region (or rectangle). Any drawing that happens outside the clip region is not rendered. I would like to do something similar for 3D rendering in Unity. I would like to define a 3D volume (a cube would be fine) such that any objects outside that volume are not rendered.

    Is this possible? If not, please tell me that so I won't waste time trying to find it.

    Thanks.
     
  3. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    611
    That kind of effects are achieved using shaders. In your case, you need a shader that takes a plane as input and evaluates every dwawn pixel against said plane. It would draw pixels (more correctly, fragments) that are above the plane, and discard those that are below.
     
  4. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    JoNAX97,

    Thanks for the pointer. I can probably figure out how to do that.