skyrim-community-shaders
skyrim-community-shaders copied to clipboard
Define PBR minimum roughness as named constant
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