Skip to content

Commit

Permalink
fix: error with UV at very edge
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 committed Dec 7, 2024
1 parent 0c42ece commit 655160a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Editor/Processors/TraceAndOptimize/OptimizeTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,11 @@ private void FitToBlockSizeAndAddPadding(List<AtlasIsland> islands, float blockS
ref var max = ref island.MaxPos;

// fit to block size
min.x = Mathf.Floor(min.x / blockSizeRatioX - paddingRatio) * blockSizeRatioX;
min.y = Mathf.Floor(min.y / blockSizeRatioY - paddingRatio) * blockSizeRatioY;
max.x = Mathf.Ceil(max.x / blockSizeRatioX + paddingRatio) * blockSizeRatioX;
max.y = Mathf.Ceil(max.y / blockSizeRatioY + paddingRatio) * blockSizeRatioY;
// if rest texture size is less than padding, fit to the UV coordinate
min.x = Mathf.Max(Mathf.Floor(min.x / blockSizeRatioX - paddingRatio) * blockSizeRatioX, 0);
min.y = Mathf.Max(Mathf.Floor(min.y / blockSizeRatioY - paddingRatio) * blockSizeRatioY, 0);
max.x = Mathf.Min(Mathf.Ceil(max.x / blockSizeRatioX + paddingRatio) * blockSizeRatioX, 1);
max.y = Mathf.Min(Mathf.Ceil(max.y / blockSizeRatioY + paddingRatio) * blockSizeRatioY, 1);
}
}

Expand Down

0 comments on commit 655160a

Please sign in to comment.