fix: vertex color applications#2161
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis change updates PBR vertex-color application in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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. ✨ 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 |
|
No actionable suggestions for changed features. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
package/Shaders/Lighting.hlsl (1)
2797-2821:⚠️ Potential issue | 🔴 CriticalVertex color is applied twice for non-PBR Glowmap materials.
In the
devbranch,emitColor *= input.Color.xyzwas gated by#if defined(TRUE_PBR)with the comment: "Non-PBR folds emitColor into diffuseColor and the global color.xyz *= vertexColor (line 2918) already covers it." The PR removes this guard, applying vertex color to emissive unconditionally.For non-PBR non-HAIR non-SKYLIGHTING:
- Emissive now gets multiplied by
Color::SrgbToLinear(input.Color.xyz)in this block.- Emissive is then added to
diffuseColor(line 2825) and folded into finalcolor.- Later,
color.xyz *= input.Color.xyzat line ~2972 applies vertex color again (non-linearized).Result: vertex color is applied twice to emissive contributions in non-PBR paths, darkening/tinting them inconsistently vs. the vanilla behavior that the guard was designed to preserve.
🔧 Suggested fix: restore TRUE_PBR guard
[branch] if (hasEmissive) { float3 glowColor = Color::Glowmap(TexGlowSampler.Sample(SampGlowSampler, uv).xyz); +# if defined(TRUE_PBR) float3 vertexColor = Color::SrgbToLinear(input.Color.xyz); if (!SharedData::linearLightingSettings.enableLinearLighting) { emitColor = Color::SrgbToLinear(emitColor); glowColor = Color::SrgbToLinear(glowColor); emitColor *= glowColor; emitColor *= vertexColor; emitColor = Color::LinearToSrgb(emitColor); } else { emitColor *= glowColor; emitColor *= vertexColor; } +# else + if (!SharedData::linearLightingSettings.enableLinearLighting) { + emitColor = Color::LinearToSrgb(Color::SrgbToLinear(emitColor) * Color::SrgbToLinear(glowColor)); + } else { + emitColor *= glowColor; + } +# endif }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package/Shaders/Lighting.hlsl` around lines 2797 - 2821, The emissive path now multiplies emitColor by the vertex color unconditionally, causing vertex color to be applied twice for non-PBR Glowmap materials; restore the original TRUE_PBR guard so vertex color is only folded into emissive for PBR materials. Concretely, wrap the emitColor *= vertexColor (the multiplication using Color::SrgbToLinear(input.Color.xyz) inside the [branch] if (hasEmissive) block) with `#if` defined(TRUE_PBR) / `#endif` so that non-PBR paths rely on the existing diffuse/final color.xyz *= input.Color.xyz behavior; leave all other operations (Color::Glowmap, Color::SrgbToLinear/LinearToSrgb, SharedData::linearLightingSettings handling, and PBRFlags/PBR::Flags::HasEmissive checks) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@package/Shaders/Lighting.hlsl`:
- Around line 2797-2821: The emissive path now multiplies emitColor by the
vertex color unconditionally, causing vertex color to be applied twice for
non-PBR Glowmap materials; restore the original TRUE_PBR guard so vertex color
is only folded into emissive for PBR materials. Concretely, wrap the emitColor
*= vertexColor (the multiplication using Color::SrgbToLinear(input.Color.xyz)
inside the [branch] if (hasEmissive) block) with `#if` defined(TRUE_PBR) / `#endif`
so that non-PBR paths rely on the existing diffuse/final color.xyz *=
input.Color.xyz behavior; leave all other operations (Color::Glowmap,
Color::SrgbToLinear/LinearToSrgb, SharedData::linearLightingSettings handling,
and PBRFlags/PBR::Flags::HasEmissive checks) unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 343b04ce-65e6-4dbe-9a15-a3bc9542ff4a
📒 Files selected for processing (1)
package/Shaders/Lighting.hlsl
|
✅ A pre-release build is available for this PR: |
3be307e to
89d36e3
Compare
Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details.
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> (cherry picked from commit cb9cbd5)
closes issue #2155
Summary by CodeRabbit