I setup a test scene with some random meshes and used the GPU Resident Drawer along with the GPU Occlusion Culling systems enabled, verified all objects, shaders, materials and render settings are compliant per the docs and it does not appear to be working correctly.
Here’s the example script
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
public class RenderingTest : MonoBehaviour
{
public bool RandomColors;
public bool RandomMeshes;
public int GridX;
public int GridY;
public int GridZ;
public Material Mat;
public Mesh[] Mesh;
private List<MeshRenderer> m_runtime;
private void Reset()
{
RandomColors = false;
RandomMeshes = false;
GridX = 25;
GridY = 5;
GridZ = 25;
Mesh = null;
}
private void Start()
{
m_runtime = new List<MeshRenderer>();
int i = 0;
GameObject wrapper = new("Wrapper");
for (int x = 0; x < GridX; x++)
{
for (int y = 0; y < GridY; y++)
{
for (int z = 0; z < GridZ; z++)
{
GameObject meshGo = new($"Object [{i}]")
{
transform =
{
position = new Vector3(x, y, z),
parent = wrapper.transform
}
};
MeshFilter mf = meshGo.AddComponent<MeshFilter>();
mf.mesh = RandomMeshes ? Mesh[Random.Range(0, Mesh.Length-1)] : Mesh[0];
MeshRenderer mr = meshGo.AddComponent<MeshRenderer>();
mr.gameObject.isStatic = true;
mr.lightProbeUsage = LightProbeUsage.Off;
MeshCollider mc = meshGo.AddComponent<MeshCollider>();
mc.sharedMesh = mf.sharedMesh;
Material[] materials = new Material[1];
materials[0] = new Material(Mat);
if (RandomColors) materials[0].color = Random.ColorHSV();
mr.sharedMaterials = materials;
m_runtime.Add(mr);
i++;
}
}
}
}
}
This is really basic, and just spawns a bunch of meshes into the scene. If I take a huge box and stick it in front of the objects in the scene - which completely occludes everything - there is zero change in the processing time. It’s still processing and rendering everything behind the box.
It’s not the scene view, the performance is the same if I close the scene view. There’s just literally no occlusion culling. Frustum culling does work, as turning the camera away will improve performance as expected - something like 35ms to 10ms.
What does work is SRP Batcher, which makes an enormous difference when enabled.
But, I can’t find anything in the docs that would suggest that I’m doing something wrong here, I’ve even tried default urp lit shaders and adjusting other settings with no change to show for it.
How do we make these tools actually work? I reached out to our enterprise account manager for an engineering call but I haven’t heard back for days now.