Unity 렌더 파이프라인 가이드
이 문서는 Unity에서 액티브 렌더 파이프라인을 얻고 설정하고 구성하는 방법에 대해 설명합니다. Unity의 렌더링 시스템을 이해하고 다양한 렌더 파이프라인을 활용하는 데 유용한 정보를 제공합니다.
개요
Unity는 콘텐츠를 렌더링하기 위해 스크립터블 렌더 파이프라인(SRP)을 사용합니다. SRP에는 유니버설 렌더 파이프라인(URP)와 고해상도 렌더 파이프라인(HDRP)이 포함됩니다. Unity가 사용하는 렌더 파이프라인 에셋을 지정하지 않으면 기본적으로 빌트인 렌더 파이프라인이 사용됩니다.
렌더 파이프라인 에셋을 선택적으로 생성하여 다양한 설정을 구성할 수 있으며, 이는 하드웨어 품질 레벨에 따라 달라질 수 있습니다.
액티브 렌더 파이프라인 결정
Unity는 다음 기준에 따라 액티브 렌더 파이프라인을 결정합니다:
단계 | 설명 |
---|---|
1 | 현재 품질 설정에서 Render Pipeline 이 참조하는 에셋 사용 |
2 | 그렇지 않으면 그래픽스 설정에서 Scriptable Render Pipeline Setting 을 참조 |
3 | 둘 다 참조하지 않으면 빌트인 렌더 파이프라인 사용 |
사용자 인터페이스에서 액티브 렌더 파이프라인 설정 방법
빌트인 렌더 파이프라인 활성화
- Edit > Project Settings > Quality를 선택합니다.
- 각 품질 수준에서
Render Pipeline 필드
의 할당을 취소합니다. - Edit > Project Settings > Graphics로 이동하여,
Scriptable Render Pipeline Setting
의 할당을 취소합니다.
SRP를 기반으로 하는 렌더 파이프라인 활성화
- 사용하려는 렌더 파이프라인 에셋을 프로젝트 폴더에서 찾습니다.
- Edit > Project Settings > Graphics를 선택하고,
Scriptable Render Pipeline Setting
필드로 드래그합니다. - 선택적으로 각 품질 수준에 대한 오버라이드를 설정합니다.
C# 스크립트를 통해 액티브 렌더 파이프라인 설정
C# 스크립트를 사용하여 액티브 렌더 파이프라인을 가져오고 설정하는 방법을 보여줍니다. 아래는 샘플 코드입니다:
using UnityEngine;
using UnityEngine.Rendering;
public class ActiveRenderPipelineExample : MonoBehaviour
{
public RenderPipelineAsset defaultRenderPipelineAsset;
public RenderPipelineAsset overrideRenderPipelineAsset;
void Start()
{
GraphicsSettings.defaultRenderPipeline = defaultRenderPipelineAsset;
QualitySettings.renderPipeline = overrideRenderPipelineAsset;
DisplayCurrentRenderPipeline();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.LeftShift)) {
SwitchDefaultRenderPipeline();
DisplayCurrentRenderPipeline();
}
else if (Input.GetKeyDown(KeyCode.RightShift)) {
SwitchOverrideRenderPipeline();
DisplayCurrentRenderPipeline();
}
}
void SwitchDefaultRenderPipeline()
{
if (GraphicsSettings.defaultRenderPipeline == defaultRenderPipelineAsset)
{
GraphicsSettings.defaultRenderPipeline = null;
}
else
{
GraphicsSettings.defaultRenderPipeline = defaultRenderPipelineAsset;
}
}
void SwitchOverrideRenderPipeline()
{
if (QualitySettings.renderPipeline == overrideRenderPipelineAsset)
{
QualitySettings.renderPipeline = null;
}
else
{
QualitySettings.renderPipeline = overrideRenderPipelineAsset;
}
}
void DisplayCurrentRenderPipeline()
{
if (GraphicsSettings.defaultRenderPipeline != null)
{
Debug.Log("The default render pipeline is defined by " + GraphicsSettings.defaultRenderPipeline.name);
}
else
{
Debug.Log("The default render pipeline is the Built-in Render Pipeline");
}
if (QualitySettings.renderPipeline != null)
{
Debug.Log("The override render pipeline for the current quality level is defined by " + QualitySettings.renderPipeline.name);
}
else
{
Debug.Log("No override render pipeline exists for the current quality level");
}
if (QualitySettings.renderPipeline != null)
{
Debug.Log("The active render pipeline is the override render pipeline");
}
else
{
Debug.Log("The active render pipeline is the default render pipeline");
}
if (GraphicsSettings.currentRenderPipeline != null)
{
Debug.Log("The active render pipeline is defined by " +GraphicsSettings.currentRenderPipeline.name);
}
else
{
Debug.Log("The active render pipeline is the Built-in Render Pipeline");
}
}
}
마무리
Unity에서 렌더 파이프라인을 설정하는 방법에 대한 이 가이드를 통해 보다 효과적으로 렌더링 과정을 이해하고 제어할 수 있습니다. 다양한 렌더 파이프라인을 활용하여 프로젝트의 그래픽 품질을 개선하세요.