[geg1] 3.volumetric representation of virtual environments
TRANSCRIPT
Game Engine Gems 1 chap 3.
Volumetric Representation of Virtual Environments
ohyecloudy http://ohyecloudy.com
shader studyhttp://cafe.naver.com/shader.cafe
2011.10.31
height map이 아니라
실제 volume으로 환경을 표현하는
기법을 살펴본다.
간단한 개념 정리 수준
height map
• 등고선을 생각하면 쉽게 이해
• 간단한 표현법
• 시각화 쉽다
• 생성 쉽다
http://www.alvaromartin.net/images/surfaceclipmaps/heightmap.jpg
• 좌표마다 높이 값이 하나만 존재
• 동굴, 돌출부 등을 표현 못함
height map 표현 한계
• 실제 3D 데이터
• height map이 가지는 제한 X
volumetric environments
Overview
Data Structures
Surface Extraction
Rendering
Physics
The Future
Conclusion
• volumetric pixel
• 코어 데이터 구조로 사용
Voxel
𝟖 × 𝟖 × 𝟖 voxels
• 2 × 2 × 2 voxels
• surface를 만드는 최소 단위
Cell
• 표현을 하려면 변환해야 함
• triangle mesh로 변환하는 작업
Surface extraction
Marching Cubes algorithm
Overview
Data Structures
Surface Extraction
Rendering
Physics
The Future
Conclusion
• 8-bit
• 0 : empty space
• rock, soil, ….
Material ID
• 단순한 volume 안/밖 결정 문제점
• 뾰족한 겉면
• 부드러운 메시 겉면을 표현하려고
• Marching Cubes Algorithm에서
– linear interpolation을 할 때 사용
Density field
• material ID (1byte)
• density (1byte)
Voxel이 가지는 데이터
• volume을 구성하는 단위
• voxel 여러 개로 이루어진다
Block
Volume은 block 리스트로 표현
• Voxel 변경
• 해당하는 block을 찾음
• shared 상태면 block을 복사해서 변경
• reference count 업데이트
Voxel 데이터 변경 시나리오 1
• 변경해서 다른 block과 같은 모양
• 모든 voxel을 비교해 공유 block을 식별하고 처리하는 작업은 비쌈
• potentially homogeneous 마크
• garbage collection 시간에 처리
Voxel 데이터 변경 시나리오 2
• 실험 결과 32 × 32 × 32
• smaller block : 공유 가능성 높음
• larger block : block 개수가 줄어들어 관리 비용이 감소
적절한 block size는?
Overview
Data Structures
Surface Extraction
Rendering
Physics
The Future
Conclusion
• real-time으로 volume 변경 가능
• 변경된 부분만 surface 재생성
• 결과는 GPU rendering에 적합한 포멧
요구 사항
• volume을 겹치는 부분 없이 나눔
• 업데이트가 수행되는 단위
• mesh data를 가진다
• vertex buffer, index buffer
• dirty flag : mesh data를 재생성?
Region
• 실험 결과 8 × 8 × 8
• smaller regions
– finer-grained occlusion culling
– 효율적인 mesh data 생성
– batch count 증가
적절한 region size는?
struct Vertex
{
float position[3];
float normal[3];
float materialId;
float alpha;
}
Output of Algorithm
• volume에서 바로 LOD를 구현
• 생성된 triangle surface는 상관 X
• mip level에 맞는 surface extraction 실행
Level of Detail
Threading the Algorithm
Overview
Data Structures
Surface Extraction
Rendering
Physics
The Future
Conclusion
• intersecting 검사
– view frustum
– bounding volume hierarchy
• 간단하게 구현 가능
visibility culling
• geometry는 미리 만들어지지 X
• volume 정보로부터 생성
• texture coord 자동 생성 필요
• Triplanar texturing 사용
The Material System
• pixel shader
• surface normal을 blend weights로 사용
• x,y,z 축으로 프로젝트된 텍스쳐를 blend weights를 사용해 섞는다
Triplanar texturing
// Interpolation means normals may not be unit length. normal = normalize(normal); // Squaring a unit vector makes the components add to one. float3 blendWeights = abs(normal * normal); // For each axis, sample the texture and multiply by the blend weights. float4 colorMapValueYZ = tex2D(colorMapX, worldPos.yz) * blendWeights.x; float4 colorMapValueXZ = tex2D(colorMapY, worldPos.xz) * blendWeights.y; float4 colorMapValueXY = tex2D(colorMapZ, worldPos.xy) * blendWeights.z; // Combine the results float4 colorMapValue = colorMapValueXY + colorMapValueYZ + colorMapValueXZ;
• 자연물 잘 표현
– rock, grass, …
• 인공물 잘 표현 못함
– 날카로운 모서리
– 높은 디테일
Triplanar texturing
Using Multiple Materials
• non-uniform 영역 초기화 – black으로 setting
• uniform triangles 렌더링 – blending mode : set
• non-uniform 영역 – blending mode : additively
– material 간 부드러운 전환
Using Multiple Materials
Overview
Data Structures
Surface Extraction
Rendering
Physics
The Future
Conclusion
• region에 있는 mesh data로 생성
• dynamically updating
– collision mesh를 재생성
– 기존 mesh와 교체
collision mesh
Overview
Data Structures
Surface Extraction
Rendering
Physics
The Future
Conclusion
• volume 사이즈를 더 크게
• data streaming
• content creation
– height map volumes (현재)
– triangle mesh -> volumes (이후)
해야 할 일들
• 지형 파괴
• 파괴된 지형을 복구
• …
게임 플레이에 어떻게 활용?
Overview
Data Structures
Surface Extraction
Rendering
Physics
The Future
Conclusion
• height map이 아닌 volume으로 표현
– 표현할 수 있는 영역을 넓힌다.
• voxel, cell, volume, block, region 설명
• LOD, material 여러 개 사용 등을 살펴 봄