Improve hysteresis distance calculation and add view frustum checks for foliage culling
This commit is contained in:
@@ -126,9 +126,15 @@ function distanceFromPointToCachedChunkCenter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getHysteresisDistance(distance: number, ratio: number): number {
|
function getHysteresisDistance(distance: number, ratio: number): number {
|
||||||
|
const normalizedRatio = Math.max(0, ratio);
|
||||||
|
|
||||||
|
if (normalizedRatio <= 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return Math.max(
|
return Math.max(
|
||||||
MIN_FOLIAGE_LOD_HYSTERESIS_DISTANCE,
|
MIN_FOLIAGE_LOD_HYSTERESIS_DISTANCE,
|
||||||
Math.max(0, distance) * Math.max(0, ratio)
|
Math.max(0, distance) * normalizedRatio
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,6 +575,8 @@ export function resolveFoliageRenderChunkLod(options: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
options.view.frustum !== null &&
|
||||||
|
options.view.frustum !== undefined &&
|
||||||
shouldCullCachedFoliageRenderChunkByFrustum({
|
shouldCullCachedFoliageRenderChunkByFrustum({
|
||||||
chunk: options.chunk,
|
chunk: options.chunk,
|
||||||
frustum: options.view.frustum,
|
frustum: options.view.frustum,
|
||||||
|
|||||||
Reference in New Issue
Block a user