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

Huge CPU overhead with additional cameras or reflection probes - am I missing something?

Discussion in 'High Definition Render Pipeline' started by chris_ngale, Nov 12, 2020.

  1. chris_ngale

    chris_ngale

    Joined:
    Nov 4, 2019
    Posts:
    6
    Hi all, I've been working on a project in the URP but I started experimenting with the HDRP recently and I'm really impressed with the visual results. Performance has been pretty good too - a simple test scene I made (one terrain, one directional light, two spotlights, one low-poly static vehicle) is running at 150fps at 1080p, 90fps at 1440p (results similar both in editor maximised and an external build).
    upload_2020-11-12_12-2-50.png

    However as soon as I add any additional camera of any form (either a camera or a real-time reflection probe) I find that I'm experiencing huge CPU overhead. For instance, if I add a single reflection probe, my framerate drops to ~50fps - independent of game resolution, even at a silly low resolution like 100x100, so it can't be a GPU bottleneck. Changing HDRP quality and post processing settings (including turning off all PP) has very little effect - maybe one or two FPS.

    This is the profiler for that 100x100 resolution run (exactly the same for any other resolution I tested up to and including 1440p). You can see that there are seven camera calls - one for the main camera (3ms) and six for the reflection probe (1.5ms each).
    upload_2020-11-12_11-47-6.png

    I tried another test with a second camera rendering to rendertexture, and the result was very similar - a 1.5-2ms overhead for each additional camera. Again, this was independent of the camera's target resolution - results were near as makes no difference for 512x512 or 16x16. This seems like a lot of CPU overhead - especially considering Unity's own documentation lists the performance impact of reflection probes as "Medium-High (this depends on the resolution of the capture)". As far as I can tell, the performance impact is almost totally independent of capture resolution, and comes down entirely to the CPU overhead associated with each camera. This suggests to me that this CPU overhead is not expected behaviour.

    Even more confusing is that the same documentation lists the performance impact of Screen Space Reflections as "High", yet I see much less of a performance impact from these. Unfortunately, baked reflections and screen space reflections don't work for my purpose - even if I can sort out an alternative for environmental reflections as seen on the vehicle windows, I still need real-time reflections of one sort or another for vehicle mirrors from the driver's view, which will either need to be planar reflection probes or separate cameras.

    I really like the results I'm seeing in the HDRP but this camera overhead is a complete deal-breaker at the moment.

    Is there something I'm missing, or should I just stick to the URP?

    Hardware:
    - Ryzen 5 3600 @ 4.2GHz
    - MSI B550M Mag Mortar
    - 32GB DDR4-3200
    - Radeon RX 580 8GB
    - Unity is installed on a 512GB SATA SSD, the project is located on a 1TB PCIe gen 4 SSD
     

    Attached Files:

  2. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    400
    HDRP perform culling for each camera, and for each shadow cascade. In the case of a reflection probe, if you setup shadow to use 4 cascades, HDRP do culling 6 + 6 * 4 = 30 times. And only thing you can do is disable shadows in reflection probe.
     
    BATTLEKOT and chris_ngale like this.
  3. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    400
    Сheck it on my game: 1 reflection probe takes 13-15ms, no shadows, 50m culling distance. So, 60fps with reflections are impossible, or require some monstrous CPU.
     
    Last edited: Nov 12, 2020
    chris_ngale likes this.
  4. chris_ngale

    chris_ngale

    Joined:
    Nov 4, 2019
    Posts:
    6
    Thank you for confirming this - as my CPU isn't particularly weak I don't understand how any game made in the HDRP is supposed to achieve reasonable performance with any form of reflection or additional camera
     
  5. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    400
    HDRP was never be planned as game production render pipe. It was be planned for a cinematics.
     
  6. tuinal

    tuinal

    Joined:
    Dec 14, 2012
    Posts:
    17
    Both cameras and RT probes are incredibly performance-heavy.

    This isn't really an HDRP thing, it's a real-time rendering thing. Look at a mirror in a AAA Unreal game like Dishonored 2 - it's either black or broken. And it never uses a 2nd camera.
     
  7. tuinal

    tuinal

    Joined:
    Dec 14, 2012
    Posts:
    17
    [Er.. yeah, I know Dishonored 2 isn't Unreal - but points still stands! :) ]