Parallax Occlusion Mapping 노드
설명
Parallax Occlusion Mapping(POM) 노드를 사용하면 머티리얼의 UV와 뎁스를 변위시켜서 머티리얼 내부에 뎁스가 있는 것처럼 보이는 시차 효과를 구현할 수 있습니다.
Custom Function 노드 또는 하위 그래프가 포함된 그래프에서 이 노드를 사용하는 동안 텍스처 샘플링 오류가 발생하면 10.3 이상 버전으로 업그레이드하여 해결할 수 있습니다.
포트
이름 | 방향 | Type | 설명 |
---|---|---|---|
Heightmap | 입력 | Texture2D | 변위의 뎁스를 지정하는 텍스처입니다. |
Heightmap Sampler | 입력 | 샘플러 상태 | Heightmap을 샘플링할 샘플러입니다. |
Amplitude | 입력 | 플로트 | 하이트맵의 높이(센티미터 단위)에 적용할 멀티플라이어입니다. |
Steps | 입력 | 플로트 | 알고리즘의 리니어 검색이 수행하는 단계 수입니다. |
UVs | 입력 | Vector2 | 샘플러가 텍스처를 샘플링하는 데 사용하는 UV입니다. |
Lod | 입력 | 플로트 | Heightmap을 샘플링하는 데 사용할 디테일 수준(LOD)입니다. |
Lod Threshold | 입력 | 플로트 | POM 효과가 페이드아웃되기 시작하는 Heightmap 밉 레벨입니다. 이는 고해상도 렌더 파이프라인(HDRP) 릿 머티리얼의 Fading Mip Level Start 프로퍼티와 같습니다. |
Depth Offset | 출력 | 플로트 | 뎁스가 있는 것처럼 보이게 만들기 위해 뎁스 버퍼에 적용할 오프셋입니다. 그림자 및 스크린 공간 앰비언트 오클루전과 같은 뎁스 버퍼에 의존하는 효과를 활성화하려면 이 출력을 마스터 노드의 Depth Offset에 연결하십시오. |
Parallax UVs | 출력 | Vector2 | 시차 오프셋을 추가한 후의 UV입니다. |
생성된 코드 예제
다음 예제 코드는 이 노드의 가능한 결과 중 하나입니다.
float3 ParallaxOcclusionMapping_ViewDir = IN.TangentSpaceViewDirection * GetDisplacementObjectScale().xzy;
float ParallaxOcclusionMapping_NdotV = ParallaxOcclusionMapping_ViewDir.z;
float ParallaxOcclusionMapping_MaxHeight = Amplitude * 0.01;
// Transform the view vector into the UV space.
float3 ParallaxOcclusionMapping_ViewDirUV = normalize(float3(ParallaxOcclusionMapping_ViewDir.xy * ParallaxOcclusionMapping_MaxHeight, ParallaxOcclusionMapping_ViewDir.z)); // TODO: skip normalize
PerPixelHeightDisplacementParam ParallaxOcclusionMapping_POM;
ParallaxOcclusionMapping_POM.uv = UVs.xy;
float ParallaxOcclusionMapping_OutHeight;
float2 _ParallaxOcclusionMapping_ParallaxUVs = UVs.xy + ParallaxOcclusionMapping(Lod, Lod_Threshold, Steps, ParallaxOcclusionMapping_ViewDirUV, ParallaxOcclusionMapping_POM, ParallaxOcclusionMapping_OutHeight);
float _ParallaxOcclusionMapping_PixelDepthOffset = (ParallaxOcclusionMapping_MaxHeight - ParallaxOcclusionMapping_OutHeight * ParallaxOcclusionMapping_MaxHeight) / max(ParallaxOcclusionMapping_NdotV, 0.0001);