fix(wetness): reflection angle; clamp puddle roughness#2246
Conversation
|
No actionable suggestions for changed features. |
446261f to
98f83a8
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughIntroduces a minimum puddle roughness constant (0.05) and clamps computed water specular roughness to that minimum; in the wetness branch the shader now overwrites the screen-space normal from the wetness normal and directly sets material.Roughness to the clamped value instead of blending. ChangesWetness Puddle Specularity
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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 unit tests (beta)
Review rate limit: 5/10 reviews remaining, refill in 25 minutes and 23 seconds. Comment |
In the deferred path, the GBuffer normal was lerped between the surface normal and wetnessNormal by wetnessGlossinessSpecular. The deferred composite does one cubemap lookup using that normal, so the lerped direction is wrong for both the material's specular and the water film reflection. Since wetnessReflectance already scales intensity by wetness amount, the reflection direction should always be wetnessNormal. Puddles only form on flat surfaces (gated by vertexNormal.z), so the material's residual specular in the combined reflectance sees negligible directional error. Also clamp waterRoughnessSpecular to wetnessMinPuddleRoughness (0.05). Without a floor, max-wet puddles reach roughness=0, creating a GGX retroreflection peak roughly 30-40x stronger when facing the sun than from other angles. Real rain water is kept rough by continuous ripple disturbance; 0.05 preserves a visually glossy appearance while distributing the specular lobe across a wider solid angle. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
98f83a8 to
6830e65
Compare
Co-authored-by: Alan Tse <alandtse@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…ders#2246) Co-authored-by: Alan Tse <alandtse@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…ders#2246) Co-authored-by: Alan Tse <alandtse@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Puddles were hard to see from non-sun-facing angles even with Dynamic Cubemaps enabled.
Root Cause
Two issues in
Lighting.hlsl:1. Deferred GBuffer normal was lerped, not assigned directly. The deferred composite does a single cubemap lookup using whatever normal is in the GBuffer. Lerping
screenSpaceNormaltowardwetnessNormalbywetnessGlossinessSpecularproduces a direction wrong for both contributions — the material's specular (wants the surface normal) and the water film reflection (wants the flat puddle normal). SincewetnessReflectancefromGetWetnessIndirectLobeWeightsalready scales intensity by wetness amount, lerping the direction was double-counting the fade.2.
waterRoughnessSpecularcould reach 0 for fully-wet puddles, creating a near-singular GGX retroreflection peak roughly 30–40× stronger when facing the sun than from any other angle. The ripple normal map adds micro-variation but the GGX distribution still peaks sharply at roughness=0.Fix
Use
wetnessNormaldirectly for the GBuffer normal andwaterRoughnessSpeculardirectly for roughness when wetness is present. Water film reflects from its own surface —wetnessReflectancealready encodes how much. Puddles only form on flat surfaces (gated byvertexNormal.z), so the material's residual specular in the combined reflectance sees negligible directional error.Clamp
waterRoughnessSpecularto a named constantwetnessMinPuddleRoughness = 0.05. Real rain water is kept rough by continuous ripple disturbance; 0.05 preserves a visually glossy appearance while distributing the specular lobe across a wider solid angle.Summary by CodeRabbit