Fix triplanar texture mapping when using Large Worlds

#3001
This commit is contained in:
Wojtek Figat
2025-02-11 00:31:37 +01:00
parent a5fffc0c9e
commit 58090aa6d6
4 changed files with 21 additions and 3 deletions

View File

@@ -171,6 +171,8 @@ cbuffer ViewData : register(b1)
float4 ViewInfo;
float4 ScreenSize;
float4 TemporalAAJitter;
float3 LargeWorldsChunkIndex;
float LargeWorldsChunkSize;
};
#endif
@@ -277,4 +279,14 @@ float2 Flipbook(float2 uv, float frame, float2 sizeXY, float2 flipXY = 0.0f)
return (uv + frameXY) / sizeXY;
}
#if USE_PER_VIEW_CONSTANTS
// Calculates the world-position offset to stabilize tiling (eg. via triplanar mapping) due to Large Worlds view origin offset.
float3 GetLargeWorldsTileOffset(float tileSize)
{
return LargeWorldsChunkIndex * fmod(LargeWorldsChunkSize, tileSize);
}
#endif
#endif