Author
Topic: Underwater debris fog issue (Read 378 times)

I just downloaded latest version of suimono (2.1.3) and I got this issue where underwater particles (debris) are only rendered on silhouettes of objects. As you can see it is simple scene with two cubes and a plane. Camera and light are added to the suimono module. Camera has underwater fog script added.

They're getting overwritten by the fog, since it doesn't detect the depth buffer in that area (no geometry being written). You can either add backgound geometry, or go into the Scripts/Suimono_UnderwaterFog.cs file and un-comment the [ImageEffectsOpaque] line around line 135. The uses for this rendering tag vary, and you might find that it causes unwanted behavior elsewhere... but it should fix the particles in this case I think.

Tried to put geometry in the background ( big plane), but it didn't work, maybr because i put it far far back.So, I edited a script, and it works!!!

Quote

The uses for this rendering tag vary, and you might find that it causes unwanted behavior elsewhere... but it should fix the particles in this case

What do you mean by that?

In my project I have 2 scenes in which i want to use Suimono, first one only underwater, and second one only above water. Since underwater scene (now fixed) works for me should I expect problems in above water scene? I should mention I disabled water transparency, since I'm developing for oculus rift

I mentioned that as a caveat only. I don't expect you to see issues by changing that line of code... but I know from previous experience that depending on what you're doing in your scene, this setting can cause compositing issues between transparent objects/fog etc.

I've had it uncommented in versions in the past, and then I always get someone with a particular issue which commenting it out fixes. Of course then there is always the other side too, as in this case. This is a case where having it one way fixes some Unity issues and causes others. But if everything is working good for you there is no reason not to keep it like this.

Transparent objects and fog are a difficult situation in Unity. There are solutions, but these are necessarily custom coded workarounds to Unity's rendering system. The ultimate problem of course is that transparent objects/particles do not write to the scene depth buffer, and thus any effect that needs to use that buffer, like the underwater fog in Suimono, are going to completely miss these objects one way or another.

The solution is to calculate fog directly in the transparent object's shader, so that it matches the image effect fog that is applied by Suimono.

Of course this won't directly work in Suimono as it uses different variables, but a similar method would be required in this case. It isn't something I've directly looked into for Suimono so I don't know how much work would be involved off the top of my head.

The only other solution I can think of is to fade out these transparent objects once they get a certain distance from the camera so that they would appear to be hidden by the fog. It isn't perfect, but it might be a better solution than seeing the particles unfogged.