Skip to content

Taper fog density at edge with a small gradient#1889

Open
slipher wants to merge 4 commits intoDaemonEngine:masterfrom
slipher:foggradient
Open

Taper fog density at edge with a small gradient#1889
slipher wants to merge 4 commits intoDaemonEngine:masterfrom
slipher:foggradient

Conversation

@slipher
Copy link
Member

@slipher slipher commented Feb 6, 2026

Introduce the fogGradient shader keyword as suggested in #1795 (comment), which can be used to configure a gradient for fog density that tapers to 0 at the edge of the fog. The density of the fog is scaled by a factor of 1 - exp(-k * t) where t is the distance under the fog plane and k a configurable constant.

  • fogGradient expFalloff <dist> configures the exponential falloff such that the density is at 50% of the maximum at <dist> qu from the fog plane.
  • fogGradient const does the same thing as the current default - no gradient; hard-edged fog.

Change the default to fogGradient expFalloff 5 instead of the current constant density. Before/after comparisons:

unvanquished-habitat-fog-abase-far-over

unvanquished-habitat-fog-abase-far-over

unvanquished-atcshd-fog-advgoon

unvanquished-atcshd-fog-advgoon

unvanquished-atcshd-fog-buildables

unvanquished-atcshd-fog-buildables

@slipher
Copy link
Member Author

slipher commented Feb 6, 2026

Also to show what it would like with a longer gradient, here's what the Habitat example would look like with expFalloff 30.

unvanquished_2026-02-06_034744_000

Add a shader keyword that can be used to configure a gradient for fog
density, which tapers to 0 at the edge of the fog. The density of the
fog is scaled by a factor of (1 - exp(-k * t)) where t is the distance
under the fog plane and k a configurable constant.

fogGradient expFalloff <dist>  configures the exponential falloff such
that the density is at 50% of the maximum at <dist> qu from the fog
plane.

fogGradient const  does the same thing as the current default - no
gradient; hard-edged fog.
Make the default gradient like `fogGradient expFalloff 5`. This makes
the fogs have softer edges without changing the appearance too much.
@illwieckz
Copy link
Member

Very nice!

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