Give Page Feedback

FAQ - How can SAM be used with the SRP Batcher?

Generally speaking, nothing needs to be done to enable the SRP Batcher when using SAM, other than following the standard requirements for GameObject compatibility found at https://docs.unity3d.com/Manual/SRPBatcher.html.

One of these requirements is that GameObjects cannot use MaterialPropertyBlocks. In regards to SAM, this means that you cannot use the Mat Prop Block Transitioner, which is a type of Cell Visual Transition Controller (component that control how Asset Chunks transition in/out of the scene and between different LODs) that manipulates a shader property (usually in order to perform cross-fading, like Unity's LODGroup component does) in order to carry out transitions.

Fortunately, we have designed the Per Material Transitioner as an alternative to the Mat Prop Block Transitioner when using the SRP Batcher, so you can still perform cross-fading if you wish without breaking the Batcher!

When using this Transitioner, note that it will use the .material property of each Renderer (unless Use Shared Material is enabled, which is not recommended). Use of that property will break Runtime Static Batching and will result in a separate material instance being created for each renderer.

Generally neither of these are issues for the SRP Batcher, however it should be noted that the memory used by the materials will not be freed by Unity automatically. You must either destroy the material instance manually, or call Resources.UnloadUnusedAssets. The latter can either be done manually or you can allow the Chunk Streamer you are using to do it automatically by enabling Unload Unused Assets (if using an Addressable Scene Chunk Streamer) or setting the Memory Freeing Strategy (if using a different default Chunk Streamer) to something other than Dont Free Memory.