static void GetRoughnessAndAngle(int roughnessIndex, int thetaIndex, int tableResolution, LTCTableParametrization parametrization, out float alpha, out float cosTheta) { float perceptualRoughness = (float)roughnessIndex / (tableResolution - 1); alpha = Mathf.Max(k_MinRoughness, perceptualRoughness * perceptualRoughness); if (parametrization == LTCTableParametrization.CosTheta) { // Parameterised by sqrt(1 - cos(theta)) float x = (float)thetaIndex / (tableResolution - 1); cosTheta = 1.0f - x * x; // Clamp to cos(1.57) cosTheta = Mathf.Max(3.7540224885647058065387021283285e-4f, cosTheta); } else { float theta = Mathf.Min(1.57f, thetaIndex / (float)(tableResolution - 1) * 1.57079f); cosTheta = Mathf.Cos(theta); } }