Version: 2022.1
언어: 한국어
Android용 싱글 패스 스테레오 렌더링
테스트와 디버그

Framebuffer orientation

If your application’s framebuffer orientation doesn’t match the device’s native display orientation (portrait, for most devices), Android rotates the application’s framebuffer to match the device’s display every frame. Depending on the device’s hardware capabilities, this additional rotation can negatively affect performance. If your application uses the Vulkan Graphics API and the device supports Vulkan, Unity can apply this rotation during rendering which reduces the performance impact of the rotation. This is called pre-rotation.

Using pre-rotation in Unity

To make Unity apply pre-rotation, you can use C# scripts or the Unity editor:

  • Through C# scripts: Set PlayerSettings.vulkanEnablePreTransform to true.

  • Through the Unity Editor:

    1. Select Edit > Project Settings.
  • Project settings 창에서 Player 탭을 선택한 다음 아래와 같이 Android Player Settings를 엽니다.

  • In the Other Settings section, enable Apply display rotation during rendering.

How Unity applies pre-rotation

Unity applies pre-rotation when it renders directly to the device’s backbuffer, not when it renders to a Render Texture. To apply the rotation, Unity modifies the projection matrix which affects the UNITY_MATRIX_MVP and UNITY_MATRIX_P Built-in shader variables. This means that Unity applies the rotation in the vertex shader.

Using pre-rotation doesn’t affect the behavior of Unity’s C# API. For example, you can still use Screen.width to access the width of the screen. The same applies to viewports and scissor rects. Unity adjusts these as needed, and also handles readback operations from the backbuffer such as Grab Pass, ReadPixels, or Screenshot.

Unity provides utility macros to handle special cases in shaders (for more information, see the Limitations section below).

UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION 매크로는 다음의 모든 조건이 true일 때에만 정의되고, 그렇지 않으면 정의되지 않습니다.

  • 플레이어 설정에서 preTransform이 활성화되었습니다.
  • 플랫폼이 Android로 설정되었습니다.
  • 그래픽스 API가 Vulkan으로 설정되었습니다.

UNITY_DISPLAY_ORIENTATION_PRETRANSFORM은 현재 preTransform 회전으로 설정된 상수입니다. 이 값은 다음 중 하나입니다.

  • UNITY_DISPLAY_ORIENTATION_PRETRANSFORM_0
  • UNITY_DISPLAY_ORIENTATION_PRETRANSFORM_90
  • UNITY_DISPLAY_ORIENTATION_PRETRANSFORM_180
  • UNITY_DISPLAY_ORIENTATION_PRETRANSFORM_270

UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION이 정의되지 않거나, 렌더 텍스처로 렌더링되면 UNITY_DISPLAY_ORIENTATION_PRETRANSFORM 값은 UNITY_DISPLAY_ORIENTATION_0입니다.

UNITY_DISPLAY_ORIENTATION_PRETRANSFORM is translated into a Vulkan specialization constant, which makes it efficient to use in if or switch statements.

제한 사항

다음과 같은 경우 preTransform을 활성화하려면 Unity 프로젝트를 사용하기 전에 추가 수정이 필요할 수 있습니다.

  • Unity의 투사 매트릭스를 사용하지 않는 셰이더
  • 프래그먼트 셰이더에서 현재 픽셀 포지션에 종속되는 셰이더(SV_Position)
  • 스크린 공간 파생물(ddx, ddy)을 사용하는 셰이더
  • Vulkan 스왑체인 이미지를 사용하는 네이티브 렌더링 플러그인을 수정해야 할 수 있음
  • 다른 렌더 텍스처와 더불어 MRT 설정의 Unity RenderPass API와 함께 백버퍼 사용

이러한 경우는 백버퍼로 직접 렌더링할 때만 적용됩니다.

추가 정보

Android용 싱글 패스 스테레오 렌더링
테스트와 디버그
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961