7 Ultimate ways to reduce draw calls in unity game

Ways to reduce draw call in unity game

Hello and welcome, You are probably facing the high draw calls issue in your game and want to reduce them, yeh you are on right place here we will explain the ways to reduce draw calls in your unity game

Well it happens whenever we create a game and we often don’t think about the performance of the game while developing it but later when we start testing it on devices then we face the performance issue in our game.

There are several reasons for the lag and when we go for Optimization then we see the different aspects of Optimization and one of the aspects is to reduce drop all so it’s very good practice to reduce the draw call in your game.

Here are a number of tips and tricks that can help to reduce the call in your game. We have given ways to reduce draw calls in your game.

What is draw call exactly?

In computer graphics, a draw call is a command sent from the CPU to the GPU to render a graphical object or scene.

The CPU sends a series of draw calls to the GPU, which is responsible for rendering the objects and creating the final image that is displayed on the screen.

A draw call specifies the necessary parameters to render an object, such as its geometry, material properties, and texture coordinates.

ways to reduce draw calls
ways to reduce draw calls

Why draw calls increases in games

Draw calls can increase in game development due to several factors:

  1. Complex Scenes: As you add more objects, characters, and details to your game scene, the number of draw calls can increase. Each object or character typically requires its own draw call.
  2. High-Quality Assets: Using high-quality assets with detailed textures and complex geometry can increase draw calls. Each unique material or shader applied to these assets contributes to additional draw calls.
  3. Dynamic Objects: Games with a lot of dynamic or interactive elements may generate more draw calls. Dynamic objects, such as destructible environments or moving characters, often require separate draw calls.
  4. Unoptimized Rendering Pipeline: Inefficient rendering pipelines can lead to unnecessary draw calls. Poorly optimized shaders, improper use of rendering techniques, or redundant calculations can all contribute to increased draw calls.
  5. Shader Variants: Each combination of shader features and properties can generate a separate shader variant, which in turn increases draw calls. Using a large number of shader variants or complex shaders can significantly impact draw call performance.
  6. UI Elements: Games with complex user interfaces (UIs) can generate additional draw calls, especially if UI elements are not efficiently batched or optimized.
  7. Lighting and Effects: Real-time lighting, shadows, and post-processing effects can increase draw calls. Each light source, shadow-casting object, or effect may require additional rendering passes and contribute to more draw calls.
  8. Inefficient Batching: Failure to properly batch objects with the same materials or properties can lead to increased draw calls. Objects that could be batched together are rendered separately, resulting in inefficient performance.

To address increased draw calls, developers need to optimize their game’s assets, rendering pipeline, and overall scene complexity. This often involves techniques such as mesh combining, texture atlasing, batching, LOD optimization, shader simplification, and efficient UI management. Profiling tools can help identify areas of concern and guide optimization efforts. These kind of mistake increase draw calls in unity game. Always try to reduce draw calls by using tricks mentioned below.

Steps to reduce draw call in games

Here are some steps to reduce draw calls in your games:

  1. Combine Meshes: Combining multiple smaller meshes into one larger mesh can reduce the number of draw calls by reducing the number of times the CPU has to send commands to the GPU.
  2. Use LOD (Level of Detail): LOD techniques allow for lower-resolution models to be used when objects are far away, reducing the number of vertices that need to be rendered and reducing the number of draw calls.
  3. Use Occlusion Culling: Occlusion culling is a technique that prevents objects from being rendered if they are not visible. This can reduce the number of draw calls by only rendering objects that are visible in the camera’s view.
  4. Use Texture Atlases: Texture atlases combine multiple textures into one large texture, reducing the number of texture switches and draw calls required.
  5. Use Instancing: Instancing allows multiple instances of the same object to be rendered with a single draw call. This can significantly reduce the number of draw calls required for a scene.
  6. Minimize State Changes: State changes, such as changes to the shader or texture, can be expensive in terms of performance. Minimizing state changes by batching objects with similar properties can reduce the number of draw calls required.
  7. Use Static Lighting: Dynamic lighting can be expensive in terms of draw calls. Using static lighting techniques can reduce the number of draw calls required for a scene.

