chore(grass): improve sss#2183
Conversation
Remap skylightingNormal z into [0,1] before cosine-lobe evaluation so backlit grass retains ambient response. Divide out vertex AO from the skylighting term (clamped to prevent blowup), producing a clean min(skylighting, vertexAO) relationship. Replace additive sss/subsurfaceColor split with a saturated albedo lerp toward full-luma (dot(albedo, 1/3)) gated by VertexNormal.w. Drop the manual normal.z clamp in complex grass since the skylightingNormal remap handles it. Requires the Skylighting::Sample API refactor.
📝 WalkthroughWalkthroughRemoved conditional normal.z clamping/renormalization when ChangesGrass shader math
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
No actionable suggestions for changed features. |
Linearize input.VertexColor at the point of use so it composes correctly with the already-linear baseColor. Both main() functions treat vertexColor as linear from here on, which lets the albedo expression drop the redundant outer saturate and double linearization. Re-express subsurface scattering as two clearer quantities: subsurfaceColor accumulates the backlit light-direction terms, and subsurfaceAlbedo bakes the VertexNormal.w weighting into albedo so the final diffuse blend is a simple product. Rename the old sss accumulator accordingly. Drop the post-frontFace normal.z clamp in the !GrassSphereNormal branch since the backface flip and later normalization already produce a valid outward-facing normal. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…um/skyrim-community-shaders into feat/grass-skylighting-sss
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package/Shaders/RunGrass.hlsl`:
- Line 728: The point-light subsurface scattering accumulation (the
subsurfaceColor += lightColor * saturate(-lightAngle) statement) is missing the
Color::VanillaNormalization() factor and should be made consistent with the
directional SSS initializer; update that line to multiply by
Color::VanillaNormalization() so point-light SSS uses the same normalization as
the directional path (keep the diffuseColor += subsurfaceColor * albedo *
SubsurfaceScatteringAmount usage unchanged).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 33f33227-5ec9-46bd-b04a-201460f527da
📒 Files selected for processing (1)
package/Shaders/RunGrass.hlsl
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package/Shaders/RunGrass.hlsl`:
- Around line 781-782: The subsurface scattering term is being multiplied by
albedo before the final albedo application, causing double-albedo attenuation;
in RunGrass.hlsl locate the diffuse accumulation where diffuseColor,
subsurfaceColor, albedo and
SharedData::grassLightingSettings.SubsurfaceScatteringAmount are used and remove
the pre-multiplication by albedo so the SSS contribution is added as
subsurfaceColor * SharedData::grassLightingSettings.SubsurfaceScatteringAmount
(letting the existing diffuseColor *= albedo line apply albedo once to the whole
diffuse result).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 26cb22e2-396a-4a9d-a3f3-0a3b6e011208
📒 Files selected for processing (1)
package/Shaders/RunGrass.hlsl
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package/Shaders/RunGrass.hlsl`:
- Line 644: The subsurfaceColor calculation uses an undefined variable
dirSoftShadow; replace dirSoftShadow with the existing dirDetailedShadow so the
expression becomes consistent with other shadow uses—update the subsurfaceColor
assignment (which references dirLightColor, dirLightAngle and
Color::VanillaNormalization()) to multiply by dirDetailedShadow instead of
dirSoftShadow in RunGrass.hlsl.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: bbdc462d-0f4a-4944-b046-b919017e3869
📒 Files selected for processing (1)
package/Shaders/RunGrass.hlsl
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
package/Shaders/RunGrass.hlsl (1)
750-751:⚠️ Potential issue | 🟠 Major | ⚡ Quick winSSS is still getting albedo-applied twice.
At Line 750,
subsurfaceColoris pre-multiplied byalbedo, then Line 751 multiplies the wholediffuseColorbyalbedoagain. This over-attenuates backlighting.Proposed fix
- diffuseColor += subsurfaceColor * albedo * SharedData::grassLightingSettings.SubsurfaceScatteringAmount; + diffuseColor += subsurfaceColor * SharedData::grassLightingSettings.SubsurfaceScatteringAmount; diffuseColor *= albedo;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package/Shaders/RunGrass.hlsl` around lines 750 - 751, subsurface scattering is being multiplied by albedo twice: adjust the SSS accumulation so albedo is only applied once; specifically, in the block that updates diffuseColor (the lines using subsurfaceColor, albedo, and SharedData::grassLightingSettings.SubsurfaceScatteringAmount), remove the extra multiplication by albedo on the subsurface term (i.e. compute the SSS contribution as subsurfaceColor * SharedData::grassLightingSettings.SubsurfaceScatteringAmount and then keep the existing diffuseColor *= albedo), ensuring subsurfaceColor, albedo, diffuseColor, and SharedData::grassLightingSettings.SubsurfaceScatteringAmount are the referenced symbols.
🧹 Nitpick comments (2)
package/Shaders/RunGrass.hlsl (2)
469-952: Please run hlslkit validation for the touched grass PS permutations before merge.Given the shader-math/control-flow updates, a targeted hlslkit compile/validation pass for relevant defines (
GRASS_LIGHTING,TRUE_PBR,LIGHT_LIMIT_FIX,SKYLIGHTING, VR/non-VR) would reduce regression risk.As per coding guidelines "**/*.hlsl: Use hlslkit for shader validation and compilation during targeted development testing and before deployment".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package/Shaders/RunGrass.hlsl` around lines 469 - 952, PR requests hlslkit validation for the modified grass pixel shader permutations; run targeted shader compilation to catch regressions. Reproduce and validate all touched PS permutations by running hlslkit (or your project's shader validation runner) against the updated PS functions (main in RunGrass.hlsl) with the relevant define combinations: TRUE_PBR on/off, LIGHT_LIMIT_FIX on/off (and LLFDEBUG), SKYLIGHTING on/off, GRASS_LIGHTING tweaks, VR vs non-VR, and permutations that affect backface handling (check Permutation::ExtraShaderDescriptor / GrassSphereNormal) and Normal/TBN code paths (GrassLighting::TransformNormal, GrassLighting::CalculateTBN); fix any compile errors or warnings, and ensure runtime changes (specColor/specular paths, shadowColor usage, Random::InterleavedGradientNoise, and stereo eyeIndex usage) behave correctly before merging.
1-1: ⚡ Quick winPR metadata suggestion: title type and issue linkage could be clearer.
Current title
chore(grass): sss improvementsis valid conventional format, but this looks behavior-affecting; considerfix(grass): correct sss lighting weighting(orfeat(grass): refine sss lighting) and add an issue keyword if applicable (Fixes #.../Addresses #...).As per coding guidelines "When reviewing PRs, please provide suggestions for: Conventional Commit Titles ... Issue References ...".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package/Shaders/RunGrass.hlsl` at line 1, Update the PR metadata: change the commit title from "chore(grass): sss improvements" to a behavior-reflecting type such as "fix(grass): correct sss lighting weighting" (or "feat(grass): refine sss lighting" if intentionally additive) and add an issue reference like "Fixes #<issue-number>" or "Addresses #<issue-number>" if one exists; mention the affected shader (RunGrass.hlsl / the SSS lighting changes) in the PR description so reviewers understand the scope.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@package/Shaders/RunGrass.hlsl`:
- Around line 750-751: subsurface scattering is being multiplied by albedo
twice: adjust the SSS accumulation so albedo is only applied once; specifically,
in the block that updates diffuseColor (the lines using subsurfaceColor, albedo,
and SharedData::grassLightingSettings.SubsurfaceScatteringAmount), remove the
extra multiplication by albedo on the subsurface term (i.e. compute the SSS
contribution as subsurfaceColor *
SharedData::grassLightingSettings.SubsurfaceScatteringAmount and then keep the
existing diffuseColor *= albedo), ensuring subsurfaceColor, albedo,
diffuseColor, and SharedData::grassLightingSettings.SubsurfaceScatteringAmount
are the referenced symbols.
---
Nitpick comments:
In `@package/Shaders/RunGrass.hlsl`:
- Around line 469-952: PR requests hlslkit validation for the modified grass
pixel shader permutations; run targeted shader compilation to catch regressions.
Reproduce and validate all touched PS permutations by running hlslkit (or your
project's shader validation runner) against the updated PS functions (main in
RunGrass.hlsl) with the relevant define combinations: TRUE_PBR on/off,
LIGHT_LIMIT_FIX on/off (and LLFDEBUG), SKYLIGHTING on/off, GRASS_LIGHTING
tweaks, VR vs non-VR, and permutations that affect backface handling (check
Permutation::ExtraShaderDescriptor / GrassSphereNormal) and Normal/TBN code
paths (GrassLighting::TransformNormal, GrassLighting::CalculateTBN); fix any
compile errors or warnings, and ensure runtime changes (specColor/specular
paths, shadowColor usage, Random::InterleavedGradientNoise, and stereo eyeIndex
usage) behave correctly before merging.
- Line 1: Update the PR metadata: change the commit title from "chore(grass):
sss improvements" to a behavior-reflecting type such as "fix(grass): correct sss
lighting weighting" (or "feat(grass): refine sss lighting" if intentionally
additive) and add an issue reference like "Fixes #<issue-number>" or "Addresses
#<issue-number>" if one exists; mention the affected shader (RunGrass.hlsl / the
SSS lighting changes) in the PR description so reviewers understand the scope.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 063f360f-04a1-4fc3-b0bb-3b2af647c7a5
📒 Files selected for processing (1)
package/Shaders/RunGrass.hlsl
Adapted from PR community-shaders#2183 and the newer dev grass color, skylighting, and SSS model while preserving this branch's existing water, terrain/cloud shadow, and no-height-fog paths.
Adapted from PR community-shaders#2183 and the newer dev grass color, skylighting, and SSS model while preserving this branch's existing water, terrain/cloud shadow, and no-height-fog paths.
Adapted from PR community-shaders#2183 and the newer dev grass color, skylighting, and SSS model while preserving this branch's existing water, terrain/cloud shadow, and no-height-fog paths.
Summary by CodeRabbit