- Home /
Ugly artefacts with SSAO and particles!
Hi there!
I'm currently using the standard unity SSAO effect in my project. And of course I'm using particles as well. But in combination with SSAO this leads to really ugly artifacts! Somehow the SSAO shines THROUGH the particles. Here two screenshots to show that:
With SSAO enabled:
But that should look more like this (WITHOUT SSAO):
Does anyone know how this problem can be solved? I have already tried all provided material shader for particles, but it's the same with any of them.
It probably has to do something with the particle not writing any Z-Value into the Depth-Buffer. But if they were, then SSAO would kick in on them as well, which would be even worse. $$anonymous$$aybe someone has a particle shader, where this problem does not occur? Would be a big help!
Answer by umauj · Feb 16, 2012 at 03:33 PM
Since the suggested approach did not work entirely (I did not manage to get the proper depth-testing for the second camera), I now found a working solution. This works due to the new feature supported in 3.5: There you can tell via an attribute, that a certain PostscreenEffect has to be applied to opaque geometry only, which solves everything.
In my case I just opened the SSAO script and added the attribute above the OnRenderImage method, like this:
[ImageEffectOpaque]
void OnRenderImage (RenderTexture source, RenderTexture destination)
Answer by Statement · Feb 04, 2012 at 01:33 PM
I think you need to render your particles through a different camera. The reason you're getting artifacts is because SSAO is a post-process screen shader that take depth values into account. This means the AO shading is added at a later stage, after geometries (and your particles) are painted.
You should add another camera that have a larger depth than your main camera. This camera shouldnt have to clear anything and should only render a layer that you set your particles to use. You should also clear the particle layer from the main camera.
This way the scene (without particles) with SSAO is rendered first. Next, the scene will be rendered with only the particles added on top of your first pass. Think of it like layers in photo shop.
I tried that out now, but somehow the SSAO step is only applied if it is added to the last camera (that with the highest depth). Which is, of course, the opposite of what I wanted to achieve. If I let the SSAO in the first cam, and then render the second camera with the transparent effects, the SSAO is not shown. Don't know why...
EDIT: I found out just now, that I have to switch the FX-camera to forward rendering. As soon as I do that, the SSAO shining-through-problem is solved. BUT: Now the second camera does not use the depth-buffer of the first... so there are no Z-Tests available! :-(
Has anyone an idea?
Does anyone know how to make the second-camera (which uses the forward renderer) use the depth-buffer of the first camera (which uses the deferred renderer)?
Your answer
![](https://koobas.hobune.stream/wayback/20220613063632im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Best way to spawn new particles 0 Answers
How to make parabolic particle form? 1 Answer
How to make windswept snow on mountains? 0 Answers
particle system problem. 1 Answer
How do i create an ink trail 1 Answer