Swim underwater "fog"

Discuss coding questions, pull requests, and implementation details.
Post Reply
User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Swim underwater "fog"

Post by MeteoricDragon » Fri Aug 17, 2018 12:44 pm

I was testing swimming underwater and noticed that the underwater fog is not implemented yet. Should something similar to how fog is displayed be used? If Yes, then Logically it should be pretty simple to turn on/off, just measure the elevation of the MainCamera and compare it with the water level. But Is there a command that toggles the fog on/off and adjusts the color? I'm looking at unity's website and there are options to modify fog for the scene, but since this is a script-based modification, I wonder how to make those adjustments.

User avatar
Interkarma
Posts: 5188
Joined: Sun Mar 22, 2015 1:51 am

Re: Swim underwater "fog"

Post by Interkarma » Fri Aug 17, 2018 7:49 pm

It's a little tricky even with a basic setup, as the fog settings are rather different between outdoor scenes and dungeon underwater. Some housekeeping is needed to ensure the settings remain correct based on context.

I also wanted to explore some other fog options for dungeon underwater, possibly volumetric fog matching the virtual water volume in the block itself.

Happy for you to work on this further if you want to take it on. :)

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Swim underwater "fog"

Post by MeteoricDragon » Sat Aug 18, 2018 3:10 am

Interkarma wrote:
Fri Aug 17, 2018 7:49 pm
It's a little tricky even with a basic setup, as the fog settings are rather different between outdoor scenes and dungeon underwater. Some housekeeping is needed to ensure the settings remain correct based on context.

I also wanted to explore some other fog options for dungeon underwater, possibly volumetric fog matching the virtual water volume in the block itself.

Happy for you to work on this further if you want to take it on. :)
Ok. Sounds interesting. I'm actually not very experienced with shaders.

Regarding exploring fog options, What is really inspiring is the underwater fog in Subnautica.

With DaggerfallUnity, the world is streamed into memory. In most tutorials, however, they have a world already in the editor scene. If I was to use the tools to experiment with fog look settings like this reference shows https://docs.unity3d.com/Manual/PostProcessing-Fog.html which How can I preview some fog or fog-like item in the editor?

User avatar
Interkarma
Posts: 5188
Joined: Sun Mar 22, 2015 1:51 am

Re: Swim underwater "fog"

Post by Interkarma » Sat Aug 18, 2018 12:24 pm

For this sort of work, I import a static environment into editor using tools on DaggerfallUnity Inspector and drop in a standalone player prefab where needed. Then I can add any custom objects, etc. and test as needed. Once things are working well, I convert the object to a prefab and work on instantiating at runtime.

You can also just run the game and drop in objects into the live world by switching back to editor from game view. Just keep in mind any changes made while the game is running will be lost when you stop playing.

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Swim underwater "fog"

Post by MeteoricDragon » Sun Aug 19, 2018 7:49 pm

I've gotten a good fog effect going, the problem right now is making that global fog effect appear only when underwater. I'm reading that there's a height property of global fog and for some reason, setting the height property to the waterblock level of playerEnterExit isn't working...

User avatar
Interkarma
Posts: 5188
Joined: Sun Mar 22, 2015 1:51 am

Re: Swim underwater "fog"

Post by Interkarma » Sun Aug 19, 2018 10:12 pm

Height fog can be tricky as there's some attenuation involved as well. It might be easier just to switch global fog on/off when player is submerged in dungeon water. It's basically the same check that makes the breath bar appear/disappear.

That would look less polished though, as the player can clip camera slightly through water plane before fog would trigger, showing a fog-less underwater area. Still, it might be an easier entry point before improving fog later.

I'm happy with whatever you choose to tackle here. It's going to look much better with any fog at all than none. :)

User avatar
MeteoricDragon
Posts: 141
Joined: Mon Feb 12, 2018 8:23 pm

Re: Swim underwater "fog"

Post by MeteoricDragon » Mon Aug 20, 2018 3:48 am

Interkarma wrote:
Sun Aug 19, 2018 10:12 pm
Height fog can be tricky as there's some attenuation involved as well. It might be easier just to switch global fog on/off when player is submerged in dungeon water. It's basically the same check that makes the breath bar appear/disappear.

That would look less polished though, as the player can clip camera slightly through water plane before fog would trigger, showing a fog-less underwater area. Still, it might be an easier entry point before improving fog later.

I'm happy with whatever you choose to tackle here. It's going to look much better with any fog at all than none. :)
I am seeing the problem you mention here. I got it to line up with the water level but it doesn't look right, You can be just under the surface and see horizontally across to the other side with minimal fog.

Post Reply