Skip to content

Commit

Permalink
Merge pull request #57 from EzioHelios/fix-tiling-uv
Browse files Browse the repository at this point in the history
Consider remapping uv range [0, 1] to image pixel range [0, w-1] (or [0, h-1]) in MeshT.BinPackTextures
  • Loading branch information
pierotofy authored Dec 13, 2023
2 parents fbe5e64 + 4962cf4 commit 1909c8f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Obj2Tiles.Library/Geometry/MeshT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ private void BinPackTextures(string targetFolder, int materialIndex, IReadOnlyLi

Debug.WriteLine("Cluster boundary (percentage): " + clusterBoundary);

var clusterX = (int)Math.Floor(clusterBoundary.Left * textureWidth);
var clusterY = (int)Math.Floor(clusterBoundary.Top * textureHeight);
var clusterX = (int)Math.Floor(clusterBoundary.Left * (textureWidth - 1));
var clusterY = (int)Math.Floor(clusterBoundary.Top * (textureHeight - 1));
var clusterWidth = (int)Math.Max(Math.Ceiling(clusterBoundary.Width * textureWidth), 1);
var clusterHeight = (int)Math.Max(Math.Ceiling(clusterBoundary.Height * textureHeight), 1);

Expand Down Expand Up @@ -1238,4 +1238,4 @@ public enum TexturesStrategy
Compress,
Repack,
RepackCompressed
}
}

0 comments on commit 1909c8f

Please sign in to comment.