Skip to content

fix(wetness): fix water roughness and normal#1717

Merged
doodlum merged 1 commit into
community-shaders:devfrom
jiayev:wetness-fix
Jan 15, 2026
Merged

fix(wetness): fix water roughness and normal#1717
doodlum merged 1 commit into
community-shaders:devfrom
jiayev:wetness-fix

Conversation

@jiayev
Copy link
Copy Markdown
Collaborator

@jiayev jiayev commented Jan 15, 2026

This pull request updates the wetness effects calculations in the Lighting.hlsl shader to use vertexNormal instead of worldNormal for several key computations. The changes improve the accuracy of wetness rendering by ensuring the correct normal is used for wetness-related factors, and by refining how wetness influences material roughness and normal blending.

Wetness effects improvements:

  • Changed initialization of wetnessNormal to use vertexNormal.xyz instead of worldNormal, ensuring wetness calculations are based on the actual vertex normal.
  • Updated calculation of minWetnessAngle to use vertexNormal.z for more precise wetness angle determination.
  • Modified the call to WetnessEffects::GetRainDrops to use wetnessNormal instead of worldNormal, improving raindrop placement accuracy.
  • Blended wetnessNormal with worldNormal based on puddle intensity, making the final normal more representative of wet surface conditions.

Material property adjustments:

  • Changed the interpolation of material.Roughness to use wetnessGlossinessSpecular instead of wetnessReflectance.x, providing a more consistent response to wetness glossiness in the material properties.

Summary by CodeRabbit

  • Bug Fixes
    • Improved wet-surface shading: raindrop highlights and occlusion now render more consistently.
    • Smoother puddle blending between dry and wet regions for more realistic reflectivity and roughness.
    • Enhanced overall lighting on wet materials for more accurate wetness appearance.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 15, 2026

Using provided base ref: 331b492
Using base ref: 331b492
Base commit date: 2026-01-15T18:32:24+10:00 (Thursday, January 15, 2026 06:32 PM)
No actionable suggestions for changed features.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 15, 2026

✅ A pre-release build is available for this PR:
Download

@jiayev
Copy link
Copy Markdown
Collaborator Author

jiayev commented Jan 15, 2026

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 15, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

This PR modifies the wetness shading calculations in package/Shaders/Lighting.hlsl: wetnessNormal is now initialized from vertex-space normals, raindrop and occlusion use the vertex-derived normal blended with worldNormal by puddle, and wet-surface roughness uses wetnessGlossinessSpecular instead of wetnessReflectance.x.

Changes

Cohort / File(s) Summary
Wetness shader calculations
package/Shaders/Lighting.hlsl
Switched wetnessNormal initialization from worldNormal to vertexNormal.xyz; changed minWetnessAngle to use vertexNormal.z; updated raindrop/occlusion computations to use wetnessNormal; added wetnessNormal = lerp(worldNormal.xyz, wetnessNormal, saturate(puddle)); replaced wetnessReflectance.x with wetnessGlossinessSpecular in wet roughness calculations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • alandtse
  • davo0411

Poem

🐰🌧️
I hop through normals, vertex-born,
Blend puddles where the light is warm,
Raindrops dance on glossy skin,
A shader's wink, a rabbit grin.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(wetness): fix water roughness and normal' directly and clearly summarizes the main changes, which address wetness effect calculations for both water roughness and normal mapping.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.



📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 72bcf52 and aeff7a7.

📒 Files selected for processing (1)
  • package/Shaders/Lighting.hlsl
🧰 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)

Do not include TODO/FIXME placeholders; provide complete, working solutions

Files:

  • package/Shaders/Lighting.hlsl
**/*

⚙️ CodeRabbit configuration file

**/*: When reviewing PRs, please provide suggestions for:

  1. Conventional Commit Titles (if not following https://www.conventionalcommits.org/ or
    if the existing title does not describe the code changes):
    Format: type(scope): description
    Length: 50 characters limit for title, 72 for body
    Style: lowercase description, no ending period
    Examples:

    • feat(vr): add cross-eye sampling
    • fix(water): resolve flowmap bug
    • docs: update shader documentation
  2. Issue References (if PR fixes bugs or implements features):
    Suggest adding appropriate GitHub keywords:

    • "Fixes #123" or "Closes #123" for bug fixes
    • "Implements #123" or "Addresses #123" for features
    • "Related to #123" for partial implementations

Otherwise, use your standard review approach focusing on code quality.

Files:

  • package/Shaders/Lighting.hlsl
🧠 Learnings (3)
📓 Common learnings
Learnt from: alandtse
Repo: doodlum/skyrim-community-shaders PR: 0
File: :0-0
Timestamp: 2025-06-24T07:17:36.604Z
Learning: When reviewing PRs, always clarify the scope if there are multiple related features or dependencies. WeatherPicker was a separate PR that was already merged, while this PR focuses specifically on WetnessEffects climate preset system enhancements.
Learnt from: alandtse
Repo: doodlum/skyrim-community-shaders PR: 0
File: :0-0
Timestamp: 2025-07-05T05:20:45.823Z
Learning: In the skyrim-community-shaders repository, file deletion error handling improvements that replace existence checks and try-catch blocks with std::filesystem::remove error-code-based approaches are considered bug fixes rather than refactoring, as they address inadequate error handling and misleading log messages.
Learnt from: jiayev
Repo: doodlum/skyrim-community-shaders PR: 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.
📚 Learning: 2025-08-03T18:37:19.690Z
Learnt from: jiayev
Repo: doodlum/skyrim-community-shaders PR: 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.

Applied to files:

  • package/Shaders/Lighting.hlsl
📚 Learning: 2025-08-17T18:37:35.839Z
Learnt from: CR
Repo: doodlum/skyrim-community-shaders PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-17T18:37:35.839Z
Learning: Applies to features/*/Shaders/**/*.{hlsl,hlsli,fx,fxh} : Avoid GPU register/buffer conflicts in HLSL; verify register usage (e.g., with hlslkit buffer scanning)

Applied to files:

  • package/Shaders/Lighting.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). (4)
  • GitHub Check: Validate shader compilation (Flatrim, .github/configs/shader-validation.yaml)
  • GitHub Check: Run Shader Unit Tests
  • GitHub Check: Validate shader compilation (VR, .github/configs/shader-validation-vr.yaml)
  • GitHub Check: Build plugin and addons
🔇 Additional comments (3)
package/Shaders/Lighting.hlsl (3)

2306-2341: LGTM! Using vertex normal for wetness calculations is a sensible improvement.

The switch from worldNormal to vertexNormal for wetness angle and raindrop calculations is physically more accurate—water accumulation and flow should respond to the macro-scale geometry rather than fine surface details from normal maps.


2368-2370: LGTM! The puddle-based normal blending creates smooth transitions.

The interpolation correctly transitions from the textured worldNormal (no puddle) to the flatter vertex-derived wetnessNormal with ripple effects (full puddle), which matches expected visual behavior for water pooling on surfaces.


3171-3176: LGTM! This fix correctly aligns roughness interpolation with the normal blending.

Using wetnessGlossinessSpecular (which directly represents wetness glossiness based on puddle/shore effects) is semantically correct and consistent with the normal lerp on line 3173. The previous use of wetnessReflectance.x was inconsistent since wetnessReflectance represents indirect specular reflectance weights rather than surface glossiness.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@doodlum doodlum merged commit 7ee4c02 into community-shaders:dev Jan 15, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants