- Home /
How do I fade just the alpha level of a material? (Java)
Edit: I ended up just rewriting the Alpha Blend shader which aloud it to be called using color.a so this approach was much easier. As for the shader I have clipping problems with billboarded trees, does anyone know how to fix this?
I've seen some other examples fading the alpha of a material, but they're all in C# and I can't seem to get them converted properly.
Does anyone know how I can fade just the alpha level of a material? I don't like the other method of using "_TintColor" as it turns everything black before it fades. (I'm using aloha blended)
I know that I have to use color.a, but it doesn't seem to work because the material is being called from a game object heavyClouds.
Here's what I have:
cloudsStormy = cloudsStormy.a;
heavyClouds.renderer.material.color = Color.Lerp (cloudsStormy,
cloudsStormy, fade);
If anyone can help me out that'd be great and I'm sure it'll help others who have a similar question out too.
Answer by save · Mar 11, 2012 at 06:57 PM
Do you mean something like this?
private var myRenderer : Renderer;
function Start () {
myRenderer = renderer;
}
function Update () {
if (myRenderer.material.color.a>0)
myRenderer.material.color.a -=1.0*Time.deltaTime; //Fade out over 1 second
}
Thanks, but this doesn't work. It says it can't find color. I'm using the alpha blended material. Any other ways? Also I'm using the object as a gameobject not a renderer, if that makes any difference.
you would just say gameObject.renderer.material.color Did you try using my method of defining the newLerp color. Id be happy to explain how it works if you still need help.