[geg1] 3.volumetric representation of virtual environments

44
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

Upload: -

Post on 27-Jun-2015

1.088 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: [GEG1] 3.volumetric representation of virtual environments

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

Page 2: [GEG1] 3.volumetric representation of virtual environments

height map이 아니라

실제 volume으로 환경을 표현하는

기법을 살펴본다.

간단한 개념 정리 수준

Page 3: [GEG1] 3.volumetric representation of virtual environments

height map

• 등고선을 생각하면 쉽게 이해

• 간단한 표현법

• 시각화 쉽다

• 생성 쉽다

http://www.alvaromartin.net/images/surfaceclipmaps/heightmap.jpg

Page 4: [GEG1] 3.volumetric representation of virtual environments

• 좌표마다 높이 값이 하나만 존재

• 동굴, 돌출부 등을 표현 못함

height map 표현 한계

Page 5: [GEG1] 3.volumetric representation of virtual environments

• 실제 3D 데이터

• height map이 가지는 제한 X

volumetric environments

Page 6: [GEG1] 3.volumetric representation of virtual environments

• Worms 3D

• Crysis sandbox

• MinerWars

• Thermite3D game engine

실제로 쓰이고 있다!

Page 7: [GEG1] 3.volumetric representation of virtual environments

Overview

Data Structures

Surface Extraction

Rendering

Physics

The Future

Conclusion

Page 8: [GEG1] 3.volumetric representation of virtual environments

• volumetric pixel

• 코어 데이터 구조로 사용

Voxel

𝟖 × 𝟖 × 𝟖 voxels

Page 9: [GEG1] 3.volumetric representation of virtual environments

• 2 × 2 × 2 voxels

• surface를 만드는 최소 단위

Cell

Page 10: [GEG1] 3.volumetric representation of virtual environments

• 표현을 하려면 변환해야 함

• triangle mesh로 변환하는 작업

Surface extraction

Page 11: [GEG1] 3.volumetric representation of virtual environments

Marching Cubes algorithm

Page 12: [GEG1] 3.volumetric representation of virtual environments

Overview

Data Structures

Surface Extraction

Rendering

Physics

The Future

Conclusion

Page 13: [GEG1] 3.volumetric representation of virtual environments

• 8-bit

• 0 : empty space

• rock, soil, ….

Material ID

Page 14: [GEG1] 3.volumetric representation of virtual environments

• 단순한 volume 안/밖 결정 문제점

• 뾰족한 겉면

• 부드러운 메시 겉면을 표현하려고

• Marching Cubes Algorithm에서

– linear interpolation을 할 때 사용

Density field

Page 15: [GEG1] 3.volumetric representation of virtual environments

• material ID (1byte)

• density (1byte)

Voxel이 가지는 데이터

Page 16: [GEG1] 3.volumetric representation of virtual environments

• volume을 구성하는 단위

• voxel 여러 개로 이루어진다

Block

Page 17: [GEG1] 3.volumetric representation of virtual environments

Volume은 block 리스트로 표현

Page 18: [GEG1] 3.volumetric representation of virtual environments

• Voxel 변경

• 해당하는 block을 찾음

• shared 상태면 block을 복사해서 변경

• reference count 업데이트

Voxel 데이터 변경 시나리오 1

Page 19: [GEG1] 3.volumetric representation of virtual environments

• 변경해서 다른 block과 같은 모양

• 모든 voxel을 비교해 공유 block을 식별하고 처리하는 작업은 비쌈

• potentially homogeneous 마크

• garbage collection 시간에 처리

Voxel 데이터 변경 시나리오 2

Page 20: [GEG1] 3.volumetric representation of virtual environments

• 실험 결과 32 × 32 × 32

• smaller block : 공유 가능성 높음

• larger block : block 개수가 줄어들어 관리 비용이 감소

적절한 block size는?

Page 21: [GEG1] 3.volumetric representation of virtual environments

Overview

Data Structures

Surface Extraction

Rendering

Physics

The Future

Conclusion

Page 22: [GEG1] 3.volumetric representation of virtual environments

• real-time으로 volume 변경 가능

