void GenerateAtmosphereTexture() { atmos.position = center + Vector3.forward; atmos.localScale = Vector3.one * (radius + atmosphere.altitude) * 2; int size = 1024; Texture2D tex = new Texture2D(size, size); for (int y = 0; y < tex.height; y++) { for (int x = 0; x < tex.width; x++) { tex.SetPixel(x, y, atmosphere.GetAtmosColor(atmosphere.PositionToAltitude01(TexCoordsToWorld(x, y, size, size, center, atmos.localScale.x)))); } } tex.Apply(); atmos.GetComponent <Renderer>().material.SetTexture(0, tex); }