I added the “ClearInstances” call before adding the instances, and suddenly the framerates are up around 70 fps.
Now i can remove the “ClearInstnaces” call and still have 70 fps. Obviously there must have been tons of instances lurking in the background.
Problem solved, but I am not completely comfortable that I can’t reproduce it.
[EDIT:] I am able to reproduce it!
While fidelling around i found that have removed the PointLights i had in the first example, and when i placed a couple of point lights over the tiles the framerates dropped very low again.
I turns out that if i have a few point ligths in the scene the rendering with Static Meshes is more effective, but if one only use directional light the instanced meshes are more effective. How can that be? (The point lights are set to stationary)
That dynamic lightning is expensive is understandable, but why does it work so bad together with instanced meshes? In my previous experiments I didn’t get no way near the same penalty when working with ordinary static meshes as i got with instanced static meshes.
with directional light, all of the trees get rendered twice no matter where the light is. once for the view once for the shadow.
with point lights, its going to do the lighting calculation using the bounds. individual meshes have tight bounds that fit around the mesh. instanced static meshes get grouped together, so a few lights inside of a forest will of course cause more shadow rendering compared to regular static meshes. They have been grouped together so in effect the pointlights will each be affecting more polygons and objects with larger bounds which then tough more neighbor groups.
Hierarchical instances should not have the same limitation or the crossover point might be different.