Dreamteck / splines

The official Dreamteck Splines for Unity repository
Apache License 2.0
22 stars 2 forks source link

Clipped SplineMesh Uniform UVs #8

Closed Kronoxis closed 2 months ago

Kronoxis commented 1 year ago

Issue

The SplineMesh has the option to generate Uniform U or Uniform V UVs, however, this goes wrong when the SplineMesh has a clip range. Note that this does not happen for the channel clip range. See Discord for images.

Changes

I believe the ClipPercent call during the CalculateLength call for Uniform UVs is wrongly clipping the modified result. After removing this call, clipping the SplineMesh provides correct uniform UVs. This PR implements that fix.

Tests available on test branch

I believe the lengths calculated in all cases are correct - the UV checker texture looks uniform on all meshes.

Visual differences

I have noticed that the Uniform UVs for a SplineMesh of equal length but clipped with either SplineMesh clip range or SplineMeshChannel clip range generate different results. Clipping the channel cuts off parts of the mesh while leaving the UVs completely untouched. Clipping the mesh will instead shift the UVs so that the start of the UV space is shifted to the start of the generated mesh.

Neither are necessarily wrong and could be seen as a feature, but this may need some documentation and/or clarification, as it's not intuitive. It makes sense when you know how to think about the difference between mesh and channel, but most users will not have this knowledge.