Search Unity

[Released] Screen Space Cavity & Curvature for Unity - Inspired by Blender's Cavity effects.

Discussion in 'Assets and Asset Store' started by JollyTheory, Mar 31, 2022.

  1. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Screen Space Cavity & Curvature is an edge high-lighting and-low-lighting screen space effect for your game, inspired by Blender's Viewport Cavity effect.

    ✅Built-In (2019.4+) • ✅URP (7.1.8+) • ✅HDRP (7.1.8+)​


    Compatibility:
    • ✔ Unity 2019 / 2020 / 2021.
    • ✔ Standard render pipeline, forward and deferred.
    • ✔ Universal Render Pipeline 7.1.8+ (Unity 2019+).
    • ✔ High Definition Render Pipeline 7.1.8+ (Unity 2019+).


    • Super simple to use: simply add to your camera/render-pipeline and adjust parameters.
    • The effect is split into two parts:
    - Control small scale highlighting with "curvature" settings,
    - And larger scale highlights with "cavity" settings.
    Separate settings are available, enabling you to dial in the desired effect:
    - Pixel radius of curvature, its brightness in outward curves and its darkness in inward curves.
    - World radius of cavity, its brightness in outward curves and its darkness in inward curves.​
    • As a source of screenspace normals, all three sources are available to choose from:
    - G-Buffer normals, Camera normals, and Depth-reconstructed normals.​
    New feature: Control the effect per-object.
    - Uses a new "output to global shader texture instead of the screen" mode. Example shaders included. Feature available for Builtin[2019/2020/2021], URP[2020/2021].
    Assetstore page.
     
    Last edited: Apr 3, 2022
  2. Fragmented_Art

    Fragmented_Art

    Joined:
    Mar 24, 2019
    Posts:
    3
    Hello, I just bought this asset, being a big fan of this viewport effect in blender, and I was wondering if it was possible to apply it only to certain elements.

    For example, the effect is particularly good on rocks, but it also applies to vegetation, and it makes everything particularly ugly.
     
    PutridEx likes this.
  3. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi,
    I am currently working on adding a feature where instead of rendering to the screen, it renders the effect to a global shader texture that you can then sample in your own shaders; thus allowing you to select objects which receive outlines etc. The feature is almost done, I just need to create some example shaders for urp on how to sample a screenspace texture (for all 2019/2020/2021 urp versions), and that turned out to not be so trivial a task.
    If you can implement sampling a screenspace texture on your own, for you own shaders, I could submit the update to be live within a day or two. Otherwise it'll take a little bit longer.
    Thank you.
    ------------------
    Big news:
    Just finished the per-object effect control update. Uses a new "output to global shader texture instead of the screen" mode. Example shaders included. Feature available for Builtin[2019/2020/2021], URP[2020/2021]. With it you will be able to filter out any objects you don't want the effect appearing on.

    Should be live in a day or two. | Edit: Now live.
     
    Last edited: Apr 5, 2022
    shyamarama, protopop and PutridEx like this.
  4. Krooq

    Krooq

    Joined:
    Jan 30, 2013
    Posts:
    194
    Looks great, I love this effect.
    Does it support DOTS Hybrid Renderer V2?
    Usually global effects like this do since the shader requirements for DOTS are mostly related to instancing.

    EDIT: I tried it and can confirm, it works and it looks dope af!!
     
    Last edited: Apr 4, 2022
  5. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi everyone, discovered that a small bug has slipped through in the latest version of the package.
    If you're importing URP.unitypackage please move the imported "URP" folder from the root of your project into "Screen Space Cavity Curvature/SRP" folder, then right click on the "URP" folder and press "Reimport" to not get any errors.
    The fix for this will be live as soon as the assetstore team approves it. Very sorry for the inconvenience.


    --Edit: The fixed version is now live, fresh imports will not have to do anything, right click on "Screen Space Cavity Curvature" folder and press Reimport if you're still having any issues.
     
    Last edited: Apr 6, 2022
    Krooq likes this.
  6. Marseol

    Marseol

    Joined:
    Jan 16, 2022
    Posts:
    10
    Hello and congratulations! Is it possible to apply a texture in the curvature only? Possibly through a texture node of the Shader Graph (such as "_ssaao_occlusiontexture3" for URP)?
     
  7. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi, this should be possible with the _SSCCTexture output mode, it outputs to a global shader texture with curvature in .r and cavity in .g
    I am not too familiar with the shader graph so not exactly sure about using it to implement this, but there are example shaders for URP in the "_SSCCTexture Examples" folder that show how to sample the texture and have separate sliders for curvature and cavity, adding a texture on top of that should be an easy modification. Please let me know if you have any trouble with it. Thank you.
     
  8. darkyer

    darkyer

    Joined:
    Sep 11, 2013
    Posts:
    21
    Hello, I bought this asset but I'm having some issues (maybe I don't understand correctly) I'm using URP, and I already added the "SSCCRenderFeature" to my URP renderer, and I can see the effect, but the readme says that I need to add a "SSCC" to my post process volume, and here is where I'm stuck, I tried to add it as an effect, but it doesn't appear in the effects of the post process volume. I'm doing something wrong?

    Thanks

    EDIT: I'm using URP 10.7.0 and Unity 2020.3.25f1
     
    Last edited: Apr 27, 2022
  9. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi, hopefully this image can help you:

    Please let me know if "ScreenSpaceCavityCurvature" doesn't appear in the effects list for you. Thank you.
     
    darkyer likes this.
  10. darkyer

    darkyer

    Joined:
    Sep 11, 2013
    Posts:
    21
    that was it, I was using the Post process volume, not the volume script, Thanks for the help!
     
  11. Sander140

    Sander140

    Joined:
    Jan 15, 2015
    Posts:
    4
    This looks really nice

    How performance heavy is it? Will it run fine on mobile phones (like OnePlus 8 Pro)?

    And how does it look when applied to games also having more "organic" creatures with more rounded edges?

    And how easy is it to exclude specific objects (like creatures) from the effect?

    Also, does it work fine when you have light, fog, and particle effects (so that it renders behind fog and so on)
     
    Last edited: May 1, 2022
  12. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi,
    Mobile is not officially supported (there's just too much variance between mobile devices), but one person tested it on iOS and it worked perfectly for them. Your mileage may vary.

    It is very easy to exclude specific objects from the effect (if you're on Builtin or URP 2020+), consult texture output mode folder's Readme.txt.
     
    shyamarama likes this.
  13. theBachi

    theBachi

    Joined:
    Jul 23, 2017
    Posts:
    3
    Hey, does it support mobile? And this new feature with shaders, that means it doesnt work as post process but is like a texture, so performance is much better?
     
  14. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi, see the comment above about mobile.
    The 'texture' output mode feature works like this: Render the entire screenspace effect, but output it to an intermediary global shader texture instead of the screen directly (what it does in default 'screen' output mode), then as the individual object's shaders get executed, they can read this texture to use that information however they want for their shading, they can ignore it for example, etc. The sample shaders for all this (Built-In, URP) are provided with the asset.
     
  15. GrooGadgets

    GrooGadgets

    Joined:
    Apr 2, 2009
    Posts:
    71
    Hey @JollyTheory does this asset work on all shaders or do I need to use the provided custom shaders?
     
  16. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi, the asset works with all shaders by default without any modifications required (applied on top of everything on screen), if you want to exclude certain objects from the effect you have to switch over to the custom provided shaders, or modify your own.
     
  17. Damian-Poci

    Damian-Poci

    Joined:
    Feb 25, 2016
    Posts:
    1
    I needed to change the path in the URP_SSCC.shade file line 195 to the actual path of the Shared.cginc file to make the asset work. Other than that it works very well :)
     
  18. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi, was that caused by moving internal folders of the asset, or was that a problem out of the box?
     
  19. unity_1D8F72B3BBF194C9DF83

    unity_1D8F72B3BBF194C9DF83

    Joined:
    May 22, 2022
    Posts:
    1
    Im running Unity 2020.3.34f1and URP 10.9 but am unable to get the effect to work. I had it working in 2019.4, I'm not sure where I'm going wrong. I've added the feature, enabled depth texture, and made sure post processing is selected on camera like last time, but no results.
     
  20. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi, yeah Unity changed something about the screenspace normals texture in URP 10.9 and didn't announce it anywhere. Working on a fix.
     
  21. genie_unity

    genie_unity

    Joined:
    Aug 3, 2018
    Posts:
    2
    Does it work well on VR devices?

    ex) Oculus quest
     
    Ony likes this.
  22. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Submitted the fix, should be live as soon as the asset store team approves it.
    Code (CSharp):
    1. For fellow asset store developers: You can use "VERSION_GREATER_EQUAL(10, 9)" to check if URP's camera normals texture is stored in worldspace or not. <10.9 viewspace, >=10.9 worldspace.
     
  23. krakentanz

    krakentanz

    Joined:
    Aug 13, 2020
    Posts:
    34
    Hey Jolly,
    I just bought the asset and I like what it does to my test scene. I use it together with another AO solution (HBAO) and also volumetric fog (Buto) in URP and they work together beautifully so that the fog gets correctly drawn after the Curvature and Cavity. Very nice!
    Now when tweaking SSCC I find that I want just a tad of the harsh curvature bright lines, but it's not possible to dim them down enough to not give me a wireframey look when up close. I set Curvature Brights to 0 but they still pop out way more than i want them to. Any chance to "go below zero" on this value, so that I just get a faint hint at the lines?

    Cheers,
    Felix
     

    Attached Files:

  24. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    Hi, is there a way to have the default intensity be at 0 so I dont have to add it to every post processing and decrease it down from 1?

    Also I have a very bad black line / spots around my character's nose and above upper lip, can I get rid of that somehow on HDRP?
     
    Last edited: Jun 18, 2022
    krakentanz likes this.
  25. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Pushed an update that completely negates those parts of the effect which are set to 0. (Version 1.1.1)

    Assuming you're on HDRP, you can modify SRP/HDRP/Runtime/SSCC.cs line 24 from
    public ClampedFloatParameter effectIntensity = new ClampedFloatParameter(1f, 0f, 1f);
    to
    public ClampedFloatParameter effectIntensity = new ClampedFloatParameter(0f, 0f, 1f);
    As for ugly lines, please send me a screenshot to my e-mail (can be found in readme.txt). I'll try to help you out.
     
    skinwalker likes this.
  26. Radivarig

    Radivarig

    Joined:
    May 15, 2013
    Posts:
    121
    I found that setting the material's render queue to 2501+ also excludes the effect which was fastest for me, not necessarily the right way to do it.
     
  27. krakentanz

    krakentanz

    Joined:
    Aug 13, 2020
    Posts:
    34
    Thanks for taking the time to adress this. The change you implemented makes it possible to turn off the lines completely, however what I was looking for was a way to make them just a tiny bit visible (10% opacity or something), but even at a very low value of 0.001 they seem to appear in the same strength as before the update.

    On another note I was wondering if it would be possible to add a way to increase the overall fidelity of the effect. I notice that there is very visible dithering wherever SSCC takes effect. I tried different quality settings, but wasn't able to solve the issue. The examle images use 12 samples.
    (Note that these images show the problem in its most severe form and are not representative of what SSCC usually does!)

    Unity_2022-06-24_11h-41m-27s.png
    When zooming in further I noticed that even in the areas where only Cavity Brights should be active (I set Curvature Darks and Cavity Darks to 0 to make sure) there is a darkening within the gradient that shouldn't be there, as it adds unnecessary contrast where instead smoothness is needed :
    Unity_2022-06-24_11h-41m-27s_closer.png

    Maybe you can look into it at some point. Here are some suggestions that came to my mind:

    A) Have the sample seed for the dithering change (or the texture move apixel) every frame.
    B) Change the dithering algorithm entirely.
    C) Try to implement either image blurring of the effect or themporal accumulation (in combination with A)) over a couple of frames.

    Thanks a lot for improving an already wonderful asset!
     
  28. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi,
    I'll look into using blue noise as the dither pattern and perhaps adding a blur pass. Not sure a blur pass would be worth the hit in performance though, the asset was designed with more of a smaller world radius for cavity in mind, and looks good enough on those more intended smaller radii in my opinion, but i'll look into it nonetheless.

    By the way are you using HDRP or URP in your screenshot?
     
  29. krakentanz

    krakentanz

    Joined:
    Aug 13, 2020
    Posts:
    34
    Thanks a lot! I agree that the blur might not be worth the performance cost. I guess blue noise that has a slight offset every frame should solve it. Thanks for having an open ear, I appreciate your support.

    The screenshots were done in URP.
     
    xpxilom and JollyTheory like this.
  30. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Just wanted to post an example of how to sample _SSCCTexture in shader graph incase someone needs it:
    Make sure to toggle off "Exposed" on the texture
    R will have curvature (-1.0, +1.0), G will have cavity (-1.0, +1.0)
     
    slushieboy99 likes this.
  31. strange_aeons

    strange_aeons

    Joined:
    Aug 18, 2015
    Posts:
    10
    hello, i just bought this one and im trying to set it up in Unity 2021, URP 12.1.7 and following the instructions, i get to the part where i need to add the SSCCRenderFeature, only it isnt showing when i try to add it. did i miss something?

    gdfsjh.png
     
  32. strange_aeons

    strange_aeons

    Joined:
    Aug 18, 2015
    Posts:
    10
    ahh i see what i was missing, i didnt double click the URP thingy :)
     
  33. TrentSterling

    TrentSterling

    Joined:
    Jan 4, 2013
    Posts:
    99
    Any answer on this? I want to use this on a bunch of synty models Ive got running in VR, but IDK if this effect will work properly as its not mentioned
     
    Ony likes this.
  34. sumioka

    sumioka

    Joined:
    Sep 26, 2018
    Posts:
    8
    I tried it.
    It was possible only in Screen mode.
     

    Attached Files:

    Ony and JollyTheory like this.
  35. jenreadpleman

    jenreadpleman

    Joined:
    Jan 10, 2017
    Posts:
    1
    How did you get it to work? When I build to Quest 2 it doesn't work.
     
  36. bodden

    bodden

    Joined:
    Mar 20, 2013
    Posts:
    9
    Couldn't get it to work. Using 2021.3.2f1 and URP12.1.6. Depth-texture is enabled. Demo-scene is showing this:
    upload_2022-12-25_17-1-5.png

    Any tips?
     
  37. bodden

    bodden

    Joined:
    Mar 20, 2013
    Posts:
    9
    Figured it out myself. Had an compiler error: Could not find Shared.cginc. (maybe, because I moved the plugin from the asset-root-folder to a sub-folder). --> edited the path manually. Works now.
     
  38. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    I had the same issue, out of the box. Initially I imported and moved the folder into a third-party location before even trying it (habits). I removed all the files and re-imported and re-expanded URP package. The
    #include "../../../Shaders/Shared.cginc"
    seems like it should be referencing the right place, relative to the location of the file but it did not compile. I copied the Shared.cginc into the same URP/Shaders folder. Even if Unity allowed it, I think including paths starting with .. to be a code smell. All your shader code should be in the same folder, or include from a given strategy path (such as environment variable or assembly definitions), or include from subdirectories, not parents. The strategy path would be the best, but maybe does not seem to exist for Unity shader compiles, unfortunately.

    Excellent shader effect, I am glad I added it to my basket.
     
  39. alfredbaudisch

    alfredbaudisch

    Joined:
    Dec 13, 2010
    Posts:
    45
    Can you create a comparison screenshot/gif showing Unity's URP SSAO vs this one side by side? It would be good to see the difference before purchasing.
     
  40. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    alfredbaudisch likes this.
  41. alfredbaudisch

    alfredbaudisch

    Joined:
    Dec 13, 2010
    Posts:
    45
  42. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Thanks very much for the comparison

    WOW this comparison is really awesome and amazing as far as I see it and think it is as follows because you have not told the difference and I want to confirm if I am right

    First one - Using URP Screen space cavity curvature asset?
    Second - Default Unity
    Third one - Unity's URP SSAO ?


    The best way for me to see them was to open the 3 images in 3 browser tabs and then switch to each one to see clearly the great difference

    please can you be so kind to tell what values are you using so we can use these same values if we own your awesome asset?
    What version of Unity you are using for these 3 screenshots?

    I guess and think that the first one that is shown here below belongs to this Screen space cavity curvature asset?

    It can be seen clearly and perfectly all the edges of everything and most of all there is a great difference in depth and shadows and is much clear and sharp in every object shown, specially the bench, the bucket, and the 2 vertical tables in the wall

    And it makes a clear difference between the next one and the third

    so then here is First one - Using URP Screen space cavity curvature asset?
    screen-space-cavity-curvature-for-unity Screenshot.png
     
    Last edited: Dec 27, 2022
  43. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Second - Default Unity
    do not know what values this may have
    Default Unity NOT using screen-space-cavity-curvature-for-unity Screenshot.png
     
  44. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Third one - Unity's URP SSAO ?
    do not know what values this may have

    Most difference for me is in the bucket and all that is in the bench with the tools that can be barely seen and in the first one you can see them clearly
    so if I am right guessing the images order, then the absolute winner is this Screen space cavity curvature asset shown on the first image above
    Default Unity URP SSAO.png
     
  45. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    thanks very much for asking this as this is really very useful and helpful to decide and see the real true difference, because with the images shown on the asset store is not clearly why this is good, and showing this comparison is clearly seen that is a excelent winner and surely be convincing to buy it.
     
    alfredbaudisch and JollyTheory like this.
  46. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    Does this require shadows enabled? Work with VR? Any mobile usage concerns with low poly models? Thanks
     
    Ony and Sir_Loin_of_Beef like this.
  47. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    I purchased it, am using URP, see the default effects, but am not able to enable the script on my camera or change any values. Would be nice to have some documentation other than the forum posts...
     
  48. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    Hi,
    For URP you don't add the script on the camera, you instead add "SSCC" to your Volume object of your scene. (Usually called "Global Volume", If you don't have one add a new one to your scene.)
     
    Proto-G likes this.
  49. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    Tried that also, but modifying the settings didn't change anything. The changes should occur real-time visually yeah?
     
  50. JollyTheory

    JollyTheory

    Joined:
    Dec 30, 2018
    Posts:
    156
    The changes should occur in real-time yes. The effect shows up, but the settings do not get modified - is that correct? Make sure your Volume is set to global, try adding any other post processing effect in the same volume and see it settings of that effect do get modified. If that still doesn't work try import SSCC in a new empty Unity project and see if it works there. If that still doesn't work send some screenshots. Also you can email me at jollytheorygames#gmail.com - i respond there faster.