Search Unity

Official New Post-processing Stack (Pre-Release)

Discussion in 'Image Effects' started by Chman, Oct 10, 2016.

  1. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    Do you happen to have a class made yourself named "Material" (in the global namespace)?
     
  2. salatlol

    salatlol

    Joined:
    Nov 2, 2016
    Posts:
    2
    I had a class Material, it was the problem. You saved my life! Thank you
     
  3. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    Still no scene view support in 5.6...
     
    McMayhem and id0 like this.
  4. JohnSmith1915

    JohnSmith1915

    Joined:
    Apr 21, 2016
    Posts:
    143
    Any way to have Depth of Field in dynamic mode for make auto focus based in distance to objects or any script that use raycasting for this? thanks.
     
    Last edited: Apr 12, 2017
    AlbertoMastretta likes this.
  5. AlbertoMastretta

    AlbertoMastretta

    Joined:
    Jan 1, 2015
    Posts:
    71
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. namespace UnityEngine.PostProcessing{
    6.     [ExecuteInEditMode]
    7.     public class FocusOnTransform : MonoBehaviour {
    8.         public Transform focusObject;
    9.         DepthOfFieldModel depthOfField;
    10.         DepthOfFieldModel.Settings depthOfFieldSettings;
    11.         public bool curveBased;//Determines if it uses a fixed value, or a curve. Useful to test values quickly, which can be later used by the curve.
    12.         [RangeAttribute(0.1f, 32f)] public float aperture;
    13.         [RangeAttribute(1, 300f)] public float focalLength;
    14.         public AnimationCurve focalLengthCurve;
    15.         [SerializeField] private float distance;//Serialized so that we can see the distance from the camera to the target object, from the editor.
    16.  
    17.         // Use this for initialization
    18.         void Start () {
    19.             depthOfField = GetComponent<PostProcessingBehaviour>().profile.depthOfField;
    20.             depthOfFieldSettings = GetComponent<PostProcessingBehaviour>().profile.depthOfField.settings;
    21.         }
    22.  
    23.         // Update is called once per frame
    24.         void Update () {
    25.             distance = Vector3.Distance(transform.position, focusObject.position);
    26.             depthOfFieldSettings.focusDistance = distance;
    27.             depthOfFieldSettings.aperture = aperture;
    28.             if(curveBased) depthOfFieldSettings.focalLength = focalLengthCurve.Evaluate(distance);
    29.             else depthOfFieldSettings.focalLength = focalLength;
    30.             depthOfField.settings = depthOfFieldSettings;
    31.         }
    32.     }
    33. }
    34.  
    Hey @JohnSmith1915!

    I made a script to control the depth of field dynamically. It's not as easy as the old versions of depth of field where you could just drag an object and it would automatically control focus on it.

    It automatically controls the focus distance, but that didn't give me good results. I added a curve control do adjust the focal length based on the distance. You can do your own curve and hopefully get good results with it.

    For the curve, X is distance, while Y is your focal distance. My curve has 2 points, one at 9,80 and another at 40, 195.

    This is my first try to make a dynamic depth of field control, if anyone has suggestions, improvements, or criticism, please let me know.

    I hope its useful for someone.
     

    Attached Files:

    Last edited: Apr 13, 2017
  6. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    It's a real shame the size of the Uber shader is so large. Could the shader be recompiled based on what's actually used? It's taking up:

    10.3 mb 7.4% Assets/PostProcessing/Resources/Shaders/Uber.shader

    With nearly an additional 1mb in noise texture assets that are sitting in a 'Resources' folder so they get compiled in regardless of whether they're used or not.

    This has blown our 100mb app size budget for our Android build and we only need to use it because of the regressed Bloom effect that no longer works under 5.6.
     
  7. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    I think in theory you could just replace the code for (each effect you're not using) with something that's only 1 line long. I'm assuming on Mobile you're not using 'physical' screen space reflections, nor all 3 types of filmic post-processing, and you've probably set the camera to be forward or deferred, not both, so you could probably be rid of half the options in Ambient Occlusion.

    Now I've got no idea if this'll work, but it might be worth a shot?
     
  8. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    It doesn't look to be that simple, I need to completely butcher the shader and then redo this crazy hacking each time the effects code base was updated. But thanks anyway, I'm not sure we're going to be able to use it at is is.
     
  9. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    What about instead of butchering each shader individually you could butcher some main part and just not call whatever effects you don't use? Presumably then you could move/remove the individual bits since they'd no longer be called.

    Another thing to consider is if you can't use the old bloom (cinematic bloom, right?) maybe compare that code and the new stack's bloom. See if something's different, and try to manually un-regress the old bloom. I've found things in the past where a version broke it and to unbreak it all I had to do was find some lines at the top that looked different to what works.
     
  10. aki-kanerva

    aki-kanerva

    Joined:
    Jan 3, 2012
    Posts:
    1,398
    Well this looks pretty gorgeous! Both the visuals and the UX for tweaking the stack. So of course the first thing I want to do is abuse it. :)

    How would I go about disabling a particular effect for certain opaque geometry? My goal is to have different post-processing for background scene and foreground, gameplay objects to make the latter pop out.

    Basically, I want to go from this:
    1.jpg

    to this:
    2.jpg

    What I did in the second screenshot was create two cameras with different post processing stacks. The stack in the camera that sees the cubes doesn't have color grading (or depth of field since it's unnecessary).

    This has downsides:
    - 2 stacks consume a lot of power
    - Occlusion issues will be frequent since the cubes are getting rendered on top of everything else
    - The cubes don't cast shadows (I could also have the background camera render them too, but that's a big chunk of extra rendering power).

    Can I do this with just one camera and use some kind of masking to prevent the color grading from affecting the cubes? Fortunately, they're always fully opaque so transparency is not an issue.

    Would a stencil mask do? How would I go about using it on a specific effect in the stack?
     
  11. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    i do have a question regarding ssr. the standard shader transparent mode does not receive screen space reflections right!? but especially glass is where you want to have those reflections. is it because transparent shader is not writing to depth buffer? is there any chance to get ssr on transparent shader? of course reflection probes do a lot but ssr would make things much more flexible.
     
  12. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Unfortunately that seems to be a problem with things that don't write to the depth buffer.

    I believe there's a standing Nobel Prize for anyone who can solve it cleanly and elegantly.
    Alas, all solutions (things like AtoC / dithering, deep transparency maps, etc all seem to break or require something that breaks a good workflow and rendering pipeline.
     
  13. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    You need to combine SSR with Reflection Probes for this type of the objects. Similar to UE4
     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I would first exhaust all possible research in making the object look different with it's own shader, ie it's own shader provides correction that's counter to the post or works with the post in a way that those colours aren't lost. This way you can stick to the one camera technique.

    Obviously it will not be utterly perfect. But your gamers don't know this. So long as it's close enough to be an acceptable result - which is hollywood's mantra. They know it's not perfect. It can't be perfect. So long as it's close enough.
     
    aki-kanerva and Martin_H like this.
  15. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    even with projection mapping for very angled glass surfaces it is hard with reflection probes - those surface would benefit a lot from ssr. i thought you could do it in separate passes where you write everything in depth buffer but dont use it for final rendering/sorting just for declared surfaces as reflection source.
     
  16. aki-kanerva

    aki-kanerva

    Joined:
    Jan 3, 2012
    Posts:
    1,398
    I'm well aware that the rule #1 of computer graphics is "cheat like hell". :) I'm not looking for perfect. The goal is usability: separating interactive objects from the background (while also looking good). So I'm definitely aiming for "unrealistic", not "perfect".

    The problem with modifying the shader for the objects themselves is that color grading is always applied on top of it. No matter how much "extra" color I put into the cubes themselves, the color grading effect will always desaturate and tint them afterwards. Or is there a way to go around that?

    That's why I was looking for a way to prevent the color grading from being applied to certain pixels - such as a stencil buffer containing the cubes.
     
  17. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You can probably use something like amplify color, and suffer the extra pass, because that supports masking. And simply not use the built in colour grading.... not ideal I know.
     
    aki-kanerva likes this.
  18. aki-kanerva

    aki-kanerva

    Joined:
    Jan 3, 2012
    Posts:
    1,398
    Holy cow, I can't believe how easy it was! I didn't even have to do manual blitting!

    In the object shader, add to Subshader:
    Code (csharp):
    1. Stencil
    2.     {
    3.         Ref 2
    4.         Comp always
    5.         Pass replace
    6.     }
    In Uber.shader (from the Post-Processing Stack), add to Subshader:
    Code (csharp):
    1. Stencil
    2.         {
    3.             Ref 2
    4.             ReadMask 2
    5.             Comp NotEqual
    6.         }
    Now, sadly, this also disables other effects that are included in the Uber shader - but happily, in our specific case, it doesn't matter.
     
  19. aki-kanerva

    aki-kanerva

    Joined:
    Jan 3, 2012
    Posts:
    1,398
    @hippocoder, I didn't realize until now that you may have assumed I was applying the color grading to the cubes. I was actually doing it for the background and trying to keep the cubes unaffected.

    1. No post-processing - background is way too saturated and contrasty:
    1.jpg

    2. Full-screen post-processing - cubes get washed out with the rest of the scene:
    2.jpg

    3. Cubes write to stencil, color grading ignores stencil - desired result achieved:
    3.jpg
     
  20. JohnSmith1915

    JohnSmith1915

    Joined:
    Apr 21, 2016
    Posts:
    143
    Works very well, i will be add raycast to change the object to focus, thank you very much.
     
  21. AlbertoMastretta

    AlbertoMastretta

    Joined:
    Jan 1, 2015
    Posts:
    71
    I'm glad it was helpful! Cheers
     
  22. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Hi all,

    I'm getting a really strange effect when I have Post processing enabled. I tried deactivating each option to fiind thhe culprit but even with everything off it still persists. Very strange. Gives a horrible light glow on everything. Im using unity 5.6.0.f3

    Comparable images below, one with PP on but nothing enabled, one with the script disabled. everything else the same. Windows build on fantastic settings. Really frustrating because it does not show in editor so I have had to build each time to test changes.
     

    Attached Files:

  23. Dhialub

    Dhialub

    Joined:
    Nov 11, 2013
    Posts:
    41
    Screenshot (4).png

    Played around a bit with the effects and the vehicle pack, looking really nice.
    Better antialiasing would be nice, though.
     
  24. YourUncleBob

    YourUncleBob

    Joined:
    Jun 11, 2012
    Posts:
    55
    We saw a big drop in quality switching to the post processing stack vs. the effects we were using (mostly from the Cinematic Effects package). We're still profiling on different platforms to see how the performance compares.

    Digging into the quality, the drop all came down to some changes in Bloom. The Cinematic Effects Bloom code seems to be used almost as is in the post processing stack, with 2 changes. The Cinematic Effects bloom had a high quality option, which our title needs to enable to get good looking bloom.

    In BloomComponent.cs texture width and height use half resolution all the time. In the Cinematic Effects, the High Quality option let you use full res textures. Using the half resolution textures we see terrible flickering of the bloom in our scenes (even with anti-flicker enabled). I defaulted it to full resolution textures and got the quality back.

    The other difference was that the old Bloom used the same High Quality flag to switch between a 4 tap and 9 tap upsample filer. The new bloom uses #if MOBILE_OR_CONSOLE instead to enable the 4 taps. We haven't profiled it yet, but I assume we're going to need the 9 tap on XBox and PS4 to keep the quality up.

    I think the High Quality option is a better way to go about this than forcing the behavior one way in the code. I understand it's more expensive, but it's really needed to achieve a decent look. If we do a mobile build, we'd turn off the high quality. For PC and consoles, we need the high quality.
     
    Zuntatos and Martin_H like this.
  25. McMayhem

    McMayhem

    Joined:
    Aug 24, 2011
    Posts:
    443
    The last word I've heard on this was:

    Now that 5.6 is released, I'm just wondering what exactly is the issue with safely applying a fix. Hoping to get some word on this.

    The original issue I posted in the 5.6 beta forum wasn't actually anything to do with the Post-processing Stack but with Sonic Ether's Bloom. If the issue is only with the Post-processing Stack asset, why am I having issues with non-related image effects? If it is a global image effect issue, why is the issue listed in the Post-processing Stack github and not on the Known Issues list for 5.6?

    Not trying to criticize, just really confused.
     
    Last edited: Apr 15, 2017
  26. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Hi all, Can anyone shed any light on the problem i have shown above? Seems no matter what setting I have I get a white haze/glow on my models and trees. This happens no matter what settings i choose or disable (even everything bar the script itself).
     
  27. cakeslice

    cakeslice

    Joined:
    Oct 18, 2014
    Posts:
    197
    If you can give me a project that reproduces the issue I don't mind taking a look :)
     
  28. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    After trying side by side how it looks when using full res I agree that a not hardcoded option for that would be very nice. When I leave it at half res I get very noticable flickering in the bloom (even with anti flicker) when I move a sharp glowing circle slowly across the screen. With full res the flickering is almost completely gone.
     
  29. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Ohh that's odd now that you mention it, i never realize that the high quality option are gone.
    i think the bloom used to have high quality option before
    upload_2017-4-17_14-47-33.png
     
    OCASM likes this.
  30. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Can someone explain why prost processing stack gives more bright color to the fog compared to what I have configured? Is that a bug?

     
  31. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Do you have tonemapping on? Could it be a linear/gamma colour space thing?

    Try manually fudging the fog colour to look correct, and check the brightness value compared to what it should be.
     
  32. Nova-Shade

    Nova-Shade

    Joined:
    Oct 15, 2015
    Posts:
    136
    This stack is really awesome !

    Here is my contribution to the thread , a Before / After post effects :






    But I still have a request... will some trigger volume will be implemented to switch from one profile to another ? I can't wait for that :)
     
    UnityLighting and JohnSmith1915 like this.
  33. Leoo

    Leoo

    Joined:
    May 13, 2013
    Posts:
    96
    So , no more Global Fog support?
     
  34. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    I don't. I use linear color space. I've tried manually getting result I need, but I can't get exactly the color I need. I switched to forward and used default fog and it took me two seconds to get right color using Color Picker on skybox. But I don't want to use forward for this project. Tell me if you need more info or video, cause I really need to solve this issue.

    p.s. it also works fine in legacy deferred.
     
  35. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Now it just doesn't work at all in deferred. But at least there's an error


    Invalid pass number (1) for Graphics.Blit (Material "(Unknown material)" with 1 passes)

    Invalid pass number (1) for Graphics.Blit (Material "(Unknown material)" with 1 passes)
    UnityEditor.DockArea:OnGUI()



    But it does seem to be working fine in a completely empty project.

    I a new scene of my project, there not error but color is messed up. Here's a good demonstration
     
    Last edited: Apr 18, 2017
  36. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Does this effect work on all outdoor scene with just Sunlight and no bakes or GI? Im getting crahses and weird effects whenever I put this on (5.6.0.f3)
     
  37. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    I'm using it on a fully procedural scene, and it's working just fine. It's a bit older version though, and on 5.5.
     
    AndyNeoman and Martin_H like this.
  38. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Thanks, might be my setup or 5.6, shame because it can add so nice visuals.
     
  39. KUFgoddess

    KUFgoddess

    Joined:
    Apr 2, 2015
    Posts:
    27
    Can anyone explain how to use this I dont see any documentation for using.
     
  40. Nova-Shade

    Nova-Shade

    Joined:
    Oct 15, 2015
    Posts:
    136
    First you create a new post processing profile ( like you create a new folder or a new material ) then you select your camera and add a post processing behaviour script. Once the script component is created , you attribute your profile file to your script. Now you are ready to play with all the settings of the stack.
     
  41. Deleted User

    Deleted User

    Guest

    I'm creating my own shader that I would like to be able to optionally sample the blur textures created as part of the Screen Space Reflections component of the Image Effect Stack. What would be the easiest way to copy these blur textures into my own shader from the SSR component on each frame/update?

    EDIT: I don't know if it matters, but my shader is part of the Forward rendering pipeline.
     
    Last edited by a moderator: Apr 20, 2017
    KUFgoddess likes this.
  42. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Last edited: Apr 24, 2017
  43. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
  44. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
  45. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Fixed the link.
     
    Last edited: Aug 15, 2017
  46. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Latest version fixed my fog color problem! Unfortunately I've encountered new problem. I have two camera setup. Main Camera renders the world and Weapons Camera renders gun. I usually apply post effects to weapons camera, cause then post effect are applied to guns and world. Unfortunately post processing stack fog in deferred doesn't work correctly on my weapon camera when "exclude skybox" is checked. It does work fine on my main camera, but I need to use it on my weapon camera.



    @Chman
     
  47. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    59
    Hi everyone! I'm very impressed with this amazzing free image effects. I'm using it in my project "Pripyat 3D" and wish to show you what it looks like.

    I just didn't use SSR because it's looking so strange in my scene...

    I wish SSR be better in future updates.
     
    OCASM, KUFgoddess and Jaimi like this.
  48. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    59
    Oh my god! This is what I always wanted from SSAO! But link is 404 now, can you reupload it?
     
  49. JohnSmith1915

    JohnSmith1915

    Joined:
    Apr 21, 2016
    Posts:
    143
  50. xrooshka

    xrooshka

    Joined:
    Mar 5, 2014
    Posts:
    59
    Baldinoboy and Adam-Bailey like this.