fix ground polyline texcoords bug for first segment on some platforms #8024
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.
Fixes #8017.
Lengthwise texcoords for the first segment of ground polylines weren't getting computed correctly on some platforms, which manifested as buggy arrow materials on the first segment of polylines on terrain.
When packing vertex attributes to polyline volumes, we attach to each vertex a pair of floats that are used to compute each fragment's distance along the polyline as a whole from its texcoords within the segment - there's a scale term and a translation term. We also use the sign and/or magnitude of these terms to indicate in the shader whether a vertex is on the top, bottom, right, or left side of the shadow volume.
The translation term should always be in the range [0, 1) since it's a translation in texcoord space, so we say that if the value packed is negative or if it has a magnitude greater than 1.0, then the vertex is on the "bottom" of the volume. The value then needs to be remapped to [0, 1).
The "magnitude greater than 1.0" part is there because the first volume has a translation term 0.0. We were always setting it to Number.POSITIVE_INFINITY in this case as a value clearly outside the [0, 1) range, but it looks like on some platforms that can have reliability problems when remapping, so this PR brings it down to a very reasonable 9.0 instead.
Sandcastle for comparison: