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

PRISM - Realistic All-In-One Post-Processing for Unity

Discussion in 'Assets and Asset Store' started by GoGoGadget, Dec 12, 2015.

  1. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    As a rule of thumb, follow Tim's post here: http://forum.unity3d.com/threads/is...or-placing-image-effects.411116/#post-2679565 - basically, anything HDR goes before PRISM, anything LDR goes after PRISM.

    //const float _FogVerticalDistance = 22.0;
    ^Find that line in PRISM.cginc and play around with it. I think it was the Fog Vertical Range value there, so try setting it to 1.

    That shouldn't happen, I will play around with it but as a temp fix you can disable MSAA. Any other effects on the camera?
     
  2. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    No other effects, turning of Unity AA corrects it but was hoping to use AA as well.
     
  3. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Will look into it this Monday, likelihood is it will be a 1 line of code fix, I vaguely recall some changes to default stuff in 5.4, but in all my 5.4 betas this did not happen :(

    Ah, I see what you mean now. So that is a completely separate thing, and basically not possible with the way PRISM does Chrom. Aberration & DoF together, would be interested to see actual images of where that effect would look good though.
     
    yc960 likes this.
  4. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Untitled-1.jpg

    The chair is subjected to stronger chromatic blur effect, yet it is barely noticeable on the lady. I think that is coupled with DoF, this is the only video game example I can think of. But I do know that DoF coupled with chromatic blur are heavily used in digital animation to make it look fancy.
     
  5. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Would be interested to see an uncompressed photo of that scene, hard to see exactly what they're doing in jpg.
     
  6. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    I don't own a PS4 so that is the best example I can find.
     
  7. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Untitled-2.jpg
    The god ray uses bloom texture so emissive particles are generating the ray as well, but at the wrong direction. However, this result looks quite familiar to the filmic anamorphic flare effect.

    vlcsnap-2016-08-13-20h30m14s409.png
    image from man of steel 2013

    Would the god ray technique apply to anamorphic flare in PRISM?
     
    GoGoGadget likes this.
  8. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    @GoGoGadget - if you get a sec, take a look at this thread:
    http://forum.unity3d.com/threads/unaccounted-in-profiler.425341/#post-2750632

    I've been experimenting this morning and these spikes/unaccounted entries *seem* to go away when I disable PRISM. Thought I might be something specific in there that could be causing this? I've been trying to turn off individual effects to see if I can narrow it down, but so far no luck.

    Thought it might be of interest to you though as I believe it's something new with Unity 5.4.
     
    GoGoGadget likes this.
  9. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Will have to do some experimentation, but that's not a bad idea. Still a few roadblocks to adding new effects, but will keep it on the table, it would be cool if I could integrate godrays into bloom like that, and quite easy in theory.

    Very weird. I'm using PRISM in production on 5.4 (albeit a very late beta) and haven't seen anything like this. What it *may* be is the profiler showing something similar to "WaitAndSync" (essentially the CPU waiting for the GPU to finish the frame, aka your game is GPU bound), but that is a total stab in the dark.
     
  10. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    I did some more experimenting on the weekend and it looks like ALL post-effect packages (available to me) are causing these huge "Unaccounted" spikes to occur. Will wait and see what results from the Unity investigation of the bug report. I'm just hoping they are fairly responsive - at the moment the performance in my game is absolute rubbish and the only way I can get it to an acceptable level is to turn off any post-effects (i.e. PRISM).
     
  11. EvilGremlin

    EvilGremlin

    Joined:
    Aug 12, 2016
    Posts:
    231
    Hey, any chance we can get a better video. The difference is difficult to see from the youtube video. I know youtube is cheap (free) but even if you offered a download for it that would be cool.
     
    GoGoGadget likes this.
  12. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,085
    Very curious to hear from anyone else on 5.4 that's seeing those "Unaccounted" issues in Profiler. At the moment I can't use PRISM as it's adding anything up to 25ms to my frames under that Unaccounted object (for whatever reason). As mentioned, it's not just PRISM - seems to be all post-effects packages, so it's something that they're all doing in common. I'm kind of stuck though because my game looks like crap without any post effects :)

    Waiting on Unity to look at my bug report.............
     
    GoGoGadget likes this.
  13. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I tested today PRIMS on Unity 5.4 on iOS and it works very well. Very nice results and performance with Bloom, DOF, Fog, GodRays and (a little bit heavier) also AO.

    But I have problems with LUT and UI Blur:

    Whatever texture I set for the LUT I get the same result: from 0 to 1 it goes from darker scene to completely black.

    UI Blur makes the UI completely transparent. Maybe I'm doing something wrong:
    - created new material and assigned the shader from prism
    - created a gameobject with an Image component
    - assigned the material
    - enabled Bloom and UI Blur
     
    Last edited: Aug 17, 2016
    GoGoGadget likes this.
  14. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Also another question. I have a vertex shader that animates the position of the vertices to simulate the wind.
    With AO enabled, I get some kind a ghost effect.
    There is an "easy" way to fix it? Which vertex shader I should touch? In what file?
    Thanks
     
  15. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    It's me again... I realized that is not only an AO issue. When the fog is stronger and the vertices animation is wider, the ghost effect is very visible, even if I disable AO.
    I'd really need a solution for this.
    Please let me know.
     
  16. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Great to hear that you're getting good results so far!

    With regards to LUT, this seems to be some new(?) behaviour in 5.4, I've recently got an Android to finally test PRISM on mobile, and it seems like in 5.4, Unity will by default set graphics settings to the 'min-spec' shader level for your target platform. So, even though I'm targeting SM3.0+ (and devices that all support 3D textures), Unity emulates SM2 or something terrible like that.
    The Fix is to go into Edit>Graphics Emulation>No emulation. I'll play around with how I can make this better for future 5.4+ PRISM updates, as I'm encountering the issue as well. Also remember, that your device does actually need to support 3D textures for PRISM's Color Correction to work (some older mobiles don't).

    With regards to UI Blur, should be pretty simple, I've gone ahead and make a quick tutorial video on it:


    Quite hard to tell exactly what your issue is. Do you mind sharing a screenshot?

    Definitely, the main PRISM trailer is from a suuuuuper old version of PRISM, it's about time for a new one.
     
    Last edited: Aug 18, 2016
  17. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Amplify Occlusion just released an update that can works without DepthNormal buffer and form mobile is a very good compromise between quality and performance.

    Do you think you could integrate something similar inside PRISM? I like very much the auto culling of AO based on DOF and maybe could be even faster inside PRIMS if you can share some passes.

    Yes, disabling graphics emulation before to run the game it works.
    Also in regards to the 3D texture requirement... I use Amplify Color from long time also on very old devices. Why PRISM needs so advanced hardware for that?

    Resolved... my shader was with "noshadow" tag. Changing it to "addshadow" now renders the animate vertices also in the depth buffer. (not very clear the connection between the two things... I mean... I don't have realtime shadows so I thought was a good idea to use "noshadow" :)

    Just a king remind about UI Blur that is not working.

    Also a minor issue, I was forced to go often in debug mode of the inspector to set the values of Bloom and Dof outside the range the you imposed. For example Bloom intensity to 30, Dof Focus Range to 9200, etc.
    Would you mind to remove the sliders for some of them?

    Thank you
     

    Attached Files:

    Last edited: Aug 18, 2016
  18. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    PRISM's AO actually can work without DepthNormals, it uses the fastest possible method (G-Buffer normals) when you're using deferred. If you're in forward however, the algorithm needs the depthnormals to reconstruct geometry correctly - reconstructing geo with just depth leads to a number of facet issues with PRISM's detail-preserving AO algorithm, so it will never work like that.

    Performance, simple as that. PRISM performs markedly better than Amplify Color, in part because it utilises SM3.0+ features. As specified on the store page, PRISM requires SM3+, this requirement will not change. I will look into the disabling graphics emulation issue further.

    They are outside of the range of 99% of users, for instance, the DoF Focus Range in a typical scene would only go to ~100. What I recommend you do is just save a PRISM-Preset for your values.

    Also, see the video I recorded above for how to get UI blur working. If it is still not working, reimport PRISM :)
     
  19. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Yes I tested it and is faster :)
    Great!

    I have an open environment with the camera planes set to 0.1 and 10000. It doesn't seem to be too strange to me and I like to have near objects out of focus, and with a value of 100 also the background is completely blurred.
    Also I'm using the presets, but for every change I have to select back the camera, and click "reset to preset" to see the changes... at this point is easier the debug mode.

    Oh! I missed the video. Probably I opened immediately after you post it, before your edit.
    I tried the way you explain, and it works, but only if I don't use the bloom texture. Because in Simple mode the the blurred image becomes very dark.
    Screenshot 2016-08-18 14.43.28.png
     
  20. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Hmm, that camera clipping plane is typically too high, as you're passing the limits of float precision by going from 0.1 to 10,000. For some games likes yours it may work, but typically you'd want it a bit smaller.

    Regarding the bloom texture, if you are using HDR bloom, and your exposure is set quite high, that will happen, as the bloom texture is influenced by the exposure. My recommendation here is just to not tick the "Use Bloom Blur Tex" option.
     
  21. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    I have an issue with Prism under Unity 5.4 P1. When exiting playmode in the editor and with "Use exposure adaptation" on in the prism settings, I get
    The Scene view becomes unusable after that. I've edited the the beginning of your HandleExposure function to do

    Code (CSharp):
    1.         if (!currentAdaptationTexture)
    2.             return;
    as a temporary workaround

    Edit: We're also seeing a slow memory leak in the editor, not related to the "Use exposure adaptation" in fact it happens when the PrismEffects component is enabled, but with none of its internal options checked. We can resolve both issues for now by removing
    Code (CSharp):
    1. #if UNITY_5_4_OR_NEWER
    2. [ImageEffectAllowedInSceneView]
    3. #endif
    from the PrismEffects class, so I think we'll do that unless you come up with a fix - we can still see the effect at edit time in the game view, so its no great loss.
     
    Last edited: Aug 21, 2016
  22. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Currently working on a 5.4-specific update to PRISM which will fix this and a few other little things that have popped up since 5.4 has come out of beta. Thanks for the bugreport!
     
  23. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    I hit the shader keyword cap and is think of stripping keywords from assets, you mentioned that some keywords in prism are shared and has complex functions, mind put a section in manuel to help us stripping out keywords when we know what effects to use? Something similar to Horizon[on]'s manuel?
     
  24. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Does not help you now, but the keyword limit is doubled to 256 in the new 5.5 beta

    Lennart
     
  25. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    It is not a perma fix, I am only running Lux and Prism with few custom shaders and reached the limit, 256 is hardly foolproof.
     
  26. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Added a section to the end of the document! I will be doing some more experiments with Unity 5.4, if they fixed the shader_feature bug I reported in it (while the bug is still active, I can't use shader_feature to save on about 4 keywords), I am very tempted to do a 5.4-only build of PRISM with this and some more changes... Will keep everyone updated.
     
    yc960, Shodan0101 and punk like this.
  27. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Hi @GoGoGadget
    I have an issue with Prism together with my water shader. Working in Forward mode, fragment shader.
    To have Fog and DoF properly working on the water I had to add a ShadowCaster path otherwise Prism render the effect reading the depth of the ground under the water.
    The problem is that my water shader also needs to access the _CameraDepthTexture but as soon as I add the ShadowCaster pass the depth of the water is always zero because the depth texture is updated before my forwardadd pass.
    Do you know how to resolve / workaround this issue?
    Thank you.
     
  28. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Just checked out the section, it has tips on 2 sets of shader keywords, does that mean all other are integral to the Package?

    I am exclusively using HDR bloom, can I remove simple bloom? or will that destablize the asset? Can I kill nightvision? What is the minimum keywords required to function?

    Ok, there is a problem, changing this line "

    #pragma multi_compile _ PRISM_GAMMA_LOOKUP PRISM_LINEAR_LOOKUP

    "
    to

    "#define PRISM_LINEAR_LOOKUP"

    prevents color correction LUT from working at all
     
    Last edited: Aug 31, 2016
  29. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Also happy to report that the asset is functioning in the new 5.5 beta.

    One more thing, I am currently using the volumetric light solution.
    https://github.com/SlightlyMad/VolumetricLights

    and It does not play well with the AO in PRISM. bug report 3.jpg

    Notice the AO is rendered after the volumetric fog, looking really off. Any suggestion as to how to fix it?
     
  30. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Hi mcmorry,

    The relevant section (and workaround) in PRISM's guide can be found under "PRISM In-Depth - Effects - Fog".
    • Note: In order to combine PRISM’s fog with other effects, PRISM’s fog draws later in the frame than other fog effects, which typically draw before transparents have been rendered. This can lead to different behaviour, like fog applying where there is a transparent surface. If you want to switch PRISM to draw entirely before transparents, simply add the line:
    • [ImageEffectOpaque]
    To PrismEffects.cs, one line above the “OnRenderImage” function.

    If you're not using Nightvision, it should not count as a keyword, as it is a Shader_Feature by default.
    With regards to everything else, there is *potential* for one more keyword to be removed, but it is technically used in the current setup. PRISM already uses very few keywords for all the effects it offers and shares keywords where possible, so apart from the two sets in the documentation, there isn't really any 'fat to trim' so to speak.

    See the above workaround, or set the AO cutoff to a shorter distance to fix this.
     
  31. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    My question is not about transparent surfaces but about CameraDepthTexture.
    Anyway I already added that attributes to avoid problems with particles and is not resolving.
     
  32. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Can you send the the shader and maybe a demo scene in private message? I'll have a play around and see what the exact problem is, and the best way to fix it for you.
     
  33. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Thank you. I sent you a message.
     
    GoGoGadget likes this.
  34. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Ok I followed the instruction and now both tonemaping and colorlut stopped working in Prism... No error showed in console but no lut or tonemapping at all.
     
  35. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Just tested out a different solution that works, swap #define for #pragma multi_compile xxx and they work (in-editor). Noted in documentation as well.
     
    yc960 likes this.
  36. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Working.
    Found a missing space on the line
    "#pragma multi_compilePRISM_LINEAR_LOOKUP"
     
    GoGoGadget likes this.
  37. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    I still like to request a lens flare feature similar to that of Scion's. I've attached a comparison and the presence of the lens flare does matter quite a bit, for scion, the lens flare cost roughly 0.1ms on a 980M gpu, and if you add something similar it would definately worth the performance cost.

    First pic is scion, 2nd PRISM.
     

    Attached Files:

  38. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Currently working on some very cool stuff for a future update, will try squeeze lens flare in.

    Can I ask what version of Unity you (or anyone else) is using? Assuming most people are on 5.3.

    Also, what Unity scene/pack is that? Seen it around the place but don't have it.
     
  39. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    5.4
     
    GoGoGadget likes this.
  40. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
  41. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    5.3 and 5.4.
     
    GoGoGadget likes this.
  42. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    5.4 and looking to try 5.5, the scene is Corridor Lighting Example, but unity killed it for some reason.

    https://www.assetstore.unity3d.com/en/#!/content/33630
     
    GoGoGadget likes this.
  43. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    408
    5.4
     
    GoGoGadget likes this.
  44. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    I'm on 5.4 P2, updating to 5.4.1. Sorry if this has come up before, in fact I think I may even asked about the same error message before, but I need to switch some of our scenes to forward rendering to gain performance, and with SpeedTrees, it seems we still have issues with AO. The last advice I read for this was to add the separate PRISMAO script onto the camera as well as the Prism script (and unchecking the integrated AO). But doing this now produces the following error at runtime:

     
    Last edited: Sep 17, 2016
  45. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    May be a 5.4 issue - I would look into it, but I've actually updated the AO on an internal version (2.0 WIP) to get that fixed anyway. PM me if you are under a tight deadline and I can help you out further.
     
    duencil likes this.
  46. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    PM Sent. Also, quick question: does the component order of the legacy PRISMAO script on the camera matter, since it is inserting itself into the PrismEffects? I was thinking to add the component programatically when a scene is setup that is found to be using forward rendering, copying settings from the integrated AO in PrismEffects to the legacy one. But at runtime theres no way to alter the component order, so it would be added after for example FXAA.
     
  47. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    No, it doesn't matter. Replied to your PM
     
  48. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    In addition to PRISM, I also own Beautify (https://www.assetstore.unity3d.com/en/#!/content/61730) which is also an stacked image effect pack that I do not use currently due to lack of some critical features(filmic grains,chromatic abberations, etc). However with their latest release adding anamophic flare I decided to see how it works. Somehow with layered bloom, anamorphic flare, lens dirt and its contrast effect, it only costs 0.5ms on my 980M on 1080p. In comparison, PRISM costs 1ms with only bloom active.

    I expect higher perf cost in PRISM since it is richer in feature but I would be curious to know if whatever they are using to cut perf cost can be used in PRISM as well?
     
  49. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Generally speaking, the less settings you have to tweak, the more performance you gain - but I would wager their bloom is a simpler bloom that doesn't offer up as much as PRISMs (which performs multiple blur passes on textures, has a built-in stability pass that is mixed with the prepass, if using HDR bloom - PRISM's "Simple" bloom probably has that sort of performance though). If you look at, say, PlayDead Games' recent slides on how they rendered their game Limbo, they spent about 1ms doing all their blur passes, then 0.7ms combine, IIRC.

    With all that being said, there's always room for improvement, particularly now that I know I don't have to support 5.0 anymore. As an example, one of the cool things coming in PRISM 2.0 is MRTs, which I'm using for certain effects like DoF (and will be looking into for Bloom) - very handy in getting cheap far/near field DoF the right way!
     
    punk and yc960 like this.
  50. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I have an issue with the fog on some iOS devices.
    On iPhone5S and iPadAir1 is perfect, but on iPhone6 and iPhone6S Plus there is a lot of banding:
    IMG_3085.jpg
    IMG_3084.jpg
    Unity 5.4.1p2, rendering with Metal, single camera, clip planes: 1, 400

    The enabled effects are Bloom, Dof, Fog (with near blur), Vignetting, LUT and God Rays

    Any idea what could be? Is really ugly to see the bands moving forward and back with the camera.