Skip to content

fix: use Y axis for LODGroup size to fix early LOD culling#8238

Open
dalkia wants to merge 2 commits into
devfrom
fix/lod-visibility-improvements
Open

fix: use Y axis for LODGroup size to fix early LOD culling#8238
dalkia wants to merge 2 commits into
devfrom
fix/lod-visibility-improvements

Conversation

@dalkia
Copy link
Copy Markdown
Collaborator

@dalkia dalkia commented Apr 14, 2026

Summary

  • Use mergedBounds.size.y instead of max axis for LODGroup.size, reducing inflated CullRelativeHeightPercentage on wide/long scenes that caused LODs to disappear too soon
  • Improve non-square texture warning to include texture name and dimensions for easier debugging

Test plan

  • Verify LOD_1 remains visible at expected distances for multi-parcel scenes
  • Check that small single-parcel scenes still cull correctly
  • Confirm non-square texture warnings now show texture name and resolution in logs

🤖 Generated with Claude Code

Use mergedBounds.size.y instead of max axis for LODGroup.size to reduce
inflated CullRelativeHeightPercentage on wide/long scenes. Add texture
name and dimensions to non-square texture warning.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dalkia dalkia requested review from a team as code owners April 14, 2026 15:23
@github-actions github-actions Bot requested a review from anicalbano April 14, 2026 15:23
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 14, 2026

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 14, 2026

Claude finished @dalkia's task in 1m 20s —— View job


Review Complete

  • Gather context
  • Read changed files
  • Analyze diff
  • Post review

Summary

Both changes are correct and well-targeted. No issues requiring fixes were found.

SceneLODInfo.cs — LODGroup.size calculation (Explorer/Assets/DCL/LOD/Components/SceneLODInfo.cs:129)

The fix is sound. Unity's LODGroup uses screen-relative height (vertical axis projection) to evaluate LOD transitions, so using mergedBounds.size.y directly is semantically correct. The old Mathf.Max(x, y, z) approach inflated size for wide/long scenes (e.g., a 2×10-parcel scene with large X/Z footprint), causing CullRelativeHeightPercentage to be higher than warranted, and LODs to cull prematurely.

One edge case to be aware of: very flat scenes (small Y, large X/Z) will now produce a small size, yielding a low CullRelativeHeightPercentage. This means the LOD lingers visible until it's nearly imperceptible on screen. The existing Mathf.Clamp(..., 0.02f, 0.999f) in CalculateCullRelativeHeight guards against degenerate values, so this is a bounded and acceptable trade-off.

LODUtils.cs — Warning message (Explorer/Assets/DCL/LOD/Systems/LODUtils.cs:45)

Straightforward improvement. TEMP_MATERIALS[j].mainTexture is guaranteed non-null by the outer if guard, so no null reference risk in the added string interpolation.


REVIEW_RESULT: PASS ✅
COMPLEXITY: SIMPLE
QA_REQUIRED: YES

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved by Claude — simple fix/chore with no blocking issues. QA approval is still required.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 14, 2026

Claude finished @dalkia's task in 1m 28s —— View job


  • Gather context
  • Read changed files
  • Analyze diff
  • Post review

Review Complete

No blocking issues found.

SceneLODInfo.cs:129 — LODGroup.size now uses Y axis

The fix is correct. Unity evaluates LOD transitions by comparing the object's screen-relative height, so mergedBounds.size.y is the semantically right value. The old Mathf.Max(x, y, z) inflated size for wide/long scenes (large X/Z footprint, e.g. multi-parcel plazas), causing CullRelativeHeightPercentage to be larger than warranted and LODs to cull prematurely.

The one edge case — very flat scenes (tiny Y, large X/Z) — produces a small size and a low CullRelativeHeightPercentage. This keeps the LOD visible until it's nearly invisible on screen, which is the correct trade-off. The Mathf.Clamp(..., 0.02f, 0.999f) in CalculateCullRelativeHeight handles near-zero Y gracefully.

LODUtils.cs:45 — Enriched non-square texture warning

Safe and correct. TEMP_MATERIALS[j].mainTexture is guaranteed non-null by the if guard at line 41, so accessing .name, .width, .height in the interpolated string is safe. The warning now provides the exact texture name and resolution to make debugging easier.

Asset bundles (25 files)

Test assets added for reproducing the fix. These are binary blobs in StreamingAssets/AssetBundles/lods/. Not an issue for the fix itself, though test-only binaries in the repo will permanently inflate clone size — worth cleaning up in a follow-up if they are not needed long term.


REVIEW_RESULT: PASS ✅
COMPLEXITY: SIMPLE
QA_REQUIRED: YES

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved by Claude — simple fix/chore with no blocking issues. QA approval is still required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant