Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  3. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Quest + LWRP/URP: MSAA not working

Discussion in 'AR/VR (XR) Discussion' started by DanjelRicci, Nov 30, 2019.

  1. rquinones84

    rquinones84

    Joined:
    Apr 18, 2016
    Posts:
    11
    Can you post the modified ForwardRenderer.cs it seems to be getting lost in the many messages above, and the links send me to 404's
     
  2. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,389
    @rquinones84

    You'll find this in ForwardRenderer.cs:
    Code (csharp):
    1.  
    2.             m_ActiveCameraColorAttachment = (createColorTexture) ? m_CameraColorAttachment : RenderTargetHandle.CameraTarget;
    3.             m_ActiveCameraDepthAttachment = (createDepthTexture) ? m_CameraDepthAttachment : RenderTargetHandle.CameraTarget;
    4.             bool intermediateRenderTexture = createColorTexture || createDepthTexture;
    5.  
    Change it to this:
    Code (csharp):
    1.  
    2. #if !UNITY_EDITOR
    3.             m_ActiveCameraColorAttachment = RenderTargetHandle.CameraTarget;
    4.             m_ActiveCameraDepthAttachment = RenderTargetHandle.CameraTarget;
    5.             bool intermediateRenderTexture = false;
    6. #else
    7.             m_ActiveCameraColorAttachment = (createColorTexture) ? m_CameraColorAttachment : RenderTargetHandle.CameraTarget;
    8.             m_ActiveCameraDepthAttachment = (createDepthTexture) ? m_CameraDepthAttachment : RenderTargetHandle.CameraTarget;
    9.             bool intermediateRenderTexture = createColorTexture || createDepthTexture;
    10. #endif
    11.  
    You may also want to search for the declarations for afterRenderExists and requiresFinalPostProcessPass and replace their initializations simply with "false".
     
    ROBYER1 likes this.
  3. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,046
    Also take the packages from the package cache and keep them locally stored in the packages folder while removing refs to the live packages in Package Manifest otherwise every time you open your proj Forwardrenderer.cs will get overwritten
     
    Brady likes this.
  4. rquinones84

    rquinones84

    Joined:
    Apr 18, 2016
    Posts:
    11
    I couldnt find any references for , afterRenderExists and requiresFinalPostProcessPass . in the entire project, what classes contain those?
     
  5. rquinones84

    rquinones84

    Joined:
    Apr 18, 2016
    Posts:
    11
    Sorry a little confused by that, not sure where the package cache is, but i have been trying to get MSAA to work for weeks now on the quest.

    I've made all the neccessary code changes time and after time.

    Is there a step im missing when i build to the quest? perhaps involving that package cache and moving them locally and removing refs to live packages?

    I had not seen that step anywhere before.
     
  6. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,389
    You'll find the ForwardRenderer.cs file in your packages. So scroll to the bottom of your project view and you'll see "Packages". Expand that and find "Universal RP". The file you seek is under the "Runtime" folder. If you right-click it and reveal in explorer, you'll see the actual path to the package cache. The package manifest is under the "Packages" folder in your project and named "manifest.json". In it, you'll find the entries for each of the installed packages.
     
  7. rquinones84

    rquinones84

    Joined:
    Apr 18, 2016
    Posts:
    11
    ok i was able to copy the insides of
    com.unity.render-pipelines.core@7.2.1 into \Packages\com.unity.render-pipelines.universal\
    And removed the reference, recompiled, then double checked to see if the file references by "show in explorer" and it does go to the contents i just added.
    Still no luck, MSAA still does not work.

    I'm going to post the main culprits that might be causing it:
    URP 7.2.1, Unity 2019.3.0f6
    Oculus setting in XR PLugin Manager "Stereo Rendering Mode"=Multiview, V2 signing=true.
    I build the app to apk then transfer over usb using adb install command.
    I am using 7x 2048x2048px "Baked Indirect" lightmaps.
    No Real time lights.
    On Cameras:
    Backgrounds of cameras are set to Color with a blueish background.
    PostProcessing=false, No FXAA and No SMAA on cameras.
    I'm using occlusion culling baked, small 14kb occlusion size. and its enabled on all cameras.
    Use Recommended MSAA checkbox = false on the object with the OVR Manager
    I am using only the lit shader, but i have some objects with transparency such as glass.
    In player Settings:
    Start in full screen=true, render outside safe area = false, Resolution scaling disabled, blit type = never.
    Use 32 bit dispaly buffer = true, Disable depth and stencil = false, render over native ui = false.
    I am using Linear Color Space.
    OpenGLES3
    Color Gamut sRGB.
    Multithreaded rendering, static batching, compute skinning, graphics jobs all set to true;
    Minimum Api = Android 7.0
    Target API = Automatic
    Scripting background Mono, Api Compatibility = .net standard 2.0, Target Architecture = ARMv7
    in UniversalRP-HighQuality.asset:
    Depth texture = false,
    Opaque Texture = false,
    HDR = false,
    MSAA = 4x
    RenderScale = 1
    Lighting main and additional = disabled
    grading mode Low Dynamic Range
    SRP Batcher = true
    Dynamic batching = true,
    Mixed lighting = false,

    Additionally im going to paste the lines i added and to the scripts i added them to
    Inside my class AAFix.cs:
    Code (CSharp):
    1.     private void Start()
    2.     {
    3.         QualitySettings.vSyncCount = 0;
    4.         Application.targetFrameRate = -1;
    5.         StartCoroutine(Fix());
    6.         QualitySettings.antiAliasing = 4;
    7.         UnityEngine.XR.XRDevice.UpdateEyeTextureMSAASetting();
    8.         Debug.LogError(UnityEngine.XR.XRSettings.eyeTextureDesc.msaaSamples);
    9.     }
    10.  
    11.     private IEnumerator Fix()
    12.     {
    13.         yield return new WaitForEndOfFrame(); // Needed to apply the changes
    14.         yield return new WaitForSeconds(0.1f); // Needed to apply the changes
    15.         //OVRPlugin.fixedFoveatedRenderingLevel = OVRPlugin.FixedFoveatedRenderingLevel.Medium;
    16.         UnityEngine.XR.XRSettings.eyeTextureResolutionScale = 0.98f; // Any value, just to trigger the refresh
    17.         yield return new WaitForEndOfFrame(); // Needed to apply the changes
    18.         UnityEngine.XR.XRSettings.eyeTextureResolutionScale = 1f; // Use your target resolution here
    19.         Debug.LogError("after: " + UnityEngine.XR.XRSettings.eyeTextureDesc.msaaSamples);
    20.         yield return null;
    21.     }
    in forwardrenderer.cs i changed the following in the exact places the forum posts say to do so.
    Code (CSharp):
    1. #if !UNITY_EDITOR
    2.                 m_ActiveCameraColorAttachment = RenderTargetHandle.CameraTarget;
    3.                 m_ActiveCameraDepthAttachment = RenderTargetHandle.CameraTarget;
    4.                 bool intermediateRenderTexture = false;
    5. #else
    6.             m_ActiveCameraColorAttachment = (createColorTexture) ? m_CameraColorAttachment : RenderTargetHandle.CameraTarget;
    7.             m_ActiveCameraDepthAttachment = (createDepthTexture) ? m_CameraDepthAttachment : RenderTargetHandle.CameraTarget;
    8.             bool intermediateRenderTexture = createColorTexture || createDepthTexture;
    9. #endif
    and
    Code (CSharp):
    1. createColorTexture &= !isStereoEnabled;  // TODO: Could this replace isRunningHololens?
    in UniversalRenderPipeline.cs i changed to the following:
    Code (CSharp):
    1.             if (QualitySettings.antiAliasing != asset.msaaSampleCount)
    2.             {
    3.                 QualitySettings.antiAliasing = asset.msaaSampleCount;
    4. #if ENABLE_VR && ENABLE_VR_MODULE
    5.                 XR.XRDevice.UpdateEyeTextureMSAASetting();
    6. #endif
    7.             }
    What else am i missing here?
    Did i miss a blit removal line of code?
    Perhaps wrong unity version or wrong URP version?
     
  8. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,389
    Here are the main differences in your setup and mine:

    • I made the modifications I posted in 7.1.8. So it's possible there may be one or two other places you'll need to look in 7.2.1. Basically look for any code that has anything to do with doing a blit, post-processing, etc.

    • I'm using 2019.3.0f3, but I doubt that matters here.

    • I'm using the legacy XR support rather than the XR Manager, and so I'm set to Single pass instead of Multiview

    • I'm using .NET 4.0
    I think that's all the major differences that I think have any chance at all of impacting the result.
     
  9. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,046
    Ensure that your Renderer assets have Opaque Texture disabled, having Opaque texture ticked anywhere (either on your game camera, or on the Render pipeline assets) will break it. Also ensure on the camera/on the pipeline assets in the same place mentioned before that HDR and Post processing are disabled/off where you can disable them as they will also cause the blit.
     
  10. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    38
    I did all the same things (also the URP/forward rendering script changes and package shenanigans) as you mentioned here and still no luck.

    I did a RenderDoc capture to see what was going on on the device following this guide:
    https://developer.oculus.com/blog/h...usage-scenarios-and-optimization-tips-part-1/

    I can "Verify no temporary buffers are used" - I'm rendering to RTDeviceEyeTextureArray with R8G8B8A8_SRGB - never to _CameraColorTexture or anything else.

    Also, it's weird because they state;
    Yet in most of their screenshots the final blit pass is there...

    I do have something blit related in the very end of the render frame under;
    PlayerEndOfFrame
    -XR.Blit

    But it does not have any render duration.

    I've noticed that MSAA does get applied in the unity editor both in and out of playmode with a Rift S connected.
    Meanwhile.
    Debug.LogError(UnityEngine.XR.XRSettings.eyeTextureDesc.msaaSamples);
    always shows 1, so i guess that's not the correct setting?
     

    Attached Files:

    ROBYER1 likes this.
  11. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,046
    Can you confirm that Fixed Foveated Rendering (FFR) is not working in this example, but MSAA is working? On the Quest that is of course, not the editor.

    I am trying to escalate this issue here as FFR is not working for us either in the same scenario, even in an empty scene with Postprocessing, HDR and Opaque texture all disabled in URP 7.2:
    https://github.com/Unity-Technologies/ScriptableRenderPipeline/pull/5900
     
  12. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    38
    MSAA is not working - never has for me (since upgrading to URP and 2019.3 - which I was forced to do to get Single Pass rendering working on Quest).

    FFR actually does work - OVRMetrics report an FOV value of 3.

    I tried downgrading to 2019.3.0f6 - no difference in testing.

    EDIT:
    Renderdoc does seem to display FFR as working at least in the output texture - but i don't really notice the same level in the headset - probably because everything is minecraft without AA.


    EDIT 2: see reply below
     
    Last edited: Feb 19, 2020
    fherbst likes this.
  13. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    38
    I am stupid....
    Back when I created the new project (for upgrading to URP and 2019.3) I forgot to disable the unused quality settings... So I was always building the medium setting with the medium quality render pipeline.



    Now both FFR and MSAA works!
    Thanks for all the help everyone - I will not change a damn thing now unless It's really necessary!
     
    MoMonay, ArchVizPRO and ROBYER1 like this.
  14. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,046
    Great! And yours is working with the edited ForwardRenderer.cs to avoid the Color Texture and other things causing the final blit?
     
  15. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    38
    Yes, this is with the edited forwardrenderer.cs and universalRP.cs as mentioned earlier;

    Code (CSharp):
    1.             if (QualitySettings.antiAliasing != asset.msaaSampleCount)
    2.             {
    3.                 QualitySettings.antiAliasing = asset.msaaSampleCount;
    4. #if ENABLE_VR && ENABLE_VR_MODULE
    5.                 XR.XRDevice.UpdateEyeTextureMSAASetting();
    6. #endif
    7.             }
    I've only noticed the blit operation I attached earlier;

    Otherwise there's nothing indicating blit operations
     
  16. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,046
    I am assuming that ForwardRenderer.cs unedited with our hacks added causes the Final Blit operations which prevent FFR from working?

    As in if you revert the changes to ForwardRenderer.cs, does FFR still work?

    MSAA will still work if you revert the changes to the regular ForwardRenderer.cs but for us FFR doesn't. It is likely your MSAA only works on the Quality setting you set that has 'Opaque Texture' unticked on it.
     
    Last edited: Feb 19, 2020
  17. rquinones84

    rquinones84

    Joined:
    Apr 18, 2016
    Posts:
    11
    THATS EXACTLY what was wrong LOL. i deleted medium and low and now MSAA works, THANK YOU EVERYONE.

    Btw i did not use any custom edits to URP, and this was on URP 7.1.8 (i had reverted last night) with unity 2019.3.0f6. I was using the code for AAFix.cs to do the eye switcher thing and i uncommented out the line that sets the anti alias settings at run time and UpdateEyeTextureMSAASetting().
    So those 2 lines were active.

    I dont know if they are neccessary anymore but i wont remove them for now i have to move on with the project now that my boss is happy.

    So everyone knows the difference between medium and high had nothing to do with the opaque or depth texture.
    Medium settings had the following differences:
    Terrain Holes = Enabled.
    Main Light = per pixel.
    Addition light = per pixel.
    Mixed Lighting = enabled.

    All the rest of my settings matched medium.

    once i deleted the medium settings it immediately worked.
    It was definitely something to do with those 3 in combination with either my lightmaps or linear color space or something else that i wont ever figure out.
    What i do know is i have 0 real time lights, only baked.

    Oh also one other step i did yesterday that i didnt write in the previous post was that in the 3 vr cameras i manually changed Opaque Texture to disabled, instead of leaving them to Use Pipeline Settings.

    but i had already tested after that with no luck on the msaa.
     
    Last edited: Feb 19, 2020
  18. rquinones84

    rquinones84

    Joined:
    Apr 18, 2016
    Posts:
    11
    Btw i havent tested FFR, nor do i even know how to turn that on, i believe the last state was that you had to manually enable it over ADB, i'd rather wait till its in the system itself.
     
    ROBYER1 likes this.
  19. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,046
    Brady and ArchVizPRO like this.
  20. jariwake

    jariwake

    Joined:
    Jun 2, 2017
    Posts:
    100
    Hi. I found this thread when trying to figure out what it the proper way to enable AA on Oculus Quest.

    There seems to be AA settings both in the pipeline setting and per camera:

    upload_2020-2-28_10-34-17.png

    But the only way to get AA working seems to be to set it per camera...why is this?

    My setup:
    Unity 2019.3.1f1

    Packages:
    URP 7.2.1
    Oculus XR Plugin 1.1.5
    XR Interaction Toolikit 0.9.3 (preview)
    XR Management
     
    ROBYER1 likes this.
  21. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,046
    FXAA is a post-processing version of anti-aliasing which is different to MSAA, try a higher MSAA setting in the render settings and keep 'AA' set to None on your camera. Let us know if that doesn't work.
     
  22. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    727
    @jariwake you should really turn off "Post Processing" toggle on camera for Quest, and as Rob said, "Anti Aliasing" below "Post Processing" to "None" (this is just a post effect, not "real" hardware MSAA).
    On your left screenshot, keep it at 4x. Also, you can prob disable "Terrain Holes".
     
  23. jariwake

    jariwake

    Joined:
    Jun 2, 2017
    Posts:
    100
    @ROBYER1 I assume that by "render settings" you mean the pipeline asset settings? There is no AA related settings in the Project Settings/Quality settings anymore..

    Anyway, I disabled the per camera and enabled the MSAA in the URP asset. But when I build and deploy to Quest, there is no AA at all....until I press the Oculus button once and go back to the application! =)

    What can explain this weirdness? A bug in URP?
     
    Last edited: Feb 28, 2020
  24. jariwake

    jariwake

    Joined:
    Jun 2, 2017
    Posts:
    100
    I see, but I still want to have bloom post processing effect in my app. According to this it should be ok: https://docs.unity3d.com/Packages/c.../manual/integration-with-post-processing.html
     
  25. PsychoStuey

    PsychoStuey

    Joined:
    Mar 4, 2015
    Posts:
    13
    Hi all, another guy over here wrestling with enabling MSAAand FFR. FFR, no problem, but the MSAA, such a pain in the ass to get it switched on. Been combing through this thread over and over trying to find the detail I missed. But anyway, one thing I noticed is that depth textures are forced on in the camera script, the drop down box is greyed out with (On, forced due to post processing).

    My question is, how in gods name do I turn it off, the tick box which says post processing is switched off on all cameras. I tried to go into the renderer and and set the post processing data to none, I never added any post processing effects at any time.

    Very annoying, any thoughts or advice?
     
  26. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    727
    @PsychoStuey best option at this point is to embed URP and modify it locally to only do the passes / things you actually want (in ForwardRenderer.cs). Future releases (> 7.2.1) should hopefully allow to do that, but currently that's your best bet.
     
    ROBYER1 likes this.
  27. PsychoStuey

    PsychoStuey

    Joined:
    Mar 4, 2015
    Posts:
    13
    Any advice on specifically what passes to take out and where to do it? I don't dive in to the technical parts of rendering, don't want to screw anything up.
     
  28. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,046
  29. PsychoStuey

    PsychoStuey

    Joined:
    Mar 4, 2015
    Posts:
    13
  30. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,046
  31. PsychoStuey

    PsychoStuey

    Joined:
    Mar 4, 2015
    Posts:
    13
    It didn't fix it for me! I don't get why it refuses to work, I have a very simple setup, no lights or shadows, purely unlit, no extra render objects or anything, just one camera (though I have a second disabled one also)
     
  32. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    38
    And of course your quality settings are using the correct render pipeline asset?
     
  33. welliAR

    welliAR

    Joined:
    Jun 25, 2018
    Posts:
    26
    I got mad about this. I need HDR, Postprocessing, MSAA & FFR. Is this possible with alle the mentioned hacks here? Just added AAFix.cs. Does nothing. Reduced to 1 Quality-Setting wit 4x MSAA on Render-Asset. If this really works. Can someone finally recap what to do :) Thx a lot
     

    Attached Files:

    snoche likes this.
  34. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    38
    I think achieving HDR is wishfull thinking.

    Otherwise the steps I did here:

     
  35. welliAR

    welliAR

    Joined:
    Jun 25, 2018
    Posts:
    26
    OK Thanks. I give up then for now... i really cant understand why this is so bad. The only thing i want is to use latest Tech like URP/Vulkan HDR, FFR and at least MSAA. All is working without MSAA :(
     
  36. welliAR

    welliAR

    Joined:
    Jun 25, 2018
    Posts:
    26
    OK, OK. I did disable HDR and now MSAA is working. But this is a nogo. I switched to URP to have those fancy effects using shader graph. Bloom and so. My Lasergame looks bad without HDR. But only for final asking. They do work on it to get all those Features Running on Quest and URP?
     
  37. rquinones84

    rquinones84

    Joined:
    Apr 18, 2016
    Posts:
    11
    Eventually im sure they will, it really depends on what you need for now, you can always update it at a later time when its all proven fixed.
    I too had no luck with getting Vulkan to work, it loads it just has weird visuals. but hopefully that changes soon. im sure theyre trying to fix each thing, while fixes break other things that they havent tested.

    I'm sure they'll get the right combination sooner or later.
     
    welliAR and ROBYER1 like this.
  38. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,046
  39. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    38
    ROBYER1 likes this.
  40. Ostermalm

    Ostermalm

    Joined:
    Oct 5, 2019
    Posts:
    3
    Finally got MSAA to work in 2018.4.9f1 - thank you to all for your tips. The difference is stunning. These are the settings that finally did it (some may be unnecessary, I just threw everything I had at it). I have not installed URP or LWRP.
    - In the OVRManager script, set the MSAA setting to "false"
    - In the camera, tagged MainCamera, renderer "Forward" and checked "Allow MSAA"
    - In Project Settings/Quality, unchecked all levels (Very High, High, etc) except the one I'm using with Quest settings that I got from a Youtube video (basically the ones recommended by Oculus including setting MSAA to 4x).
    - Put in a new GameObject with the AAFix shown by Danjel Ricci here: https://forum.unity.com/threads/quest-lwrp-urp-msaa-not-working.786026/#post-5363064
    - Put these lines in a Start block in one of my objects, along with "using UnityEngine.XR":
    XRSettings.eyeTextureResolutionScale = 1.0f;
    OVRManager.fixedFoveatedRenderingLevel = OVRManager.FixedFoveatedRenderingLevel.Off;
    QualitySettings.antiAliasing = 4;
    (still experimenting with FFR, so I don't know yet if that works or not).
     
  41. snoche

    snoche

    Joined:
    Feb 22, 2010
    Posts:
    80
    I am having the same problem with MSAA, I tried the aafix but it doesn't nothing

    I am usign Unity 2019.4.3
    Vulkan
    HDR, FFR and postprocess to have bloom

    All works fine except MSAA and Multiview
    Is any plant top fix/implement that any time soon?

    Thanks
     
  42. RyanKeable

    RyanKeable

    Joined:
    Oct 16, 2013
    Posts:
    26

    I have been working on implementing HDR and bloom for a little while now and there’s a few issues with it for sure.

    applying tone mapping before your final blit helps significantly but it doesn’t solve everything.

    the _cameraColourTexture looks OK when rendering opaque and transparents but certain aspects like the UI will go jagged again in the final blit. I don’t currently understand why.

    to my eye the first blit for the bloom pyramid is getting MSAA resolved so I do not know how many resolves are occurring and whether or not subsequent resolves are making the issue worse.

    I was going to try rendering everything with no MSAA samples up until my final blit and see if that made a difference. A lot of it is guess work on my end as I am new to this type of graphics programming.

    I am not using FFR as I am running fine at 72fps already, I am just trying to have HDR colours MSAA resolved nicely.
     
    ROBYER1 likes this.
  43. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,389
    @RyanKeable please drop a note here with any updates on your progress. I'd be very interested to see your solutions, particularly getting bloom working with this!
     
  44. tom_fv

    tom_fv

    Joined:
    Jul 19, 2017
    Posts:
    13
    I've just come across this problem and I think (early days) I may have a fix, but it involves copying the Universal Render Pipeline package to your projects Packages folder and editing a file.

    Using 2019.4.18f1
    URP 7.5.2

    I edited this file:
    Packages/com.unity.render-pipelines.universal@7.5.2/Runtime/UniversalRenderPipelineCore.cs
    specifically the function CreateRenderTextureDescriptor

    Code (CSharp):
    1. static RenderTextureDescriptor CreateRenderTextureDescriptor(Camera camera, float renderScale,
    2.     bool isStereoEnabled, bool isHdrEnabled, int msaaSamples, bool needsAlpha)
    3. {
    4.     RenderTextureDescriptor desc;
    5.     GraphicsFormat renderTextureFormatDefault = SystemInfo.GetGraphicsFormat(DefaultFormat.LDR);
    6.     // NB: There's a weird case about XR and render texture
    7.     // In test framework currently we render stereo tests to target texture
    8.     // The descriptor in that case needs to be initialized from XR eyeTexture not render texture
    9.     // Otherwise current tests will fail. Check: Do we need to update the test images instead?
    10.     if (isStereoEnabled)
    11.     {
    12.         desc = XRGraphics.eyeTextureDesc;
    13.         renderTextureFormatDefault = desc.graphicsFormat;
    14.     }
    To:

    Code (CSharp):
    1. static RenderTextureDescriptor CreateRenderTextureDescriptor(Camera camera, float renderScale,
    2.     bool isStereoEnabled, bool isHdrEnabled, int msaaSamples, bool needsAlpha)
    3. {
    4.     RenderTextureDescriptor desc;
    5.     GraphicsFormat renderTextureFormatDefault = SystemInfo.GetGraphicsFormat(DefaultFormat.LDR);
    6.     // NB: There's a weird case about XR and render texture
    7.     // In test framework currently we render stereo tests to target texture
    8.     // The descriptor in that case needs to be initialized from XR eyeTexture not render texture
    9.     // Otherwise current tests will fail. Check: Do we need to update the test images instead?
    10.     if (isStereoEnabled)
    11.     {
    12.         desc = XRGraphics.eyeTextureDesc;
    13.         desc.msaaSamples = msaaSamples;
    14.         renderTextureFormatDefault = desc.graphicsFormat;
    15.     }
    Specifically adding the line:
    Code (CSharp):
    1. desc.msaaSamples = msaaSamples;
    Initial tests seem to work just now, but will post if there are any problems
     
    FutureVisual likes this.
  45. RyanKeable

    RyanKeable

    Joined:
    Oct 16, 2013
    Posts:
    26
    So there is a couple of things I do to attempt to smooth out the AA issues:


    half4 Frag(Varyings input) : SV_Target
    {
    UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);

    float2 uv = UnityStereoTransformScreenSpaceTex(input.uv);

    half3 color = (0.0).xxx;

    // Camera Colour Texture
    color = SAMPLE_TEXTURE2D_X(_BlitTex, sampler_LinearClamp, uv).xyz;


    // Bloom
    half3 bloom = SAMPLE_TEXTURE2D_X(_Bloom_Texture, sampler_LinearClamp, uv).xyz;

    bloom = Vibrance(bloom, -0.05);
    bloom = Saturation(bloom, 1.25);

    bloom *= _Bloom_Intensity * 0.8h; // temp balancing
    color += bloom.xyz;

    color = NeutralTonemap(color); // assits with anti aliasing

    color = Vibrance(color, -0.1);
    color = Saturation(color, 1.1);
    color = Gamma(color, 1.2);
    color = Exposure(color, .5);
    }


    return half4(color, 1.0);
    }


    Unity's NeutralTonemap() seems to really help reduce the Aliasing but other forms of Tonemapping (other than straight Reinhard) do not help. I also tonemap in the Bloomfilter pass after the colour filter is applied to help in the bloom chain too. The supporting colour corrections are there to bring back the colour definition I want that is lost during the tonemapping.

    Secondly, to further help smooth out the bloom blur I do this:


    for (int i = mipCount - 3; i >= 0; i--)
    {
    int lowMip = (i == mipCount - 2) ? ShaderConstants._BloomMipDown[i + 1] : ShaderConstants._BloomMipUp[i + 1];
    int highMip = (i == 0) ? ShaderConstants._BloomMipDown[1] : ShaderConstants._BloomMipDown[i];

    int dst = ShaderConstants._BloomMipUp[i];

    cmd.SetGlobalTexture(ShaderConstants._MainTexLowMip, lowMip);
    cmd.Blit(highMip, BlitDstDiscardContent(cmd, dst), m_BloomMaterial, 3);
    }


    Which is passing the first full blurred render(H and V) to the scatter blend pass rather than the bloomfilter render. This also helps smooth out the aliasing.

    Adversly, the best approach would be to encode to RGBM in each pixel shader you are using and then decode in your filter and final blit passes. This occupies your alpha channel however and you would need to pass transparency in through another buffer, which I do not know how to do.

    I'll write up a proper blog about this at some point with support materials and images.
     
    Last edited: Feb 4, 2021
  46. alloystorm

    alloystorm

    Joined:
    Jul 25, 2019
    Posts:
    28
    Reverting from URP 7.5.2 to 7.3.1 solved my problem with MSAA.

    Did some further testing just now. Actually the last version that works for me is 7.5.1, the latest 7.5.3 is also having the issue.

    So definitely something is broken since 7.5.2.
     
    Last edited: Feb 8, 2021
  47. Fabian-Haquin

    Fabian-Haquin

    Joined:
    Dec 3, 2012
    Posts:
    231
    Is there any update of this ?

    I can't make MSAA work in VR at all but it works without with the same setup:

    Unity 2020.1.17
    URP 8.3.1
    SteamVR
    Tested with Oculus Rift S and HP Reverb G1

    Edit: Updated to URP 9.0.0 preview and it work
     
    Last edited: Feb 25, 2021
unityunity