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

3D object as cutout alpha/transparency mask

Discussion in 'General Graphics' started by ceend, Oct 30, 2019.

  1. ceend

    ceend

    Joined:
    Jan 8, 2014
    Posts:
    12
    Hi,

    I want to fade out the rim of my scene in all 3 dimensions with a movable 3D sphere as an effector for the visible parts. Everything inside the sphere is visible. Everything outside not. Is that possible?

    Something like the alpha cutout like here just as a global scene 3D effect? Best would be with a soft falloff:

    https://assetstore.unity.com/packag...a-mask-ui-sprites-tilemaps-particles-3d-29764

    Here is the workflow in C4D shown:


    Any ideas, scripts or plugins out there? Maybe using culling to cut away objects outside the sphere?

    Cheers
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    It's not really possible to do this with another 3D mesh in the scene. Rather the solution would be to use a shader that calculates the distance to a point in the world that you pass to the shader, and fade in/out based on that calculation.

    There are some excellent examples of how to do this here:
    https://www.patreon.com/posts/19530112
    https://www.patreon.com/posts/19355776
    https://www.patreon.com/posts/26438849

    Those examples all use noise and a alpha test shader, but it could be made soft by just switching to alpha blending.
     
  3. ceend

    ceend

    Joined:
    Jan 8, 2014
    Posts:
    12
    Hi bgolus,

    that is getting very close. Thanks a lot man!