Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Want to find a good 'fade effect' tutorial

Discussion in 'Shaders' started by Kinkladze11, Apr 25, 2015.

  1. Kinkladze11

    Kinkladze11

    Joined:
    Feb 25, 2015
    Posts:
    36
    Hey hey,

    Am pretty new here and am trying to learn how to create a fade effect for my game objects.

    I've looked around this site and the wider internet but am struggling to understand the concepts at work here. Could anybody point me in the right direction of a good beginner level tutorial for this technique?

    Thanks.
     
  2. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    Fade? Like Fog? In Render Settings/Lighting panels there's fog control. That will make objects like like they are fading in the distance.

    Or if you mean making objects fade to clear then you need to animate a transparent shader's alpha value in the main color.
     
  3. Kinkladze11

    Kinkladze11

    Joined:
    Feb 25, 2015
    Posts:
    36
    Hey , thanks for replying.

    Am trying to make certain game objects fade in and out of the game at certain points (i.e. go from completely transparent to fully visible and vice versa)

    I've figured out that it is the alpha value that needs to be changed and from what I can tell using 'Lerp' seems to useful in this situation however I'm a little unsure how to put the code together so any pointers would be very welcome.

    This is what I've done codewise at the moment......it compiles but doesn't do anything.....

    using UnityEngine;
    using System.Collections;

    public class FadeTest : MonoBehaviour {

    public Renderer rend;
    void Start() {
    rend = GetComponent<Renderer>();
    }
    void Update() {
    //
    float Ialpha = rend.material.color.a;
    Ialpha = Mathf.Lerp(0f, 1f,2f);
    }
    }
     
    Last edited: Apr 26, 2015