Fog lighting

Discuss coding questions, pull requests, and implementation details.
Post Reply
User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Fog lighting

Post by pango »

I've been thinking again about this fog color issue recently.
Basically the problem is that fog receives light too, so it should look black, not grey, during the night.
However it would be wrong around sources of light, lamps, torches... I'm not sure it can be fixed in a perfectly convincing way...
Last edited by pango on Sat Dec 28, 2019 2:11 pm, edited 1 time in total.
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
King of Worms
Posts: 4752
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Fog lifghting

Post by King of Worms »

Just a note on the underwater fog.

The dungeon water fog is a abomination. You dive in a dark dungeon just to be welcomed with the bright light blue water like in the middle of the day on some exotic destination.

User avatar
jayhova
Posts: 924
Joined: Wed Jul 19, 2017 7:54 pm
Contact:

Re: Fog lighting

Post by jayhova »

The problem with fog in my estimation is that it is very poorly modeled in almost every application. Fog, in general, does not have a color. It is however reflective. So any given unit of fog, say a cubic meter, will reflect all the light in the scene where it resides. If one is looking at an object, let's say a mountain, through a significant amount of fog, some of the light from that mountain will be scattered before reaching your eye. The light you see instead will be the sum of all the light hitting the fog along the path to the object you are looking at. If you are looking at the horizon, you will see a band of light that is the sum of the light reflected from above and below the horizon.

Edit: The caveat here is that this really only applied to fog which is mostly water vapor and not to fog-like things like smoke which do have a color.
Remember always 'What would Julian Do?'.

User avatar
pango
Posts: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Fog lighting

Post by pango »

Yes, that's how it's best modeled in games, usually with proprietary tricks so it's not too expensive to render.
I'm not sure we can venture in that direction, even if the result could look very cool (have different fog densities, or even moving fog,,...)
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Fog lighting

Post by BadLuckBurt »

I'll just leave this here, I don't know how to implement this and wether it works on DFU's scale. I do know the mountains from my terrain sampler look very weird with the standard fog.

DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
DigitalMonk
Posts: 111
Joined: Sun Nov 10, 2019 8:01 pm

Re: Fog lighting

Post by DigitalMonk »

BadLuckBurt wrote: Sat Dec 28, 2019 6:34 pm I'll just leave this here, I don't know how to implement this and wether it works on DFU's scale. I do know the mountains from my terrain sampler look very weird with the standard fog.
He makes passing reference to having the particle system follow the player. This is fairly common for atmospheric effects (rain, snow, dust storms), because you don't necessarily need to render 100 square miles of fog -- just render enough in front of the player that it looks "dense enough". Also, probably not centered on the player, because the player can't see the fog that's behind them, so the emitter should be in front of the player (Unity should do view culling to ignore particles that are out of scene, but why make it work harder than it has to? For that matter, if the particle system can be pie-wedge shaped, that would probably be best -- somewhat wider angle then the FoV, so that rapidly turning doesn't let you see the lack of fog). The only trick I noticed him mention was switching the coordinate system from Local to World coordinates, so that once a particle was created, it would stay in the same world position even if the emitter moved to follow the player. You would need that for the puffs to seem real and placed in the world, instead of looking like cataracts that moved with you.

You _could_ try creating one huge fog generator over the landscape, but at least on any video card I've ever had, that would crush framerate. Alpha-blending through all of the textures is just too slow.

Then, of course, there's always using a pixel shader to implement "proper" atmospheric light scattering:
https://developer.nvidia.com/gpugems/gp ... scattering
That will be the best looking but, honestly, that's pretty low level and something that Unity ought to be providing rather than us trying to wedge that into their rendering stack...

Post Reply