Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions package/Shaders/Effect.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ PS_OUTPUT main(PS_INPUT input)
finalColor *= fogMul;
# endif
psout.Diffuse = finalColor;
float3 outputAlbedo = 0;
# if defined(LIGHTING) && defined(LIGHT_LIMIT_FIX) && defined(LLFDEBUG)
if (SharedData::lightLimitFixSettings.EnableLightsVisualisation) {
if (SharedData::lightLimitFixSettings.LightsVisualisationMode == 0) {
Expand All @@ -861,6 +862,7 @@ PS_OUTPUT main(PS_INPUT input)
} else {
psout.Diffuse.xyz = LightLimitFix::TurboColormap((float)lightCount / MAX_CLUSTER_LIGHTS);
}
outputAlbedo = psout.Diffuse.xyz;
}
# endif

Expand All @@ -879,11 +881,11 @@ PS_OUTPUT main(PS_INPUT input)

#if defined(MULTBLEND) || defined(MULTBLEND_DECAL)
psout.Specular = float4(psout.Diffuse.xyz, finalColor.w);
psout.Albedo = float4(psout.Diffuse.xyz, finalColor.w);
psout.Albedo = float4(outputAlbedo, finalColor.w);
psout.Reflectance = float4(psout.Diffuse.xyz, finalColor.w);
psout.Masks = float4(Color::RGBToLuminance(psout.Diffuse.xyz).xxx, finalColor.w);
#else
psout.Albedo = float4(0, 0, 0, finalColor.w);
psout.Albedo = float4(outputAlbedo, finalColor.w);
psout.Specular = float4(0, 0, 0, finalColor.w);
psout.Reflectance = float4(0, 0, 0, finalColor.w);
psout.Masks = float4(0, 0, 0, finalColor.w);
Expand Down
1 change: 1 addition & 0 deletions package/Shaders/Lighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -3146,6 +3146,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
} else {
psout.Diffuse.xyz = shadowColor.xyz;
}
outputAlbedo = psout.Diffuse.xyz;
baseColor.xyz = 0.0;
} else {
psout.Diffuse.xyz = color.xyz;
Expand Down
1 change: 1 addition & 0 deletions package/Shaders/RunGrass.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
albedo = diffuseColor;
} else {
psout.Diffuse = float4(diffuseColor, 1);
}
Expand Down