# CullingResults

> A struct containing the results of a culling operation.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine.Rendering](/engine/6000.6/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IEquatable\<CullingResults>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public struct CullingResults : IEquatable<CullingResults>
```

## Remarks

In the Scriptable Render Pipeline, when Unity performs a culling operation, it stores the results in a `CullingResults` struct. This data includes information about visible objects, lights, and reflection probes. Unity uses this data to render objects and process lights. A `CullingResults` struct also provides several functions to aid shadow rendering.

To obtain a `CullingResults` struct, call [ScriptableRenderContext.Cull](/engine/6000.6/script-reference/unityengine/rendering/scriptablerendercontext/cull.md).

A `CullingResults` struct is valid within the scope of a [RenderPipeline.Render](/engine/6000.6/script-reference/unityengine/rendering/renderpipeline/render.md) function; its data goes out of scope when the `Render` function returns. You can use the same `CullingResults` struct multiple times within the same render loop, and you can share a `CullingResults` struct between multiple [Cameras](/engine/6000.6/script-reference/unityengine/camera.md) if you know that they can see the same objects. This can save on wasted CPU operations, and therefore improve performance.

After Unity performs drawing operations with `CullingResults`, you can't invoke [ScriptableRenderContext.Cull](/engine/6000.6/script-reference/unityengine/rendering/scriptablerendercontext/cull.md) again or modify the renderer list. The renderer list must remain consistent throughout the rendering process to avoid unpredictable results or crashes. To ensure that the renderer list isn't accidentally modified, wrap your code between [ScriptableRenderContext.PushDisableApiRenderers](/engine/6000.6/script-reference/unityengine/rendering/scriptablerendercontext/pushdisableapirenderers.md) and [ScriptableRenderContext.PopDisableApiRenderers](/engine/6000.6/script-reference/unityengine/rendering/scriptablerendercontext/popdisableapirenderers.md).

This example demonstrates how to obtain a `CullingResults` struct, and then pass it to [ScriptableRenderContext.DrawRenderers](/engine/6000.6/script-reference/unityengine/rendering/scriptablerendercontext/drawrenderers.md).

## Examples

```csharp
using UnityEngine;
using UnityEngine.Rendering;

public class ExampleRenderPipeline : RenderPipeline
{
    public ExampleRenderPipeline()
    {
    }

    protected override void Render(ScriptableRenderContext context, Camera[] cameras)
    {
        foreach (Camera camera in cameras)
        {
            // Get the culling parameters from the current camera
            camera.TryGetCullingParameters(out var cullingParameters);

            // Schedule the cull operation that populates the CullingResults struct
            CullingResults cullingResults = context.Cull(ref cullingParameters);

            // Place code that schedules drawing operations using the <see cref="UnityEngine.Rendering.CullingResults"></see> struct here
            // See <see cref="UnityEngine.Rendering.ScriptableRenderContext.DrawRenderers"></see> for details and examples
            // …

            // Execute all of the scheduled operations, in order
            context.Submit();
        }
    }
}
```

## Properties

| Property                                                                                                                                       | Description                                                       |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| [lightAndReflectionProbeIndexCount](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/lightandreflectionprobeindexcount.md) | Gets the number of per-object light and reflection probe indices. |
| [lightIndexCount](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/lightindexcount.md)                                     | Gets the number of per-object light indices.                      |
| [reflectionProbeIndexCount](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/reflectionprobeindexcount.md)                 | Gets the number of per-object reflection probe indices.           |
| [visibleLights](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/visiblelights.md)                                         | Array of visible lights.                                          |
| [visibleOffscreenVertexLights](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/visibleoffscreenvertexlights.md)           | Off-screen lights that still affect visible vertices.             |
| [visibleReflectionProbes](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/visiblereflectionprobes.md)                     | Array of visible reflection probes.                               |

## Methods

| Method                                                                                                                                                                               | Description                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [ComputeDirectionalShadowMatricesAndCullingPrimitives](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/computedirectionalshadowmatricesandcullingprimitives.md) | Calculates the view and projection matrices and shadow split data for a directional light.                                                                                                                                                                                                                                                 |
| [ComputePointShadowMatricesAndCullingPrimitives](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/computepointshadowmatricesandcullingprimitives.md)             | Calculates the view and projection matrices and shadow split data for a point light.                                                                                                                                                                                                                                                       |
| [ComputeSpotShadowMatricesAndCullingPrimitives](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/computespotshadowmatricesandcullingprimitives.md)               | Calculates the view and projection matrices and shadow split data for a spot light.                                                                                                                                                                                                                                                        |
| [FillLightAndReflectionProbeIndices](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/filllightandreflectionprobeindices.md)                                     | Fills a buffer with per-object light indices.                                                                                                                                                                                                                                                                                              |
| [GetLightIndexMap](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/getlightindexmap.md)                                                                         | If a [RenderPipeline](/engine/6000.6/script-reference/unityengine/rendering/renderpipeline.md) sorts or otherwise modifies the [VisibleLight](/engine/6000.6/script-reference/unityengine/rendering/visiblelight.md) list, an index remap will be necessary to properly make use of per-object light lists.                                |
| [GetReflectionProbeIndexMap](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/getreflectionprobeindexmap.md)                                                     | If a [RenderPipeline](/engine/6000.6/script-reference/unityengine/rendering/renderpipeline.md) sorts or otherwise modifies the [VisibleReflectionProbe](/engine/6000.6/script-reference/unityengine/rendering/visiblereflectionprobe.md) list, an index remap will be necessary to properly make use of per-object reflection probe lists. |
| [GetShadowCasterBounds](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/getshadowcasterbounds.md)                                                               | Returns the bounding box that encapsulates the visible shadow casters.  Can be used to, for instance, dynamically adjust cascade ranges.                                                                                                                                                                                                   |
| [SetLightIndexMap](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/setlightindexmap.md)                                                                         | If a [RenderPipeline](/engine/6000.6/script-reference/unityengine/rendering/renderpipeline.md) sorts or otherwise modifies the [VisibleLight](/engine/6000.6/script-reference/unityengine/rendering/visiblelight.md) list, an index remap will be necessary to properly make use of per-object light lists.                                |
| [SetReflectionProbeIndexMap](/engine/6000.6/script-reference/unityengine/rendering/cullingresults/setreflectionprobeindexmap.md)                                                     | If a [RenderPipeline](/engine/6000.6/script-reference/unityengine/rendering/renderpipeline.md) sorts or otherwise modifies the [VisibleReflectionProbe](/engine/6000.6/script-reference/unityengine/rendering/visiblereflectionprobe.md) list, an index remap will be necessary to properly make use of per-object reflection probe lists. |
