void SetColours(PRNG rand, Material material) { var colChance = new Chance(rand); var primaryA_HSV = Vector3.zero; var secondaryA_HSV = Vector3.zero; var primaryB_HSV = Vector3.zero; var secondaryB_HSV = Vector3.zero; // One light grey, one dark grey if (colChance.Percent(25)) { primaryA_HSV = new Vector3(0, 0, Mathf.Lerp(0.55f, 1, rand.ValueBiasUpper(.4f))); secondaryA_HSV = primaryA_HSV + new Vector3(0, 0, rand.SignedValueBiasCentre(0.4f)); primaryB_HSV = new Vector3(0, 0, Mathf.Lerp(0f, 0.45f, rand.ValueBiasLower(.4f))); secondaryB_HSV = primaryB_HSV + new Vector3(0, 0, rand.SignedValueBiasCentre(0.4f)); } // One colour, one grey else if (colChance.Percent(25)) { // Pick grey, tending towards either very dark or very light float greyValue = rand.ValueBiasExtremes(0.8f); primaryA_HSV = new Vector3(0, 0, greyValue); secondaryA_HSV = new Vector3(0, 0, greyValue + rand.SignedValueBiasCentre(0.5f) * .3f); // If grey is dark, use bright colour, otherwise dark colour float colourValue = (greyValue < 0.5f) ? rand.ValueBiasUpper(0.7f) : rand.ValueBiasLower(0.7f); primaryB_HSV = new Vector3(rand.Value(), rand.Range(0.2f, 0.9f), Mathf.Lerp(0.1f, 0.9f, colourValue)); secondaryB_HSV = primaryB_HSV + rand.JiggleVector3(0.1f, 0.2f, 0.4f); } // Two similar colours else if (colChance.Percent(25)) { primaryA_HSV = new Vector3(rand.Range(0, 1), rand.Range(0.1f, 0.8f), rand.Range(0.2f, 0.8f)); secondaryA_HSV = primaryA_HSV + rand.JiggleVector3(0.1f, 0.2f, 0.3f); primaryB_HSV = new Vector3(primaryA_HSV.x + rand.Range(0.05f, 0.1f), rand.Range(0.1f, 0.8f), rand.Range(0.2f, 0.8f)); secondaryB_HSV = primaryB_HSV + rand.JiggleVector3(0.1f, 0.2f, 0.3f); } // Two distinct colours else if (colChance.Percent(25)) { primaryA_HSV = new Vector3(rand.Value(), rand.Range(0.2f, 0.9f), rand.Range(0.1f, 0.9f)); secondaryA_HSV = primaryA_HSV + rand.JiggleVector3(0.1f, 0.2f, 0.3f); primaryB_HSV = new Vector3((primaryA_HSV.x + rand.Range(0.2f, 0.8f)) % 1, rand.Range(0.2f, 0.9f), rand.Range(0.1f, 0.9f)); secondaryB_HSV = primaryB_HSV + rand.JiggleVector3(0.1f, 0.2f, 0.3f); } material.SetColor("_PrimaryColA", HSVToRGB(primaryA_HSV)); material.SetColor("_SecondaryColA", HSVToRGB(secondaryA_HSV)); material.SetColor("_PrimaryColB", HSVToRGB(primaryB_HSV)); material.SetColor("_SecondaryColB", HSVToRGB(secondaryB_HSV)); }