Vertex colors not working in shader graph.
I made a simple test triangles and created a shader graph with vertex color connected to the albedo of the pbr master. Instead of the intended red color, it is only gray, as if the vertex color did not exist.
void Start()
{
Vector3[] verticies;
int[] triangles;
Color[] colors;
verticies = new Vector3[3];
triangles = new int[3];
colors = new Color[3];
verticies[0] = new Vector3(0.0f, 0.0f, 0.0f);
verticies[1] = new Vector3(1.0f, 0.0f, 0.0f);
verticies[2] = new Vector3(0.5f, 1.0f, 0.0f);
triangles[0] = 0;
triangles[1] = 1;
triangles[2] = 2;
for(int i = 0; i < colors.Length; i++)
{
colors[i] = Color.red;
}
Mesh mesh = GetComponent<MeshFilter>().mesh;
mesh.vertices = verticies;
mesh.triangles = triangles;
mesh.colors = colors;
}
Comment
Your answer
Follow this Question
Related Questions
Giving Instantiated Clones their own properties and variables 1 Answer
Complex if and/or statement for finding neighboring triangles in a mesh 1 Answer
Mesh wont render although there are no errors! 1 Answer
Rotate a point around a mesh vertex 1 Answer
How can I create a plane at any given vertex position? 0 Answers