Announcement

Collapse
No announcement yet.

Optimizing scene

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Optimizing scene

    Good morning,
    I created an environment with static meshes, some foliage and many particle systems. I already worked for optimizing it, but I achieve 32-33 FPS in game. Foliage is already set with culling and LODs. I was thinking of optimizing the lights:
    1) Should I set point Lights on Static or Movable for best performance?
    2)Any tip to gain more fps?
    3)I'm pretty sure I need to manage shadows because when I remove them I gain many fps. How could I manage this problem without removing shadows?
    Thank you for your assistance.
    Last edited by The dragon01; 03-14-2020, 04:24 PM.

    #2
    Hi, can you show the result of the following console commands when you run you're game in standalone (not PIE or in Editor)?

    stat unit ; stat gpu ; stat rhi

    stat commands give information on how your scene performs.
    And a screenshot from the shader complexity viewmode when you're fps is low would be useful too.


    As for your other questions:

    (1) static. Static means it gets precomputed and baked into textures (you need to build lightning) and therefore you will have a fixed cost during runtime, meaning after building lightning it is no difference whether you have one or one hundred static lights in your scene.
    Movable means your lights and shadows are dynamic and need to be computed during runtime and especially the dynamic shadows are heavy on performance (so if you would need to make lights movable you should see if you can disable shadows on them).

    (2) Try with as less dynamic shadow lights as possible, use less foliage, keep the shader complexity low (under optimization viewmodes you can switch to "Shader Complexity" then you will see how complex your materials are. One think you should keep in mind there, is that since 4.23 masked materials (grass, trees,. ..) show up wrong, they are shown green although they are much heavier)
    You can also press F5 during the game to switch to the shader complexity viewmode.

    (3) use static lightning if possible, since it is precomputed it runs fastest.

    Comment


      #3
      Good morning,
      thank you for your fast response. I uploaded the screen containing required results of those commands: stat gpu, stat unit and stat rhi.
      @chrudimer I set all lights to static light considering movable ones weren't necessary, and I reduced shadows according with what you said, but I'm still between 27- 40 FPS. Any other idea considering also the screenshot?
      Thank you.
      Attached Files
      Last edited by The dragon01; 03-15-2020, 02:53 PM.

      Comment


        #4
        After you set the lights to static, you need to actually build the lightning

        Click image for larger version

