Slow FPS - and Inspector/Debug/Render Targets

I built a semi-complex scene, i have sky dome, animated clouds (~9 xprnt png files i rotate around at various speeds to get clouds moving across the sky) a terrain using a hight bitmap and TerrainMaterial with textures for grass, sand, and pebbles for a river bed and a waterMaterial to give effect of flowing water. Then i have around 10 different xprnt png trees and animals usin gBillboard and clone each of thode 2-3 x each to have a number of trees and animals around the scene. Then, in the center i have a ‘Temple’ with domes, arches, and lots of pillars. 76 pillars. there are 3 different pillar styles, so at first i cloned the 3 base ones into the 76 total needed. Yesterday I changed from cloning them to instantiateHierarchy to see if that would help with my slow FPS, which it did, but, only slightly.
And, that is the problem, i am getting slow FPS. Like ~19 fps when inside the “temple”, only around 12 fps when outside of the Temple with camera looking at the temple. It goes to ~25 when outside not looking at the temple.
Big problem is that inside the temple i have a TV screen which i texture a Video onto and when the scene does 19 FPS (anything below 30) it makes the video choppy. So, i need to figure out how i can save my temple and still get a good enough fps for a 30 fps video to play smoothly in the scene.

According to INSPECTOR there are a total of 1455 meshes - when i don’t instantiate the pillars there are only 808 meshes total - I get around 22 FSP without the pillars and ~19 with them. . (Of course, i need the pilars) If I don’t load the temple at all, then I get ~46FPS when I play the video and the camera is looking at it. I get ~48FPS when looking at the river, and 60fps not looking at either of those. Without the temple there are 286 meshes total. All of that would be ‘acceptable’ but, I have to have the Temple in the scene, that is the main part.
Now, one thing I haven’t mentioned yet, is i do have quite a number of LARGE png/jpg textures. I forgot to mention that around the terrain i have 4 - what i call panorama images, there are 5100x800 24bit png files with xparency of pasture to mountains, that blend in with my terrain and give a realistic distant view. It looks great, but 4 5100x800 pngs probably take some resources. Then, the grass texture on my terrain is 2kx2k file - and still it is a repeating texture. Then, on the temple i have a number (~14) fairly large texture files - most around 1600x1200, some as large as 3600x2600 - so the marble effects look detailed even close up. None of those are repeating, one texture image covers an entire wall. I love the way the temple and scene looks, but, i will start working on trying to reduce the texture images sizes to see if that is my main culprit.

Wow, sorry for all the detail, but, i wanted you to know what the basic scene was, this is too much for me to post it all up on a playground.
Other than any ADVICE on where else i might look, to increase my FPS, i have a question about
“Render Targets”. As far as i know, my scene is using straight forward rendering, but, i was in the INSPECTOR turning off and on various things to see what is causing the slow FPS, and In the Debug panel i saw a switch to turn off Render Target. I thought if i flip it off, the scene would stop rendering, would either stand still, or would go black. I was surprised when it seemed to do nothing. Everything just worked as Normal - EXCEPT for 2 very curious things happened. Even inside the Temple with the video playing the FPS shot up from 19 FPS to 60 FPS. What? And, I had Windows Task Manager up and I noticed another very peculiar thing - When I turned Render Targets OFF the GPU work load on the PC shot up from ~30% to 60%. The GPU workload increased and the FPS shot way up. And, the whole scene, everything seemed to render just as before - the water was flowing etc.

