Fix SpotLight3D light_projector doesn't render when shadow_enabled is false - #1326
Fix SpotLight3D light_projector doesn't render when shadow_enabled is false#1326Shakai-Dev wants to merge 2 commits into
light_projector doesn't render when shadow_enabled is false#1326Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
ChangesLight projector shadow handling
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@servers/rendering/renderer_rd/storage_rd/light_storage.cpp`:
- Around line 1035-1051: Replace the invalid RSE::LIGHT_SPOT reference in the
projector/shadow matrix branch with RS::LIGHT_SPOT, matching the
rendering-server enum used throughout the surrounding function.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0de94a42-a16f-4bcf-8558-2d96b1e29618
📒 Files selected for processing (1)
servers/rendering/renderer_rd/storage_rd/light_storage.cpp
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
The Problem
When
shadow_enabledis set tofalseon a SpotLight3D,LightStorage::update_light_bufferspreviously skipped calculatinglight_data.shadow_matrixaltogether. However, the spotlight shader relies onshadow_matrixto calculate projector UVs whenever alight_projectortexture is assigned but sinceshadow_matrixwas never written when shadows were disabled, the shader read garbage/uninitialized matrix data, resulting in broken projector UVs, black output or visual glitches from stale memory.The Solution
This PR adds a fallback check inside
LightStorage::update_light_buffersfor when shadows are disabled (has_shadowisfalse). If a spotlight has a valid projector texture assigned (has_projectoristrue), the matrix is now calculated manually using the spotlight's parameters (spot_angle,radius,light_transform) & stored intolight_data.shadow_matrix.Summary by CodeRabbit