Skip to content

fix(deferred): llf visualization debug mode#1745

Closed
alandtse wants to merge 1 commit into
community-shaders:devfrom
alandtse:llf_vis_fix
Closed

fix(deferred): llf visualization debug mode#1745
alandtse wants to merge 1 commit into
community-shaders:devfrom
alandtse:llf_vis_fix

Conversation

@alandtse
Copy link
Copy Markdown
Collaborator

@alandtse alandtse commented Jan 23, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Corrected albedo visualization output in lighting and debug visualization modes across rendering pipelines.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings January 23, 2026 04:12
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

The changes introduce local variables (outputAlbedo and albedo) that capture diffuse color values within debug visualization paths (light limit fix and lights visualization branches) across three shader files, then propagate these values to the albedo output in conditional branches.

Changes

Cohort / File(s) Summary
Debug Albedo Visualization
package/Shaders/Effect.hlsl, package/Shaders/Lighting.hlsl, package/Shaders/RunGrass.hlsl
Modified shader files to assign diffuse color to albedo variables within debug visualization conditional blocks (light limit fix and lights visualization). Effect.hlsl introduces outputAlbedo variable and propagates it to psout.Albedo in all shader paths; Lighting.hlsl and RunGrass.hlsl assign diffuse/color values to outputAlbedo/albedo within LIGHT_LIMIT_FIX and LightLimitFix branches respectively.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • jiayev
  • doodlum

Poem

🐰 Through shader paths so bright and clear,
Albedo whispers, "I am here!"
From diffuse light to debug's glow,
The colors dance and brightly show,
Three files blend in visualization's cheer! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically identifies the fix as addressing a light limit fix (llf) visualization debug mode, which aligns with the changes made across three shader files to correct albedo output in debug visualization paths.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Using provided base ref: 44eb788
Using base ref: 44eb788
Base commit date: 2026-01-19T23:55:15Z (Monday, January 19, 2026 11:55 PM)
No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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);
}
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
}
}
psout.Diffuse = float4(diffuseColor, 1);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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.

outputAlbedo is only set inside the LLF debug path, so deferred albedo becomes zero in normal rendering, including MULTBLEND/MULTBLEND_DECAL paths that previously carried psout.Diffuse. Initialize outputAlbedo to 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

@alandtse
Copy link
Copy Markdown
Collaborator Author

Taking to draft as looking at another PR LLF may be working?

@alandtse alandtse marked this pull request as draft January 23, 2026 04:33
@github-actions
Copy link
Copy Markdown

✅ A pre-release build is available for this PR:
Download

@alandtse
Copy link
Copy Markdown
Collaborator Author

Must be crazy. Closing as dev apparently works.

@alandtse alandtse closed this Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants