Search Unity

Fading Alpha Not Working?

Discussion in 'Scripting' started by Darkmoon, Jun 24, 2013.

  1. Darkmoon

    Darkmoon

    Joined:
    Nov 23, 2012
    Posts:
    28
    I have an object that I'm trying to fade out (alpha) over time. I've tried with the standard Diffuse shader, but it doesn't respect the color parameters' alpha component.

    So, I tried the "Transparent/Diffuse" shader. Even though my diffuse texture has no alpha in it and the alpha component of the Color parameter is set to opaque, the object became translucent.

    The cutout shader is not an option, because alpha seems to be on/off only.

    My question is..

    a.) am I missing an obvious way to fade the object?
    b.) is there a shader included that will render an opaque object (Diffuse + Bump) but will respect the Alpha component of the Diffuse texture if it is < 1f (255)?

    Thanks in advance!
     
  2. raviraj_vdy

    raviraj_vdy

    Joined:
    May 14, 2009
    Posts:
    309
  3. Darkmoon

    Darkmoon

    Joined:
    Nov 23, 2012
    Posts:
    28
    Yes, that is what I'm doing, but the since model isn't entirely convex, it seems the shader has Z-ordering issues and some bit of the model look like they are transparent.
    $Capture.JPG

    The one on the left is rendered with Transparent/Diffuse and the right the standard Diffuse.
     
  4. Darkmoon

    Darkmoon

    Joined:
    Nov 23, 2012
    Posts:
    28
    Well... I'm circumventing the problem by using the Standard shader until it's time to fade out the object, at which point i switch to the Transparent shader. I don't know if this is how it's intended to be used, but it works well enough.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, you should definitely only use transparent shaders when you actually need transparency.

    --Eric
     
  6. raviraj_vdy

    raviraj_vdy

    Joined:
    May 14, 2009
    Posts:
    309
    I dont think its the model issue because it depends on the shader that you use, it should work.