One thing you can do is scale the particular instance transform to zero.
I do something like this for a custom multimesh I use.
var ZERO_TRANSFORM = Transform.IDENTITY.scaled(Vector3.ZERO)
for i in multimesh.instance_count:
The previous code effectively “hides” every instance of the multimesh and stops them from being rendered altogether, so there’s no performance loss.
You can even set the color of a particular instance which has a transparent material in order to fade them out. Do keep in mind however that transparent instances are still being processed by the renderer.
You can see it all in action here
Hi!!!, I read your comment and tried implementing it by my self, but, some how, I still get the same fps drop as if all instances where being rendered. Could you give some more advice on how did you implemented your grass system? I am trying to create a grass field too
Here’s the code
I use an area to determine when the player enters the multimesh and another one to determine the player position and render distance.
The most important bit is to be aware of how much time per frame you spend iterating over the instances, especially if you have a lot of them. To avoid iterating over the whole list in a single frame I split the iteration into batches and process them over multiple frames.
You can ignore the following part, as it is quite convoluted and the performance gains are not that huge.
Another optimization I use is to have a dynamic amount of meshes being available to be shown. As mentioned before, the biggest cost lays in iterating over all of the meshes, but if you only have a set amount of meshes you can show, then you can potentially break the iteration once you’re showing all the instances you have available.
This is handled by the dynamic pool, which grows or shrinks trying to fit the amount of meshes in the display area.
Keep in mind that there might be better options for creating grass. This is mostly to increase performance of wide area multimeshes by limiting the render distance, since Godot doesn’t have occlusion culling.
Glad to have been of help, looks great!