ndepoel / FSR3Unity

FSR 3.1 Upscaler integration for Unity built-in render pipeline, with support for DX11, Mac, Linux and consoles.
https://discussions.unity.com/t/open-source-fidelityfx-super-resolution-3-1-fsr3-upscaler-for-unity-birp-dx11-ppv2-hdrp17-multi-platform/917847
MIT License
251 stars 30 forks source link

Increase FPS? #5

Open 2324268086 opened 1 year ago

2324268086 commented 1 year ago

It seems that there is no effect on optimizing performance. Is it only useful for AMD graphics cards? I thought it could make my fps higher

ndepoel commented 1 year ago

Hi,

FSR2 does not only work on AMD graphics cards, it is useful on Nvidia and Intel cards just as well. However, the performance benefit you get from it very much depends on the circumstances. FSR2 itself is not a cheap technique to run; it takes a significant amount of GPU time per frame to execute, and whether that gets compensated by rendering at a lower resolution depends on what you're rendering and how that is affected by resolution changes.

If your scene has a lot of fillrate-heavy effects, such as alpha blended particles, lots of foliage overdraw, or expensive pixel shaders that use a lot of texture samples, then you'll likely see a big benefit from rendering at a lower resolution and upscaling with FSR2. Exotic rendering techniques like ray tracing will also gain a lot from this. If on the other hand your scenes and shaders are relatively simple, then the difference from upscaling might not be as pronounced.

Secondly, you're see more benefit from FSR2 upscaling as you target higher resolutions. 1080p is where I would say FSR2 is barely worth it for performance; it may be useful on older or low-end graphics cards, but most of the time with 1080p you're better off rendering at native resolution. At 1440p or 4K output resolutions however, FSR2 becomes much more useful. Using FSR2 Performance mode can even make targeting 4K 60fps viable on a mid-range graphics card.

Finally, FSR2 will only help performance if your game is GPU bound. If the framerate is being limited by the CPU being maxed out, then applying FSR2 upscaling won't help performance. FSR2 helps by reducing the rasterization load on the GPU, with the tradeoff being some extra GPU compute load being added instead. This means that you'll only see a benefit if your game is limited by GPU rasterization performance. This also depends on what hardware you're using exactly; a high-end graphics card with loads of rasterization power and high memory bandwidth is less likely to see performance gains from FSR2, compared to a low-end or mid-range graphics card.

If you want to know more about what FSR2 is doing and how it affects the overall rendering performance of your game, I recommend using a profiler to gain more insight in your render pipeline. You can use the timeline view in Unity's internal profiler, or use an external tool like RenderDoc or PIX to make a GPU capture and analyze that. This will show you how much GPU time FSR2 uses up and allows you to make useful comparisons as to what effect various output resolutions and FSR2 quality modes have.

2324268086 commented 1 year ago

To apply FSR2 to a camera, simply add the Fsr2ImageEffect script to your camera game object. It should be placed at the bottom of the components list, to ensure that it's the last image effect in the chain.

Please use the code to set the rendering order. Once the camera dynamically adds a script, it will become invalid

ndepoel commented 1 year ago

Please use the code to set the rendering order. Once the camera dynamically adds a script, it will become invalid

I would love to, but as far as I know Unity does not provide any way to change the order of components on a game object programmatically, at least not at run-time. Script execution order also doesn't make any difference; the order in which OnRenderImage calls are executed on scripts is entirely determined by the order of the components on a game object, as it's set up in the editor.

To be perfectly honest, I wouldn't recommend using the Fsr2ImageEffect script in a real game project anyway. It exists mostly as a proof-of-concept and as an example of how to integrate FSR2 into a render pipeline in its simplest form. It has too many problems with post-processing effects and interaction with other rendering components to be truly usable.

The modified Post-Processing Stack V2 package with FSR2 on the other hand is production-ready and something I can recommend using. It integrates with Unity's post-processing in a way that's much closer to optimal, and it doesn't have any problems with component ordering. If you're already making use of Unity's PPV2 stack, then it's a very simple drop-in replacement.

2324268086 commented 1 year ago

ppv2 is okay, but it also needs to be placed at the bottom to work properly