ensure bump map scale is texture UV scale invariant. adjust examples. #26899
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Right now our bump scale is dependent upon the texture UV scale in world space. This is incorrect, rather a bump map should look the same regardless of the texture UV scale in world space. Our normal factors are invariant to texture UV scale, it is just the bump scale that isn't.
By fixing this, this allows us to use more sensible scale factors that are close to 1.0 by default. Otherwise we had to use weird 0.01 scale factors or similar if the texture UV scale in world space wasn't close to unity.
You can see here how we made the normal factors texture UV scale invariant, it is the normalization right here using the determinant scale:
https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js#L36C2-L36C2
Also in Babylon.js, they are normalizing the texture UV space in this code, which they label "construct a scale-invariant frame":
https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Shaders/ShadersInclude/bumpFragmentMainFunctions.fx#L105
This is a breaking change to anyone who is using bump map scale factors. But I believe it should increase our compatibility with other systems who do this correctly.
This contribution is funded by Threekit