Changing texture main color causes lighting to be ignored?

18580-lighting.png

The dice at the bottom were dragged into the scene manually, the dice at the top were spawned and re-tinted via code (to the same values that the prefab has by default).

Why is lightning being ignored?

For reference, I’m using default diffuse shaders.

Code:

//for ease of reading, the prefab switch statement has been omitted
inst = Instantiate(colorizedPrefabd10,pos,Quaternion.identity) as GameObject;

Renderer[] renders = inst.GetComponentsInChildren<Renderer>();
int i = 0;
foreach(Renderer r in renders) {
	if(Size >= 8) {
		switch(i) {
			case 0:
				r.material.color = numberColor;//numbers (transparent diffuse)
				break;
			case 1:
				r.material.color = overlayColor;//overlay (transparent diffuse)
				break;
			case 2:
				r.material.color = baseColor;//underlay (diffuse)
				break;
			default:
				break;
		}
	}
}
//after this it's the d4 and d6 else-blocks, then adding random force and torque.

If I comment out the r.material.color lines, the lighting remains normal, but I don’t get the user-defined colors.

Just browsed again through your code and got the answer :slight_smile:

Color is a class having argb values in a 0-1 range (float), and you initialize it using values in 0-255 range. This results in white color (all values are treated as 1).