Version: 2020.1
public Rendering.CullingOptions cullingOptions ;

描述

用于在可编程渲染管线中配置剔除操作的标志。

Unity 将一些 CullingOptions 标志设置为默认值,并根据从中获取 ScriptableCullingParameters 结构的 Camera 的属性来设置其他标志。可在执行剔除操作之前覆盖这些值。

以下示例说明如何从摄像机获取 ScriptableCullingParameters 对象,通过取消设置 CullingOptions.OcclusionCull 标志来对 ScriptableCullingParameters 对象禁用遮挡剔除,然后在剔除操作中使用 ScriptableCullingParameters 对象。

using UnityEngine;
using UnityEngine.Rendering;

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

protected override void Render(ScriptableRenderContext context, Camera[] cameras) { // Get the culling parameters from the desired Camera if (cameras[0].TryGetCullingParameters(out var cullingParameters)) { // Disable occlusion culling cullingParameters.cullingOptions &= ~ CullingOptions.OcclusionCull;

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

// Place code that schedules drawing operations using the CullingResults struct here // See ScriptableRenderContext.DrawRenderers for details and examples // …

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

另请参阅:ScriptableRenderContext.CullCamera