Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Hiding texture dynamically / Smooth cutout edges

Discussion in 'General Graphics' started by shoo, Jul 15, 2016.

  1. shoo

    shoo

    Joined:
    Nov 19, 2012
    Posts:
    67
    Hello! I am trying to make my black sphere disappear dynamically from bottom to top, so it will create nice appearing effect for my another sphere. I have two ways of making this:
    1) Just move UV layout with some nice looking alpha gradient. I am sure this method will create effect which I need. But I will spend a lot of coding time every time I need to change something (like mask, shape, etc.).
    2) Apply Unlit Transparent Cutout shader. This way is way easier, but the problem is... I have ugly cutout edge(on the screenshot), and I have no idea how I can get rid of this and makes it smoother(maybe someone have any idea?).

    Or maybe Unity have better ways to do such things?
     

    Attached Files:

  2. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    974
    You could possibly also make it by using vertex colour shader, then animate by looping through the mesh vertices, changing their colour.alpha depending on the vertices location y.
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,366
    You can just use the alpha test shader and animate the cutoff value. Just have a gradient alpha texture going from the top to the bottom and as you change the cutoff value it'll move up the object. If you're unhappy with the quality of the edge try keeping the gradient texture only 1 pixel wide. There might be noise in the texture either from your graphics program doing dithering or the compression causing artifacts, both of which making it only 1 pixel wide will avoid.

    If you want to get into custom shaders you can have the cutoff edge be based on world or local mesh position, or UVs, or vertex colors, or any multitude of options. I did an effect a while ago with a black sphere disappearing using a cubemap with a bunch of gradient shapes so it looked like it was ripping apart.