Optimizing the midcore: Increasing FPS using SRP Batcher

In the realm of midcore gaming, striking the right balance between vibrant visuals and high performance is crucial. We’ve discussed this topic before, but today, let’s focus on the SRP Batcher. This tool not only speeds up object rendering by 2-4 times but also reduces the overall load on mobile devices.

I’ll share insights from my experience using SRP Batcher in creating maps for midcore projects.

Differences between SRP and Legacy Render Pipeline

Legacy Render Pipeline is Unity’s standard rendering pipeline, offering limited customization and optimization options, which can impact performance. While Unity still supports it, they recommend transitioning to the SRP. For mobile devices, there’s the URP template, and for PCs, the HDRP template. Alternatively, you can craft your own render pipeline from scratch.

Scriptable Render Pipeline (aka SRP) provides a more adaptable approach to rendering. It allows for the creation of customized pipelines tailored to specific project needs, reducing draw calls and enhancing rendering speed.

How it works

In essence, SRP enhances game performance by batching (combining) many small objects with the same shader into one larger object before rendering, which helps reduce communication time between CPU and GPU. 

This is particularly beneficial for minor objects sharing a material, such as stones, trees, and props.

Here’s a technical breakdown:

1) Scene analysis: SRP Batcher scans the scene for objects using the same shader and similar material properties.

2) Grouping of objects: It groups objects based on the similarity of their characteristics, primarily those sharing the same shader.

3) Creation of an SRP batch: It combines these grouped objects into a single large object — an SRP batch.

4) Drawing batches: These batches are then sent for rendering, where objects within a batch are drawn in a single render call, drastically cutting down the number of render operations and boosting performance.

5) Updating batches: As scenes evolve during gameplay, the SRP batcher updates the batches accordingly, recalculating them as needed if objects like pebbles are moved or altered.


Important note:

For SRP Batcher to function, shaders must be compatible with SRP. You can verify this by checking the shader’s settings in the inspector window:

Ensure it uses the Shader Graph or is manually adjusted with the CBUFFER_START(UnityPerMaterial) and CBUFFER_END macros.

Tags {"RenderPipeline" = "UniversalPipeline"
   "RenderType" = "Opaque"
   "Queue" = "Geometry"}
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

float4 _BaseMap_ST;
float4 _BaseColor;

In Railroad Empire, SRP Batcher manages all trees and pebbles. Here’s an example:

It consolidates almost all background trees into a single object rendered in one call instead of 125.

However, there are limitations. The effectiveness of SRP Batcher diminishes with multiple light sources or when using more than one texture atlas for trees along with a world_UV mask for an entire forest’s flowers. In such cases, do not expect a significant FPS boost. At the end of the day, every project is unique and requires its own stack of optimization tools.

SRP Batcher is an invaluable optimization tool for reducing CPU and GPU communication time, making it a worthy addition to any development pipeline. However, it’s not a catch-all solution; careful planning of content architecture within the engine is still necessary.

Back to blog