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

Discussion Forward+ Rendering in 2022.2 beta

Discussion in 'Universal Render Pipeline' started by Unusual-Cadence, Sep 24, 2022.

  1. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    42
    Hello! Is there any info anywhere on the new Forward+ rendering feature in the latest beta? I can't find any documentation anywhere on how it works, what the restrictions are, how to profile it etc. It seems to work great in a test scene, and I can add loads of point lights etc to a scene with all of them rendering, but I did notice a warning that says 'Orthograpthic Cameras are not supported in Forward+ mode'... but it seems to work anyway! What are the drawback/restrictions of using an Orthographic camera, and is there any possibility this will be 'properly' supported in the future as this is the kind of camera I'd be wanting to use for my project!
     
  2. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    If you want a run-down of how it works, check out: https://www.3dgep.com/forward-plus/

    Basically, it's just forward rendering with much better light culling. So it lets you do MSAA, have better control over emission/lightmaps/AO, have more advanced material types, etc. All the advantages of forward rendering without looping through every light for every pixel.

    I don't know about the orthographic camera restriction. I'm guessing Unity just hasn't implemented the culling phase for it. There's no technical reason they couldn't support it.

    I wanted to use an orthographic camera in my game (top-down/RPG), but found that too many shaders/assets/features didn't support it correctly. Eventually, I relented and switched to perspective with a very low FOV (and far away). There's very little visual difference between a camera with an FOV of like 2.5 and an orthographic camera (other than screwing the pooch on your near/far planes if you're not careful)

    This is basically what I do to set my camera position, which is an "almost-orthographic" look. Set the camera to perspective and set the field of view to like 2.5. Then...

    Code (CSharp):
    1. public static void setupPerspectiveFromOrthoParams(Camera camera, Vector3 lookAt, float rotationX, float rotationY, float orthographicSize)
    2. {
    3.     Transform transform = camera.transform;
    4.     Quaternion rotation = Quaternion.Euler(rotationX, rotationY, 0);
    5.     Vector3 direction = rotation * Vector3.forward;
    6.     float distance = orthographicSize * (1 / Mathf.Tan(camera.fieldOfView * .5f * Mathf.Deg2Rad));
    7.     transform.position = new Ray(lookAt, direction).GetPoint(-distance);
    8.     transform.rotation = rotation;
    9. }
    The main reason to go full orthographic is if you have a prerendered background and 3D characters (eg Bauldur's Gate style).
     
    Last edited: Sep 25, 2022
    DevDunk likes this.
  3. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    We'll be adding some more documentation around this feature for sure. The in-view light limits are the same for now (256 for desktop, 32 for >= GLES 3.1, 16 otherwise). These are not necessarily fixed forever, we're just taking it one step at a time. Besides that, there are no limits for lights per object or pixel. This allows instancing to work better, as it's not limited to 8 lights for the whole instanced draw, and procedural draws can actually get more than just the directional light. The same goes for rendering in DOTS.

    Orthographic is currently not supported due to the culling not being implemented for it, but it will be later on. So the drawback is just that it doesn't work right now :)
     
  4. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    42
    Alright, that's great news! Is there any idea when the light culling will be supported for orthographic cameras? Sadly I'm not able to use the perspective camera as suggested above for a bunch o' reasons. What happens right now when I use the Forward+ mode and have say, 16 lights in view in orthographic mode? Does every material shader render as if it has the maximum number of lights affecting it?
     
  5. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    191
    When is XR support for Forward+ likely to land? Specifically SPI.
     
  6. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Also looking for an ETA on XR support for Forward+ and cannot find any info. Any news?

    // Wildstyle
     
  7. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    Oh it doesnt work in XR? To be honest, I feel like the primary use case for Forward+ would litterally be in XR, so I hope they add support soon. I genuinely thought that XR would have been the direct reason they wanted to add this renderer.
     
    WildStyle69 likes this.
  8. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    We don't have an ETA, but we are working on it :)
     
    WildStyle69 likes this.
  9. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    610
    I feel Forward+ has been released under false pretenses - the feature seems more like it is in Beta right now.

    First off: huge fan of Forward+!!!

    However, I would like to know the best place to give feedback for it. I have some notes:
    - Depth Priming Mode is incompatible with MSAA
    - Use Rendering Layers for Lights simply doesn't work, neither does the Culling Mask on Lights themselves
    - Orthographic Camera Support (but that has been mentioned earlier in this thread)

    If these get fixed I really don't see why I would ever need Forward or Deferred again (perhaps just Forward for more performant Quality Settings), so I would love to see these issues fixed!
     
  10. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    @CaseyHofland I appreciate the interest in Forward+ :D
    Are you seeing this issue only for Forward+? Because it shouldn't be affected by that, but I won't rule it out of course :)
    This was fixed this week, and will be backported to 2022.2. Can't say which version yet though.
    Barring potential issues, I've finished up development of XR support and am currently working on landing that. Orthographic support is next up, and I've already worked out most of the math needed for the culling. Not sure whether it can be backported yet.
     
  11. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    610
    So here is a scene with MSAA set to 8x and Forward Plus Renderer Depth Priming Mode to Forced
    Forward Plus Normal.png

    Nothing wrong here, but now we add decals:
    Decals.png
    1. Jagged edges
    2. Overdraw
    3. Color is off (the decal is brighter than shown here)

    Add Screen Space Ambient Occlusion aaaand:
    Ambient Occlusion.png

    Mr. Game & Watch is back in town. (note: the white cube is transparent and as to my understanding not part of depth priming)

    Turn Depth Priming Mode off, we get:
    Depth Priming Mode off.png
    Scene looks great, jagged decal is in this case because of mipmaps

    So there's definitely something funky going on. Hope that this gets picked up: even though "not having depth priming mode" is perfectly fine, it lost me an hour of debugging so a comment in the documation at least would be appreciated.
     
  12. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    610
    That's great to hear! Even though there's no ETA yet, should we expect this closer to "will be backported this month" or "will be backported 3 months from now"? Regardless: kudos! Just asking so I can make plans for our current project.

    Kudos again! At least that's fixable by giving any orthographic cameras a Forward renderer.
     
    peterbay likes this.
  13. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    Does this mean you'll have an ETA on XR release soon?

    Pretty excited to try this out, could be a silver bullet for my project right now. :D I'm using Deferred, so am keen to try out Forward+.

    Best Regards,

    Will
     
    peterbay likes this.
  14. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    @CaseyHofland Yikes, that does not look good. Could I get you to submit a bug report on it? Then we'll get it fixed :)
    The backport PR is created and is being tested at the moment. Hard to give an estimate as it depends on a number of things at this point, and isn't tied to a particular patch version yet.
    No ETA yet, but the current status is that it's being tested :)
     
    WildStyle69 likes this.
  15. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    I've play a bit with forward+ few month ago and really like the result.
    In a 100-ish point lights scene the performance is better than deffered.
     
    CaseyHofland and peterbay like this.
  16. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Is this supposed to work on IOS? If so, its broken.
     
  17. Foreverplane_

    Foreverplane_

    Joined:
    Nov 11, 2018
    Posts:
    11
    Critical bug here.
    Hybrid per instance property if it connected somehow to color-based nodes in shader graph makes material pink.
    Unity 2022.2.8f.

    This makes it impossible to change material properties from ecs systems. Has anyone come across?
     
  18. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    I'll take a look and see how it looks on my end :)

    This sounds more like an issue with Entities Graphics or Shader Graph than Forward+. Can you try making a thread in the Shader Graph forum?
     
    Foreverplane_ likes this.
  19. Foreverplane_

    Foreverplane_

    Joined:
    Nov 11, 2018
    Posts:
    11
  20. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    78
    I just want to write that I am excited to try out Forward+, but my project is VR. I'm hoping VR compatibility will at least land in the 2022 LTS.

    I've found that Forward with Depth Priming works very well in my project, but it can't handle the number of lights that I need, so I have to use Deferred. Deferred seems to perform worse in general than Forward, so I'm very excited for Forward+ in URP!

    I've tried the Depth Texture with Deferred but it doesn't seem to help in any way, whereas Depth Priming saves a good chunk of time.
     
  21. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    It's possible to have depth priming in deferred (HDRP does this). The costs on CPU side (draw calls) will be higher but I think the bottleneck of your project is on GPU.

    You can try submitting an idea on the roadmap (deferred depth priming) so that they may add this to URP in the future.
     
    Liam2349 likes this.
  22. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    78
    Thanks, that's pretty cool. I've tried all three render pipelines at some stage of my project (open world PCVR game), I found HDRP to be really heavy no matter what I did so I settled into URP, but it's awesome that HDRP has that. I'm also hoping we get cached shadow maps!

    I'm seeing a small improvement from depth priming when I am CPU limited (50 - 60% GPU usage), and a large improvement when GPU limited, but my open world is still very much a work in progress. I am targeting 11ms as my frame budget (1080Ti + 8700k).

    Here are some interesting results I found, just for reference:
    Deferred: 60% GPU, 5.2ms.
    Forward: 90% GPU, 4.7ms.
    Forward + Depth Priming: 60% GPU, 4.3ms.

    The pipeline asset settings are as close as possible in all three tests, which I did at the same time by changing quality levels in a build.

    So Forward is able to better make use of my GPU in this specific scenario (stood outside of a house in my open world), but enabling Depth Priming makes it even faster still and without the extra GPU load. I haven't measured the CPU load, but I try to keep the GPU load down as I assume that will increase the most when going into VR, but I should do a proper test on this.

    One key note is that the Forward tests are not rendering all lights in the house (all lighting is real-time), but I still see that Depth Priming saves a good chunk of time, and in my other tests I find Forward to be generally faster than Deferred anyway.

    EDIT: Submitted the request, thanks.
     
    Last edited: Mar 5, 2023
    wwWwwwW1 likes this.
  23. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    42
    Any word on Forward+ being supported by the Orthographic camera?
     
  24. lilacsky824

    lilacsky824

    Joined:
    May 19, 2018
    Posts:
    171
    2023.2 support orthographic.
     
  25. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    Indeed :) We also backported to 2023.1 and 2022.2, so it is available from these versions:
    2023.2.0a10
    2023.1.0b15
    2022.2.18f1
     
    DevDunk and CaseyHofland like this.
  26. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    610
    I... can't remember if I ever submitted that bug report :rolleyes: we don't use depth priming so it didn't come up :p

    In any case, did you ever get a chance to look at this?
     
  27. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    42
    That's great news, thanks! I looked through all the point release and URP changelogs and I couldn't see any mention of it. I guess I missed something obvious!

    Edit: D'oh, it's right at the top of the 2022.2.18 changelist, I did miss something obvious!
     
    peterbay likes this.
  28. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    78
    Hi, do you know if Forward+ for XR will make it into the 2022 LTS?
     
  29. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    I don't think I've seen a case like this come in, so I haven't looked at it. Does it still happen on one of the versions I posted above? That fixed quite a few issues.

    Yes, it will be in the LTS too :)
     
    Liam2349 likes this.
  30. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    610
    We're actually going to update our project version next week, so I'll let you know by then (right now we're sprinting pls kl me)
     
    peterbay likes this.
  31. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    78
    Very exciting! I look forward to testing it out in my project.

    Also, there is no information right now on when the new LTS will arrive. Is there any date range you are targeting? Historically it seems the LTS should release any time now.
     
  32. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    Good to hear :D Sorry, I don't have anything to share regarding dates. 2023 LTS should be based on 2023.2, so at least way that has to release first.
     
    Liam2349 likes this.
  33. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    @peterbay - the 2022 LTS has dropped now right, is XR support for Forward+ in already or coming soon?
     
  34. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    I'm not able to find the release note about support for XR. But in this post about ECS milestones, they have confirm that forward+ for XR is now in Unity 2022 LTS.
    1. Forward+ Support on XR devices: Forward+ support for XR platforms is now available, unlocking new lighting capabilities in XR. Specifically, this allows creators to have more than one directional light in the scene.
     
    WildStyle69 and Liam2349 like this.
  35. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    78
    That's cool, thanks. I've noticed roughly a 7% frame rate increase with Forward+ DepthPriming compared with Deferred, but I've not had a chance to test in VR yet. I'm hoping to do it within the next week or two. Also, this is just for the world without additional player-controlled lights.

    One thing I'm not sure on, is under which circumstances Unity recommends using Deferred vs. Forward+. It seems like Forward+ is universally better, at least in my scenes, which do have around 10 or 12 active lights at any time (and this will increase).

    Have you found anything regarding this?
     
  36. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    The benefits for forward+ compared to deffered are -
    we can have various material while each of them using it's own custom lighting logic. this approach does not fit well in traditional deferred rendering.

    And most of the custom shader you found on asset store are written in Forward mode. Upgrade those shader to forward+ compatible is much easier.

    Plus I'm really not sure about the performance of current Deferred rendering path in URP.
    (Last time I check it's even slower than built-in, probably cause by other features URP uses. But have not use a formal test so it's a vey bias result.). It would be awesome to have some real comparison stats from Unity.

    For the differences between forward, deferred and forward+, you can check this post.

    Forward+ is essentially a traditional forward rendering path with a much better light culling stage. But since the Forward+ mode is just release so expect some bug occur along the way.
     
    Last edited: Jun 9, 2023
    Liam2349 likes this.
  37. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    761
    If you need to access GBuffers, you have to switch to Deferred path.

    But I found that enqueueing a custom GBuffer pass (with Depth Priming after opaque rendering) in any Forward path can be fast too unless the bottleneck is on vertex shader (many vertices).
     
    echu33 likes this.
  38. ANB_Seth

    ANB_Seth

    Joined:
    Mar 4, 2022
    Posts:
    14
    Hi, its been a while, but does anyone know when or if Forward+ will be fully functional for VR (XR)? I have tried the latest Version out yesterday 2023.2.0a22 and realtimelights are still having blocky flickering edges.
     
  39. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    Are you using a custom shader?
    I've encounter similar issue for my custom shader when I first tried to modify my shader so it can work with Forward+ few months ago...But don't really remember how it got solved....

    If not. maybe screenshot the issue and tag the Unity staff.
     
  40. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    78
    Haven't had a chance to try in VR yet, but there are certainly shader issues. One of my custom shaders is completely borked, works fine in regular Forward and Deferred. It's shader graph.

    I have an asset named Volumetric Blood Fluids, which does not render under Forward+, but that may just be due to missing passes rather than bugs with Unity. I'm not sure.

    Forward+ works well with Amplify Impostors, which currently does not render correctly under Deferred + Decals.

    Note: All of the above is for URP in 2022.
     
  41. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    (Just reminder, probably won't help in your case :)")
    For anyone want to make cutom shader compatible with forward+, check out this repo. if your shader graph include custom lighting code(ex: retrieve addtional light data via custom function node). search the code blocks with USE_FORWARD_PLUS definetions. which contains required changes.

    Changes can also be found in official graphics repo
     
    Liam2349 likes this.
  42. ANB_Seth

    ANB_Seth

    Joined:
    Mar 4, 2022
    Posts:
    14
    I use basic URP Lit shaders ... but it pretty much on all shaders. Shaders look nice, problem are the realtimelights in VR on them. The lights have flickering blocky edges. Can post a screen later. But the problem existed before, just wondering if its just my project or if its still being worked on or not
     
  43. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    Since forward+ only support XR recently. That could be a bug and you might want to submit a bug report.
     
  44. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Hi,

    Is there any plans to make Forward plus compatible with existing custom image effects and shaders, like deferred was a very easy to use, directly working with all image effects so far ?

    Forward plus seems to break everything, both image effects and shaders, without any apparent way on how to make all work again.

    Thanks
     
  45. mattdevv

    mattdevv

    Joined:
    Dec 28, 2019
    Posts:
    12
    Adding on to this, is there going to be support for custom projection matrices? e.g. Matrix4x4.Frustum()

    I saw in the URP code that XR cameras use a modified view center when creating forward+ tiles. Modifying the code to do this for my camera too wasn't correct though, there was artifacts around the edges of point lights and shearing the frustum vertically moved the shadow tiles inversely.

    For reference, the change I made was to ForwardLights.cs and I altered the tiling job's center offset to reflect the shearing along the Z axis in the projection matrix

    from:
    Code (CSharp):
    1. centerOffset = cameraData.xrRendering && cameraData.xr.viewCount > 0 ? 2f * cameraData.xr.ApplyXRViewCenterOffset(math.float2(0.0f, 0.0f)) : float4.zero,
    to:
    Code (CSharp):
    1. centerOffset = cameraData.xrRendering && cameraData.xr.viewCount > 0 ? 2f * cameraData.xr.ApplyXRViewCenterOffset(math.float2(0.0f, 0.0f)) : new float4(-viewToClips[0][2][0], -viewToClips[0][2][1], 0, 0),