I want to change the vertex colors of my mesh. The light sources must not affect the objects with this shader, its lighting must be determined only by its vertices colors, so I turned the Lighting Off
. I use this simple shader:
Shader "VertexColored/Simple" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
ColorMaterial AmbientAndDiffuse
Lighting Off
SetTexture [_MainTex] {
Combine texture * primary
}
}
}
Fallback "VertexLit"
}
And this script:
using UnityEngine;
using System.Collections;
public class BehaviourScript : MonoBehaviour {
void Start() {
Color[] exclrs = new Color[11]
{
new Color32(25, 25, 25, 255),
new Color32(50, 50, 50, 255),
new Color32(75, 75, 75, 255),
new Color32(150, 150, 150, 255),
new Color32(200, 200, 200, 255),
new Color32(255, 255, 255, 255),
new Color32(200, 200, 200, 255),
new Color32(150, 150, 150, 255),
new Color32(75, 75, 75, 75),
new Color32(50, 50, 50, 255),
new Color32(25, 25, 25, 255),
};
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
Vector3[] normals = mesh.normals;
Color[] colors = mesh.colors;
for(int i = 0; i < vertices.Length; i++)
{
for(int j = 0; j < 11; j++, i++)
{
colors[i] = exclrs[j];
}
i--;
}
mesh.colors = colors;
}
}
When the game is launched, in editor I can see this:
This is EXACTLY what I wanted to achieve!
But in built for PC(x86) version I see this:
Why the results from the editor and from the built .exe differs? What should I do to see my effect in built version? Maybe I need to use an another shader?