본문 바로가기
카테고리 없음

ZClip : 오브젝트가 니어/ 파 클립에 잘리는걸 막기

by 대마왕J 2022. 2. 21.

https://docs.unity3d.com/kr/2021.1/Manual/SL-ZClip.html

ShaderLab command: ZClip

Sets the GPU’s depth clip mode, which determines how the GPU handles fragments that are outside of the near and far planes.

어떻게 GPU가 니어/ 파 플랜 외부의 픽셀셰이더를 다룰것인지를 결정하게 해주는 GPU의 댑스 클립 모드를 세팅합니다. (주: 오브젝트가 니어/ 파 클립에 잘리는걸 막을 수 있습니다)

Setting the GPU’s depth clip mode to clamp can be useful for stencil shadow rendering; it means that there is no need for special case handling when the geometry goes beyond the far plane, which results in fewer rendering operations. However, it can result in incorrect Z ordering.

GPU의 댑스 클립 모드를 클램프로 세팅하면, 스텐실 셰도우 랜더링에 유용할 수 있습니다 : 이것은 지오메트리가 파 플렌 넘어가도 뭐 습헤셜하게 건드려줄게 없다는 뜻으로서, 결과적으로 렌더링 오퍼레이션이 줄어듭니다. 그리고 Z 오더가 잘못될 수도 있죠. 

렌더 파이프라인 호환성

Feature name 빌트인렌더 파이프라인 유니버설 렌더 파이프라인(URP)  고해상도 렌더 파이프라인(HDRP)  Custom SRP
ZClip 지원 지원 지원 지원

사용법

This command makes a change to the render state. Use it in a Pass block to set the render state for that Pass, or use it in a SubShader block to set the render state for all Passes in that SubShader.

이 명령은 렌더 스테이트를 변경합니다. Pass 블럭 안에서 Pass를 위해 랜더 스테이트를 세팅하거나, 섭셰이더 블럭에서 모든 패스를 위해 렌더 스테이트를 셋팅할 수 있습니다. 

 

SignatureExample syntax 기능
ZClip [enabled] ZClip True Sets the depth clip mode.

Valid parameter values

 

파라미터 기능
enabled True Sets the depth clip mode to clip.  This is the default setting. 
댑스 클립 모드를 클립으로. 이건 기본 세팅입니다. 
  False Sets the depth clip mode to clamp. 
Fragments closer than the near plane are at the near plane exactly, and fragments further away than the far plane are at the far plane exactly.
댑스 클립 모드를 클램프로 
니어 플랜보다 가까이 있는건 니어 플렌 그 자리에 정확히 있고, 파 클립보다 먼건 파 클립에 정확히 있습니다. 

예제

This example code demonstrates the syntax for using this command in a Pass block.

패스 블럭에서 사용하려면 이렇게 쓰시고 

Shader "Examples/CommandExample"
{
    SubShader
    {
         // The rest of the code that defines the SubShader goes here.

        Pass
        {    
              // Sets the GPU's depth clip mode to clamp for this Pass
              // You would typically do this if you are rendering stencil shadows
              ZClip False
            
              // The rest of the code that defines the Pass goes here.
        }
    }
}

This example code demonstrates the syntax for using this command in a SubShader block.

섭 셰이더 블럭에서 쓰려면 이케 쓰세요 

Shader "Examples/CommandExample"
{
    SubShader
    {
         // Sets the GPU's depth clip mode to clamp for this SubShader
         // You would typically do this if you are rendering stencil shadows
         ZClip False

         // The rest of the code that defines the SubShader goes here.        

        Pass
        {    
              // The rest of the code that defines the Pass goes here.
        }
    }
}
반응형

댓글