Frustum culling for XR Single-Pass Rendering

I’m rendering particles in a compute shader in XR.
For performance, we’re doing cpu-side frustum culling using
GetStereoProjectionMatrix to transform the particles into clip space then cull against -1:1.

For Single-Pass rendering, this doesn’t work because we would need a union of the projectview matrices in order to not overcull on one of the eyes by assuming a shared projection. Is there a way to get this unioned frustum? If not, is there a recommended approach for cpu-side culling?

Hey @ramagosula,
Not sure if you are looking for single pass culling in XR. If so, that is how URP deals with XR culling today, you could find the relevant code here: Graphics/Packages/com.unity.render-pipelines.core/Runtime/XR/XRSystem.cs at fc267ad41df7e0cf39300c4c4d57dd1dc890c054 · Unity-Technologies/Graphics · GitHub
API you might be interested in: Unity - Scripting API: XR.XRDisplaySubsystem.GetCullingParameters
Hope it helps,
Thomas

That looks perfect, thanks. Does it work with Built-In RP? That’s what we’re currently using.

One more question: What is the culling matrix, vs the projection matrix In the ScriptableCullingParameters? The docs just say ’ cullingMatrix The matrix for the culling operation.’

I am not familiar with BiRP to make a comment. The API is an XRSDK system API, which should work in BiRP. However, I am not sure about the workflow there, and I am not sure how to configure the pipeline to use that culling data.

Hopefully someone who is more knowledgeable with BiRP can make a comment.

After having tried it out, it works just fine with BiRP.
Only thing I’m unsure of is whether passing in 0 for the cullingPassIndex is valid for XRDisplaySubsystem.GetCullingParameters, but it seems to be working well-enough.

1 Like