Skip to content

Commit

Permalink
Fix off-by-one error
Browse files Browse the repository at this point in the history
  • Loading branch information
jstone-lucasfilm committed Dec 29, 2023
1 parent 1348ece commit 0dd8059
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 0dd8059

Please sign in to comment.