Skip to content

feat(height fog): separate inscattering color settings#2301

Merged
doodlum merged 4 commits into
community-shaders:devfrom
jiayev:fog-update
May 9, 2026
Merged

feat(height fog): separate inscattering color settings#2301
doodlum merged 4 commits into
community-shaders:devfrom
jiayev:fog-update

Conversation

@jiayev
Copy link
Copy Markdown
Collaborator

@jiayev jiayev commented May 9, 2026

This pull request introduces significant improvements and new features to the Exponential Height Fog system, focusing on enhanced physical realism, greater artistic control, and improved integration with vanilla fog. The most important changes include the addition of a physically-based inscattering model using the Henyey-Greenstein phase function, new settings for controlling fog color and sunlight attenuation, and options to blend or disable vanilla fog. The UI and serialization logic have also been updated to support these new parameters.

Physically-based fog and inscattering improvements:

  • Implemented the Henyey-Greenstein phase function for directional inscattering, allowing for anisotropic (directional) light scattering effects and more realistic fog appearance. The new parameter directionalInscatteringAnisotropy replaces the old exponent-based model. [1] [2] [3] [4] [5] [6] [7]

  • Added new fog color blending controls: fogInscatteringColor (custom color added to fog), and originalFogColorAmount (controls blending between the original and custom fog color). These are exposed in the UI and weather variable registry. [1] [2] [3] [4] [5]

Sunlight and vanilla fog integration:

  • Introduced sunlightAttenuationAmount to control how much direct sunlight is attenuated by the exponential height fog, improving control over sunlight/fog interactions. [1] [2] [3] [4] [5]

  • Added disableVanillaFog option and blending logic, allowing users to disable vanilla fog entirely or blend it with exponential height fog. All affected shaders now respect this setting, and the UI exposes a checkbox with a tooltip. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

UI, serialization, and versioning updates:

  • Updated the UI to support new sliders and color pickers for the added settings, including detailed tooltips for advanced parameters.
  • Extended serialization, weather variable registration, and versioning to include all new parameters. [1] [2] [3] [4] [5]

These changes provide both improved physical accuracy and greater flexibility for artists and users configuring the fog system.

Summary by CodeRabbit

  • New Features

    • Fog inscattering color and original-fog mixing controls.
    • Directional inscattering anisotropy (Henyey–Greenstein) and sunlight attenuation amount.
    • "Disable Vanilla Fog" toggle to choose vanilla vs exponential fog behavior.
  • Improvements

    • Updated fog blending to overlay/compose vanilla and exponential height fog more predictably.
    • More physically based directional inscattering and improved dynamic cubemap tinting.
  • Other

    • Feature version bumped.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 389963e0-9996-45eb-b8c2-7f93d8aea4c0

📥 Commits

Reviewing files that changed from the base of the PR and between 6856c81 and 516249d.

📒 Files selected for processing (1)
  • package/Shaders/Water.hlsl
🚧 Files skipped from review as they are similar to previous changes (1)
  • package/Shaders/Water.hlsl

📝 Walkthrough

Walkthrough

Reparameterizes exponential height fog: replaces directional exponent with Henyey‑Greenstein anisotropy, adds sunlight attenuation and inscattering color controls, exposes a “disable vanilla fog” toggle, and updates multiple shaders to layer and optionally bypass vanilla fog when composing exponential fog.

Changes

Exponential Height Fog Enhancement

Layer / File(s) Summary
Data Contracts & Settings Structure
src/Features/ExponentialHeightFog.h, package/Shaders/Common/SharedData.hlsli
ExponentialHeightFogSettings replaces directionalInscatteringExponent with directionalInscatteringAnisotropy; adds sunlightAttenuationAmount, disableVanillaFog, fogInscatteringColor, originalFogColorAmount; padding adjusted and struct size contract updated to 6 × float4.
Shader Math & Phase Functions
features/Exponential Height Fog/Shaders/ExponentialHeightFog/ExponentialHeightFog.hlsli
Added ShouldDisableVanillaFog() and HenyeyGreenstein(cosTheta, g). GetExponentialHeightFog composes inscattering color (alpha-driven mix + optional cubemap tint), uses Henyey‑Greenstein for directional inscattering, and applies (1 − expFogFactor). GetSunlightFogAttenuation computes slope-integral only above a lightDirZ threshold and blends via sunlightAttenuationAmount.
Shader Fog Composition
package/Shaders/Effect.hlsl, package/Shaders/ISSAOComposite.hlsl, package/Shaders/Lighting.hlsl, package/Shaders/Water.hlsl
Shaders now preserve vanilla fog outputs, compute exponential height fog separately, and perform layered blending where vanilla fog may be applied first or bypassed based on ShouldDisableVanillaFog().
Configuration & Serialization
src/Features/ExponentialHeightFog.cpp, features/Exponential Height Fog/Shaders/Features/ExponentialHeightFog.ini
JSON serialization and ImGui updated for new parameters; weather variable registrations added/updated; INI Version bumped to 1-2-0.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • doodlum
  • davo0411
  • Dlizzio

