- Home /
Vertex Alpha value doesn't update?
I'm trying to show a fading splash screen, So I setted up a strecthed cube in front of the camera(as explained in the guide). Now I want to fade out that cube changin vertices alpha values. The code for this(script attached to the cube):
void Update () {
float alpha = Mathf.Sin (Time.time);
Mesh myMesh = GetComponent<MeshFilter>().mesh;
if(myMesh){
Debug.Log("transparency changed!");
}else{
Debug.Log("cube not found!");
}
Color[] meshColor = myMesh.colors;
int i;
for(i=0;i<meshColor.Length; i++){
meshColor[i].a = alpha;
}
}
seem's that vertex color is not used at all by any of the material ( I tried all materials and no one showed vertex color): That's a big feature lack! fix that! In FREE version of unity there's no need at all for use "COLORS" component in vertices since no material is using vertex colors => memory waste. Alpha value in vertices will allow for a lot of nice effects even on older fixed-pipeline hardware. Seems a big pity Unity "skipped" that important detail in FREE version.
Why don't you use a transparent material and manipulate its alpha value? Furthermore for a spash screen it might be better to use a GUITexture. Its alpha value can be manipulated quite easy.
Answer by Fixe · Sep 29, 2012 at 12:24 PM
I successfully used the material. But what If I needed a per-vertex alpha value for more complex effects?
Something similar is discussed in this thread: http://forum.unity3d.com/threads/39837-Fog-of-war-$$anonymous$$esh.
However this is somewhat difficult to handle. Often you can just go with a transparent texture.