fix(sss): prevent divide 0 albedo when blend decals#1489
Conversation
WalkthroughThe Burley subsurface scattering shader adjusts albedo scaling to interpolate with sssAmount, applies per-sample masking with early skips, scales diffuse mean free path by sssAmount, removes redundant mask checks, and makes sample weight unconditional. Final color composition now lerps with sssAmount rather than multiplying directly by AlbedoTexture. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant R as Renderer
participant S as Burley.hlsli (Shader)
participant T as Textures (Albedo, Mask)
R->>S: Invoke SSS pass
Note over S: Compute centerColor/weight<br/>Adjust albedo divisor via sssAmount
S->>S: diffuseMeanFreePath *= sssAmount
loop For each sample
S->>T: Sample MaskTexture
alt mask <= epsilon
S-->>S: Skip sample
else mask > epsilon
S->>T: Sample AlbedoTexture
Note over S: sampleColor uses lerp(1.0, max(Albedo, EPS), sampleMask)
S->>S: Compute pdf, diffusionProfile, normalWeight
S-->>S: sampleWeight = (diffusionProfile / pdf) * normalWeight
S-->>S: Accumulate color and weight
end
end
Note over S: Final color scales via lerp(1.0, AlbedoTexture, sssAmount)
S-->>R: Output SSS color
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)**/*.{cpp,cxx,cc,c,h,hpp,hxx,hlsl,hlsli,fx,fxh,py}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
features/*/Shaders/**/*.{hlsl,hlsli,fx,fxh}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (6)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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 |
|
✅ A pre-release build is available for this PR: |
This pull request updates the subsurface scattering shader logic in
Burley.hlslito improve color normalization and mask handling. The changes make the subsurface scattering effect more robust by using mask-driven blending for albedo normalization and sample inclusion, leading to more accurate rendering results.Subsurface Scattering Improvements
1.0and the albedo value based onsssAmount, rather than always normalizing by the albedo, which improves color accuracy in regions with low subsurface scattering.1.0and the albedo based onsssAmount, rather than always multiplying by the albedo, which helps maintain correct color in non-scattering regions.Code Clean-up
Summary by CodeRabbit