Quick Reference
UV는 텍스처 위치를 가리키고 sampler는 읽기 정책을 정하므로, 확대에는 mag filter, 축소에는 min filter와 필요할 때 mip filter, 범위 밖에는 repeat·clamp를 선택합니다.
| sampler 설정 | 바꾸는 상황 | 잘못되면 |
|---|---|---|
| Address mode: repeat / clamp / mirror | UV가 0..1 밖으로 갈 수 있을 때 | seam에서 이웃 tile이 섞이거나 테두리가 늘어남 |
| Mag filter | texture가 화면에서 확대될 때 | nearest면 계단, linear면 의도치 않은 흐림 |
| Min + mip filter | texture가 축소될 때 | mip 없으면 shimmer, 잘못된 mip이면 blur |
| LOD bias / clamp | material별 detail 또는 streaming 범위를 조정할 때 | 과한 negative bias는 aliasing과 bandwidth 증가 |
| Anisotropy | 비스듬한 지면/도로처럼 footprint가 긴 표면 | 낮으면 먼 거리에서 줄무늬와 흐림 |
| Compare sampler | depth shadow map을 읽을 때 | 일반 color sampling과 비교 규칙을 혼동 |
좌표에서 texel까지
텍스처는 이미지 데이터이고, UV는 그 이미지에서 어디를 읽을지 나타내는 좌표입니다. 보통 (0, 0)부터 (1, 1) 범위를 쓰지만, wrapping 설정에 따라 범위를 벗어난 좌표도 반복하거나 clamp할 수 있습니다. texture 좌표의 origin 방향과 texel center 규약은 API, image loader, shader convention에 따라 확인해야 합니다.
fragment UV -> sampler state -> texture sample -> color/material value텍스처 샘플링은 단순한 배열 조회가 아닙니다. filtering, mipmap, color space, compression, cache locality가 결과 품질과 성능에 영향을 줍니다. texture와 sampler를 분리하는 API에서는 같은 image에 clamp sampler와 repeat sampler를 따로 연결할 수 있으므로, image asset의 색 공간과 sampling policy를 한 값으로 취급하지 않습니다.
sampler state는 texture 데이터와 별개로 “어떻게 읽을지”를 정합니다. 같은 texture라도 nearest로 읽으면 날카롭고, linear+mipmap으로 읽으면 부드럽고 안정적이며, repeat/clamp 설정에 따라 UV 범위 밖의 결과가 달라집니다.
Filtering과 LOD
Nearest filtering은 가장 가까운 texel 하나를 읽습니다. Linear filtering은 주변 texel을 섞어 부드럽게 만듭니다. 화면에서 텍스처가 작게 보이면 GPU는 보통 fragment UV의 화면 미분값으로 footprint를 추정해 적절한 mip level을 고릅니다. textureLod 같은 explicit LOD sample은 이 자동 추정을 우회하므로, compute shader나 특수 효과에서는 의도적으로 LOD를 지정해야 합니다.
anisotropic filtering은 footprint가 한 방향으로 길어진 경우 여러 방향의 정보를 더 잘 보존합니다. detail을 공짜로 늘리는 설정은 아니며, sample 수와 bandwidth가 늘 수 있습니다. normal map처럼 방향 데이터인 texture는 linear filtering을 쓰더라도 sample 뒤 normal을 다시 normalize해야 하는 경우가 많습니다.
texture compression은 메모리와 bandwidth를 줄이는 대신 block 단위 압축 특유의 artifact를 만들 수 있습니다. albedo, normal, mask처럼 데이터 성격이 다르면 적절한 압축 포맷도 달라집니다.
색 데이터와 숫자 데이터
| 상황 | 설정 |
|---|---|
| 픽셀 아트처럼 날카로운 결과 | nearest |
| 일반 표면 텍스처 | linear + mipmap |
| 멀리서 반짝임 | mipmap, anisotropic filtering |
| 반복 패턴 | repeat wrapping |
| 경계 밖 번짐 방지 | clamp wrapping |
| data texture | color decode를 끄고 filtering/mip의 의미를 개별 확인 |
| texture 내용 | color space | filtering / mip 판단 |
|---|---|---|
| albedo, UI color | 보통 sRGB decode 후 linear shading | 일반적으로 linear + mip |
| normal map | linear data | filtering 후 normalize, compression의 normal 지원 여부 |
| roughness / mask | linear data | 값 평균이 material 의미에 맞는지 확인 |
| LUT | 제작 규약에 따름 | 보통 clamp, 정해진 coordinate와 precision |
| depth shadow map | depth compare 규약 | compare sampler, border/clamp와 PCF |
데이터 텍스처는 색처럼 감마 변환하면 값이 깨질 수 있습니다. 또한 "mip을 끈다"가 항상 정답은 아닙니다. roughness, mask, normal처럼 축소된 footprint에서 어떤 평균이 의미 있는지 material 모델과 함께 판단합니다.
sampling 오류를 읽는 법
mipmap을 끄면 가까이서는 선명해 보여도 멀리서 aliasing과 shimmering이 심해질 수 있습니다. UV seam은 텍스처 좌표가 끊기는 경계이므로 normal map seam이 보이면 tangent space, padding, wrapping, mip 생성까지 함께 확인해야 합니다.
| 증상 | 확인할 설정 |
|---|---|
| 멀리서 반짝이거나 moire가 생김 | mip chain, min filter, LOD bias, anisotropy |
| tile 경계에 다른 색이 보임 | repeat/clamp, atlas padding, border color |
| material이 지나치게 밝거나 어두움 | sRGB decode/encode 횟수와 data texture 설정 |
| normal이 뭉개지거나 조명이 꺾임 | normal map space, filtering 뒤 normalize, tangent seam |
| compute에서 sample이 흐리거나 0번 mip만 읽힘 | explicit LOD와 dispatch의 UV footprint |
참고 링크
1 sources