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

Gabriel

  • Newbie
  • *
  • Posts: 3
    • View Profile
Underwater debris fog issue
« on: January 12, 2017, 04:37:02 PM »
Hi,

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.

I know it works properly in 2.1.2. I can't figure out what is wrong. 

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1479
    • View Profile
    • Tanuki Digital
Re: Underwater debris fog issue
« Reply #1 on: January 12, 2017, 05:41:41 PM »
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.

Gabriel

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Underwater debris fog issue
« Reply #2 on: January 12, 2017, 06:25:48 PM »
Thanks for such a quick response, you're great.

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

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1479
    • View Profile
    • Tanuki Digital
Re: Underwater debris fog issue
« Reply #3 on: January 12, 2017, 08:20:44 PM »
Glad it worked :)

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.

CleRIC

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Underwater debris fog issue
« Reply #4 on: June 16, 2017, 04:24:55 AM »
Sorry for necroposting  ::)

I have a similar problem and I don't know how to solve it (click video).

Suimono fog doesn't work on transparent objects if I uncomment line in "Suimono_UnderwaterFog.cs" (0-9 seconds of video)
Code: [Select]
[ImageEffectOpaque]
void OnRenderImage(...)

If I comment that line and set geometry plane in front of the camera then it gives strange effect (19-54 seconds of video).

So... How to make the suimonoFog work on transparent objects?
I will be glad to any direction where to dig to solve this problem.

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1479
    • View Profile
    • Tanuki Digital
Re: Underwater debris fog issue
« Reply #5 on: June 16, 2017, 10:50:15 AM »
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.

I've faced similar issues in Tenkoku, and I suggest a way to go about this for that system here:
http://tanukidigital.com/forum/index.php?topic=980.msg3805#msg3805

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.

CleRIC

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Underwater debris fog issue
« Reply #6 on: June 19, 2017, 04:32:11 AM »
Thank you!
I made it with your help ;)