Unity는 멀티뷰를 지원하는 Android 기기용 싱글 패스 스테레오 렌더링을 지원합니다. 멀티뷰는 GL_OVR_multiview2와 GL_OVR_multiview_multisampled_render_to_texture OpenGL ES 확장자로 구성됩니다. 이러한 확장자에는 조각이 2개(한 눈에 하나씩)인 2D 텍스처 배열을 사용하는 셰이더가 필요합니다. 이는 더블 와이드 2D 텍스처를 사용하는 싱글 패스 스테레오 렌더링에 대한 Unity의 PC/PS4 구현과는 다릅니다. 즉 Android에 싱글 패스 스테레오 렌더링을 지원하는 셰이더 수정 사항은 다른 플랫폼과는 다릅니다.
커스텀 셰이더로 싱글 패스 스테레오 렌더링을 사용하려면 셰이더 코드를 추가해야 합니다. 커스텀 셰이더가 다음과 같은 경우에는 코드를 추가하지 않아도 됩니다.
참고: 이러한 셰이더 변경사항은 멀티 패스 스테레오 렌더링과 호환될 수 있습니다.
GPU가 렌더링되는 눈을 알기 위해 unity_StereoEyeIndex
빌트인 셰이더 변수를 사용하려는 경우 셰이더 단계 출력 구조체에서 UNITY_VERTEX_OUTPUT_STEREO
를 반드시 선언해야 합니다. 예를 들면 다음과 같습니다.
struct v2f {
float2 uv : TEXCOOR0;
float4 vertex : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
출력 데이터를 초기화하려면 버텍스 셰이더 함수에 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO()
를 사용해야 합니다. 예를 들면 다음과 같습니다.
v2f vert (appdata v)
{
v2f o;
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
이어지는 단계에서 unity_StereoEyeIndex
를 초기화하려면 처음에 UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX()
를 추가합니다. 예를 들면 다음과 같습니다.
fixed4 frag (v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
셰이더가 다른 셰이더 단계를 사용한다면 UNITY_TRANSFER_VERTEX_OUTPUT_STEREO()
매크로를 사용하여 눈 인덱스(eye index)를 후속 단계로 전송해야 합니다.
팁: 오브젝트의 최종 포지션을 계산하려면 mul(UNITY_MATRIX_MVP, IN.vertex)
가 아닌 UnityObjectToClipPos(IN.vertex)
를 사용하는 것이 가장 좋습니다.
2D 텍스처 배열인 눈 텍스처를 처리하려면 반드시 포스트 프로세싱 셰이더를 업데이트해야 합니다. 여기에 도움이 될 수 있도록 Unity에는 UNITY_DECLARE_SCREENSPACE_TEXTURE()
매크로가 포함되어 있습니다. 텍스처가 멀티 패스와 단일 패스 모드 모두에서 작동하게 하려면 각 텍스처를 이 매크로에 래핑합니다. 또한 텍스처를 샘플링할 때 UNITY_SAMPLE_SCREENSPACE_TEXTURE()
매크로를 사용합니다.
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX()
를 싱글 패스 모드에서 이미 호출한 경우에 이 매크로를 사용할 수 있습니다. Unity에는 뎁스 텍스처와 화면 공간 섀도우맵에 관한 유사한 매크로도 포함되어 있습니다. HLSLSupport.cginc
에서 전체 목록을 확인할 수 있습니다.
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.