So if we implement these steps in our game, than we can reduce the number of draw calls required to render a scene, that leads in improved performance and a better user experience for players.

Best practice to reduce draw calls in unity game

Reducing draw calls is crucial for optimizing the performance of your Unity game. Draw calls occur when Unity renders a mesh or object, and minimizing them can improve frame rates and overall gameplay experience. Here are some best practices to help you reduce draw calls in Unity:

  1. Combine Meshes:
    • Merge static and dynamic objects that share the same materials into a single mesh. Unity provides a Mesh.CombineMeshes function that allows you to combine multiple meshes into one.
  2. Use Texture Atlases:
    • Combine multiple textures into a single texture atlas. This reduces the number of materials and draw calls associated with different textures. Unity’s Sprite Packer can help with 2D games.
  3. Batching:
    • Unity automatically batches static and dynamic objects with the same material into a single draw call. Ensure that your GameObjects use the same materials and meet the batching requirements. Static objects should be marked as static in the Inspector window.
  4. GPU Instancing:
    • Use GPU instancing for materials that support it. This allows the GPU to render multiple instances of the same mesh with a single draw call, reducing CPU overhead.
  5. Culling:
    • Implement frustum culling to avoid rendering objects that are not in the camera’s view. Unity automatically performs some culling, but you can optimize it further by setting appropriate culling masks and using Occlusion Culling for large scenes.
  6. Level of Detail (LOD):
    • Implement LOD for distant objects by providing lower-poly versions of meshes. Unity has a built-in LOD Group component that handles LOD for you.
  7. Dynamic Batching:
    • For mobile platforms, take advantage of Unity’s dynamic batching feature. Objects that share the same material and have a low vertex count may be dynamically batched at runtime.
  8. Avoid Excessive Material Changes:
    • Minimize the number of materials and shader changes in your scene. Using a limited set of materials helps reduce draw calls.
  9. Use GPU Skinning:
    • For animated characters, consider using GPU skinning instead of CPU skinning. This offloads some of the processing to the GPU, reducing CPU overhead.
  10. Optimize UI:
    • If you have a lot of UI elements, consider using the Unity UI system efficiently. Use canvas groups and combine UI elements where possible.
  11. Shader Variants:
    • Be mindful of the number of shader variants you have in your project, as each variant can lead to additional draw calls. Simplify and consolidate shaders when feasible.

Always remember to profile your game using Unity’s Profiler to identify performance bottlenecks and validate the impact of your optimizations. Experiment with different techniques and measure their effects on performance to find the best balance for your specific game. These are some best practices to reduce draw calls in unity game.

reduce draw calls in unity

Unity draw calls reducing ultimate techniques – reduce draw calls

To reduce draw calls in Unity is a crucial aspect of performance optimisation, especially for mobile, VR, and large-scale games. A draw call is a command sent to the GPU to render a set of objects, and having too many can lead to performance issues such as frame drops and stuttering. Optimizing draw calls not only improves rendering performance but also ensures smoother gameplay, especially on less powerful hardware. Here are some ultimate techniques to reduce draw calls in Unity:

1. Static Batching

  • What it is: Static batching combines multiple static objects (non-moving) that share the same material into a single mesh, reducing the number of draw calls required to render them.
  • How it works: When static batching is enabled in Unity, it automatically groups static objects into one mesh at runtime. This way, all objects that share the same material are rendered in a single draw call, which is far more efficient than rendering each object individually.
  • When to use: Use static batching for objects that don’t move during gameplay, like terrain, buildings, or static props.

2. Dynamic Batching

  • What it is: Dynamic batching combines dynamic (moving) objects into fewer draw calls by grouping them into one. Unlike static batching, dynamic batching happens at runtime for objects that move or change.
  • How it works: Unity can dynamically batch objects that are using the same material and meet certain conditions (e.g., similar vertex count). This reduces the overhead of multiple draw calls for smaller, simpler objects.
  • When to use: Use dynamic batching for smaller objects with similar materials, such as characters, moving props, and projectiles. However, dynamic batching has performance limitations if objects are too complex.

