The value to be compared against (if Comp is anything else than always) and/or the value to be written to the buffer (if either Pass, Fail or ZFail is set to replace). 0–255 integer.
비교할 값 (Comp가 항상 아닌 것) 및 / 또는 버퍼에 쓸 값 (Pass, Fail 또는 ZFail이 Replace로 설정된 경우)입니다.0-255 정수.
ReadMask
ReadMask readMask
An 8 bit mask as an 0–255 integer, used when comparing the reference value with the contents of the buffer (referenceValue & readMask) comparisonFunction (stencilBufferValue & readMask). Default: 255.
참조 값을 버퍼의 내용 (referenceValue & readMask)과 비교할 때 사용되는 8 비트 마스크 (0-255 정수) comparisonFunction (stencilBufferValue & readMask).기본값 : 255.
WriteMask
WriteMask writeMask
An 8 bit mask as an 0–255 integer, used when writing to the buffer. Default: 255.
0-255 정수의 8 비트 마스크로, 버퍼에 쓸 때 사용됩니다.기본값 : 255.
Comp
Comp comparisonFunction
The function used to compare the reference value to the current contents of the buffer. Default: always.
이 함수는 참조 값을 버퍼의 현재 내용과 비교하는 데 사용됩니다.기본값 : 항상.
Pass
Pass stencilOperation
What to do with the contents of the buffer if the stencil test (and the depth test) passes. Default: keep.
스텐실 테스트 (및 깊이 테스트)가 통과하면 버퍼의 내용으로 수행 할 작업.기본값 : 유지.
Fail
Fail stencilOperation
What to do with the contents of the buffer if the stencil test fails. Default: keep.
스텐실 테스트가 실패 할 경우 버퍼의 내용으로 수행 할 작업.기본값 : 유지.
ZFail
ZFail stencilOperation
What to do with the contents of the buffer if the stencil test passes, but the depth test fails. Default: keep.
스텐실 테스트가 통과했지만 깊이 테스트가 실패 할 경우 버퍼의 내용으로 수행 할 작업.기본값 : 유지.
Comp, Pass, Fail and ZFail will be applied to the front-facing geometry, unless Cull Front is specified, in which case it’s back-facing geometry. You can also explicitly specify the two-sided stencil state by defining CompFront, PassFront, FailFront, ZFailFront (for front-facing geometry), and CompBack, PassBack, FailBack, ZFailBack (for back-facing geometry).
Cull Front가 지정되지 않은 경우 Comp, Pass, Fail 및 ZFail이 전면 대칭 지오메트리에 적용됩니다.CompFront, PassFront, FailFront, ZFailFront (정면 지오메트리의 경우) 및 CompBack, PassBack, FailBack, ZFailBack (후면 지오메트리의 경우)을 정의하여 양면 스텐실 상태를 명시 적으로 지정할 수도 있습니다.
Comparison Function
Comparison function is one of the following:
Greater
Only render pixels whose reference value is greater than the value in the buffer.
참조 값이 버퍼의 값보다 큰 픽셀 만 렌더링합니다.
GEqual
Only render pixels whose reference value is greater than or equal to the value in the buffer.
참조 값이 버퍼의 값보다 크거나 같은 픽셀 만 렌더링합니다.
Less
Only render pixels whose reference value is less than the value in the buffer.
참조 값이 버퍼의 값보다 작은 픽셀 만 렌더링합니다.
LEqual
Only render pixels whose reference value is less than or equal to the value in the buffer.
참조 값이 버퍼의 값보다 작거나 같은 픽셀 만 렌더링합니다.
Equal
Only render pixels whose reference value equals the value in the buffer.
참조 값이 버퍼의 값과 동일한 픽셀 만 렌더링합니다.
NotEqual
Only render pixels whose reference value differs from the value in the buffer.
참조 값이 버퍼의 값과 다른 픽셀 만 렌더링합니다.
Always
Make the stencil test always pass.
스텐실 테스트를 항상 통과 시키십시오.
Never
Make the stencil test always fail.
스텐실 테스트를 항상 실패하게 만드십시오.
Stencil Operation
Stencil operation is one of the following:
Keep
Keep the current contents of the buffer.
버퍼의 현재 내용을 유지하십시오.
Zero
Write 0 into the buffer.
버퍼에 0을 씁니다.
Replace
Write the reference value into the buffer.
참조 값을 버퍼에 씁니다.
IncrSat
Increment the current value in the buffer. If the value is 255 already, it stays at 255.
버퍼의 현재 값을 증가시킵니다.값이 이미 255이면 255로 유지됩니다.
DecrSat
Decrement the current value in the buffer. If the value is 0 already, it stays at 0.
버퍼의 현재 값을 감소시킵니다.값이 이미 0이면 0으로 유지됩니다.
Invert
Negate all the bits.
모든 비트를 부정합니다.
IncrWrap
Increment the current value in the buffer. If the value is 255 already, it becomes 0.
버퍼의 현재 값을 증가시킵니다.값이 이미 255이면 0이됩니다.
DecrWrap
Decrement the current value in the buffer. If the value is 0 already, it becomes 255.
버퍼의 현재 값을 감소시킵니다.값이 이미 0이면 255가됩니다.
Deferred rendering path
Stencil functionality for objects rendered in the deferred rendering path is somewhat limited, as during the base pass and lighting pass the stencil buffer is used for other purposes. During those two stages stencil state defined in the shader will be ignored and only taken into account during the final pass. Because of that it’s not possible to mask out these objects based on a stencil test, but they can still modify the buffer contents, to be used by objects rendered later in the frame. Objects rendered in the forward rendering path following the deferred path (e.g. transparent objects or objects without a surface shader) will set their stencil state normally again.
The deferred rendering path uses the three highest bits of the stencil buffer, plus up to four more highest bits - depending on how many light mask layers are used in the scene. It is possible to operate within the range of the “clean” bits using the stencil read and write masks, or you can force the camera to clean the stencil buffer after the lighting pass using Camera.clearStencilAfterLightingPass.
스텐실 버퍼가 다른 목적으로 사용되는 기본 패스 및 조명 패스 중에는 지연 렌더링 경로에서 렌더링 된 객체의 스텐실 기능이 다소 제한적입니다. 이 두 단계 동안 쉐이더에 정의 된 스텐실 상태는 무시되고 마지막 단계에서만 고려됩니다. 이 때문에 스텐실 테스트를 기반으로 이러한 객체를 마스크 처리 할 수는 없지만 나중에 프레임에서 렌더링되는 객체가 사용하도록 버퍼 내용을 수정할 수 있습니다. 지연 경로를 따르는 순방향 렌더링 경로에서 렌더링 된 객체 (예 : 투명한 객체 또는 표면 셰이더가없는 객체)는 스텐실 상태를 정상적으로 다시 설정합니다.
지연 렌더링 경로는 스텐실 버퍼의 세 개의 최상위 비트와 최대 네 개의 최상위 비트를 사용합니다 (장면에서 사용되는 조명 마스크 레이어의 수에 따라 다름). 스텐실 읽기 및 쓰기 마스크를 사용하여 "깨끗한"비트 범위 내에서 작동하거나 Camera.clearStencilAfterLightingPass를 사용하여 조명 통과 후 카메라가 스텐실 버퍼를 청소하도록 할 수 있습니다.
[HideInInspector] - does not show the property value in the material inspector.
[NoScaleOffset] - material inspector will not show texture tiling/offset fields for texture properties with this attribute.
[Normal] - indicates that a texture property expects a normal-map.
[HDR] - indicates that a texture property expects a high-dynamic range (HDR) texture.
[Gamma] - indicates that a float/vector property is specified as sRGB value in the UI (just like colors are), and possibly needs conversion according to color space used. See Properties in Shader Programs.
[PerRendererData] - indicates that a texture property will be coming from per-renderer data in the form of a MaterialPropertyBlock. Material inspector changes the texture slot UI for these properties.
OpenGL Core 4.1+/ES3.0+ on Windows, macOS, Linux, iOS and Android
Metal on macOS and iOS
Vulkan on Windows and Android
PlayStation 4 and Xbox One
WebGL (requires WebGL 2.0 API)
특징및 제한사항
다이나믹 배칭보다 우선 작동한다, 인스턴싱된 오브젝트는 다이나믹 배칭은 작동안함
여러개의 라이트를 받게되면 기본 패스만 인스턴싱 처리된다.
라이트맵이나 리플렉션 프로브가 적용되면 인스터싱 되지않는다.
쉐이더가 투 패스 이상일 경우 첫번째 패스만 인스턴싱됨
너무많은 인스턴싱은(D3D : 64KB, Opengl : 16KB) 쉐이더 컴파일 실패를 부를수 있다.
UNITY_MAX_INSTANCE_COUNT 로 숫자를 제한할수있다.
최대갯수는 500개, 오픈지엘은125개가 기본
오픈지엘 3.0이상 작동
SkinnedMeshRenderer는 지원되지 않음
인스턴스 별 데이터 추가
기본적으로 Unity는 인스턴스화 된 각각의 드로 콜에서 서로 다른 Transform을 가진 GameObject 인스턴스를 일괄 처리합니다. 인스턴스화 된 GameObjects에 더 많은 분산을 추가하려면 Shader를 수정하여 Material 색상과 같은 인스턴스 별 속성을 추가하십시오.
아래 예제는 각 인스턴스에 대해 서로 다른 색상 값을 가진 인스턴스화 된 셰이더를 만드는 방법을 보여줍니다.
모든 인스턴스 별 등록 정보는 특별히 명명 된 상수 버퍼에 정의되어야합니다. 이 매크로 쌍을 사용하여 각 인스턴스에 고유하게 만들 속성을 래핑합니다.
UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
이 메서드를 사용하여 유형별 및 이름 별 인스턴스 별 Shader 속성을 정의합니다. 이 예제에서 _Color 속성은 고유합니다.
UNITY_SETUP_INSTANCE_ID(v);
이것을 사용하여 셰이더 기능에서 인스턴스 ID에 액세스 할 수있게 만듭니다. 버텍스 쉐이더의 맨 처음에 사용해야하며 프래그먼트 쉐이더에서는 옵션입니다.
UNITY_TRANSFER_INSTANCE_ID(v, o);
이것을 사용하여 입력 구조의 인스턴스 ID를 버텍스 쉐이더의 출력 구조로 복사하십시오. 프래그먼트 셰이더에서 인스턴스 별 데이터에 액세스해야하는 경우에만 필요합니다.
UNITY_ACCESS_INSTANCED_PROP(arrayName, color)
인스턴스화 상수 버퍼에 선언 된 인스턴스 별 Shader 속성에 액세스하려면이 옵션을 사용합니다. 인스턴스 ID를 사용하여 인스턴스 데이터 배열을 색인화합니다. 매크로의 arrayName은 UNITY_INSTANCING_BUFFER_END (이름) 매크로의 arrayName과 일치해야합니다.
#pragma instancing_options #pragma instancing_options 지시어는 다음 스위치를 사용할 수 있습니다.
SwitchFunction
forcemaxcount:batchSizeand maxcount:batchSize
대부분의 플랫폼에서 Unity는 대상 장치의 최대 상수 버퍼 크기를 모든 인스턴스 별 속성을 포함 하는 구조체의 크기로 나누어 인스턴스화 데이터 배열 크기를 자동으로 계산합니다. 일반적으로 배치 크기에 대해 걱정할 필요가 없습니다. 그러나 일부 플랫폼 (Vulkan, Xbox One 및 Switch) 에서는 여전히 고정 배열 크기가 필요합니다. maxcount 옵션을 사용하여 해당 플 '폼에 대한 일} 처리 크기를 지정할 수 있습니다. 이 옵션은 다른 플랫폼에서 완전히 무시됩니다. 모든 플랫폼에서 배치 크기를 강제로 설정하려면 forcemaxcount를 사용하십시오 (예를 들어, DrawMeshInstanced를 통해 256 개의 인스턴스 스프라이트가있는 드로잉 만 발행하는 경우). 두 옵션의 기본값은 500입니다.
assumeuniformscaling
유니티에 모든 인스턴스가 균일 한 스케일링 (모든 X, Y, Z 축에 대해 동일한 스케일)을 가지고 있다고 가정하도록 지시하려면이 옵션을 사용하십시오.
lodfade
이것을 사용하여 LOD 페이드 값을 인스턴스화 할 수 있습니다. 이것은 SpeedTree 및 LOD 페이드 기능을 사용하는 다른 LOD 기술에 유용합니다.
procedural:FunctionName
Unity가 Graphics.DrawMeshInstancedIndirect와
함께 사용할 추가변형을 생성하도록 지시하려면이
옵션을 사용하십시오.
버텍스 쉐이더 단계의 시작 부분에서 Unity는
콜론 다음에 지정된 함수를 호출합니다.
인스턴스 데이터를 수동으로 설정하려면
일반적으로 인스턴스 당 데이터를 셰이더에
추가하는 것과 같은 방법으로이 함수에 인스턴스
별 데이터를 추가하십시오. Unity는 가져온
인스턴스 속성 중 하나가 조각 Shader에 포함되어
있으면 조각 Shader의 시작 부분에서이 함수를
호출합니다.
UnityObjectToClipPos 셰이더 스크립트를 작성할 때는 mul (UNITY_MATRIX_MVP, v.vertex) 대신 항상
UnityObjectToClipPos (v.vertex)를 사용하십시오. 인스턴스화 된 쉐이더에서 UNITY_MATRIX_MVP를 정상적으로 계속 사용할 수 있지만
UnityObjectToClipPos는 오브젝트 공간에서 클립 공간으로 정점 위치를 변환하는
가장 효율적인 방법입니다. Unity는 또한 프로젝트의 모든 셰이더를 스캔하고,
mul (UNITY_MATRIX_MVP, v)의 모든 항목을 UnityObjectToClipPos (v)로 자동으로
대체하는 셰이더 업그레이드 프로그램을 구현합니다. UNITY_MATRIX_MVP (UNITY_MATRIX_MV와 함께)가 사용되는 장소가 여전히있는 경우