• 변경된 부분만 surface 재생성

• 결과는 GPU rendering에 적합한 포멧

요구 사항

Page 23: [GEG1] 3.volumetric representation of virtual environments

• volume을 겹치는 부분 없이 나눔

• 업데이트가 수행되는 단위

• mesh data를 가진다

• vertex buffer, index buffer

• dirty flag : mesh data를 재생성?

Region

Page 24: [GEG1] 3.volumetric representation of virtual environments

• 실험 결과 8 × 8 × 8

• smaller regions

– finer-grained occlusion culling

– 효율적인 mesh data 생성

– batch count 증가

적절한 region size는?

Page 25: [GEG1] 3.volumetric representation of virtual environments

struct Vertex

{

float position[3];

float normal[3];

float materialId;

float alpha;

}

Output of Algorithm

Page 26: [GEG1] 3.volumetric representation of virtual environments

• volume에서 바로 LOD를 구현

• 생성된 triangle surface는 상관 X

• mip level에 맞는 surface extraction 실행

Level of Detail

Page 27: [GEG1] 3.volumetric representation of virtual environments

Threading the Algorithm

Page 28: [GEG1] 3.volumetric representation of virtual environments

Overview

Data Structures

Surface Extraction

Rendering

Physics

The Future

Conclusion

Page 29: [GEG1] 3.volumetric representation of virtual environments

• intersecting 검사

– view frustum

– bounding volume hierarchy

• 간단하게 구현 가능

visibility culling

Page 30: [GEG1] 3.volumetric representation of virtual environments

• geometry는 미리 만들어지지 X

• volume 정보로부터 생성

• texture coord 자동 생성 필요

• Triplanar texturing 사용

The Material System

Page 31: [GEG1] 3.volumetric representation of virtual environments

• pixel shader

• surface normal을 blend weights로 사용

• x,y,z 축으로 프로젝트된 텍스쳐를 blend weights를 사용해 섞는다

Triplanar texturing

Page 32: [GEG1] 3.volumetric representation of virtual environments

// 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;

Page 33: [GEG1] 3.volumetric representation of virtual environments

• 자연물 잘 표현

– rock, grass, …

• 인공물 잘 표현 못함

– 날카로운 모서리

– 높은 디테일

Triplanar texturing

Page 34: [GEG1] 3.volumetric representation of virtual environments

Using Multiple Materials

Page 35: [GEG1] 3.volumetric representation of virtual environments

• non-uniform 영역 초기화 – black으로 setting

• uniform triangles 렌더링 – blending mode : set

• non-uniform 영역 – blending mode : additively

– material 간 부드러운 전환

Using Multiple Materials

Page 36: [GEG1] 3.volumetric representation of virtual environments

Overview

Data Structures

Surface Extraction

Rendering

Physics

The Future

Conclusion

Page 37: [GEG1] 3.volumetric representation of virtual environments

• region에 있는 mesh data로 생성

• dynamically updating

– collision mesh를 재생성

– 기존 mesh와 교체

collision mesh

Page 38: [GEG1] 3.volumetric representation of virtual environments

Overview

Data Structures

Surface Extraction

Rendering

Physics

The Future

Conclusion

Page 39: [GEG1] 3.volumetric representation of virtual environments

• volume 사이즈를 더 크게

• data streaming

• content creation

– height map volumes (현재)

– triangle mesh -> volumes (이후)

해야 할 일들

Page 40: [GEG1] 3.volumetric representation of virtual environments

• 지형 파괴

• 파괴된 지형을 복구

• …

게임 플레이에 어떻게 활용?

Page 41: [GEG1] 3.volumetric representation of virtual environments

Overview

Data Structures

Surface Extraction

Rendering

Physics

The Future

Conclusion

Page 42: [GEG1] 3.volumetric representation of virtual environments

• height map이 아닌 volume으로 표현

– 표현할 수 있는 영역을 넓힌다.

• voxel, cell, volume, block, region 설명

• LOD, material 여러 개 사용 등을 살펴 봄

Page 43: [GEG1] 3.volumetric representation of virtual environments
Page 44: [GEG1] 3.volumetric representation of virtual environments