chore(grass lighting): complex grass improvements#1456
Conversation
WalkthroughReplaces a boolean complexity check with a texture-sampled length test, halves wrapAmount, simplifies wrapped directional and point-light wrap computations (applied also in LIGHT_LIMIT_FIX), and increases shadow influence on subsurface scattering in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Frame
participant PixelShader as RunGrass.hlsl
participant TexBase as TexBaseSampler
participant Output as Color
Frame->>PixelShader: invoke per-pixel shading
PixelShader->>TexBase: Load(int3(0, int(y)-1, 0))
TexBase-->>PixelShader: texel.xyz
Note right of PixelShader: complex = (0.9 < length(texel.xyz) < 1.1)
PixelShader->>PixelShader: wrapAmount = saturate(normal.w*10.0) * 0.5
PixelShader->>PixelShader: wrappedDir = saturate(dirAngle + wrapAmount)/(1+wrapAmount)
PixelShader->>PixelShader: wrappedPoint = saturate(lightAngle + wrapAmount)/(1+wrapAmount)
PixelShader->>PixelShader: sss *= lerp(1.0, dirDetailShadow, 0.5)
PixelShader->>Output: output final shaded color
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Pre-merge checks (1 passed, 1 warning, 1 inconclusive)❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
Poem
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
✨ Finishing Touches🧪 Generate unit tests
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
package/Shaders/RunGrass.hlsl (2)
595-599: Wrap intensity halved; verify visual balance, and drop redundant saturate
- Halving wrap changes overall grass brightness and rimming; please sanity-check a few time-of-day scenes.
wrappedDirLightis already saturated; the extrasaturate()on Line 599 is redundant.- lightsDiffuseColor += dirLightColor * saturate(wrappedDirLight) * dirDetailShadow; + lightsDiffuseColor += dirLightColor * wrappedDirLight * dirDetailShadow;
617-617: SSS shadow coupling may flicker; consider a smoother maskScreen-space shadow masks are noisy; squaring the factor reduces shimmer on thin blades with backlighting.
- float3 sss = dirBacklighting * dirLightColor * saturate(-dirLightAngle) * lerp(1.0, dirDetailShadow, 0.5); + float3 sss = dirBacklighting * dirLightColor * saturate(-dirLightAngle) + * lerp(1.0, saturate(dirDetailShadow * dirDetailShadow), 0.5);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
package/Shaders/RunGrass.hlsl(4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{cpp,cxx,cc,c,h,hpp,hxx,hlsl,hlsli,fx,fxh,py}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Do not include TODO/FIXME placeholders; provide complete, working solutions
Files:
package/Shaders/RunGrass.hlsl
🧠 Learnings (1)
📓 Common learnings
Learnt from: jiayev
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-08-03T18:37:19.690Z
Learning: ISReflectionsRayTracing.hlsl and ISWorldMap.hlsl in the skyrim-community-shaders repository are image-space post-processing shaders that perform color sampling and blending operations that need proper linear color space handling for the linear lighting system. ISReflectionsRayTracing handles screen-space reflections and should use conditional Color::IrradianceToLinear/Gamma conversions similar to ISCompositeLensFlareVolumetricLighting.hlsl. ISWorldMap performs 7x7 color accumulation that should be done in linear space similar to the pattern used in ISSAOComposite.hlsl.
⏰ 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)
- GitHub Check: Build plugin and addons
- GitHub Check: Validate shader compilation (VR, .github/configs/shader-validation-vr.yaml)
- GitHub Check: Validate shader compilation (Flatrim, .github/configs/shader-validation.yaml)
🔇 Additional comments (1)
package/Shaders/RunGrass.hlsl (1)
678-679: Point-light wrap formula change: confirm parity with directional and energy feelThe simplified wrapped Lambert for clustered lights matches the directional path; good for consistency. Please spot-check near point/spot lights for over-bright grazing angles given the shared
wrapAmountfromVertexNormal.w(authoring-dependent).
|
✅ A pre-release build is available for this PR: |
Summary by CodeRabbit
Improvements
Refactor