Document not found! Please try again

Scalable multi-GPU cloud raytracing with OpenGL

76 downloads 0 Views 3MB Size Report
Scalable multi-GPU cloud raytracing with OpenGL. Matúš Chochlık ... Multi-GPU programming using OpenGL ..... Raytraced data volume from an MRI brain scan.
Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Scalable multi-GPU cloud raytracing with OpenGL Mat´ uˇs Chochl´ık ˇ University of Zilina ˇ Digital technologies 2014, Zilina, Slovakia

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Overview

Goals Rendering distant details in visualizations Raytracing Multi-GPU programming using OpenGL Cloud trace Algorithm Implementation Results

Future work

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Results

Future work

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Goals

Research Methods of distant detail rendering Simple raytracing algorithms Using modern GPUs for raytracing Using multiple GPUs in OpenGL

Develop An efficient algorithm fitting the GPU pipeline and architecture

Implement a working prototype Evaluate the usability for other purposes Medical or volumetric data visualization Solid geometry raytracing

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Distant detail rendering

Sky Atmosphere Clouds Celestial bodies

Distant landscapes Distant landmarks and skylines Used in Computer games Outdoor simulations and visualizations Source: X-Ray engine / S.T.A.L.K.E.R.

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Future work

Outline

Distant details

Raytracing

Cloud trace

Sky and cloudscape rendering

Sky planes Sky spheres or sky domes Sky boxes Combinations and extensions of the above

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Results

Future work

Outline

Distant details

Raytracing

Cloud trace

Results

Sky plane One or several planes, with cloud textures applied, rendered above the ground Can be animated by transforming texture coordinates by exchanging different texture images

Simple to implement Can appear flat and unconvincing especially if the observer’s altitude changes Mat´ uˇs Chochl´ık

Source: http://indiegorenderer.com

Multi-GPU cloud raytracing

Future work

Outline

Distant details

Raytracing

Cloud trace

Results

Sky sphere, sky dome

One or several concentric spheres or hemi-spheres with textures applied Centered at or near the observer

The texture mapping (from 2D planar to spherical coordinates) causes the texture to be distorted Lack of detail in certain areas

The textured sphere geometry is more complex

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Future work

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Sky box

One or several (nearly) concentric cubes with textures applied The cub(es) are centered at the observer They can be moved slightly at a different pace to simulate view parallax effect.

Requires textures for 5 (without the ground) or 6 faces Animation by texture coordinates does not work well Animated by exchanging texture images Simple geometry Clouds do not appear flat

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Combined

A combination of sky boxes sky domes sky planes particle systems post-processing effects bloom lens flare light rays etc.

Distant segments of regular geometry can be blended into the sky box Source: Half − life 2 / http://half-life.wikia.com

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Important properties of sky textures Visual properties Realistic cloud sizes, shapes and distributions. Realistic lighting and (self) shadowing. Realistic atmospheric light scattering.

The texture image pixels can encode basic data that can be finalized later Cloud density Cloud distance Cloud lighting Atmosperic density Atmosphere lighting and shadowing etc.

Dynamic finishing of a static texture One texture can result in multiple final images which can be smoothly animated HDR and other effects can be applied The light direction must be static More demanding that just a plain colorized texture Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Sources of sky textures

Textures for a skybox can be obtained in several ways: Real sky photography (usually requires post-processing) Static Limited number or requires a lot of storage space Can be difficult to ”photoshop” into a full cube-map

Simple generating algorithms (Perlin noise, etc.) Fast and simple Low quality Sometimes looking unnatural

Advanced algorithms (usually raytracing) Computationaly expensive and slow High quality

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Future work

Outline

Distant details

Raytracing

Cloud trace

Results

Raytracing Visualization technique for generating an image by tracing the path of light through pixels in an image plane and simulating the effects of its encounters with virtual objects. Capable of producing a very high degree of visual realism. Greater computational cost than other techniques.

Source: http://en.wikipedia.org

Is recursive.

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Future work

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Raytracing

