Underwater fog problem

Unity version: Unity 5.1.1p3

I’m using the RenderSettings class to create an underwater fog effect which appears to be the most common way of doing this. It works fine in the Unity preview player in forward rendering mode, but in the built version it no longer works. It also doesn’t work in deferred mode either in the player or a build.

Does anyone know another way, especially to get fog working in deferred mode (is it even possible)? All my searches seem to point me to methods very similar to my own, so I’m doubtful there’s anything new there. I don’t need anything fancy here, my scenes assume underwater is dark and murky where you can barely see your hand in front of your face. Fog worked really well for that, I don’t need refraction effects or anything fancy. A post processing type of thing would be fine, probably.

Anyone have suggestions? What are people doing for this type of thing in deferred mode?

Anyone? I’m on 5.1.2p3 now, not that it matters. :stuck_out_tongue:

Deferred requires fog as post fx then to be tweaked in lighting window. It happens in 2 different places.

Thanks, I’m trying to do that but am not having much luck. Probably doing it all wrong. I put the GlobalFog script on the camera, then in the scene clicked Lighting->Fog. I’m playing with the settings but just not seeing any fog at all.

I’m starting out in one scene and then switching to a lake scene with the fog in it. That’s the scene where I’ve clicked the Fog in the Lighting window. If I just sit in that scene I can see fog in the water reflections, but nowhere else. When I hit play and go to that scene, the Fog box unchecks itself and I see nothing anymore. I can’t recheck the box either, something’s stopping me.

This is all rather confusing.

I agree, it’s confusing. by “fog box” do you mean the lighting window tickbox changes when you load the new scene, or the post fx disables itself?

Sorry, by “fog box” I meant the checkbox next to “fog” in the lighting window. It unchecks itself when I load the new scene in play mode. The Global Fog script on the camera remains checked like it should.

I don’t really want fog except underwater, so if I’m not ultimately going to be able to turn it on and off with the camera position then this is a waste of time. At this point I’m about ready to just throw a dark quad over the screen when it’s underwater and call it a day.

Wait… Think I just figured something out. My old UnderWater script that did the fog the forward rendering way was still there. When I deactivated that I could click the Fog checkbox. That script must have been turning it off then.

Thanks for the help. I’ll play with this a bit more and see if I can get anywhere.

Can’t see it real well in this pic because of quality change, but it looks like about the best I can do right now. There’s a greenish band along the the water plane, then under that (the bottom of the lake) is straight black. Same for the boat, all black.

This will be better than nothing, I guess. The forward rendering fog was really nice, if it could look a little more like that I’d be reasonably happy with it.

Anyway, thanks for the help.

You should try all this in a new project, as some assets do tinker annoyingly so with settings like a protective nanny. There is no technical reason fog would look any different in forward or deferred (if both are using post fx or global fog).

I can only assume it’s due to addons or mistakes. Bear in mind that Unity splits global fog options in lighting window and on the camera itself - something I consider absurd but there it is.

Ok, thanks. I think I’ve got it working like my old system now where it’ll turn it all on and off if camera goes above/below water. All opaque stuff is just black though regardless of my settings (so far anyway, maybe I just need to play more). I can live with that though, I’m going for the dark and murky view anyway where you can’t see anything.

I might post my scripts here later in case anyone else runs into the same problem.

Hard to see here in the screenshot, looks brighter in the game. The boat here is red which you can see shining down from above the water, but under that everything is just black as can be. It’ll work ok for my purposes, but others may not like this much.

Anyway, I’ll keep fiddling, I’m probably just missing something still.