Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix terrain shadows #674

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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
Expand All @@ -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
Expand Down
Loading