skyrim-community-shaders icon indicating copy to clipboard operation
skyrim-community-shaders copied to clipboard

Define PBR minimum roughness as named constant

Open coderabbitai[bot] opened this issue 3 months ago • 2 comments
trafficstars

Description

The recent change in PR #1351 updated the minimum roughness clamp value from 0.005 to 0.04 for the GGX microfacet model to ensure visible specular highlights. However, this magic number should be defined as a named constant to improve code maintainability and make the physical reasoning behind this value clearer.

Context

Currently in package/Shaders/Lighting.hlsl line 2108:

pbrSurfaceProperties.Roughness = clamp(rawRMAOS.x, 0.04, 1.0);

This magic number should be replaced with a descriptive named constant like PBR_MIN_ROUGHNESS.

Benefits

  • Improved code readability and maintainability
  • Makes the physical reasoning behind the value more explicit
  • Easier to adjust if needed in the future
  • Follows best practices for avoiding magic numbers

References

  • PR: https://github.com/doodlum/skyrim-community-shaders/pull/1351
  • Comment: https://github.com/doodlum/skyrim-community-shaders/pull/1351#discussion_r2249344753

coderabbitai[bot] avatar Aug 03 '25 02:08 coderabbitai[bot]