Fix Rendering Issue in PBRTerrain #2365
Merged
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.
This PR attempts to fix a rendering bug that a few jme users have experienced on certain devices, as discussed in this thread: https://hub.jmonkeyengine.org/t/requesting-help-troubleshooting-pbrterrain-bug/47895
I believe the issue was due to a combination of things that were done incorrectly in the process of reading normal maps, calculating tangents, and then blending the normal values.
I believe it is also important to normalize the normal value prior to blending each layer, which I previously was not doing.
There's also some code that is necissary for putting a normal map in the proper range, and this was being done improperly for tri-planar normal mapping. It should be done 3 times (once per read) and then normalized, and this was incorrect previously.
Once this PR is done I'll post back to that thread and request testing from the users who were experiencing the bug on their device.