SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
CUDA Raytracing을 이용한
voxel 오브젝트 가시성 검사
유영천
https://megayuchi.com
Tw: @dgtman
도형을 화면에 표시하는 방법
• Rasterization
• Ray Tracing
View
Matrix
Projection
Matrix
X
X ->
Rasterization
X 𝑉𝑖𝑒𝑤 matrix−1
𝑃𝑖𝑥𝑒𝑙. 𝑥 ÷ 𝑊𝑖𝑑𝑡ℎ × 2 − 1
𝑝𝑟𝑜𝑗𝑒𝑐𝑡𝑖𝑜𝑛 𝑚𝑎𝑡𝑟𝑖𝑥[0][0]
−(𝑃𝑖𝑥𝑒𝑙. 𝑦 ÷ 𝐻𝑒𝑖𝑔ℎ𝑡 × 2 − 1)
𝑝𝑟𝑜𝑗𝑒𝑐𝑡𝑖𝑜𝑛 𝑚𝑎𝑡𝑟𝑖𝑥[1][1]
0
,1 , 0
Ray Tracing
,
가장 앞의 픽셀을 그리는 방법
Rasterization
• 기본적으로 모든 매시는 순서
없이 그린다.
• Z-buffer를 이용해서 가장 앞에
있는 픽셀로 덮어쓴다.
• 삼각형->WVP 변환 후 얻은
z값을 z-buffer에 기록. 현재
Z값이 기존 z값보다 작으면
기존 픽셀을 덮어쓴다.
Ray Tracing
• depth버퍼 없다.
• Ray가 발사됐을 때 Ray마다
가장 앞에 있는 픽셀을
찾아낸다.
Z-Buffer
(-1.0, -1.0) (1.0, -1.0)
(-1.0, 1.0) (1.0, 1.0)
(0, Height) (Width, Height)
(Width, 0)
1.0
1.0
1.0
1.0
1.0
0.47
1.0
0.46
1.0
0.41
1.0
0.42
0.42
0.45
0.43
0.44
1.0
0.43
1.0
0.43
0.43
0.43
0.43
0.43
1.0
0.42
1.0
0.41
0.43
0.46
0.45
0.46
0.47
0.46
0.46
0.46
0.46
0.44
0.45
0.46
0.46
0.45
0.45
0.46
0.45
0.46
0.46
0.44
0.44
0.42
1.0
0.45
0.46
1.0
1.0
0.46
1.0
0.47
0.47
1.0
1.0
1.0
1.0
0.45
1.0
0.45
1.0
1.0 1.0
1.0
1.0
1.0
1.0
1.0 1.0
1.0
1.0
1.0
1.0
1.0 1.0
1.0
1.0
1.0
1.0
1.0 1.0
1.0
1.0
1.0
1.0
0.46
0.47
1.0
0.48
0.47
0.48
0.48
0.48
0.48
1.0
0.48
1.0
1.0
1.0
1.0
1.0
1.0 1.0
1.0
1.0
1.0
0.48
0.48
0.48
0.48
1.0
1.0
1.0
1.0
0.44
NDC
(0, 0)
Rasterization
Ray tracing에서 어느 오브젝트, 어느 삼각형이 앞에 있는지 어떻게 알지?
쉬운방법
• Ray 하나당 모든 오브젝트를 순회한다.
• Ray가 많아지면 당연히 미친듯이 느려진다.
KD-Tree
• X,Y,Z 축에 정렬된 BSP Tree.
• 각 node를 3가지 축과 축방향의 거리 D값으로 표현할 수 있다.
• KD-Tree를 탐색할 때 카메라로부터 가까운 node와 먼 node를 찾을
수 있다.
• Ray의 교차판정 등에 많이 사용한다.
• Near node와 Far node를 구분하지 않는다면 Quad-Tree와 별
차이는 없다.
• 게임의 월드를 KD-Tree로 관리하는 경우가 많다.
KD-Tree를 이용한 가장 가까운 오브젝트 탐색
• root node가 ray와 충돌하지 않으면 순회 중지.
• 현재 node의 자식 node 2개중 한 개만 ray와 충돌할 경우 충돌하는
노드를 방문.
• 현재 node의 자식 node 2개가 모두 충돌할 경우 먼 node를 stack에
push하고 가까운 node를 방문.
• 방문한 node가 leaf일 때 leaf에 들어있는 매시의 삼각형들에
대해서 ray와 충돌체크. 현재 leaf에서 충돌한 경우 t값을 저장하고
순회 중지.
• 방문한 node가 leaf일 때 어떤 삼각형도 ray와 충돌하지 않는 경우
stack에서 node포인터를 꺼내서 방문.
KD-Tree Traversal
0 1
2
node A
node A-a
node A-b
node A-b-a node A-b-b
node A
node A-a node A-b
node A-b-a node A-b-b
가시성 검사에 응용
S/W Occlusion Culling
• 적당히 작은 사이즈의 버퍼에 최대한 간소화된 방법으로 매시를
그려본다. 이 과정에서 얻은 depth값을 버퍼에 기록.
• 오브젝트 또는 트리의 node/leaf를 depth버퍼에 대해 z-test.
렌더링 파이프라인에 넣기 전에 이 단계에서 가려지는
오브젝트를 걸러낸다.
• 이것을 GPU에서 처리하면 H/W Occlusion Culling.
• S/W방식(CPU에서)으로 처리하는 이유는 GPU와의 통신시간을
트리 탐색중 바로 적용할 수 있기 때문.
복셀 월드에서의 S/W Occlusion Culling
• 복셀 지형 특성상 안이 꽉 차 있고 모양이 복잡하다.
• 복셀 오브젝트간 가리고 가려지는 상황이 엄청 빈번하다.
• S/W Occlusion Culling을 시도했을때 depth를 써넣고 테스트 하는
비용이 너무 크다.
• 복셀 오브젝트 개수만 해도 5-10만개씩 되기 때문에 이미 수집한
5-10만개의 오브젝트에서 보이지 않는 오브젝트를 제거할때도
생각보다 CPU시간을 많이 소모한다.
• S/W Occlusion Culling에 적합한가?
Ray Tracing을 이용한 가시성 검사
• Ray Tracing에선 처음부터 가려지는 픽셀-오브젝트는 그릴 일이
없다.
• Z-test도 필요없다.
• Ray를 쏴서 충돌하는 픽셀의 컬러값 대신 충돌한 지형지물의
오브젝트 ID 또는 leaf의 ID를 기록하면 정확히 보이는 오브젝트
목록만 얻을 수 있다.
Ray Tracing을 이용한 가시성 검사-복셀월드
• 복셀 오브젝트당 삼각형 개수는 비교적 적은 편이다.
• 변경/삭제가 빈번하지 않다.
• 복셀 오브젝트 변경시 트리를 재구축할 필요없이 leaf의 삼각형만
갱신해주면 된다.
• S/W Occlusion Culling으로 보이지 않는 오브젝트를
제외시키기보다 Ray Tracing을 이용해서 보이는 오브젝트만을
골라내는 편이 더 효율적이다.
Ray Tracing을 이용한 복셀월드의 가시성 검사
1. 메모리에 적당한 사이즈의 화면 버퍼를 만든다(ex: 512×512)
2. view matrix, projection matrix를 이용해서 각 픽셀로부터
월드공간의 ray를 만든다.
3. 각 픽셀에서 출발한 ray로 복셀 오브젝트들로 구성된 KD-Tree를
순회하며 ray가 충돌하는 가장 가까운 오브젝트를 찾는다.
4. 오브젝트를 찾으면 화면 버퍼에 오브젝트의 ID를
기록한다.(테스트 시에는 depth값-ray가 충돌했을 때의 t값)
5. 버퍼의 기록된 오브젝트 ID를 가지고 렌더링 될 복셀 오브젝트
목록을 만든다.
CPU vs GPU
• CPU로 구현하면 안되나?
• CPU로 구현해보자.
[i7 8700k 6 cores – 12 threads]
Single Thread - 2408.62 ms
Multi Thread – 12 thread(HT enabled) - 353.59 ms
60프레임을 위해서는 16ms를 초과하면 안된다! CPU로는 무리!
CUDA로 구현
CUDA를 이용한 구현
• CPU로는 너무 느리다. GPU를 사용하자.
• DirectX Raytracing API를 사용하면 간단하게 구현할 수 있다.
그러나…
• GTX 900시리즈 같은 DXR 지원 안하는 GPU에서도 성능 향상을
보고 싶다.
• 그래픽 API를 사용할 수 없는 환경에서도 이 기능을 사용하고 싶다.
예를 들면 서버라든가.
• 그렇다면 CUDA를 사용한다.
기본 구현
• 트리 재구성 비용을 줄이기 위해 트리는 최대 depth만큼 미리
빌드해 둔다.
• 트리는 어차피 CPU측에 먼저 구현해야 한다. (picking, CPU를
이용한 오브젝트 수집 등)
• GPU측(CUDA memory)에 트리 전체를 업데이트.
• 복셀 오브젝트가 추가/삭제/변경 될 경우 CUDA측 트리의
leaf내용만 업데이트.
• Raytracing을 이용한 depth, Object ID를 저장하는 코드는 CPU
코드로 먼저 작성한다. 1)검증, 2) 포팅 용이함을 위해서다.
GPU측에 KD-Tree구현하기
• KD-Tree 순회 코드는 CPU코드를 거의 그대로 사용할 수 있다.
• CUDA는 device memor와 host memory를 구분하므로 트리를
구축할때는 간단하지 않다. 팁을 제시하자면…
1. cudaMallocManaged()를 사용한다. – 가장 쉽다. 하지만 느리다.
2. cudaMalloc()/cudaMallocHost()를 이용해서 구현한다.
a. Host메모리에 먼저 구현. 트리를 배열로 표현.
b. 각 노드는 child node를 저장할때 포인터 대신 node 배열에서의 index로 저장.
c. 똑같은 사이즈의 Device메모리를 만들어서 host->device로 한번에 카피.
GPU Memory
System Memory
CUDA Code
node 0 node 1 node 2 node 3 node 4 node 5
node 0
node 1 node 2
node 3 node 4 node 5
node 0 node 1 node 2 node 3 node 4 node 5
KD_AXIS axis;
float d;
DWORD child[2];
cudaMemcpy()
Visual Studio Debugger
Parallel NSight Debugger
성능 테스트
[i7 8700k 6 cores – 12 threads]
Single Thread - 2408.62 ms
Multi Thread – 12 thread(HT enabled) - 353.59 ms
CUDA(GTX970) - 12.2468 ms
60프레임 가능! 사용 가능!
성능 테스트
SW Occlusion Culling CUDA Raytracing (GTX970) delta
DX11 (1920x1200)
렌더링된 오브젝트 3580 2428 -32%
카메라 정지시 FPS 294 345 +17%
카메라 이동시 FPS 220 246 +11%
DXR (1920x1200)
렌더링된 오브젝트 2675 1873 -29%
카메라 정지시 FPS 20 21 +5%
카메라 이동시 FPS 19 19 0%
오차 문제
• Ray Tracing버퍼의 해상도가 512x512정도면 충분한가?
• 일반적으로 게임 해상도는 1920x1080이상이므로 512x512버퍼의
Raytracing테스트로는 완벽하지 않을 수 있다.
• 멀리 있는 오브젝트들의 앞뒤 관계에서 오차가 발생할 수 있다.
• 그렇다고 게임의 네이티브 해상도와 일치시키면 너무 느리다.
오차 문제 - 해결안
• Ray Tracing버퍼의 해상도가 512x512정도면 충분한가?
• 일반적으로 게임 해상도는 1920x1080이상이므로 512x512버퍼의
Raytracing테스트로는 완벽하지 않을 수 있다.
• 멀리 있는 오브젝트들의 앞뒤 관계에서 오차가 발생할 수 있다.
• 그렇다고 게임의 네이티브 해상도와 일치시키면 너무 느리다.
• 오브젝트의 ID대신 KD-Tree의 leaf의 ID를 저장한다.
• 다소의 불필요한 렌더링을 감수한다. 오차를 줄인다.
제약사항
• nvidia GPU 한정
• GPU 성능 요구사항
생각해볼 주제
• CUDA 최적화
• OpenCL로의 포팅
• 디버깅 환경이 거지같지만 포인터가 있으니 ‘의지’가 있다면 가능.
• Compute Shader로의 포팅
• 이론상 불가능하진 않지만 포인터가 없기 때문에 꽤~~~~ 빡실듯.
참고자료
• https://graphics.stanford.edu/papers/gpu_kdtree/kdtree.pdf