Sequence Diagram(s)

sequenceDiagram
  participant Settings as Settings/UI
  participant Weather as Weather Registry
  participant Shader as Pixel Shader
  participant Pixel as Pixel Output

  Settings->>Weather: register new variables (inscatter, anisotropy, attenuation, disable flag)
  Pixel->>Shader: sample scene color, vanilla fog
  Shader->>Settings: query exponentialHeightFog settings
  Shader->>Shader: compute exponential inscatter (HenyeyGreenstein, sunlight attenuation)
  Shader->>Pixel: blend vanilla and exponential layers (maybe bypass vanilla)
Loading

Poem

"I'm a rabbit in the mist, I tweak the light with care,
I mix the vanilla fog with anisotropic flare,
Henyey's curve I hum along the breeze,
Sunlight softens, colors blend with ease,
Hop — the world grows dreamy, wrapped in gentle haze."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the primary change: adding separate inscattering color settings to the height fog system, including new color controls and blend factors.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
package/Shaders/Water.hlsl (1)

1282-1295: ⚡ Quick win

Extract the new water-fog blend into a helper.

These two blocks are effectively the same implementation with different local variable names. Pulling them into a small helper would keep future ShouldDisableVanillaFog() changes in one place and reduce the odds of the two water paths drifting apart again.

Also applies to: 1333-1346

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package/Shaders/Water.hlsl` around lines 1282 - 1295, Extract the repeated
water-fog blending logic into a small helper function (e.g., BlendWaterFog) and
replace the duplicated blocks in both branches (the block under
ExponentialHeightFog::ShouldDisableVanillaFog() and the else block, and the
similar occurrence at lines ~1333-1346) with calls to that helper; the helper
should accept the inputs fogColor, finalColorPreFog, eyeIndex, fogDistanceFactor
and exponentialHeightFog.w (or the full exponentialHeightFog.xyz and .w if you
prefer) and perform the GetWaterFogFade(eyeIndex) multiplication and the two
lerp blends currently done with fogDistanceFactor and exponentialHeightFog.w so
both paths use the exact same implementation and names are unified.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package/Shaders/Water.hlsl`:
- Around line 1333-1346: The refraction path still forces fogFactor = 0 for
exponential fog, which breaks the new disableVanillaFog toggle; update the
refraction handling (the code that sets fogFactor and computes
refractionColor/finalColorPreFog) to honor
ExponentialHeightFog::ShouldDisableVanillaFog(): either gate the zeroing of
fogFactor with ExponentialHeightFog::ShouldDisableVanillaFog() or apply the
exponential fog blend (using exponentialHeightFog.xyz, exponentialHeightFog.w
and GetWaterFogFade(eyeIndex)) to refractionColor just like the non-refraction
path does; ensure you touch the logic that computes finalColorPreFog,
refractionColor and fogFactor so the new toggle is consistently respected.

---

Nitpick comments:
In `@package/Shaders/Water.hlsl`:
- Around line 1282-1295: Extract the repeated water-fog blending logic into a
small helper function (e.g., BlendWaterFog) and replace the duplicated blocks in
both branches (the block under ExponentialHeightFog::ShouldDisableVanillaFog()
and the else block, and the similar occurrence at lines ~1333-1346) with calls
to that helper; the helper should accept the inputs fogColor, finalColorPreFog,
eyeIndex, fogDistanceFactor and exponentialHeightFog.w (or the full
exponentialHeightFog.xyz and .w if you prefer) and perform the
GetWaterFogFade(eyeIndex) multiplication and the two lerp blends currently done
with fogDistanceFactor and exponentialHeightFog.w so both paths use the exact
same implementation and names are unified.
🪄 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: bc687227-9f8d-46de-9131-5827803dde13

📥 Commits

Reviewing files that changed from the base of the PR and between 58d53e3 and 6856c81.

📒 Files selected for processing (9)
  • features/Exponential Height Fog/Shaders/ExponentialHeightFog/ExponentialHeightFog.hlsli
  • features/Exponential Height Fog/Shaders/Features/ExponentialHeightFog.ini
  • package/Shaders/Common/SharedData.hlsli
  • package/Shaders/Effect.hlsl
  • package/Shaders/ISSAOComposite.hlsl
  • package/Shaders/Lighting.hlsl
  • package/Shaders/Water.hlsl
  • src/Features/ExponentialHeightFog.cpp
  • src/Features/ExponentialHeightFog.h

Comment thread package/Shaders/Water.hlsl
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

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

@doodlum doodlum merged commit c1a200e into community-shaders:dev May 9, 2026
15 checks passed
This was referenced May 16, 2026
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.

2 participants