Godot's OpenGL3 on Mobile Part 2 - Reduce Draw Calls



Godot's OpenGL3 on Mobile - Reduce Draw Calls

As mentioned before Godot 3.4.4 draw calls are not optimized with OpenGL3. This means the mobile GPU is working harder to draw the scene and is the bottleneck on mobile. In this blog, I will go over some techniques I used to lower the draw calls in Solares.



Monitors help see how many vertices, draw calls, and materials are being used.

Vertices Reduction

Optimize Models

There are many ways that you can optimize your models within Blender. One way I have found to optimize the number of faces rendered is by using the 'Delimeter' modifier in Blender. This will cut down on how many faces and vertices your model will have and can be fine-tuned.


Using 'Delimeter' to reduce model face count from 747 -> 442

Shaders

It's important to reduce draw calls and the vertices number in 3D. To reduce them I use a shader to increase the UV scale giving the illusion of more cubes for the floor tile. For example, a floor cube that is scaled (3,1,1) will have its UV X scaled by 3. This makes it look like I have 3 cubes but in reality, there is only 1. This will work well when your texture is a repeating-seamless texture.


I only have 5-floor cubes in this level, but in the game, there is 9-floor cubes.

Draw Calls

Lightmaps

Shadows add a lot of depth and realism to your game. For mobile, however, they are considerably more expensive to render than they are on desktop. Dynamic shadows are calculated during runtime and mobile devices don't handle this as efficiently as desktop computers do. Static objects that don't move rarely cast dynamic shadows and you can benefit from disabling them and using lightmap instead. I only enable dynamic shadows on the player and a limited number of moving objects.


In the 'Geometry' part of your object, you can disable 'Cast Shadow' and turn on 'Used in Baked Light'. This will make your object cast a shadow when you bake the shadows. If you would like shadows to be baked onto the object, turn on 'Generate Lightmap' so your object will receive shadows being cast onto it.


Godot Lightmapper generates shadows for my scene. Here are the configurations I used for this scene.

Reuse Materials

Try to reuse as many materials as possible. You can significantly reduce draw calls and shader compilation by using the same material when you can. Below you can see I use 2 materials for multiple parts of the scene.


Show reusability of 2 materials

Conclusion

By using a combination of these tricks you can really boost the performance of your game on mobile. My favorite trick to use is the light mapper and the reusability of materials.


Get Solares

Buy Now$2.00 USD or more

Leave a comment

Log in with itch.io to leave a comment.