Contenu connexe

Tendances

빠른 렌더링을 위한 오브젝트 제외 기술
빠른 렌더링을 위한 오브젝트 제외 기술빠른 렌더링을 위한 오브젝트 제외 기술
빠른 렌더링을 위한 오브젝트 제외 기술YEONG-CHEON YOU
 
191019 Forward / Deferred Rendering
191019 Forward / Deferred Rendering191019 Forward / Deferred Rendering
191019 Forward / Deferred RenderingKWANGIL KIM
 
NDC11_슈퍼클래스
NDC11_슈퍼클래스NDC11_슈퍼클래스
NDC11_슈퍼클래스noerror
 
Unreal python
Unreal pythonUnreal python
Unreal pythonTonyCms
 
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술henjeon
 
GPGPU(CUDA)를 이용한 MMOG 캐릭터 충돌처리
GPGPU(CUDA)를 이용한 MMOG 캐릭터 충돌처리GPGPU(CUDA)를 이용한 MMOG 캐릭터 충돌처리
GPGPU(CUDA)를 이용한 MMOG 캐릭터 충돌처리YEONG-CHEON YOU
 
[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shadingMinGeun Park
 
08_게임 물리 프로그래밍 가이드
08_게임 물리 프로그래밍 가이드08_게임 물리 프로그래밍 가이드
08_게임 물리 프로그래밍 가이드noerror
 
프레임레이트 향상을 위한 공간분할 및 오브젝트 컬링 기법
프레임레이트 향상을 위한 공간분할 및 오브젝트 컬링 기법프레임레이트 향상을 위한 공간분할 및 오브젝트 컬링 기법
프레임레이트 향상을 위한 공간분할 및 오브젝트 컬링 기법YEONG-CHEON YOU
 
Visual Studio를 이용한 어셈블리어 학습 part 2
Visual Studio를 이용한 어셈블리어 학습 part 2Visual Studio를 이용한 어셈블리어 학습 part 2
Visual Studio를 이용한 어셈블리어 학습 part 2YEONG-CHEON YOU
 
Intrinsics: Low-level engine development with Burst - Unite Copenhagen 2019
Intrinsics: Low-level engine development with Burst - Unite Copenhagen 2019 Intrinsics: Low-level engine development with Burst - Unite Copenhagen 2019
Intrinsics: Low-level engine development with Burst - Unite Copenhagen 2019 Unity Technologies
 
[1023 박민수] 깊이_버퍼_그림자_1
[1023 박민수] 깊이_버퍼_그림자_1[1023 박민수] 깊이_버퍼_그림자_1
[1023 박민수] 깊이_버퍼_그림자_1MoonLightMS
 
게임프로젝트에 적용하는 GPGPU
게임프로젝트에 적용하는 GPGPU게임프로젝트에 적용하는 GPGPU
게임프로젝트에 적용하는 GPGPUYEONG-CHEON YOU
 
Past, Present and Future Challenges of Global Illumination in Games
Past, Present and Future Challenges of Global Illumination in GamesPast, Present and Future Challenges of Global Illumination in Games
Past, Present and Future Challenges of Global Illumination in GamesColin Barré-Brisebois
 
Stable SSAO in Battlefield 3 with Selective Temporal Filtering
Stable SSAO in Battlefield 3 with Selective Temporal FilteringStable SSAO in Battlefield 3 with Selective Temporal Filtering
Stable SSAO in Battlefield 3 with Selective Temporal FilteringElectronic Arts / DICE
 
NDC2011 - 절차적 지형과 트렌드의 추적자들
NDC2011 - 절차적 지형과 트렌드의 추적자들NDC2011 - 절차적 지형과 트렌드의 추적자들
NDC2011 - 절차적 지형과 트렌드의 추적자들Jubok Kim
 
송창규, unity build로 빌드타임 반토막내기, NDC2010
송창규, unity build로 빌드타임 반토막내기, NDC2010송창규, unity build로 빌드타임 반토막내기, NDC2010
송창규, unity build로 빌드타임 반토막내기, NDC2010devCAT Studio, NEXON
 
나만의 엔진 개발하기
나만의 엔진 개발하기나만의 엔진 개발하기
나만의 엔진 개발하기YEONG-CHEON YOU
 

Tendances (20)

빠른 렌더링을 위한 오브젝트 제외 기술
빠른 렌더링을 위한 오브젝트 제외 기술빠른 렌더링을 위한 오브젝트 제외 기술
빠른 렌더링을 위한 오브젝트 제외 기술
 
191019 Forward / Deferred Rendering
191019 Forward / Deferred Rendering191019 Forward / Deferred Rendering
191019 Forward / Deferred Rendering
 
NDC11_슈퍼클래스
NDC11_슈퍼클래스NDC11_슈퍼클래스
NDC11_슈퍼클래스
 
Unreal python
Unreal pythonUnreal python
Unreal python
 
Ndc11 이창희_hdr
Ndc11 이창희_hdrNdc11 이창희_hdr
Ndc11 이창희_hdr
 
Ssao
SsaoSsao
Ssao
 
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술Ndc2010 전형규   마비노기2 캐릭터 렌더링 기술
Ndc2010 전형규 마비노기2 캐릭터 렌더링 기술
 
GPGPU(CUDA)를 이용한 MMOG 캐릭터 충돌처리
GPGPU(CUDA)를 이용한 MMOG 캐릭터 충돌처리GPGPU(CUDA)를 이용한 MMOG 캐릭터 충돌처리
GPGPU(CUDA)를 이용한 MMOG 캐릭터 충돌처리
 
[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading
 
08_게임 물리 프로그래밍 가이드
08_게임 물리 프로그래밍 가이드08_게임 물리 프로그래밍 가이드
08_게임 물리 프로그래밍 가이드
 
프레임레이트 향상을 위한 공간분할 및 오브젝트 컬링 기법
프레임레이트 향상을 위한 공간분할 및 오브젝트 컬링 기법프레임레이트 향상을 위한 공간분할 및 오브젝트 컬링 기법
프레임레이트 향상을 위한 공간분할 및 오브젝트 컬링 기법
 
Visual Studio를 이용한 어셈블리어 학습 part 2
Visual Studio를 이용한 어셈블리어 학습 part 2Visual Studio를 이용한 어셈블리어 학습 part 2
Visual Studio를 이용한 어셈블리어 학습 part 2
 
Intrinsics: Low-level engine development with Burst - Unite Copenhagen 2019
Intrinsics: Low-level engine development with Burst - Unite Copenhagen 2019 Intrinsics: Low-level engine development with Burst - Unite Copenhagen 2019
Intrinsics: Low-level engine development with Burst - Unite Copenhagen 2019
 
[1023 박민수] 깊이_버퍼_그림자_1
[1023 박민수] 깊이_버퍼_그림자_1[1023 박민수] 깊이_버퍼_그림자_1
[1023 박민수] 깊이_버퍼_그림자_1
 
게임프로젝트에 적용하는 GPGPU
게임프로젝트에 적용하는 GPGPU게임프로젝트에 적용하는 GPGPU
게임프로젝트에 적용하는 GPGPU
 
Past, Present and Future Challenges of Global Illumination in Games
Past, Present and Future Challenges of Global Illumination in GamesPast, Present and Future Challenges of Global Illumination in Games
Past, Present and Future Challenges of Global Illumination in Games
 
Stable SSAO in Battlefield 3 with Selective Temporal Filtering
Stable SSAO in Battlefield 3 with Selective Temporal FilteringStable SSAO in Battlefield 3 with Selective Temporal Filtering
Stable SSAO in Battlefield 3 with Selective Temporal Filtering
 
NDC2011 - 절차적 지형과 트렌드의 추적자들
NDC2011 - 절차적 지형과 트렌드의 추적자들NDC2011 - 절차적 지형과 트렌드의 추적자들
NDC2011 - 절차적 지형과 트렌드의 추적자들
 
송창규, unity build로 빌드타임 반토막내기, NDC2010
송창규, unity build로 빌드타임 반토막내기, NDC2010송창규, unity build로 빌드타임 반토막내기, NDC2010
송창규, unity build로 빌드타임 반토막내기, NDC2010
 
나만의 엔진 개발하기
나만의 엔진 개발하기나만의 엔진 개발하기
나만의 엔진 개발하기
 

Similaire à CUDA를 이용한 복셀 오브젝트 가시성 검사

Developing Next-Generation Games with Stage3D (Molehill)
Developing Next-Generation Games with Stage3D (Molehill) Developing Next-Generation Games with Stage3D (Molehill)
Developing Next-Generation Games with Stage3D (Molehill) Jean-Philippe Doiron
 
Single shot multiboxdetectors
Single shot multiboxdetectorsSingle shot multiboxdetectors
Single shot multiboxdetectors지현 백
 
Windows to reality getting the most out of direct3 d 10 graphics in your games
Windows to reality   getting the most out of direct3 d 10 graphics in your gamesWindows to reality   getting the most out of direct3 d 10 graphics in your games
Windows to reality getting the most out of direct3 d 10 graphics in your gameschangehee lee
 
Image ORB feature
Image ORB featureImage ORB feature
Image ORB featureGavin Gao
 
Single shot multiboxdetectors
Single shot multiboxdetectorsSingle shot multiboxdetectors
Single shot multiboxdetectors지현 백
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCanSecWest
 
"Energy-efficient Hardware for Embedded Vision and Deep Convolutional Neural ...
"Energy-efficient Hardware for Embedded Vision and Deep Convolutional Neural ..."Energy-efficient Hardware for Embedded Vision and Deep Convolutional Neural ...
"Energy-efficient Hardware for Embedded Vision and Deep Convolutional Neural ...Edge AI and Vision Alliance
 
Advanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineAdvanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineNarann29
 
GPGPU Computation
GPGPU ComputationGPGPU Computation
GPGPU Computationjtsagata
 
Screen Space Reflections in The Surge
Screen Space Reflections in The SurgeScreen Space Reflections in The Surge
Screen Space Reflections in The SurgeMichele Giacalone
 
Keras on tensorflow in R & Python
Keras on tensorflow in R & PythonKeras on tensorflow in R & Python
Keras on tensorflow in R & PythonLonghow Lam
 
그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...
그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...
그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...ozlael ozlael
 
Blur Filter - Hanpo
Blur Filter - HanpoBlur Filter - Hanpo
Blur Filter - HanpoHanpo Cheng
 
Applying your Convolutional Neural Networks
Applying your Convolutional Neural NetworksApplying your Convolutional Neural Networks
Applying your Convolutional Neural NetworksDatabricks
 
CUDA by Example : Constant Memory and Events : Notes
CUDA by Example : Constant Memory and Events : NotesCUDA by Example : Constant Memory and Events : Notes
CUDA by Example : Constant Memory and Events : NotesSubhajit Sahu
 
Anil Thomas - Object recognition
Anil Thomas - Object recognitionAnil Thomas - Object recognition
Anil Thomas - Object recognitionIntel Nervana
 
Mongodb debugging-performance-problems
Mongodb debugging-performance-problemsMongodb debugging-performance-problems
Mongodb debugging-performance-problemsMongoDB
 

Similaire à CUDA를 이용한 복셀 오브젝트 가시성 검사 (20)

Developing Next-Generation Games with Stage3D (Molehill)
Developing Next-Generation Games with Stage3D (Molehill) Developing Next-Generation Games with Stage3D (Molehill)
Developing Next-Generation Games with Stage3D (Molehill)
 
Single shot multiboxdetectors
Single shot multiboxdetectorsSingle shot multiboxdetectors
Single shot multiboxdetectors
 
Windows to reality getting the most out of direct3 d 10 graphics in your games
Windows to reality   getting the most out of direct3 d 10 graphics in your gamesWindows to reality   getting the most out of direct3 d 10 graphics in your games
Windows to reality getting the most out of direct3 d 10 graphics in your games
 
Image ORB feature
Image ORB featureImage ORB feature
Image ORB feature
 
Single shot multiboxdetectors
Single shot multiboxdetectorsSingle shot multiboxdetectors
Single shot multiboxdetectors
 
December 4, Project
December 4, ProjectDecember 4, Project
December 4, Project
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
 
"Energy-efficient Hardware for Embedded Vision and Deep Convolutional Neural ...
"Energy-efficient Hardware for Embedded Vision and Deep Convolutional Neural ..."Energy-efficient Hardware for Embedded Vision and Deep Convolutional Neural ...
"Energy-efficient Hardware for Embedded Vision and Deep Convolutional Neural ...
 
Advanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineAdvanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering Pipeline
 
GPU - how can we use it?
GPU - how can we use it?GPU - how can we use it?
GPU - how can we use it?
 
Gpu perf-presentation
Gpu perf-presentationGpu perf-presentation
Gpu perf-presentation
 
GPGPU Computation
GPGPU ComputationGPGPU Computation
GPGPU Computation
 
Screen Space Reflections in The Surge
Screen Space Reflections in The SurgeScreen Space Reflections in The Surge
Screen Space Reflections in The Surge
 
Keras on tensorflow in R & Python
Keras on tensorflow in R & PythonKeras on tensorflow in R & Python
Keras on tensorflow in R & Python
 
그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...
그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...
그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! -...
 
Blur Filter - Hanpo
Blur Filter - HanpoBlur Filter - Hanpo
Blur Filter - Hanpo
 
Applying your Convolutional Neural Networks
Applying your Convolutional Neural NetworksApplying your Convolutional Neural Networks
Applying your Convolutional Neural Networks
 
CUDA by Example : Constant Memory and Events : Notes
CUDA by Example : Constant Memory and Events : NotesCUDA by Example : Constant Memory and Events : Notes
CUDA by Example : Constant Memory and Events : Notes
 
Anil Thomas - Object recognition
Anil Thomas - Object recognitionAnil Thomas - Object recognition
Anil Thomas - Object recognition
 
Mongodb debugging-performance-problems
Mongodb debugging-performance-problemsMongodb debugging-performance-problems
Mongodb debugging-performance-problems
 

Plus de YEONG-CHEON YOU

DirectStroage프로그래밍소개
DirectStroage프로그래밍소개DirectStroage프로그래밍소개
DirectStroage프로그래밍소개YEONG-CHEON YOU
 
Visual Studio를 이용한 어셈블리어 학습 part 1
Visual Studio를 이용한 어셈블리어 학습 part 1Visual Studio를 이용한 어셈블리어 학습 part 1
Visual Studio를 이용한 어셈블리어 학습 part 1YEONG-CHEON YOU
 
XDK없이 XBOX게임 개발하기(UWP on XBOX)
XDK없이 XBOX게임 개발하기(UWP on XBOX)XDK없이 XBOX게임 개발하기(UWP on XBOX)
XDK없이 XBOX게임 개발하기(UWP on XBOX)YEONG-CHEON YOU
 
Introduction to DirectX 12 Programming , Ver 1.5
Introduction to DirectX 12 Programming , Ver 1.5Introduction to DirectX 12 Programming , Ver 1.5
Introduction to DirectX 12 Programming , Ver 1.5YEONG-CHEON YOU
 
MMOG Server-Side 충돌 및 이동처리 설계와 구현
MMOG Server-Side 충돌 및 이동처리 설계와 구현MMOG Server-Side 충돌 및 이동처리 설계와 구현
MMOG Server-Side 충돌 및 이동처리 설계와 구현YEONG-CHEON YOU
 
실시간 게임 서버 최적화 전략
실시간 게임 서버 최적화 전략실시간 게임 서버 최적화 전략
실시간 게임 서버 최적화 전략YEONG-CHEON YOU
 
Voxel based game_optimazation_relelase
Voxel based game_optimazation_relelaseVoxel based game_optimazation_relelase
Voxel based game_optimazation_relelaseYEONG-CHEON YOU
 
CUDA를 게임 프로젝트에 적용하기
CUDA를 게임 프로젝트에 적용하기CUDA를 게임 프로젝트에 적용하기
CUDA를 게임 프로젝트에 적용하기YEONG-CHEON YOU
 
서버와 클라이언트 같은 엔진 사용하기
서버와 클라이언트 같은 엔진 사용하기서버와 클라이언트 같은 엔진 사용하기
서버와 클라이언트 같은 엔진 사용하기YEONG-CHEON YOU
 
win32 app에서 UWP API호출하기
win32 app에서 UWP API호출하기win32 app에서 UWP API호출하기
win32 app에서 UWP API호출하기YEONG-CHEON YOU
 
Azure로 MMO게임 서비스하기
Azure로 MMO게임 서비스하기Azure로 MMO게임 서비스하기
Azure로 MMO게임 서비스하기YEONG-CHEON YOU
 
Development AR App with C++ and Windows Holographic API
Development AR App with C++ and Windows Holographic APIDevelopment AR App with C++ and Windows Holographic API
Development AR App with C++ and Windows Holographic APIYEONG-CHEON YOU
 
빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)YEONG-CHEON YOU
 
Tips and experience_of_dx12_engine_development._ver_1.2
Tips and experience_of_dx12_engine_development._ver_1.2Tips and experience_of_dx12_engine_development._ver_1.2
Tips and experience_of_dx12_engine_development._ver_1.2YEONG-CHEON YOU
 
Implements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayImplements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayYEONG-CHEON YOU
 
Porting direct x 11 desktop game to uwp app
Porting direct x 11 desktop game to uwp appPorting direct x 11 desktop game to uwp app
Porting direct x 11 desktop game to uwp appYEONG-CHEON YOU
 
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~YEONG-CHEON YOU
 
DirectX + C++을 이용한 WindowsStore App과 Windows Phone용 게임 개발
DirectX + C++을 이용한  WindowsStore App과 Windows Phone용 게임 개발DirectX + C++을 이용한  WindowsStore App과 Windows Phone용 게임 개발
DirectX + C++을 이용한 WindowsStore App과 Windows Phone용 게임 개발YEONG-CHEON YOU
 

Plus de YEONG-CHEON YOU (20)

DirectStroage프로그래밍소개
DirectStroage프로그래밍소개DirectStroage프로그래밍소개
DirectStroage프로그래밍소개
 
Visual Studio를 이용한 어셈블리어 학습 part 1
Visual Studio를 이용한 어셈블리어 학습 part 1Visual Studio를 이용한 어셈블리어 학습 part 1
Visual Studio를 이용한 어셈블리어 학습 part 1
 
XDK없이 XBOX게임 개발하기(UWP on XBOX)
XDK없이 XBOX게임 개발하기(UWP on XBOX)XDK없이 XBOX게임 개발하기(UWP on XBOX)
XDK없이 XBOX게임 개발하기(UWP on XBOX)
 
Introduction to DirectX 12 Programming , Ver 1.5
Introduction to DirectX 12 Programming , Ver 1.5Introduction to DirectX 12 Programming , Ver 1.5
Introduction to DirectX 12 Programming , Ver 1.5
 
MMOG Server-Side 충돌 및 이동처리 설계와 구현
MMOG Server-Side 충돌 및 이동처리 설계와 구현MMOG Server-Side 충돌 및 이동처리 설계와 구현
MMOG Server-Side 충돌 및 이동처리 설계와 구현
 
실시간 게임 서버 최적화 전략
실시간 게임 서버 최적화 전략실시간 게임 서버 최적화 전략
실시간 게임 서버 최적화 전략
 
Voxelizaition with GPU
Voxelizaition with GPUVoxelizaition with GPU
Voxelizaition with GPU
 
Voxel based game_optimazation_relelase
Voxel based game_optimazation_relelaseVoxel based game_optimazation_relelase
Voxel based game_optimazation_relelase
 
Sw occlusion culling
Sw occlusion cullingSw occlusion culling
Sw occlusion culling
 
CUDA를 게임 프로젝트에 적용하기
CUDA를 게임 프로젝트에 적용하기CUDA를 게임 프로젝트에 적용하기
CUDA를 게임 프로젝트에 적용하기
 
서버와 클라이언트 같은 엔진 사용하기
서버와 클라이언트 같은 엔진 사용하기서버와 클라이언트 같은 엔진 사용하기
서버와 클라이언트 같은 엔진 사용하기
 
win32 app에서 UWP API호출하기
win32 app에서 UWP API호출하기win32 app에서 UWP API호출하기
win32 app에서 UWP API호출하기
 
Azure로 MMO게임 서비스하기
Azure로 MMO게임 서비스하기Azure로 MMO게임 서비스하기
Azure로 MMO게임 서비스하기
 
Development AR App with C++ and Windows Holographic API
Development AR App with C++ and Windows Holographic APIDevelopment AR App with C++ and Windows Holographic API
Development AR App with C++ and Windows Holographic API
 
빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)빌드관리 및 디버깅 (2010년 자료)
빌드관리 및 디버깅 (2010년 자료)
 