Scenes in ray tracing can be described mathematically. Scenes may also incorporate Polygonal models Images Volumetric data Light sources

Properties of the surfaces and interiors of objects in the scene determine further raytracing steps

Mat´ uˇs Chochl´ık

Raytracing can simulate various optical effects Reflection Refraction Scattering Dispersion Incandescence Emission

Using multiple rays per pixel can be used for Antialiasing Simulation of depth-of-field Motion blur

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Basic raytracing algorithm 1

For each pixel on the virtual screen, cast one or multiple rays originating at the position of the observer through the position of the screen pixel in world space.

2

Find the nearest object that the ray intersects with.

3

Cast secondary rays from the point where the object was hit to all light sources.

4

For any light source not obstructed by other objects calculate the amount of light hitting the surface of the object.

5

Take into account the surface and interior properties of the object the properties of the light and the angle at which the light arrives.

6

Calculate the final color of the light reaching the observer.

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Raytracing algorithm extensions

1

When an object is hit by the primary ray, recursivelly shoot rays from the surface along vectors determined by the surface properties and find intersections with other objects Reflection Refraction Scattering

2

For volumetric objects sample along the ray through the defining data.

3

etc.

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Cloud trace - overview

Purpose Generator of skybox cube-map texture images. Provides also basic ray-trace data for dynamic finishing. Testbed for other multi-GPU raytracing applications.

Properties Open-source. Multi-platform. Implemented using OpenGL (OGLplus1 ). Utilizes multiple GPUs if available (currently only nVidia+glX). Is usable from the command line to allow scripting. Allows to import cloud scenes from CSV and Blender. Has a build-in cloud volume and placement generator.

1

http://oglplus.org/ Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Architecture

Thread(s)

GPU resources Renderer Copier

Raytracer(s) Loader

Saver

Main

Generator

Main-glX Main-GLFW

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Components Main Initializes the GL contexts and other components Currently has two implementations: glX – multi-GPU, GLFW – multi-platform, single GPU.

Loaders – load cloud volume and placement data Generators – generate cloud volume and placement data Saver – saves raytrace output or finalized images Mat´ uˇs Chochl´ık

GPU resources – manage used GPU resources (textures, shaders, etc.) Raytracers – raytrace the cloudscape, generate output data Threads – execute the raytracers Copier – does efficient data copying between GPUs Renderer – renders the final image from the raytrace data by using a finishing shader Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Cloud representation Cloud volume and structure is represented by a cubic 3D texture Individual clouds are represented as spheres enclosing the cube. Finding ray-sphere intersections consists of very simple vector operations well suited for the GPU.

Cloud parametes are stored in a buffer on the GPU Position Radius Rotation Unit density Unit light attenuation etc.

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Main rendering algorithm 1

Parse input parameters

2

Load or generate the cloud volume texture

3

Load or generate the cloud placement and parameters

4

Initialization (threads, GL contexts, components). Face set rendering – for each of the 6 cube faces:

5

1 2 3 4

Cleanup output buffer Setup raytracer(s) Activate raytracer(s) (each in its own thread) Face tile rendering – for each tile on a face: 1 2

5 6 7

Raytrace a batch of tiles Copy the raytraced tiles into a shared buffer

Suspend raytracer(s) Render the final image, using finishing shadera Save face final image and/or intemediate raytrace data Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Future work

Outline

Distant details

Raytracing

Cloud trace

Results

Raytracing algorithm – CPU

1

Each cube face is divided into rectangular tiles

2

The individual tiles are assigned to idle raytracers in batches

3

Each raytracer processes a single tile on the GPU

4

After all tiles in a batch are processes they are copied by the copier into a shared texture.

Mat´ uˇs Chochl´ık

Ray-cloud intersection search

Multi-GPU cloud raytracing

Future work

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Raytracing algorithm – GPU

1

Find ray direction

2

Search for intersections Sample the interior of the intesected cloud-spheres

3

1

Cloud interior sampling

