diff --git a/features/Terrain Shadows/Shaders/TerrainShadows/ShadowUpdate.cs.hlsl b/features/Terrain Shadows/Shaders/TerrainShadows/ShadowUpdate.cs.hlsl index be5485669..47abdf8a8 100644 --- a/features/Terrain Shadows/Shaders/TerrainShadows/ShadowUpdate.cs.hlsl +++ b/features/Terrain Shadows/Shaders/TerrainShadows/ShadowUpdate.cs.hlsl @@ -17,8 +17,9 @@ float GetInterpolatedHeight(float2 pxCoord, bool isVertical) uint2 dims; TexHeight.GetDimensions(dims.x, dims.y); - int2 lerpPxCoordA = min(0, int2(pxCoord - .5 * float2(isVertical, !isVertical))); - int2 lerpPxCoordB = min(0, int2(pxCoord + .5 * float2(isVertical, !isVertical))); + // oob is fine + int2 lerpPxCoordA = int2(pxCoord - .5 * float2(isVertical, !isVertical)); + int2 lerpPxCoordB = int2(pxCoord + .5 * float2(isVertical, !isVertical)); float heightA = TexHeight[lerpPxCoordA]; float heightB = TexHeight[lerpPxCoordB]; @@ -29,9 +30,9 @@ float GetInterpolatedHeight(float2 pxCoord, bool isVertical) heightB = (heightB - ZRange.x) / (ZRange.y - ZRange.x); bool inBoundA = all(lerpPxCoordA > 0); - bool inBoundB = all(lerpPxCoordB < dims); + bool inBoundB = all(lerpPxCoordB < int2(dims)); if (inBoundA && inBoundB) - return lerp(heightA, heightB, frac(pxCoord.x - .5)); + return lerp(heightA, heightB, frac((isVertical ? pxCoord.x : pxCoord.y) - .5)); else if (!inBoundA) return heightB; else @@ -49,9 +50,9 @@ float2 GetInterpolatedHeightRW(float2 pxCoord, bool isVertical) float2 heightB = RWTexShadowHeights[lerpPxCoordB]; bool inBoundA = all(lerpPxCoordA > 0); - bool inBoundB = all(lerpPxCoordB < dims); + bool inBoundB = all(lerpPxCoordB < int2(dims)); if (inBoundA && inBoundB) - return lerp(heightA, heightB, frac(pxCoord - .5)); + return lerp(heightA, heightB, frac((isVertical ? pxCoord.x : pxCoord.y) - .5)); else if (!inBoundA) return heightB; else