EDIT: Now on Github GitHub - OCASM/SSMS: Screen space multiple scattering for Unity.

In games, fog looks pretty unrealistic:


According to this paper light scatters when traveling through fog, resulting in a blurry image, which clearly is not the case there:

http://www.cs.columbia.edu/CAVE/projects/ptping_media/

So, by repurposing Keijiro’s Takahashi’s bloom it’s possible to make a much more convincing image:


Matches reality much more closely:

The white sphere is there to show that bright pixels in the foreground don’t bleed into the background (which is what happens if you use regular bloom). With actual bloom added on top of that this is the final result:

It has a fancy name but it’s basically a DOF effect. Only issue right now is that transparent objects don’t work well with it, something to do with not being able to write their values to the depth buffer I guess. Other than that it looks great, just add it after fog in the camera stack:



2888959–212321–SMSS_Basic.unitypackage (11.4 KB)

42 Likes

That does look very very nice indeed. Can a color tint be used at all? And could this be altered for height fog like the Unity fog effect?

I just tried it in my project and it looks lovely, though when I build the game it seems to freeze the rendering, it works fine in the Editor but not in a standalone build for some reason.

Okay I really need to test this later this night. This could help to hide the billboards of my trees.

I did some tests and the answer is yes to both of them. Will release an updated version later today or tomorrow after I polish it a bit.

Yeah I screwed up. Just put the Shaders folder inside the Resources folder.

1 Like

Just tried this out, but for some reason it isn’t having any visual effect. No errors, and changing any of the properties, order in the fx stack, on, off, etc all make no difference at all.

New version: uses a slightly modified version of the Global Fog effect found in the Standard Assets. Supports both distance and height fog:

No fog:

Height fog:

Height fog + SMSS:

Height fog + Distance fog + SSMS:

No fog:

Height fog:

Height fog + SSMS:

Another benefit is that alpha blended particles no longer look like crap. OK, sometimes they do.

I should have mentioned this earlier but it only works properly on Deferred. In Forward the vertical UV coordinates are flipped so that causes some problems.

Included in the package are the SSMS files and modified versions of GlobalFog.cs and GlobalFog.shader. They need other components from the “Effects” package from the Standard Effects so make sure you have those imported beforehand.

I also uploaded a very basic project (tested on 5.5) that shows how to set it up.

2889801–212436–SSMS_UnityFog.unitypackage (17.6 KB)
2889801–212437–SSMSTest.zip (2.44 MB)

11 Likes

Very nice change, though I am getting a difference in the fog from the standard GlobalFog and your modified version which makes it unusable in my case which is a shame as it looks lovely.

What difference are you getting? For some reason when you import the updated Global fog script the shader becomes unassigned. Maybe that’s the problem?

Thought I’d post a vid
Here is the first package in my forest scene. It adds a lot of depth and is an attractive aesthetic.

6 Likes

Looks great; love the color! What are you using for rain if you don’t mind me asking?

I’m using Liquidum for the rain.

https://forum.unity3d.com/threads/liquidum-pro-v1-5-x-unity-asset.265764/page-5
Possibly a dead asset, but it still works in 5.5 for me, and I tailored it a bit for my usage case.

4 Likes

Is this 5.5 only? Neither version is working at all for me on 5.4.

I’ve only tested it on 5.5.

Another update: to avoid conflicts with the Standard Assets I copied the fog effect into another file . I also changed file names so this time in order to update:

  • Copy your settings for fog and SSMS.
  • Remove them from the camera.
  • Delete the SSMS folder.
  • Import the package.
  • Add the effects back (SSMS Global Fog and SSMS).

The downsides of ad-hoc coding :sweat_smile:. I promise next updates will be more straightforward.

The new feature is energy loss. The idea being that depending on what the fog is made of some light will be absorbed by it so the image that reaches the eye/camera is much darker. To simulate this the pixels behind the fog are darkened based on its density. This doesn’t affect the fog color.



Instead of an example project the package now includes a basic scene that shows how to setup the effect.

2890724–212528–SSMS_20161218.unitypackage (33.8 KB)

6 Likes

This is looks great, Thanks for sharing.
Btw i think it would be easier to distribute update by using a repo for this.
It seems you keep having trouble doing update :slight_smile:

1 Like

+1 for a public repository

New version looks awesome.

In the new version I have to manually enable and disable the SSMS before it starts working. If I enable it in a start function, that also doesn’t work. Is it waiting for something else to initialize?

You wanted a public repo? You got it:

https://github.com/OCASM/SSMS

Tell me if anything is broken.

The latest version requires SSMS Global Fog to be in the camera stack, before SSMS itself since it creates the necessary fog rendertexture to calculate how blurry each part of the screen should be.

5 Likes

New update: Added a slider to make the blur, well, blurrier:

Set at 1:

At 10:

At 100:

No decrease in performance, but take note that higher values = more artifacts.

3 Likes