fix(deferred): llf visualization debug mode#1745
Conversation
📝 WalkthroughWalkthroughThe changes introduce local variables ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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.
Pull request overview
This PR fixes the Light Limit Fix (LLF) debug visualization mode to correctly display in the deferred rendering albedo buffer. When LLF debug visualization is enabled, the debug colors (showing light counts via color mapping) should appear in both the diffuse output and the deferred albedo buffer.
Changes:
- Modified three shader files to ensure debug visualization colors are written to the albedo buffer in deferred rendering mode
- RunGrass.hlsl: Sets albedo variable to debug visualization color
- Lighting.hlsl: Sets outputAlbedo to debug visualization color
- Effect.hlsl: Introduces outputAlbedo variable and uses it for deferred albedo output
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| package/Shaders/RunGrass.hlsl | Sets albedo to debug visualization color when LLF debug mode is active |
| package/Shaders/Lighting.hlsl | Sets outputAlbedo to visualization color when debug mode is active, used in deferred albedo buffer |
| package/Shaders/Effect.hlsl | Introduces outputAlbedo variable, sets it for debug visualization, and uses it in deferred albedo output |
| @@ -824,6 +824,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace) | |||
| } else { | |||
| diffuseColor.xyz = LightLimitFix::TurboColormap((float)lightCount / MAX_CLUSTER_LIGHTS); | |||
| } | |||
There was a problem hiding this comment.
When debug visualization is enabled, psout.Diffuse is never assigned. The else branch (line 829) assigns psout.Diffuse = float4(diffuseColor, 1), but when the visualization is enabled, only albedo is set. This leaves psout.Diffuse uninitialized, which will cause undefined behavior. Add psout.Diffuse = float4(diffuseColor, 1); before this line to match the pattern used in Effect.hlsl (line 854 sets psout.Diffuse, then line 865 sets outputAlbedo) and Lighting.hlsl (where psout.Diffuse.xyz is always set before line 3149).
| } | |
| } | |
| psout.Diffuse = float4(diffuseColor, 1); |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
package/Shaders/Effect.hlsl (1)
855-889: Restore non-debug albedo behavior for MULTBLEND.
outputAlbedois only set inside the LLF debug path, so deferred albedo becomes zero in normal rendering, including MULTBLEND/MULTBLEND_DECAL paths that previously carriedpsout.Diffuse. InitializeoutputAlbedoto the old behavior and keep the debug override.✅ Proposed fix
- float3 outputAlbedo = 0; + float3 outputAlbedo = 0; +#if defined(MULTBLEND) || defined(MULTBLEND_DECAL) + outputAlbedo = psout.Diffuse.xyz; +#endif # if defined(LIGHTING) && defined(LIGHT_LIMIT_FIX) && defined(LLFDEBUG) if (SharedData::lightLimitFixSettings.EnableLightsVisualisation) { if (SharedData::lightLimitFixSettings.LightsVisualisationMode == 0) { psout.Diffuse.xyz = LightLimitFix::TurboColormap(0.0); } else if (SharedData::lightLimitFixSettings.LightsVisualisationMode == 1) { psout.Diffuse.xyz = LightLimitFix::TurboColormap(0.0); } else { psout.Diffuse.xyz = LightLimitFix::TurboColormap((float)lightCount / MAX_CLUSTER_LIGHTS); } outputAlbedo = psout.Diffuse.xyz; } # endif
|
Taking to draft as looking at another PR LLF may be working? |
|
✅ A pre-release build is available for this PR: |
|
Must be crazy. Closing as dev apparently works. |
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.