Tips and experience_of_dx12_engine_development._ver_1.2
Tips and experience_of_dx12_engine_development._ver_1.2Tips and experience_of_dx12_engine_development._ver_1.2
Tips and experience_of_dx12_engine_development._ver_1.2
 
Implements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture ArrayImplements Cascaded Shadow Maps with using Texture Array
Implements Cascaded Shadow Maps with using Texture Array
 
Porting direct x 11 desktop game to uwp app
Porting direct x 11 desktop game to uwp appPorting direct x 11 desktop game to uwp app
Porting direct x 11 desktop game to uwp app
 
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
 
DirectX + C++을 이용한 WindowsStore App과 Windows Phone용 게임 개발
DirectX + C++을 이용한  WindowsStore App과 Windows Phone용 게임 개발DirectX + C++을 이용한  WindowsStore App과 Windows Phone용 게임 개발
DirectX + C++을 이용한 WindowsStore App과 Windows Phone용 게임 개발
 

Dernier

Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
Risk Management in Engineering Construction Project
Risk Management in Engineering Construction ProjectRisk Management in Engineering Construction Project
Risk Management in Engineering Construction ProjectErbil Polytechnic University
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectssuserb6619e
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Crushers to screens in aggregate production
Crushers to screens in aggregate productionCrushers to screens in aggregate production
Crushers to screens in aggregate productionChinnuNinan
 
