Skip to content

Commit 4d7a747

Browse files
committed
Sync with Francisco's GeoTextures Fix
1 parent 025ea81 commit 4d7a747

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

62_CAD/Images.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,16 @@ GeoreferencedImageInfo GeoreferencedImageStreamingState::computeGeoreferencedIma
107107
const uint32_t2 viewportTileLength = currentViewportTileRange.bottomRightTile - currentViewportTileRange.topLeftTile + uint32_t2(1, 1);
108108
// If the last tile is visible, we use the fractional span for the last tile. Otherwise it's just a normal tile
109109
const bool2 lastTileVisible = isLastTileVisible(currentViewportTileRange.bottomRightTile);
110+
const uint32_t2 lastSampledImageTileTexels = { lastTileVisible.x ? lastTileSamplingExtent.x : oneTileTexelSpan, lastTileVisible.y ? lastTileSamplingExtent.y : oneTileTexelSpan };
110111
const uint32_t2 lastGPUImageTileTexels = { lastTileVisible.x ? lastTileTargetExtent.x : GeoreferencedImageTileSize, lastTileVisible.y ? lastTileTargetExtent.y : GeoreferencedImageTileSize };
111112

112113
// Instead of grouping per tile like in the offset case, we group per texel: the same reasoning leads to a single texel at current mip level having a span of `dirU * 2^(currentMappedRegionTileRange.baseMipLevel)/ fullResImageExtents.x`
113-
// in the U direction. Therefore the span in worldspace of the OBB we construct is just this number multiplied by the number of gpu texels spanned to draw.
114-
// The number of texels is just `GeoreferencedImageTileSize` times the number of full tiles (all but the last) + the number of texels of the last tile, which might not be a full tile if near the right boundary
115-
viewportEncompassingOBB.dirU = worldspaceOBB.dirU * float32_t((GeoreferencedImageTileSize * (viewportTileLength.x - 1) + lastGPUImageTileTexels.x) << currentMappedRegionTileRange.baseMipLevel) / float32_t(fullResImageExtents.x);
116-
// Simply number of gpu texels in the y direction divided by number of texels in the x direction.
117-
viewportEncompassingOBB.aspectRatio = float32_t(GeoreferencedImageTileSize * (viewportTileLength.y - 1) + lastGPUImageTileTexels.y) / float32_t(GeoreferencedImageTileSize * (viewportTileLength.x - 1) + lastGPUImageTileTexels.x);
114+
// in the U direction. Therefore the span in worldspace of the OBB we construct is just this number multiplied by the number of image texels spanned to draw.
115+
// The number of texels is just `GeoreferencedImageTileSize * 2^{mipLevel}` times the number of full tiles (all but the last) + the number of texels of the last tile, which might not be a full tile if near the right boundary
116+
const uint32_t2 sampledImageTexels = oneTileTexelSpan * (viewportTileLength - 1u) + lastSampledImageTileTexels;
117+
viewportEncompassingOBB.dirU = worldspaceOBB.dirU * float32_t(sampledImageTexels.x) / float32_t(fullResImageExtents.x);
118+
// Simply number of image texels in the y direction divided by number of texels in the x direction.
119+
viewportEncompassingOBB.aspectRatio = float32_t(sampledImageTexels.y) / float32_t(sampledImageTexels.x);
118120

119121
// GPU tile corresponding to the real image tile containing the viewport top left - we can let it be negative since wrapping mode is repeat, negative tiles are correct modulo `gpuImageSideLengthTiles`
120122
const uint32_t2 viewportTopLeftGPUTile = currentViewportTileRange.topLeftTile - currentMappedRegionTileRange.topLeftTile + gpuImageTopLeft;

0 commit comments

Comments
 (0)