Optimization, Saved By Batching is Low
I am not getting a good frame rate in my outdoor area. I am averaging 45 fps in this area.
I am thinking my issue is because my "Saved By Batching" is super low. The other area had a massive "Saved By Batching" while this one is very low.
Things I have done related to static batching:
Try to reuse material for as many objects as possible
Made sure no materials are "(instance)"
Every object in this scene is marked as Batching Static (Everything but lightmap static)
Everything I have done:
Removed all "Realtime" lights in favor of baking/mixed
Setup light probes
LOD's on every object
Everything using "Standard" Shader and custom shader I got from this forum: https://forum.unity.com/threads/shader-moving-trees-grass-in-wind-outside-of-terrain.230911/
Baked Occlusion Culling
Everything set to static
Any ideas on how I can bump up this number so I don't have 3,000+ unsaved by batching?
That's the only real reason why I can think I am getting such a bad frame rate in this area.
My Scene:
My Profiler:
Try setting the objects to lightmap static (because what's the use of all those baked lights if nothing is lightmap static?)
Your Profiler complains about transparent geometry, but from the screenshot you provided it looks like there's nothing transparent there... Double-check your materials to see if they're set to "transparent" ins$$anonymous$$d of "opaque".
Thanks for the suggestions!
I will try setting all of my trees to lightmap static. Ill have to lower my lighting settings to make it so it doesn't take 3 years.
I will have to check to make sure my shader isn't transparent.
Show us GPU Profiler. You are showing us CPU profiler.(it is not enable by default. Click add profiler)
Something is rendering even when it is not necessary => extra CPU call to GPU
Here is the GPU profiler enabled.
I tried to lightmap bake my trees but that takes an unacceptable amount of time to do so. I let it run overnight and it still wasn't done in the morning. I baked everything else in my scene except the terrain (and my trees).
---Lighting Window Settings---
--- Realtime Lighting:
Realtime Global Illu$$anonymous$$ation: false
---$$anonymous$$ixed Lighting:
Bake Global Illu$$anonymous$$ation: true
Lighting $$anonymous$$ode: Shadowmask
---Light$$anonymous$$apping Settings:
Progressive
Direct Samples: 3
Indirect Samples: 10 (Won't let me lower it below this value)
Bounces: 1
Lightmap Resolution: 4 texels per unit
Lightmap Padding: 2 texels
Compress Lightmaps: true
Amdient Occlusion: true
Directional $$anonymous$$ode: Non-Directional
Lightmap Parameters: Default-VeryLowResolution
The image link is dead and light map should not take overnight and not still complete. Something is clearly broken
I'm having a hard time finding "Transparent" anything. I went through all of the images and made sure everything was NOT marked as "Alpha as Transparency". I found only 1 image that had that and I turned it off. Haven't seen any improvement from it.
Is there an easy way for me to track down what might be marked as transparent?
The only thing that I think it could be is that I am using a custom shader. However, I went into the code and change "RenderType"="TransparentCutout" to "RenderType"="Opaque". However, that didn't seem to have any affect on the transparent render times in the profiler.
The problem was stuff not get batched together. Changing images property or shader property won't chang anything.
Look at GPU profiler debug frame. It will tell you why stuff like same models, same materials cannot be batched together
1st of all. ReEnable GPU Instancing on all materials(tree and grass too). This is what help static object have less drawcall => reduce CPU work load.
2nd: Recheck if everything is static objects.
3rd: Seem like your camera Oculusion culling not working. $$anonymous$$aybe because you forgot to re-bake or not enough objects being static
4th: Your custom shader you got from forum did not support GPU-Instancing. That's why your tree and grass worth 6 million tris. When it only suppose to be like 1$$anonymous$$ max even with 1000 of trees of 200k tris for each tree.
Everything in my scene is static batched, I have checked many many times.
I did a lot of reading about GPU Instancing after you posted that link, thanks for that. I completely misunderstood what that was. I am going to have to add this into the custom shader, that alone may take some time since I haven't written a shaders before. Also I will not be able to set "static batching" and instancing at the same time, static batching takes higher precedence and will disable instancing at run time.
Oculusion culling needs to be re-baked I guess, there were a lot of changes that were made while I have been testing. After I figure all of this out I will come back and tell you my findings. From what I have read about GPU instancing so far though that may be what this scene needs.
Try searching for grass, tree instancing on Github. It might surprise what you can found there.
https://github.com/keijiro/$$anonymous$$vantGrass
https://github.com/Heep042/Instanced-Foliage/blob/master/Assets/$$anonymous$$aterials/Grass.shader
I have been down for a week rebuilding a few things on my computer...
Now I'm back!
@NoDumbQuestion I looked at those github links and while they are good they actually don't implement anything themselves. They seem to setup the framework but miss the actual code to implement GPU instancing. So I will have to read more docs on how to do that. Again this is something that isn't really going to be easy.
I cracked open the Frame Debugger. There are two main things that are causing things not to get batched.
(Render.OpaqueGeometry) "An object is affected by multiple forward lights"
(Render.TransparentGeometry) "An object is affected by multiple forward lights"
Note: $$anonymous$$y camera is set to deferred, NOT forward.
Render.OpaqueGeometry:
I have no idea why this is affect by "foward lights" I went to all of my shaders and disabled "Specular Highlights" and "Reflections" in the "Forward Rendering Options". This had zero effect.
Render.TransparentGeometry:
Again same thing as above. However, many of my "Cutout" Rendering $$anonymous$$ode shaders are in this "Transparent" section. No idea why it is marking it such can't figure it out.
Both of these account for ALL my batches (3654) while my "saved by batching" remains around (164).
path. https://docs.unity3d.com/$$anonymous$$anual/RenderTech-DeferredShading.html This might be the problem. Not sure. I think you should ask this on forum. Someone have experiences with enviroment might helpObjects with Shaders that do not support deferred shading are rendered after deferred shading is complete, using the forward rendering
Your answer
Follow this Question
Related Questions
Static batching option not working 0 Answers
Static batching break : objects belong to different static batches 0 Answers
Designing an efficient cloud particle system to represent weather 1 Answer
More saved batches than actual number of batches? 1 Answer
Rendering performance of single large mesh vs multiple smaller meshes 0 Answers