Autonomous emergency braking system (aeb) ppt.ppt
Autonomous emergency braking system (aeb) ppt.pptAutonomous emergency braking system (aeb) ppt.ppt
Autonomous emergency braking system (aeb) ppt.pptbibisarnayak0
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 

Dernier (20)

Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
Risk Management in Engineering Construction Project
Risk Management in Engineering Construction ProjectRisk Management in Engineering Construction Project
Risk Management in Engineering Construction Project
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in projectDM Pillar Training Manual.ppt will be useful in deploying TPM in project
DM Pillar Training Manual.ppt will be useful in deploying TPM in project
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Crushers to screens in aggregate production
Crushers to screens in aggregate productionCrushers to screens in aggregate production
Crushers to screens in aggregate production
 
Autonomous emergency braking system (aeb) ppt.ppt
Autonomous emergency braking system (aeb) ppt.pptAutonomous emergency braking system (aeb) ppt.ppt
Autonomous emergency braking system (aeb) ppt.ppt
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 

CUDA를 이용한 복셀 오브젝트 가시성 검사

  • 1. CUDA Raytracing을 이용한 voxel 오브젝트 가시성 검사 유영천 https://megayuchi.com Tw: @dgtman
  • 2.
  • 3. 도형을 화면에 표시하는 방법 • Rasterization • Ray Tracing
  • 4.
  • 6. X 𝑉𝑖𝑒𝑤 matrix−1 𝑃𝑖𝑥𝑒𝑙. 𝑥 ÷ 𝑊𝑖𝑑𝑡ℎ × 2 − 1 𝑝𝑟𝑜𝑗𝑒𝑐𝑡𝑖𝑜𝑛 𝑚𝑎𝑡𝑟𝑖𝑥[0][0] −(𝑃𝑖𝑥𝑒𝑙. 𝑦 ÷ 𝐻𝑒𝑖𝑔ℎ𝑡 × 2 − 1) 𝑝𝑟𝑜𝑗𝑒𝑐𝑡𝑖𝑜𝑛 𝑚𝑎𝑡𝑟𝑖𝑥[1][1] 0 ,1 , 0 Ray Tracing ,
  • 7. 가장 앞의 픽셀을 그리는 방법 Rasterization • 기본적으로 모든 매시는 순서 없이 그린다. • Z-buffer를 이용해서 가장 앞에 있는 픽셀로 덮어쓴다. • 삼각형->WVP 변환 후 얻은 z값을 z-buffer에 기록. 현재 Z값이 기존 z값보다 작으면 기존 픽셀을 덮어쓴다. Ray Tracing • depth버퍼 없다. • Ray가 발사됐을 때 Ray마다 가장 앞에 있는 픽셀을 찾아낸다.
  • 8. Z-Buffer (-1.0, -1.0) (1.0, -1.0) (-1.0, 1.0) (1.0, 1.0) (0, Height) (Width, Height) (Width, 0) 1.0 1.0 1.0 1.0 1.0 0.47 1.0 0.46 1.0 0.41 1.0 0.42 0.42 0.45 0.43 0.44 1.0 0.43 1.0 0.43 0.43 0.43 0.43 0.43 1.0 0.42 1.0 0.41 0.43 0.46 0.45 0.46 0.47 0.46 0.46 0.46 0.46 0.44 0.45 0.46 0.46 0.45 0.45 0.46 0.45 0.46 0.46 0.44 0.44 0.42 1.0 0.45 0.46 1.0 1.0 0.46 1.0 0.47 0.47 1.0 1.0 1.0 1.0 0.45 1.0 0.45 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.46 0.47 1.0 0.48 0.47 0.48 0.48 0.48 0.48 1.0 0.48 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 0.48 0.48 0.48 0.48 1.0 1.0 1.0 1.0 0.44 NDC (0, 0) Rasterization
  • 9. Ray tracing에서 어느 오브젝트, 어느 삼각형이 앞에 있는지 어떻게 알지? 쉬운방법 • Ray 하나당 모든 오브젝트를 순회한다. • Ray가 많아지면 당연히 미친듯이 느려진다.
  • 10. KD-Tree • X,Y,Z 축에 정렬된 BSP Tree. • 각 node를 3가지 축과 축방향의 거리 D값으로 표현할 수 있다. • KD-Tree를 탐색할 때 카메라로부터 가까운 node와 먼 node를 찾을 수 있다. • Ray의 교차판정 등에 많이 사용한다. • Near node와 Far node를 구분하지 않는다면 Quad-Tree와 별 차이는 없다. • 게임의 월드를 KD-Tree로 관리하는 경우가 많다.
  • 11. KD-Tree를 이용한 가장 가까운 오브젝트 탐색 • root node가 ray와 충돌하지 않으면 순회 중지. • 현재 node의 자식 node 2개중 한 개만 ray와 충돌할 경우 충돌하는 노드를 방문. • 현재 node의 자식 node 2개가 모두 충돌할 경우 먼 node를 stack에 push하고 가까운 node를 방문. • 방문한 node가 leaf일 때 leaf에 들어있는 매시의 삼각형들에 대해서 ray와 충돌체크. 현재 leaf에서 충돌한 경우 t값을 저장하고 순회 중지. • 방문한 node가 leaf일 때 어떤 삼각형도 ray와 충돌하지 않는 경우 stack에서 node포인터를 꺼내서 방문.
  • 12. KD-Tree Traversal 0 1 2 node A node A-a node A-b node A-b-a node A-b-b node A node A-a node A-b node A-b-a node A-b-b
  • 14. S/W Occlusion Culling • 적당히 작은 사이즈의 버퍼에 최대한 간소화된 방법으로 매시를 그려본다. 이 과정에서 얻은 depth값을 버퍼에 기록. • 오브젝트 또는 트리의 node/leaf를 depth버퍼에 대해 z-test. 렌더링 파이프라인에 넣기 전에 이 단계에서 가려지는 오브젝트를 걸러낸다. • 이것을 GPU에서 처리하면 H/W Occlusion Culling. • S/W방식(CPU에서)으로 처리하는 이유는 GPU와의 통신시간을 트리 탐색중 바로 적용할 수 있기 때문.
  • 15. 복셀 월드에서의 S/W Occlusion Culling • 복셀 지형 특성상 안이 꽉 차 있고 모양이 복잡하다. • 복셀 오브젝트간 가리고 가려지는 상황이 엄청 빈번하다. • S/W Occlusion Culling을 시도했을때 depth를 써넣고 테스트 하는 비용이 너무 크다. • 복셀 오브젝트 개수만 해도 5-10만개씩 되기 때문에 이미 수집한 5-10만개의 오브젝트에서 보이지 않는 오브젝트를 제거할때도 생각보다 CPU시간을 많이 소모한다. • S/W Occlusion Culling에 적합한가?
  • 16. Ray Tracing을 이용한 가시성 검사 • Ray Tracing에선 처음부터 가려지는 픽셀-오브젝트는 그릴 일이 없다. • Z-test도 필요없다. • Ray를 쏴서 충돌하는 픽셀의 컬러값 대신 충돌한 지형지물의 오브젝트 ID 또는 leaf의 ID를 기록하면 정확히 보이는 오브젝트 목록만 얻을 수 있다.
  • 17. Ray Tracing을 이용한 가시성 검사-복셀월드 • 복셀 오브젝트당 삼각형 개수는 비교적 적은 편이다. • 변경/삭제가 빈번하지 않다. • 복셀 오브젝트 변경시 트리를 재구축할 필요없이 leaf의 삼각형만 갱신해주면 된다. • S/W Occlusion Culling으로 보이지 않는 오브젝트를 제외시키기보다 Ray Tracing을 이용해서 보이는 오브젝트만을 골라내는 편이 더 효율적이다.
  • 18. Ray Tracing을 이용한 복셀월드의 가시성 검사 1. 메모리에 적당한 사이즈의 화면 버퍼를 만든다(ex: 512×512) 2. view matrix, projection matrix를 이용해서 각 픽셀로부터 월드공간의 ray를 만든다. 3. 각 픽셀에서 출발한 ray로 복셀 오브젝트들로 구성된 KD-Tree를 순회하며 ray가 충돌하는 가장 가까운 오브젝트를 찾는다. 4. 오브젝트를 찾으면 화면 버퍼에 오브젝트의 ID를 기록한다.(테스트 시에는 depth값-ray가 충돌했을 때의 t값) 5. 버퍼의 기록된 오브젝트 ID를 가지고 렌더링 될 복셀 오브젝트 목록을 만든다.
  • 19.
  • 20. CPU vs GPU • CPU로 구현하면 안되나? • CPU로 구현해보자. [i7 8700k 6 cores – 12 threads] Single Thread - 2408.62 ms Multi Thread – 12 thread(HT enabled) - 353.59 ms 60프레임을 위해서는 16ms를 초과하면 안된다! CPU로는 무리!
  • 22. CUDA를 이용한 구현 • CPU로는 너무 느리다. GPU를 사용하자. • DirectX Raytracing API를 사용하면 간단하게 구현할 수 있다. 그러나… • GTX 900시리즈 같은 DXR 지원 안하는 GPU에서도 성능 향상을 보고 싶다. • 그래픽 API를 사용할 수 없는 환경에서도 이 기능을 사용하고 싶다. 예를 들면 서버라든가. • 그렇다면 CUDA를 사용한다.
  • 23. 기본 구현 • 트리 재구성 비용을 줄이기 위해 트리는 최대 depth만큼 미리 빌드해 둔다. • 트리는 어차피 CPU측에 먼저 구현해야 한다. (picking, CPU를 이용한 오브젝트 수집 등) • GPU측(CUDA memory)에 트리 전체를 업데이트. • 복셀 오브젝트가 추가/삭제/변경 될 경우 CUDA측 트리의 leaf내용만 업데이트. • Raytracing을 이용한 depth, Object ID를 저장하는 코드는 CPU 코드로 먼저 작성한다. 1)검증, 2) 포팅 용이함을 위해서다.
  • 24. GPU측에 KD-Tree구현하기 • KD-Tree 순회 코드는 CPU코드를 거의 그대로 사용할 수 있다. • CUDA는 device memor와 host memory를 구분하므로 트리를 구축할때는 간단하지 않다. 팁을 제시하자면… 1. cudaMallocManaged()를 사용한다. – 가장 쉽다. 하지만 느리다. 2. cudaMalloc()/cudaMallocHost()를 이용해서 구현한다. a. Host메모리에 먼저 구현. 트리를 배열로 표현. b. 각 노드는 child node를 저장할때 포인터 대신 node 배열에서의 index로 저장. c. 똑같은 사이즈의 Device메모리를 만들어서 host->device로 한번에 카피.
  • 25. GPU Memory System Memory CUDA Code node 0 node 1 node 2 node 3 node 4 node 5 node 0 node 1 node 2 node 3 node 4 node 5 node 0 node 1 node 2 node 3 node 4 node 5 KD_AXIS axis; float d; DWORD child[2]; cudaMemcpy() Visual Studio Debugger Parallel NSight Debugger
  • 26. 성능 테스트 [i7 8700k 6 cores – 12 threads] Single Thread - 2408.62 ms Multi Thread – 12 thread(HT enabled) - 353.59 ms CUDA(GTX970) - 12.2468 ms 60프레임 가능! 사용 가능!
  • 27. 성능 테스트 SW Occlusion Culling CUDA Raytracing (GTX970) delta DX11 (1920x1200) 렌더링된 오브젝트 3580 2428 -32% 카메라 정지시 FPS 294 345 +17% 카메라 이동시 FPS 220 246 +11% DXR (1920x1200) 렌더링된 오브젝트 2675 1873 -29% 카메라 정지시 FPS 20 21 +5% 카메라 이동시 FPS 19 19 0%
  • 28. 오차 문제 • Ray Tracing버퍼의 해상도가 512x512정도면 충분한가? • 일반적으로 게임 해상도는 1920x1080이상이므로 512x512버퍼의 Raytracing테스트로는 완벽하지 않을 수 있다. • 멀리 있는 오브젝트들의 앞뒤 관계에서 오차가 발생할 수 있다. • 그렇다고 게임의 네이티브 해상도와 일치시키면 너무 느리다.
  • 29. 오차 문제 - 해결안 • Ray Tracing버퍼의 해상도가 512x512정도면 충분한가? • 일반적으로 게임 해상도는 1920x1080이상이므로 512x512버퍼의 Raytracing테스트로는 완벽하지 않을 수 있다. • 멀리 있는 오브젝트들의 앞뒤 관계에서 오차가 발생할 수 있다. • 그렇다고 게임의 네이티브 해상도와 일치시키면 너무 느리다. • 오브젝트의 ID대신 KD-Tree의 leaf의 ID를 저장한다. • 다소의 불필요한 렌더링을 감수한다. 오차를 줄인다.
  • 30.
  • 31. 제약사항 • nvidia GPU 한정 • GPU 성능 요구사항
  • 32. 생각해볼 주제 • CUDA 최적화 • OpenCL로의 포팅 • 디버깅 환경이 거지같지만 포인터가 있으니 ‘의지’가 있다면 가능. • Compute Shader로의 포팅 • 이론상 불가능하진 않지만 포인터가 없기 때문에 꽤~~~~ 빡실듯.