For each sample in the interior of the cloud, cast a secondary ray to the light source, calculating the sample lighting.

4

Backtrace all samples along the primary ray and blend them into the final value according to the sample density.

5

Output raytrace data Casting secondary rays Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Performance testing Hardware CPU – Intel Xeon W3550, 8 cores @3.07 GHz RAM – 8 GB GPU – 2 x nVidia Quadro 600 (GPU0 , GPU1 )

Test cases T(A) GPU0 : Finisher + Raytracer

T(B)

Testing scenes S2 – 2 cloud spheres S4 – 4 cloud spheres ... S512 – 512 cloud spheres S1024 – 1024 cloud spheres

Mat´ uˇs Chochl´ık

GPU0 : Finisher GPU1 : Raytracer

T(C) GPU0 : Finisher + Raytracer GPU1 : Raytracer

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Typical rendering times and scalability

00:30

18:00

T(Aoff-screen) T(Boff-screen) T(Coff-screen)

00:25

16:00

30:00

T(Aoff-screen) T(Boff-screen) T(Coff-screen)

24:00

00:15

00:10

Real rendering time

Real rendering time

Real rendering time

14:00 00:20

12:00 10:00 08:00 06:00 04:00 02:00

S2

S4

S8 Scene

S16

S32

00:00 S64

21:00 18:00 15:00 12:00 09:00 06:00

00:05

00:00

T(Aon-screen) T(Bon-screen) T(Con-screen)

27:00

03:00 00:00 S128

S256

S512

S1024

S2

S4

S8

S16

Scene

Rendering times in off-screen mode

Mat´ uˇs Chochl´ık

S32

S64

S128

S256

Scene

Rendering times in on-screen mode

Multi-GPU cloud raytracing

S512

S1024

Outline

Distant details

Raytracing

Cloud trace

Results

Future work

Multi-GPU execution speedup Off-screen

On-screen

1.8

70

1.7 1.6 1.5

50

1.4

Speedup

Speedup

T(A)/T(B) T(A)/T(C)

60

1.3 1.2 1.1

40 30 20

1 0.9

10

T(A)/T(B) T(A)/T(C)

0.8 0.7

0 S1 02

12

4

T (A)

Execution speedup T (B) and T (C ) in Scenario 2 in off-screen and on-screen modes. Mat´ uˇs Chochl´ık

56

28

4

Scene

T (A)

S5

S2

4

S1

2

S6

02

12

56

28

6

S3

S1

S8

S4

S2

S1

S5

S2

4

S1

2

S6

6

S3

S1

S8

S4

S2

Scene

Multi-GPU cloud raytracing

Outline

Distant details

Raytracing

Cloud trace

Results

Raytrace output data

Cloud density data (inverted)

Primary lighting data

Cloud distance data (normalized)

Secondary lighting data

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Future work

Outline

Distant details

Raytracing

Cloud trace

Finished output

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Results

Future work

Outline

Distant details

Raytracing

Cloud trace

Finished output

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Results

Future work

Outline

Distant details

Raytracing

Cloud trace

Finished output

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Results

Future work

Outline

Distant details

Raytracing

Cloud trace

Finished output

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Results

Future work

Outline

Distant details

Raytracing

Cloud trace

Animations

Cloud trace allows command line invocation. Cloud placement data is animated and prepared for each frame by an external script. Each frame is rendered by a single invocation of Cloud trace.

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Results

Future work

Outline

Distant details

Raytracing

Cloud trace

Planned features for Cloud trace Optimizations Network rendering Raytracers as separate network servers Common broker dispatching raytrace tasks

Other output parameters Cloud age – usable in animations Cloud light emission Cloud altitude

Multiple light sources Multiple textures Improved cloud texture generator Other finishing shaders

Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Results

Future work

Outline

Distant details

Raytracing

Cloud trace

Results

Multi-GPU medical imaging data visualization

Raytraced data volume from an MRI brain scan Mat´ uˇs Chochl´ık

Multi-GPU cloud raytracing

Future work