BRG를 사용하여 렌더링하기 위한 첫 번째 단계는 BatchRendererGroup의 인스턴스를 생성하고 OnPerformCulling 구현을 통해 초기화하는 것입니다.
OnPerformCulling 콜백은 BRG의 주요 엔트리 포인트이며 Unity는 표시되는 오브젝트를 컬링할 때마다 이 콜백을 호출합니다.수신하는 파라미터에 대한 자세한 내용은 OnPerformCulling을 참조하십시오.일반적으로 OnPerformCulling 콜백이 수행해야 하는 작업은 2가지입니다.
간단한 구현에서는 이러한 작업을 OnPerformCulling 콜백에서 직접 수행할 수 있지만, 고성능 구현에서는 이 작업의 대부분을 버스트 잡에서 수행하는 것이 가장 좋습니다.OnPerformCulling 콜백은 잡이 출력을 BatchCullingOutput 파라미터에 작성한 후 완료되는 JobHandle을 반환해야 합니다.구현에 잡을 사용하지 않는 경우 빈 JobHandle을 반환할 수 있습니다.
See the following code sample for an example of how to create a BatchRendererGroup object and initialize it with the most minimum OnPerformCulling callback that compiles.
using System;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Rendering;
public class SimpleBRGExample :MonoBehaviour
{
private BatchRendererGroup m_BRG;
private void Start()
{
m_BRG = new BatchRendererGroup(this.OnPerformCulling, IntPtr.Zero);
}
private void OnDisable()
{
m_BRG.Dispose();
}
public unsafe JobHandle OnPerformCulling(
BatchRendererGroup rendererGroup,
BatchCullingContext cullingContext,
BatchCullingOutput cullingOutput,
IntPtr userContext)
{
// This example doesn't use jobs, so it can return an empty JobHandle.
// Performance-sensitive applications should use Burst jobs to implement
// culling and draw command output.In this case, this function would return a
// handle here that completes when the Burst jobs finish.
return new JobHandle();
}
}
OnPerformCulling을 사용하여 드로우 커맨드를 생성하기 전에 드로우하려는 메시와 사용하려는 머티리얼을 BatchRendererGroup 오브젝트에 제공해야 합니다.자세한 내용은 다음 주제인 메시 및 머티리얼 등록을 참조하십시오.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.