So, What IS this RENDER TARGETS that i can turn off from the Inspector/Debug panel? And, what is it controlling?
Can I set some option in the Renderer that will do this automatically for my scene? Will that work, is that i would need to do? And, what downsides are there to disabling it?
I have an old I-7 using an NVidia GeForce GT graphics card. Turning Render Targets off shoots its workload up from 30 to 60%, so i wonder how this will work on other systems out there. But, if this is all i need to do, that would be great. (I have an old Dell I-5 tablet with intel graphics built in, and before i was only getting 5 FPS on that, i haven’t tried it turning off the Render Targets on that and see how that performs yet, i will, but, probably not for a day or so, i am busy right now.

Thanks for the help.

Welcome aboard!

There are a lot of threads in this forum related to optimizing performances, try to do a search. Some things you can quickly try/check are:

  • make sure your meshes are not pickable (they are by default). It can slow down a lot your scene if you have meshes with lots of faces
  • freeze the meshes / their world matrices and see if it helps
  • if you suspect your big textures to be a problem, try to put dummy 1x1 textures, or even don’t set textures at all and see how it comes
  • use the performance tab of your browser to find what are the bottlenecks in your app

Regarding the render targets: those are used to render some effects like the glow/highlight layers, the shadow maps, etc. If you disable them, they won’t be generated anymore and will be “freezed” in their latest state.


is very strange as turning off render targets should have lowered the GPU load…

If you are able to post a live link to your scene we may be able to help more.

Evgeni_Popov - thanks for the reply and advice. I only work on this part time, so I didn’t respond right away.

In my first post I had asked what code is used to duplicate the Render Target option that is in the Inspector. I have tweaked my scene as i described below, and doubled performance, but, if i can, in code, do what the inspector does by turning off Render Target, at least most of the time, this should work for what i need. Currently I get ~45 fps inside my temple model, or outside looking at it - when Render Target is enabled. Around 50 Absolute FPS (don’t know why that is more when FPS is not at 60?). But, when i turn Render Target off I get 60 FPS and 140 Absolute FPS. That should work for what I need. The only thing i can see is that the reflections on the water do not update with Render Target off, everything else in my scene seems to work fine. Most of the time my camera isn’t even looking at the river in my scene, so if i knew how to turn on and off this feature I could turn Render Target on - may be once every 3-4 frames, and only when it is looking at the river and only when the camera moves. Where the video plays, the river is not in camera view.

So, can you or someone tell me what the code is to duplicate how the inspector is turning Render Target on and off. I think that would resolve my problems for now. I’ll keep looking to optimize, but, for now that will work…

I’m not wanting to post up my scene yet online, But, a demo with slightly better performance that my scene is Babylon.js - Train demo When Render Target is on, with the camera raised up in the air looking down on the entire scene, on my PC the absolute FPS ~75 and with Render Target turned off it is ~155 FPS - the only thing i noticed when Render Target is off is same with my scene, the water reflections don’t update when the camera is moved (they update when the train goes over the water, they just don’t update their mapping when the camera is moved). So if this can be controlled in software I could enable Render Target only when the camera is moving, and even then updating every 4-5 frames may be all that’s needed. In my scene, i would only need to do this when the River is in the camera view and the camera is moving.

I just don’t know what code or command that is -

As far was what i did to double my FPS. I brought the Temple back into Blender and joined and manually baked a number of meshes. Before the temple was over 1100 meshes. And, previously I only made 1 of each of 3 types of pilars in blender and made instantiateHierarchy copies of them in Babylon. What i wound up doing was making copies of all needed pilars in Blender and then joining all of the similar pilars as one mesh. The Temple went from 12 MG GLB to now over 50 MB. And, it takes 2x longer to load. But, the temple went from 1100+ meshes to 100 meshes, including all the 80 pilars (and i even added another 20 invisible cubes for collisions, the actual temple is only 80 meshes now). I could reduce the temple further but, i haven’t learned how to bake meshes that have different textures in one mesh and texture. Well, not without makes the texture files too large. What i did was make a number of textures files with 4-6 textures in one file and remapped the meshes to those texures, then joined the meshes. But, that was as far as i could go so far. The texture sizes didn’t seem to affect performance too much.

I also had some other meshes, glb files, that i baked and made 1 or 2 meshes per glb file, that also helped. With this i went from 19 fps inside the temple to 45.

The inspector is simply doing scene.renderTargetsEnabled = false to disable render target rendering, and set it back to true to reenable it.