From 0dd80595dbc0a31079997f2e71c53ce6ec9a84da Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Thu, 28 Dec 2023 16:55:18 -0800 Subject: [PATCH] Fix off-by-one error --- libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl b/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl index 62b18310e6..85430c00ca 100644 --- a/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl +++ b/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl @@ -608,12 +608,12 @@ float mx_latlong_alpha_to_lod(float alpha) { // Return the mip level associated with the given alpha in a prefiltered environment. float lodBias = (alpha < 0.25) ? sqrt(alpha) : 0.5 * alpha + 0.375; - return lodBias * float($envRadianceMips); + return lodBias * float($envRadianceMips - 1); } float mx_latlong_lod_to_alpha(float lod) { // Return the alpha associated with the given mip level in a prefiltered environment. - float lodBias = lod / float($envRadianceMips); + float lodBias = lod / float($envRadianceMips - 1); return (lodBias < 0.5) ? mx_square(lodBias) : 2.0 * (lodBias - 0.375); }