3. GPU Instancing

  • What it is: GPU instancing allows Unity to draw many identical objects in a single draw call by sending a single command to the GPU and drawing all instances of the object.
  • How it works: Rather than drawing each object individually, GPU instancing sends one draw call to render all instances of an object with the same mesh and material. The GPU then handles the rendering of each instance with a single command, dramatically reducing draw calls.
  • When to use: GPU instancing is ideal for rendering many identical objects in a scene, such as trees, rocks, or enemies that share the same mesh and material. It is particularly useful for procedural generation and large, populated environments.

4. Texture Atlases

  • What it is: A texture atlas is a large image that contains multiple smaller textures packed together.
  • How it works: Instead of using separate textures for each object or material, a texture atlas combines multiple textures into one, allowing you to use a single material for many objects. This reduces the number of material switches and thus minimizes draw calls.
  • When to use: Use texture atlases when you have multiple objects using different textures but can combine them into a single larger texture. This is particularly effective for UI elements, sprites, and modular environments like tiled floors and walls.

5. Material Optimization

  • Shared Materials: Ensure that all objects that share the same material (e.g., same shader and texture) use that material to reduce unnecessary material switches during rendering.
  • Consolidating Materials: Instead of using multiple materials with similar properties, combine them into a single material wherever possible. For example, combining objects with similar colors or textures into one material can reduce the number of materials and, in turn, the number of draw calls.

6. Level of Detail (LOD)

  • What it is: LOD involves using lower-resolution models for objects that are far away from the camera and higher-resolution models for objects close to the camera.
  • How it works: As objects move farther from the camera, Unity can automatically switch to a simpler, lower-polygon version of the mesh (LOD) to reduce the rendering load. This not only improves performance by reducing the number of vertices being processed but also reduces draw calls when simpler LOD models are used.
  • When to use: LOD is particularly useful for large open-world games or environments with many distant objects, such as forests, cities, or mountains.

7. Object Pooling

  • What it is: Object pooling is a technique where objects are reused from a pre-allocated pool rather than instantiated and destroyed repeatedly during gameplay.
  • How it works: Instead of creating and destroying objects (which can lead to performance spikes and excessive draw calls), object pooling reuses objects from a pre-created pool. This avoids frequent draw call spikes caused by object instantiation and destruction.
  • When to use: Use object pooling for frequently instantiated objects, such as bullets, enemies, or power-ups, especially in fast-paced games where objects are constantly being created and destroyed.

8. Frustum Culling and Occlusion Culling

  • What it is: Culling is the process of not rendering objects that are outside the camera’s view (frustum culling) or are hidden by other objects (occlusion culling).
  • How it works: Unity automatically culls objects that are outside the camera’s view or occluded by other objects, reducing the number of objects that need to be drawn. By ensuring that only visible objects are rendered, you can cut down on unnecessary draw calls.
  • When to use: Enable occlusion and frustum culling for large environments where a significant number of objects may be off-screen or hidden behind other objects.

9. Combine Meshes and Group Objects

  • What it is: Combining smaller meshes into larger ones or grouping objects with the same material can reduce the total number of objects the renderer needs to process.
  • How it works: Unity allows you to combine smaller meshes into a single mesh, reducing the number of objects that require separate draw calls. Grouping objects by material and combining them when possible also reduces the number of draw calls.
  • When to use: Use this technique for environments with multiple small objects that share the same material (e.g., modular building pieces, foliage).

How to create a game in unity without coding – Step by step ultimate tutorial

What is game development? – A detailed knowledge of game development.

Reduce draw calls technique

Summary

By employing these techniques, you can drastically reduce draw calls in Unity, leading to smoother performance and faster rendering. Static and dynamic batching, GPU instancing, texture atlases, and LOD are some of the most effective methods for optimising game and reducing draw calls. Additionally, material optimization, object pooling, and culling techniques can further streamline your game’s performance. A combination of these approaches, tailored to the specific needs of your project, will help ensure a smooth and responsive gaming experience across all platforms.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top