ExtrudeGeometry: Improve Default UV Generator #21875
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.
Related issue: #4994
Description
Per the linked issue, some surfaces in extruded geometry would have default generated uv coordinates such that their textures were stretched. This was a result of having two uv mapping schemes—one for surfaces close to vertical, one for surfaces close to horizontal—and using the vertical mapping for all but the most horizontal of surfaces.
This change increases the quality of the default mapping by using the horizontal mapping scheme in more cases. We determine whether to use the vertical scheme or the horizontal scheme by taking the angle between the up vector and a segment in the generated extrusion surface. When the angle is less than 45 degrees, we treat it as mostly vertical; when it is greater, we treat it as mostly horizontal. We then apply the matching scheme.
Borrowing the images that @WestLangley kindly submitted to illustrate the difference, we have the before:
And the after: