Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Lightning fast, quality occlusion: Simple SSAO

Discussion in 'Assets and Asset Store' started by arkano22, Feb 28, 2016.

  1. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi guys,

    I´ve implemented the algorithm described in this article I wrote some years ago:

    http://www.gamedev.net/page/resourc...a-simple-and-practical-approach-to-ssao-r2753

    And enhanced it with the latest advances in SSAO: an approximate separable kernel, and interleaved sampling. The result is an extremely fast, very high-quality SSAO filter that can be used virtually everywhere. You don´t have to take my word for it. Here's a video:



    The occlusion for these screenshots was calculated in less than 2.5ms / frame in an Intel HD graphics 4000, at full resolution:





    The asset has already been submitted to the Asset Store and is waiting for validation. Stay tuned!
     
    Last edited: Feb 29, 2016
    nxrighthere and theANMATOR2b like this.
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Pretty interested! Does it use unity's deferred for any speedups as in your article?
     
  3. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    It uses Unity's standard _CameraDepthNormalsTexture, which I assume is reused in the deferred pipeline, so yes. It does not generate any custom intermediate buffers apart from the AO buffer itself.

    Per-pixel positions (which are needed instead of plain depths in my original algorithm) are reconstructed from depths at the cost of 1 vector multiply per sample in the fragment shaders.
    Most people reconstruct this by multiplying by the inverse projection matrix per-fragment, which is not exactly fast.
     
    Last edited: Feb 28, 2016
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Great stuff. I assume it works on a PS4 just fine and that level of hardware would probably make this immeasurable cost, say <0.2ms? :D
     
    arkano22 likes this.
  5. zugsoft

    zugsoft

    Joined:
    Apr 23, 2014
    Posts:
    453
    Great, he works on forward?
     
  6. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Yes, it works in all rendering paths. Forward, deferred, legacy deferred and vertex lit.
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Your technique has a fundamentally slow flaw :(

    It has to wait for asset store.
     
  8. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Very true! hahaha. Due to this flaw, it takes about 5 days to get the occlusion going instead of a few milliseconds...:p
     
  9. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Looks Great!
    I didn't understand any of this but as long as I can incorporate it without tweaking any code and its fast and makes my art look prettier - it sounds awesome!
     
    arkano22 likes this.
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Does the effect get slower as you approach it due to cache misses, and what happens in the far distance? is there a fall off?
     
  11. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Cache misses with big radiuses (such as when the camera gets close to a surface) cannot be easily avoided. However, interleaved sampling takes advantage of the cache, as the sampling pattern is not random. That helps quite a lot with this issue.

    There's a "Min radius" parameter, which clamps the radius so that it doesn´t become very small. So you can still get some occlusion on far away mountains, for example, which looks pretty good. If the radius turns out to be 0 (when looking at the void, for instance) the algorithm is guaranteed to return 0 occlusion.

    In future versions I might include a falloff, as I understand that for some users having occlusion in such distant stuff is not desirable.
     
  12. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Yep. It is 100% plug&play. If you like to fiddle with sliders, checkboxes and similar stuff, then plug&tweak&play. But you will have to write zero code when using it. :)
     
    theANMATOR2b likes this.
  13. SAOTA

    SAOTA

    Joined:
    Feb 9, 2015
    Posts:
    220
    Good work. Nice read!
     
  14. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    I´ve added a video to the original post, so that you can see the effect in motion.
     
  15. Olafson

    Olafson

    Joined:
    Aug 7, 2012
    Posts:
    255
    How fast is it, compared to other SSAO solutions? Like lets say, Unitys Standard and SSAO Pro?
     
  16. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    I´ve compared it to SESSAO (Sonic Ether's) and it is about 1ms faster depending on the screen resolution, with similar quality (color bleeding disabled in sessao). Compared to Unity Standard it is about 2.5 times faster.
     
  17. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Hi,

    Unity 4 ou 5?
    Dx 9 or Dx11?
     
  18. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Unity 5. Dx9 and Dx11.
     
  19. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Thanks for the reply.
     
    arkano22 likes this.
  20. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Some more screenies, this time from the viking village, which is an open environment.
    This runs in 3.2 ms at 1440 x 900, using 32 samples per pixel and a fairly big radius.

    As I wrote before, such big radiuses are no problem for the algorithm as it runs 4 times at half-resolution, using the same sampling pattern for all pixels in each one of the 4 buffers, and then reconstructs the full-res image using a special filter. This way cache misses are greatly reduced as all fetches in each pattern are completely coherent, and the quality is not compromised at all.

    Unity's standard SSAO spends 10.3 ms for the same scene and the result is very blotchy.



     
  21. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    For the first update after the initial release, I´ve added color bleeding, which is pretty easy to do once the initial algorithm is in place. The fetching pattern is exactly the same as with AO only, so the only extra cost is the color buffer fetches and a couple of dot products per sample. It is optional, so if you set its intensity to zero it is not calculated at all.

    In this gif you can see the same scene with no SimpleSSAO, AO only and AO+color bleeding.

    color_bleeding.gif

    Now I´m looking for a way to plug-in the ao and bleeding buffers into unity's lighting pipeline instead of doing a simple blend on top of the final image.
     
    elias_t and larku like this.
  22. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi again,

    I´ve managed to integrate the AO buffer generated by SimpleSSAO into Unity's lighting pipeline, using command buffers. This has 2 great advantages:

    - Instead of just being multiplied on top of the final image as usual, the AO term is used in the lightning equations. This is important for a realistic look, because as the name implies, Ambient Occlusion should only occlude ambient lightning. Specular highlights and colors in the HDR range aren't affected at all. This way SSAO looks like real AO should, instead of looking like grayish dirt around objects.

    - SSAO can be controlled on a per-object basis. Or more specifically, per material. You can select which materials are affected by SSAO and how much. This works by plugging the SSAO term into the ambient term of the Standard shader. So it works with pretty much any shader you´re using, and if it doesn´t, you´re only one texture lookup away from making it work.

    Here you can see the difference between regular multiplicative blending, and lightning pipeline integrated SSAO. You will be able to select one or the other, depending on which you like best:

    IntegratedAO.gif
     
  23. zugsoft

    zugsoft

    Joined:
    Apr 23, 2014
    Posts:
    453
    Did you test on Mobile?
     
  24. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Yes, it runs fine in my iPhone 4S. However I haven´t tested on Android yet.
     
  25. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    Hi
    Yeah, integrated looks so much more natural. I would also ask, if this works on my Mac.
    I´ve made bad experience not to ask, lately :rolleyes:

    Cheers
    Michael
     
  26. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    I develop on Mac, so if anything it will be where it works best.
     
  27. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    Yeah, I know!
    Great! Wait for it!
    Michael
     
  28. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    791
    Looks very promising!
    So you're using deinterleaved texturing, interesting. Did you got texture arrays to work in Unity ?
     
    arkano22 likes this.
  29. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Will you be adding even more speed gains such as lower res and so forth? any other toys to set it apart from SSAO Pro which we currently use? Love bleeding, wondered if there are other things it can do. You mentioned per-material tweaks, which is exciting, perhaps we can use it for highlighting or something yet undiscovered :)
     
    Brity likes this.
  30. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Texture arrays are planned for 5.4, which is released in a couple weeks (theoretically speaking...:rolleyes:). In absence of texture arrays, what I did was lerping between 4 texture fetches depending on the modulo of uv coordinates. It's not as fast as it could be, but its still faster than jittered sampling. Once texture arrays are available in Unity I´ll be the first to make use of them, haha.

    The first version (still waiting for approval) uses 2x2 interleaved sampling, but I have a 4x4 version already in place, which is slightly faster and gives even better quality. Low radii suffer a bit though, since samples "snap" to a 4x4 grid so the quality isn´t that great compared to 2x2. 4x4 forces me to make 16 texture reads instead of 4, or use conditional branching (branching is faster in my tests). So I hope texture arrays will be even more helpful in this case. ;)
     
    hopeful likes this.
  31. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Downsampling (lower res) doesn't really improve speed in this case, due to the sampling method i´m using. Lower res allows you to use larger radii and increases the chance of hitting the cache, but interleaved sampling already takes care of that. So sampling at half-resolution doesn´t give an acceptable quality/speed ratio anymore.

    This is the paper explaining the idea behind SimpleSSAO's sampling. It was used in Nvidia's HBAO+. If you like technical stuff is worth a read, really simple method with spectacular results:

    https://developer.nvidia.com/sites/default/files/akamai/gameworks/samples/DeinterleavedTexturing.pdf

    Per-material tweaks will be only available in forward-rendering I´m afraid, at least for now. Doing it in deferred would require an additional material-ID pass which I´m not sure is worth the effort. We'll see. :)
     
    Brity and hippocoder like this.
  32. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    Could you show samples with speedtree and terrain foliage? Also with cutout and transparency.

    How do performances and quality compare to ssao pro?

    Can you change ssao color?

    How does SSAO compare to HBAO, They look different but I can't tell how.

    How does color bleeding work and what controls do we have? Bounce distance/intensity? is intensity control capped or can it be amplified?


    Your cornell box video looks good so I embed it (you should in your first post, also add a link to your asset for the impulse buy).
     
    Last edited: May 13, 2016
  33. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    We have:

    - Simple SSAO (arkano22)
    - Amplify Occlusion (Amplify Creations)
    - HBAO (Michael Jimenez)
    - SSAO Pro (Thomas Hourdel)
    - SESSAO (SonicEther)
    - Unitys Cinematic Effects(BETA) Ambient Occlusion

    Forgot something?

    Someone has time and money to buy and compare them all? o_O
     
    laurentlavigne and larku like this.
  34. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    Hourdel's SSAO Pro and the new Unity AO may be the same thing, as he is working for Unity now, and other assets of his have become part of Unity.
     
  35. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    791
    AFAIK the new Unity Cinematic AO is based on Keijiro's work rather than SSAO Pro. From what I've tested this new AO is far to be as performant as the solution from Mr Thomas Hourdel.
     
  36. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi there,

    Yes, there's lots of SSAO variations out there. To be honest, almost any of them will do the job, and the difference is in the details. It is up to the user to make it look good in their game (which most of the time is a matter of not going apesh** crazy with the effect intensity, as i´ve seen people often do). To the untrained eye, they will all look the same or very similar.

    I´ve compared SSAOPro and SESSAO with my algorithm. SSAO Pro uses the same basic occlusion function, which is something I wrote an article about like 9 years ago, since then a lot of people have adopted it mainly because it is easy to implement and looks good. SESSAO is a bit more involved mainly due to the color bleeding (which has no physical basis whatsoever, at least not an obvious one upon inspecting its code). Both of them do a nice job.

    However, most of these algorithms use random sampling. Basically they just take random samples around each pixel in the screen, calculate occlusion for each one of them, then blur the result to get rid of the resulting noise. This can look good, but there's two problems:
    • It is anti-cache: the random nature of the memory accesses makes it slow. the GPU cannot predict where you are going to sample next, so it is constantly fetching the wrong addresses.
    • The result is not coherent. This means you need big blurring kernels to make it look smooth, because each pixel's neighborhood occlusion values have high variance.
    So the result usually looks blotchy, and the only way to fix that is moar blurring. This removes fine-scale detail and cranks up the cost.

    Nvidia's HBAO+ however uses a very clever solution to this, which is the same I use: interleaved sampling. Won´t go into technical details, but it solves both issues: The GPU cache is happy as it can easily predict the sampling pattern, and you only need a blur kernel size of the same size as your interleaving pattern (which is usually 2x2 or 4x4) for near-perfect, blotch free results. This is both faster and looks better than random sampling. No need to do SSAO at half resolution either. I also combined it with this paper for further speed.

    However the occlusion function used by HBAO+ is very slow, so I used the faster one I described in the article. The results are faster than HBAO+ and of better quality than most other algorithms that use random sampling.

    Of course this is all just technical gibberish of little interest to the end user. I´m not trying to sell my product (not making a dime out of it anyway lol), just giving reasons why I think it is conceptually better. I´m happy to talk about graphics and SSAO with anyone so feel free to ask and/or give your opinion on the subject.

    The moral of the story is: just buy the SSAO that looks best to you and you feel more comfortable using. Then, make good use of it as that's where the key resides. Your users are not likely to appreciate the difference between different algorithms, but will immediately notice intrusive and exaggerate usage of SSAO.

    That is, unless you use Unity's default one. God, it's ugly :eek:.
     
    Last edited: May 15, 2016
  37. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi Laurent, almost missed your post!

    Mine is a bit faster than SSAO Pro, and the quality is better. However SSAO Pro use more samples to achieve a similar look, so at the same sample count the speed gap is smaller. Comparing them is not an exact science i'm afraid.

    There's no built in control to change the occlusion color, but it's dirt cheap and easy to add so count on having it in the next release.

    HBAO uses a different occlusion function to calculate ao for each sample. If we are talking about the classic HBAO approach, I know for a fact it's slower. Looks a bit different also.

    There's both bounce distance and intensity controls. Both are capped to sane values, but you can remove the capping by modifying a couple attributes in the source code.
     
  38. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    I remember reading a paper about some-AO, from Naughty Dogs I think, where it showed great occlusion under tables, which standard SSAO failed to give. Since we use AO to make volume more readable, that was awesome to see. How does your implementation handle table shadows?

    Snow doesn't show much occlusion, or if there is occlusion it's blue colored, is it something doable in your plugin?

    Enlighten being what it is, I no longer need to flag geometry as static since Gi doesn't really work anymore so it's really freed my level design a lot. But I still want my light bounce, you know, that super soft look you get. I wonder if adding another simpleSSAO on top of the base one would emulate 2 bounce lighting?

    By the way, haven't seen any example with foliage, how does it fare?
     
  39. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Yes, all screen-space based occlusion approaches have the same weakness: they cannot account for occlusion from stuff you can´t see onscreen. The underside of a table, for instance, should cast really nice occlusion on the floor beneath it, right? well, not with SSAO. Since the underside of the table isn´t actually rendered if you cannot see it, the floor under it shows no occlusion. Same for stuff outside of the view frustum.

    My method has an optional extension to account for backfaces inside the view frustum, you can check the article and you´ll see I mention it and make some comparisons. It allows the table to occlude the floor under it, however this doubles the cost of the effect as you need to repeat for backfaces everything you do for front faces, so it's usually deemed not worth it for games.

    Sure, snow occlusion is not a problem. Though what you describe is more of a combination of occlusion + scattering.

    SimpleSSAO can emulate local 1 bounce of indirect light. It is great for adding some high-frequency details, but not really good for that soft look you mention. Realtime multi-bounce dynamic GI is still quite expensive to do...but hey, a few years ago even simple GI was unthinkable so we might see this stuff happening soon!

    I saw some quite promising results from Sonic Ether, I think he uses a variation of reflective shadow maps for his GI effect. Not sure if it can be extended to multiple bounces though.
     
    m4d and laurentlavigne like this.
  40. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Thanks very much for the technical backgrounds!
     
  41. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    That did it so I bought it - but where is this option in the inspector?
    I'm having a few problems:
    1. The inspector doesn't respond some time the visualization need me to unfocus then focus back, possibly one of the many 5.4 bugs but maybe your editor script has bugs.
    2. Integration Integrate looks good but no color bleeding?
    3. How do I increase the intensity of color bleeding?
    4. AO shadow color coming when?
    5. Grass transparency works but foliage transparency is broken, if you switch to AO visualization you can see this:
    Screen Shot 2016-05-15 at 5.26.38 PM.png

    Fram afar AO looks really good
    Screen Shot 2016-05-15 at 5.24.34 PM.png
    but as you get closer it fades away.
    and strange zebra patterns on the ground around the camera
    Screen Shot 2016-05-15 at 5.30.33 PM.png
    settings I use:
    Screen Shot 2016-05-15 at 5.31.10 PM.png
    Now playing with bleeding (fake GI)
    It doesn't seem to work in deffered linear
    Screen Shot 2016-05-15 at 5.46.15 PM.png
     
  42. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    Also the AO depends on the view angle, probably an effect of screen spaceness and can be mitigated by cranking up vignetting to 9000... but still would be nice to lower discrepancy.
    On a sidenote, it would be nice to control power distribution of oclusion intensity, this way I get AO on every nook but the AO doesn't darken to black... probably having AO color will solve that.

    Screen Shot 2016-05-15 at 5.55.49 PM.png Screen Shot 2016-05-15 at 5.55.58 PM.png
     
  43. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    Hi Laurent,

    1. What do you mean by "unfocus" and "focus back"? do you mean Unity's window? I haven't had this problem (Unity 5.3.4). The editor script generates a CommandBuffer that is added to/removed from the camera, nothing too fancy.

    2. There is color bleeding in "Integrate" mode, but only in deferred. In forward rendering, there is no easy way to get access to any color buffer since AO is applied per-object as they get rendered. The only way to get color bleeding in this combination (Integrate + forward) would be to re-render everything a second time just for this, which is a bit overkill in my opinion. Technically feasible, but I doubt the cost/relevance ratio would convince anyone.

    Always take a look at the 3 indicators at the bottom of the effect in the inspector, as they tell you what works and to which level for the current rendering combination (deferred + integrate, forward + integrate, deferred + multiply, forward + multiply)

    3. To increase bleeding intensity, use the "Bleeding Intensity" parameter ;).

    4. Probably in a week or so, as I´m pretty busy right now.

    5. Cannot reproduce it here. Which shader are you using for foliage? Is it an alpha cutoff shader?

    About color bleeding in deferred linear, it works. However by looking at your screenshots, I see you're in "Multiply" mode. Switch to "Integrate" for better results, as multiplying the GI on top of the image can only darken/tint colors but will not add any extra lighting. This gives very subtle results most of the time.
     
  44. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    1. Yes in unity's window. it may be a 5.4 new "feature" so I wouldn't bother but just be aware that command buffer sometimes don't get added so you probably need to add extra checks.
    2. Deferred is fine, I just couldn't get integrate to work, must be related to editor bug in 1.
    3. I cranked it to 50 and with integrate I'm getting some pretty awesome results for a cartoony look - subtlety is so overrated ;)
    4. OK
    5. using speedtree foliage shader, tree designer shader works fine
    6. AO density varies a lot as I get closer
    7. tons of artifacts and variation when changing camera ange Screen Shot 2016-05-15 at 8.31.00 PM.png Screen Shot 2016-05-15 at 8.31.15 PM.png
    8. I'll eventually go for a flat cartoony look and notice dithering pattern a lot, blur 1 or 2 doesn't blur the AO, it spreads the dither. Screen Shot 2016-05-15 at 8.35.47 PM.png
    9. artifacts when moving May 15, 2016 20:58.gif
     
    Last edited: May 16, 2016
  45. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    1. No idea, for me command buffers have always worked well. Truth is I haven´t tried 5.4 yet so it might be a "feature" :p.

    5. For me the Nature/Speed tree shader, set to "leaf" or "frond" works perfect, just like a cutout shader should. Tree Creator Leaves also works well. Make sure your alpha cutoff is not zero!

    Definitely there's something weird going on there, specially with the dithering pattern (which is the unblurred output of the algorithm) and the artifacts. Seems like the blur is not working at all for some reason. Can you share your scene with me so that I can take a look?

    cheers!
     
  46. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    Sure, I PM-ed you the link. Good luck with 5.4 ;)
     
  47. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    Screen Shot 2016-05-17 at 1.56.22 PM.png Screen Shot 2016-05-17 at 1.56.30 PM.png Another thing I'd like to either understand or see an extra setting for is grass occlusion. It's a nature terrain shader and I'm having difficulty increasing AO density of the grass without blasting the rest of the scene.
    Note that the darkness at the base of a strand of grass is texture ramp, not AO effect.

    Man, you need to add tooltips to those sliders.
     
  48. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    @arkano22 your inspector is not working because you don't recreate the CB once you clear it.
    You need to add SetupCommandBuffer once the value has changed. Like this:
    Code (CSharp):
    1.         public VisualizationMode Visualization{
    2.             get{return m_Visualization;}
    3.             set{
    4.                 if (value != m_Visualization){
    5.                     CleanupCommandBuffers();
    6.                     m_Visualization = value;
    7.                     SetupCommandBuffers ();
    8.                 }
    9.             }
    10.         }
    EDIT: On once scene this works but the one I sent you, it doesn't... probably another one of those 5.4 "feature" ;) The fix is to toggle the camera off then back on, which is awesome workflow. @Aras fix this please !!

    Code (CSharp):
    1.             bool oldCameraEnable = GetComponent<Camera> ().enabled;
    2.             GetComponent<Camera> ().enabled = false;
    3.             GetComponent<Camera> ().enabled = oldCameraEnable;
     
    Last edited: May 17, 2016
  49. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,891
    HI Laurent,

    Glad you got your parameters right ;). About grass, I suppose your textures are not dense enough to generate as much occlusion. There's no easy way to change occlusion parameters depending on the specific shader, as this is a fullscreen effect...I guess your best bet here is to just bake the grass occlusion, or use a ramp as you´re doing now. Anyway, grass is not that dynamic so baked occlusion is going to look better.

    Not sure what you wrote about the inspector not working? There's no need to re-create the command buffer after it has been cleared, as it is cleared and regenerated every frame before rendering the camera. Also once you´ve added a command buffer to a camera, you can clear and re-generate it as many times as you want, no need to re-add it either.

    I suppose the issue is that Unity does not repaint the game view when you´re not in play mode, unless something changes in the scene (which makes absolute sense). So your adjustments to the inspector are not picked up unless you change something, like say, move an object... I´ll look into it, there should be an easy way to force a repaint.

    cheers! :)
     
  50. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    479
    What do you think of this?
    http://forum.unity3d.com/threads/om...-occlusion-asset-comparison-with-hbao.290139/

    And what do you think about the new Unity cinematic effects pack AO?