Name:	build_lightning.jpg
Views:	301
Size:	202.4 KB
ID:	1733137

        Building lightning will take some time depending on how many lights you have in your scene, quality settings, lightmap resolution of the meshes, ...
        So direct under the build lightning only button you can set the lightning quality (this makes no difference in game performance, so unless you want to build lightning fast to get a preview, you would choose production quality).

        Next you should make sure that all not moving meshes are set to static (if they are set to movable then the lightning won't be build for them) and further before you build lightning you should place "Lightmass Importance Volumes" in your level covering the areas the player can travel (inside those volumes you will have higher lightning quality, but placing them everywhere in your level will greatly increase lightning build times)


        And another thing is, all the meshes you want to build lightning for, need to have a seperate non overlapping lightmap UV-Channel (normally they will already have that).



        For further info on static lightning you could read the doc: https://docs.unrealengine.com/en-US/...***/index.html
        and I find the learning videos from epic games very useful https://www.unrealengine.com/en-US/o...arning-courses in this case "Lightning Essential Concepts And Effects".

        From your image "Lights", "Shadow Projection" and "Shadow Depths" take up around 26ms. Those are because you have many dynamic lights/ not build the static lightning (then even if you set it to static it will still be dynamic, cause it is not build).

        Else you are slightly (48 MB) above your texture streaming pool size. You can change the size of the streaming pool via console using: r.streaming.PoolSize or set it inside of the "DefaultEngine" file, then you won't have to set it via console every time you restart the editor. The default value is 1000 MB.

        Comment


          #5
          Good Morning
          well that's embarassing but yes, I forgot to build lightning. Doing it I achieved about 80 Fps! That's amazing!
          About the texture streaming pool size: will I lose FPS by changing it's value?
          Thank you very much!!!

          Comment


            #6
            No you won't loose FPS, but if you would use up more video memory than your GPU has you would experience issues but no constant FPS drop (but 1000 MB pool size is fairly low).

            The streaming pool contains all textures that are set to stream.
            Basically if you're close up to an object you want to see high details, so have a high texture resolution, but if you only see this object from far away or don't see it at all, then you don't need to have the full resolution texture loaded into memory. Therefore unreal engine generates mip maps (the same texture in smaller sizes) for all textures. In order to generate mip maps the size of the texture needs to be a power of two though (so something like 2048x2048 or 512x1024, ...). So if you would have a texture size of 2048x2048 the first mip map would have a size of 1024x1024 then 512x512, ...
            The streaming pool size is the upper limit for this pool size. Therefore if the engine would like to stream in a higher resolution mip map it can't do this if this would lead to going beyond this streaming pool size. You get to see the "TEXTURE STREAMING POOL OVER X MiB BUDGET" warning though. The X stands for the amount of Megabytes the engine would need to go beyond the current streaming pool size.
            So if you're far beyond the pool size you would eventually see blurry textures, since the engine would have to do with lower resolution mip maps (you can try this by setting the pools size to a small number like 200 MB).


            To see the video memory used by unreal engine you could use "stat D3D12RHI" if you're running DX12, further there is also "stat memory" and for texture streaming "stat streaming" and if you would type in "stat streaming" auto completion would give some more suggestions. Basically if you never done this it might be useful to type in "stat" and try all the stat commands, and see what info they give.
            And generally (I assume you already do this, but it is rather important for performance therefore I mention it) always test performance in standalone, else you will also see the performance used up by the editor.

            Comment


              #7
              Originally posted by The dragon01 View Post
              Good morning,
              I created an environment with static meshes, some foliage and many particle systems. I already worked for optimizing it, but I achieve 32-33 FPS in game. Foliage is already set with culling and LODs. I was thinking of optimizing the lights:
              1) Should I set point Lights on Static or Movable for best performance?
              2)Any tip to gain more fps?
              3)I'm pretty sure I need to manage shadows because when I remove them I gain many fps. How could I manage this problem without removing shadows?
              Thank you for your assistance.
              1: Use movable ONLY when you need to actually move said light otherwise use stationary for its quality (Similar but slightly less quality to dynamic, MUCH cheaper and a lot less buggy with things like reflection captures.) or static (Lowest cost, drops quality harshly due to ue4 or nothing really anti-aliasing its lightmaps so reserve this far/ambient lights, like skylight, otherwise use stationary for its flexibility.)

              2: Strip off anything that takes a lot of power and doesnt contribute much. Use the command: profilegpu to help you find what is taking so much time to compute. Also, if you use planar reflections, force only 1 to be visible at a time, based on when it actually matters, otherwise use reflection capture/ssr.

              3: Static only, you will get identical fps and keep your shadows, they wont look as good as stationary but they are free.

              A tip: If you dont use a day night cycle, dont even touch dynamic directional lights, instead use a stationary directional light with cascaded shadow maps with lower settings and distance than the dynamic one. You will gain a lot of graphical quality and a bit of framerate.

              Yet another tip: For that scene and other ones, you might want to keep an eye on global illumination if you want most of the area to be pitch black, as GI will, as its name implies, illuminate a lot more than just what is directly in the light, as it does in real life.

              More tips: Reduce texture size when you cant tell the difference between the higher and lower res version. You will save a good amount of vram, stop it from going over the texture pool, and probably improve texture quality elsewhere due to the freed up space. Even if you dont need to free up space, its good practice and can actually free up some space in the final product.

              Even more tips: If your aiming for DX11/DX12 only (Or DX13 if your from the future) Try BC7 compression on transparent textures, you will gain some texture quality at literally no cost whatsoever, just compatibility will be an issue for really old systems and it takes 2X space on non-transparent textures, but it looks great.

              Comment


                #8
                3: Static only, you will get identical fps and keep your shadows, they wont look as good as stationary but they are free.
                Hmm, as far as I understands it static lights do have a cost on performance as they increase the shader instruction count (so volumetric lightmaps to light movable objects are more costly than surface lightmaps) but it is a fixed cost that does not depend on the amount of static lights since everything is baked into lightmaps.
                Also the lightmaps cost memory and disk space (especially for large open worlds the disk space might be a problem) but still as far as actual performance between the light types goes, static lights are the best.

                Even more tips: If your aiming for DX11/DX12 only (Or DX13 if your from the future) Try BC7 compression on transparent textures, you will gain some texture quality at literally no cost whatsoever, just compatibility will be an issue for really old systems and it takes 2X space on non-transparent textures, but it looks great.
                Never thought of that one, but now I will make sure that all my textures that have an alpha channel use the BC7 compression. Thanks for that one!

                Comment


                  #9
                  Just some notes.

                  FPS alone no longer plays a large part in determining performance issues as rendering per frame is not done how it use to be as in how long does it take to render out a single frame. It can tell you something is wrong but can not tell you what it is that is causing the performance drop as part of the total number of rendered elements which is based on the refresh time of the single elements.

                  It could be lights, it could be shadows, it could be complex shaders. In other words it could be just one thing alone but as part of the total time in ms to refresh the render, based on the numbers, it's a best guess as to the cause and what is required to solve the problem.

                  As part of the process it's now best practice to complete the project and then record a profile of the project in real time and then play back the profile and step through per frame and see how the various elements are rendered as a total sum of the refresh rate.

                  The process.

                  https://www.youtube.com/watch?v=-csRxRj_zcw&t=1663s

                  By process of elimination you can see the result as to changes made as to elements that clearly, with out guessing, as to the impact of doing things like changing lighting types.

                  Also give forward rendering a try as well
                  Clarke's third law: Any sufficiently advanced technology is indistinguishable from magic.
                  Custom Map Maker Discord
                  https://discord.gg/t48GHkA
                  Urban Terror https://www.urbanterror.info/home/

                  Comment


                    #10
                    Thank you all,
                    you gave a lot of important informations to me. I'm applying whatever you said and results look really good. I achieved about 100FPS. I think my scene needs some work for performance optimization, and I'll follow what you guys said. I considered FPS the most important thing in optimization but now I'm discovering many other parameters.
                    FrankieV I will also consider the profile recording as part of my work on this project because I didn't know it, but it can be really usefull.
                    I've got another question: is It a good idea to use static lights to light my scene without any directional light? Instead of that I'm using a skylight.
                    Thank you very much.

                    Comment


                      #11
                      Is it a computer-only product? or is it for consoles / other platforms too? If for console too, then trying to get and maintain over 60 FPS is almost pointless because the current generation of consoles lack the capacity to render more than 60 FPS, except for perhaps the Pro versions (PS4 Pro, etc). And for computers, lots of computers are still in the 8-16 GB RAM / 2-3 GHz CPU range, and do not have dedicated graphics cards. Even ones with dedicated GPUs are restricted to not sharing some resources, and the refresh rate of the monitor, apparently, must be 120 MHz to attain 120 FPS anyway. The main purpose of maintaining higher FPS is to synchronize rendering with the refresh rate of the display, thus removing stutters, stops, and certain kinds of lag. The FPS is also restricted by the type of HDMI in use, 1.4 or 2.0, and the resolution, 1920x1080p or higher or lower for some computers. So, optimizing to a certain FPS isn't the answer alone. It's going to require optimizing for particular computer specs, particular platforms, and even particular TV setups. Optimizing for faster and less problematic use of Unreal Engine is different from optimizing for platform/device scalability.

                      Comment


                        #12
                        I've got another question: is It a good idea to use static lights to light my scene without any directional light? Instead of that I'm using a skylight.
                        There is nothing that would force you to use a "directional light". A "directional light" lights the whole scene (as opposed to point light, spot light,... those have an attenuation radius). If you don't need a directional light that lights the whole scene (for example a sun or a moon) then you don't need to add a "directional light".

                        Comment


                          #13
                          Originally posted by chrudimer View Post

                          Hmm, as far as I understands it static lights do have a cost on performance as they increase the shader instruction count (so volumetric lightmaps to light movable objects are more costly than surface lightmaps) but it is a fixed cost that does not depend on the amount of static lights since everything is baked into lightmaps.
                          Also the lightmaps cost memory and disk space (especially for large open worlds the disk space might be a problem) but still as far as actual performance between the light types goes, static lights are the best.



                          Never thought of that one, but now I will make sure that all my textures that have an alpha channel use the BC7 compression. Thanks for that one!
                          100% correct. Lightmaps can be shunk to near-non existent sizes though, and said shader cost is so low it can be flat out ignored, as it is the same cost as some basic math, Ex: Adding a few variables

                          Comment


                            #14
                            Originally posted by The dragon01 View Post
                            Thank you all,
                            you gave a lot of important informations to me. I'm applying whatever you said and results look really good. I achieved about 100FPS. I think my scene needs some work for performance optimization, and I'll follow what you guys said. I considered FPS the most important thing in optimization but now I'm discovering many other parameters.
                            FrankieV I will also consider the profile recording as part of my work on this project because I didn't know it, but it can be really usefull.
                            I've got another question: is It a good idea to use static lights to light my scene without any directional light? Instead of that I'm using a skylight.
                            Thank you very much.
                            Directional lights/skylights are optional. Photorealistic scenes flat out ignore directional lights, only going with a skylight.

                            Comment


                              #15
                              Good mornig,
                              many thanks to all of you. I found really usefull your advices and now it seemes there are no more problems. FPS are great and following your advices results are very good.
                              presto423 This environment will be used in a computer game, so I was trying to achieve more FPS but in fact what you said is right and it risks to became an useless work at a certain point.
                              Bits360 thank you for your answer because I thought directional lights were important to achieve a good scene. But considering that this environment is set at night and without moon it would be pointless I think.
                              chrudimer I found your advices very usefull and you helped me a lot.
                              Moral of the story: thanks to all of you guys; you saved my project!

                              Comment

                              Working...
                              X