Quick Comparison
Camera는 world를 view space로 보고 projection으로 화면에 맞춥니다. Perspective는 거리에 따라 크기가 달라지고, Orthographic은 크기를 유지합니다. z-fighting은 대개 두 표면의 거리와 depth precision 문제이므로 near를 필요 이상으로 작게, far를 필요 이상으로 크게 잡지 않습니다.
| 증상·목적 | 먼저 볼 Camera 값 | 다음 확인 |
|---|---|---|
| 멀수록 작아지는 3D view | Perspective, field of view | 화면 비율·camera position |
| 타일맵·전술도·UI용 view | Orthographic, orthographic size | world unit과 화면 범위 |
| 물체가 갑자기 잘림 | Near/Far clipping plane | layer culling mask·camera stack |
| 멀리서 표면이 깜빡임 | near를 키우고 far를 줄일 수 있는지 | 겹친 geometry·depth write |
| UI·minimap·reflection | 별도 Camera의 projection·clear·layer 역할 | main Camera 설정을 복사하지 않음 |
camera 문제 진단 순서
보이지 않음 -> clipping plane / layer / culling
크기 감각 이상 -> projection type / FOV / orthographic size
앞뒤가 깜빡임 -> 겹친 surface / near-far range / depth state
특정 view만 이상 -> 그 Camera의 pipeline·stack·target textureprojection을 고르는 기준
Perspective projection은 카메라에서 멀어질수록 작아지는 원근을 만듭니다. 1인칭·3인칭 3D 공간처럼 거리감이 의미일 때 맞습니다. Orthographic projection은 거리에 따른 크기 변화를 없애므로 2D, grid, minimap, 일부 isometric view에 맞습니다. 3D scene이라고 반드시 Perspective, UI라고 반드시 Orthographic인 규칙은 없으며, 화면에서 필요한 거리감과 조작 정확도가 선택 기준입니다.
camera를 이동하면 view matrix에서는 world가 반대 방향으로 변환돼 보입니다. 이 수학 모델은 custom matrix와 shader를 읽을 때 유용하지만, 일반 Unity gameplay code에서 Camera Transform을 직접 역행렬로 다룰 이유는 적습니다. Camera component의 Transform·projection property와 render pipeline 설정을 먼저 사용합니다.
near·far와 depth precision
depth buffer는 fragment의 깊이를 비교해 가려짐을 처리합니다. depth precision은 near/far range, graphics API, projection, render pipeline의 depth 방식에 영향을 받으므로 단순한 “권장 숫자”가 모든 project에 맞지 않습니다. 다만 near를 아주 작게 하고 far를 아주 크게 잡으면 깊이를 구분해야 하는 범위가 불필요하게 넓어져 서로 가까운 surface가 번갈아 보이는 z-fighting이 생길 수 있습니다.
수정 전 확인
- 실제 gameplay에서 camera가 가장 가까이 갈 거리
- 실제로 보여야 하는 가장 먼 object·sky·terrain 거리
- 겹친 decal, coplanar mesh, transparent depth state가 있는지
그 뒤 near는 가능한 멀리, far는 필요한 만큼만 둔다.두 polygon이 실제로 같은 평면에 겹치면 near/far를 조정해도 z-fighting이 남을 수 있습니다. decal·outline·overlay는 geometry offset, depth bias, renderer의 depth test/write가 필요할 수 있고 선택한 render pipeline에서 지원하는 방식으로 처리합니다.
여러 Camera를 분리하기
minimap, render texture, UI, reflection, shadow는 main view와 다른 projection·clipping·layer·target을 필요로 할 수 있습니다. 여러 Camera가 같은 object를 그릴 때는 순서와 clear 방식, camera stack, post-processing 여부를 함께 확인합니다. main Camera의 near/far를 minimap 요구 때문에 넓히면 main view의 depth precision을 희생할 수 있으므로 역할별로 Camera를 나눕니다.
z-fighting은 shader만의 문제가 아닙니다. 실제 겹친 geometry와 depth state를 확인한 뒤, scene scale에 맞게 Camera clipping range를 좁히세요. 어느 Camera에서 문제가 보이는지도 먼저 분리해야 합니다.
참고 링크
2 sources