30.12.2013 Views

Presentation in pdf format - University of Minnesota Duluth

Presentation in pdf format - University of Minnesota Duluth

Presentation in pdf format - University of Minnesota Duluth

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Siddharth Deokar<br />

Graduate Research Student<br />

Department <strong>of</strong> Computer Science<br />

<strong>University</strong> <strong>of</strong> M<strong>in</strong>nesota <strong>Duluth</strong><br />

Advised by<br />

Pete Willemsen<br />

May 22, 2009


Outl<strong>in</strong>e<br />

Problem Overview<br />

Background<br />

System Overview<br />

Sort<strong>in</strong>g on the GPU & Blend<strong>in</strong>g<br />

Aggregate Snow<br />

LDR, HDR Render<strong>in</strong>g<br />

Model<strong>in</strong>g <strong>of</strong> snow<br />

Results<br />

Conclusion<br />

2


Problem Overview (The Big<br />

Picture)<br />

Snow<strong>in</strong>g conditions<br />

Real Life Problem<br />

<br />

Follow<strong>in</strong>g beh<strong>in</strong>d a snowplow or other vehicles can be dangerous<br />

Difficult to see other vehicles or judge their speed<br />

<br />

Due to poor visibility and snow, it becomes difficult to detect<br />

speed changes <strong>of</strong> other vehicles result<strong>in</strong>g <strong>in</strong> the potential for rear<br />

end collisions<br />

Why snow render<strong>in</strong>g ?<br />

Create a virtual <strong>in</strong>teractive environment where a person can<br />

drive around <strong>in</strong> blow<strong>in</strong>g snow and foggy conditions.<br />

<br />

Understand how we drive <strong>in</strong> snow<strong>in</strong>g conditions<br />

Try to make w<strong>in</strong>ter driv<strong>in</strong>g safe<br />

3


Problem Overview Cont<strong>in</strong>ued…<br />

Goal <strong>of</strong> my research<br />

Effective render<strong>in</strong>g <strong>of</strong> snow<strong>in</strong>g conditions<br />

Improve visual render<strong>in</strong>g <strong>of</strong> snow<br />

<br />

<br />

Interaction between light and snow<br />

Create more realistic scenes<br />

Experiment Framework: Simulated Highway [Pete<br />

Willemsen] & Snow Plow [Michele Olsen]<br />

Video (SnowRender<strong>in</strong>gSimulation.mov)<br />

4


Background<br />

<br />

GPU<br />

Why GPU ?<br />

<br />

<br />

Many Stream Processors<br />

SIMD Architecture<br />

Massive Parallelization<br />

Dedicated for render<strong>in</strong>g high end graphics like video games, 3D games<br />

<br />

Textures<br />

Ma<strong>in</strong> memory structure<br />

<strong>of</strong> a GPU<br />

Each colored square is an <strong>in</strong>dividual<br />

texel, which can be a vector values<br />

Shaders ?<br />

<br />

<br />

One shader for updat<strong>in</strong>g positions<br />

Another Shader for sort<strong>in</strong>g positions<br />

12 13 14 15<br />

8 9 10 11<br />

4 5 6 7<br />

0 1 2 3<br />

5


Background cont<strong>in</strong>ued…<br />

Particle System [Andrew Norgren]<br />

Po<strong>in</strong>t Sprites<br />

<br />

Render millions <strong>of</strong> particles <strong>in</strong> real time<br />

Video (ParticlesAsPo<strong>in</strong>tSprites.mov)<br />

6


System Overview<br />

Sort<strong>in</strong>g & Blend<strong>in</strong>g<br />

Why sort<strong>in</strong>g or blend<strong>in</strong>g ?<br />

Quick Sort<br />

GPU Sort<br />

Additive Blend<br />

Aggregate Snow Effect<br />

High Dynamic Range Render<strong>in</strong>g<br />

Model snow particles<br />

Transparency<br />

Scatter<strong>in</strong>g <strong>of</strong> Light<br />

7


Sort<strong>in</strong>g & Blend<strong>in</strong>g on the GPU<br />

Why is sort<strong>in</strong>g required ?<br />

Objects are drawn <strong>in</strong> a sequence which is provided by<br />

the user <strong>in</strong> his code<br />

Problem with<br />

transparent<br />

objects block<strong>in</strong>g<br />

objects beh<strong>in</strong>d<br />

them<br />

Video (unsorted<br />

particles.mov)<br />

8


Sort<strong>in</strong>g <strong>of</strong> Snow Particles<br />

Sort the particles based on each <strong>in</strong>dividual particle’s<br />

distance from the eye<br />

Euclidean Distance<br />

Quick Sort<br />

Sort<strong>in</strong>g done by CPU<br />

Maps with GPU memory every frame to sort<br />

<br />

Map the particle positions from the vertex buffer to CPU<br />

memory<br />

9


Sort<strong>in</strong>g <strong>of</strong> Snow Particles<br />

Cont<strong>in</strong>ued…<br />

GPU Sort<br />

Inherent Parallelism<br />

Gets rid <strong>of</strong> CPU communication<br />

Faster than us<strong>in</strong>g the best sort<strong>in</strong>g algorithms on the<br />

CPU<br />

<br />

Algorithms like Quick Sort cannot be implemented on the<br />

GPU as it cannot write to arbitrary memory locations<br />

The GPU does not support this functionality to avoid write<br />

after read operations by different stream processors when<br />

access<strong>in</strong>g the same memory location<br />

10


GPU Sort<br />

Implemented by Gov<strong>in</strong>daraju, N., Raghuvanshi, N.,<br />

Henson, M., Tuft, D., Manocha, D. [A Cache Efficient<br />

Sort<strong>in</strong>g Algorithm for Database and Data M<strong>in</strong><strong>in</strong>g<br />

Computations us<strong>in</strong>g Graphics Processors, 2005]<br />

They have used texture mapp<strong>in</strong>g to implement a<br />

bitonic sort algorithm<br />

I have modified the algorithm to suit the sort<strong>in</strong>g <strong>of</strong><br />

particles <strong>in</strong> our system<br />

11


GPU Sort Cont<strong>in</strong>ued…<br />

Bitonic Sequence<br />

A sequence which has at most one local m<strong>in</strong>imum or<br />

maximum<br />

When you break a bitonic sequence at the m<strong>in</strong>imum or<br />

maximum you get two sorted sequences, one ascend<strong>in</strong>g and<br />

the other descend<strong>in</strong>g<br />

Examples: 1,2,3,4,5,6,7,8 2,5,8,10,7,4,3,1<br />

9,8,5,3,6,10,11,12<br />

<br />

<br />

splitt<strong>in</strong>g the second sequence at 10 gives us 2,5,8,10 and 7,4,3,1 which<br />

are sequences <strong>in</strong> ascend<strong>in</strong>g and descend<strong>in</strong>g order respectively<br />

In the third example, the m<strong>in</strong>imum is 3 and splitt<strong>in</strong>g the sequence at<br />

3 gives us 9, 8, 5, 3 and 6, 10, 11, 12 which are sequences <strong>in</strong> descend<strong>in</strong>g<br />

and ascend<strong>in</strong>g order respectively<br />

12


GPU Sort Cont<strong>in</strong>ued…<br />

(Bitonic Sort)<br />

Stage 1: Bitonic Sequence<br />

Created<br />

Stage 2: Bitonic<br />

Sort<br />

Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Pass 6<br />

13


Example <strong>of</strong> Bitonic Sort<br />

Unsorted Sequence 12 8 14 6 15 10 9 13<br />

Pass 1 12 8 14 6 15 10 9 13<br />

Result 8 12 14 6 10 15 13 9<br />

Pass 2 8 12 14 6 10 15 13 9<br />

Result 8 6 14 12 13 15 10 9<br />

Pass 3 8 6 14 12 13 15 10 9<br />

Bitonic Sequence 6 8 12 14 15 13 10 9<br />

Pass 4 6 8 12 14 15 13 10 9<br />

Result 6 8 10 9 15 13 12 14<br />

Pass 5 6 8 10 9 15 13 12 14<br />

Result 6 8 10 9 12 13 15 14<br />

Pass 6 6 8 10 9 12 13 15 14<br />

Sorted Sequence 6 8 9 10 12 13 14 15<br />

14


GPU Sort Cont<strong>in</strong>ued…<br />

Apply<strong>in</strong>g GPU Sort to our system<br />

The particles are stored <strong>in</strong> a 2-D texture where each cell<br />

holds the position <strong>of</strong> a particle as a 4-D vector<br />

conta<strong>in</strong><strong>in</strong>g values <br />

Calculate Euclidean distance <strong>of</strong> each particle from eye<br />

Indices for particles ?<br />

Indices Distances GPU Sort Sorted Indices<br />

1 2 3 4 25 38 33 28 1 14 9 4<br />

5 6 7 8 + 40 32 27 36 = 16 8 3 12<br />

9 10 11 12 37 34 26 31 13 10 2 7<br />

13 14 15 16 29 35 39 30 5 11 15 6<br />

15


GPU Sort Cont<strong>in</strong>ued…<br />

Drawback<br />

GPU Sort is very fast for a small number <strong>of</strong> particles but<br />

becomes slow as the number <strong>of</strong> particles <strong>in</strong>creases<br />

For example, the time taken to render a frame with one<br />

million particles is more than 0.01 seconds which is necessary<br />

for an <strong>in</strong>teractive environment.<br />

Solution<br />

GPU Sort done over a number <strong>of</strong> passes<br />

It is Fast but,<br />

<br />

<br />

This approach is restricted as the particles are mov<strong>in</strong>g and hence we<br />

cannot have a large number <strong>of</strong> passes to sort the particles <strong>in</strong> a<br />

particular position<br />

On the other hand, by us<strong>in</strong>g a few passes gives us artifacts which are<br />

easily noticeable to the human eye<br />

16


Additive Blend<strong>in</strong>g<br />

Alternative to sort<strong>in</strong>g<br />

Alpha value is used to comb<strong>in</strong>e the color value <strong>of</strong> a<br />

fragment with<br />

the color <strong>of</strong> a<br />

pixel already<br />

stored <strong>in</strong> the<br />

framebuffer<br />

17


GPU Sort and Blend<strong>in</strong>g Cont<strong>in</strong>ued…<br />

Video (Sort<strong>in</strong>g.mov)<br />

18


Aggregate Snow Effects<br />

Snow particles are conf<strong>in</strong>ed <strong>in</strong> a certa<strong>in</strong> doma<strong>in</strong><br />

To show snow particles everywhere is not<br />

computationally feasible<br />

In real world it is hard to see <strong>in</strong>dividual snow particles<br />

after a certa<strong>in</strong> distance<br />

Aggregation <strong>of</strong> snow becomes more prom<strong>in</strong>ent as you<br />

look <strong>in</strong>to the horizon with objects becom<strong>in</strong>g less and<br />

less visible with <strong>in</strong>creas<strong>in</strong>g distance<br />

19


Aggregate Snow Effects Cont<strong>in</strong>ued…<br />

Visibility<br />

As the amount <strong>of</strong> snow <strong>in</strong>creases, visibility decreases<br />

Derive a relation between the snow density <strong>in</strong> our simulation<br />

system and visibility <strong>in</strong> the simulated scene<br />

Video (Real World Aggregation.mov)<br />

20


Aggregation: Snow Density<br />

21


Aggregate Snow Effect<br />

Video (Visibility.mov)<br />

22


High Dynamic Range Render<strong>in</strong>g<br />

Our visual system supports a very high contrast ratio which<br />

is not reflected <strong>in</strong> graphical scenes<br />

Low Dynamic Range Render<strong>in</strong>g<br />

8 bits per color (RGB)<br />

<br />

Contrast ratio <strong>of</strong> 256:1 per color<br />

High Dynamic Range Render<strong>in</strong>g<br />

Better contrast ratio<br />

Create more realistic scenes<br />

Example: Light Source (yellow)<br />

LDR RGB = {1,1,0}<br />

HDR RGB = {4,4,0}<br />

4 times brighter than a light source with <strong>in</strong>tensity {1,1,0}<br />

23


HDR Render<strong>in</strong>g Process<br />

Render Scene<br />

Extract High<br />

Lum<strong>in</strong>ance<br />

Downsample<br />

& Blur<br />

Additive<br />

Blend<strong>in</strong>g<br />

F<strong>in</strong>al Image<br />

Bloom Mask<br />

24


HDR Render<strong>in</strong>g Cont<strong>in</strong>ued…<br />

Render us<strong>in</strong>g<br />

HDR<br />

Extract High Lum<strong>in</strong>ance<br />

Downsampl<strong>in</strong>g & Blur<br />

Bloom Mask<br />

Image rendered<br />

us<strong>in</strong>g HDR<br />

F<strong>in</strong>al Image<br />

25


HDR Render<strong>in</strong>g Cont<strong>in</strong>ued…<br />

HDR Scene is tone mapped <strong>in</strong> order to be displayed on<br />

the monitor<br />

HDR Image Tone Mapp<strong>in</strong>g LDR Image<br />

Tone Mapp<strong>in</strong>g<br />

26


HDR Render<strong>in</strong>g Cont<strong>in</strong>ued…<br />

F<strong>in</strong>al Image displayed on screen<br />

27


Model<strong>in</strong>g <strong>of</strong> Snow<br />

Snow<br />

Translucent particles<br />

<br />

Interact with light to produce scatter<strong>in</strong>g effect<br />

Model shape <strong>of</strong> a snow particle, appearance and<br />

scatter<strong>in</strong>g <strong>of</strong> light due to snow<br />

28


Transparency<br />

Gaussian Function<br />

Gives snow opacity at the centre and becomes<br />

transparent as we move away from the centre<br />

29


Shapes for snow particles<br />

Particles are modeled after actual snow flakes<br />

These images give an outer boundary to our snow<br />

particles so that they resemble actual snowflakes<br />

30


Shapes for snow particles<br />

cont<strong>in</strong>ued…<br />

Particles as snow flakes<br />

Gaussian Transparency<br />

Snow flake<br />

F<strong>in</strong>al Image with<br />

Gaussian transparency<br />

and snow flake shape<br />

31


Dynamic Lights<br />

We can have many lights active <strong>in</strong> the system at any given<br />

moment <strong>of</strong> time<br />

Light source <strong>in</strong><strong>format</strong>ion is available through use <strong>of</strong> textures<br />

Data 1 Position 1 Intensity 1 Direction 1 Spotlight<br />

Parameters 1<br />

Data 2 Position 2 Intensity 2 Direction 2 Spotlight<br />

Parameters 2<br />

Data 3 Position 3 Intensity 3 Direction 3 Spotlight<br />

Parameters 3<br />

Data 4 Position 4 Intensity 4 Direction 4 Spotlight<br />

Use active lights for scatter<strong>in</strong>g calculations<br />

Parameters 4<br />

32


Scatter<strong>in</strong>g<br />

Ray Trac<strong>in</strong>g<br />

Trac<strong>in</strong>g path <strong>of</strong> light through every pixel<br />

Computationally expensive<br />

Phase /Scatter<strong>in</strong>g function<br />

Henyey Greenste<strong>in</strong> Phase Function<br />

<br />

Widely used <strong>in</strong> atmospheric<br />

sciences because <strong>of</strong> its simplicity<br />

eye<br />

θ<br />

33


Scatter<strong>in</strong>g Cont<strong>in</strong>ued…<br />

S<strong>in</strong>gle parameter g (asymmetry parameter) controls<br />

the distribution <strong>of</strong> scattered light<br />

Forward Scatter<strong>in</strong>g<br />

Back Scatter<strong>in</strong>g<br />

34


Scatter<strong>in</strong>g<br />

Video (scatter<strong>in</strong>g.mov)<br />

35


Results<br />

Sort<strong>in</strong>g<br />

4<br />

3.5<br />

3<br />

2.5<br />

2<br />

1.5<br />

Time In 1<br />

seconds<br />

0.5<br />

0<br />

15K 65K 250K 500K 1M 2M<br />

Number <strong>of</strong> Particles<br />

Quick Sort<br />

GPU Sort with<br />

Passes<br />

GPU Sort w/o<br />

Passes<br />

36


Results Cont<strong>in</strong>ued…<br />

GPU Sort (With Passes Vs Without Passes)<br />

0.02<br />

0.018<br />

0.016<br />

0.014<br />

0.012<br />

0.01<br />

0.008<br />

0.006<br />

Time In<br />

seconds<br />

0.004<br />

0.002<br />

0<br />

15K 65K 250K 500K 1M 2M<br />

Number <strong>of</strong> Particles<br />

GPU Sort with<br />

Passes<br />

GPU Sort w/o<br />

Passes<br />

37


Results Cont<strong>in</strong>ued…<br />

Visibility<br />

Image 1 = > Visibility 0.76 (Less snow 6000 particles/s)<br />

Image 2 = > Visibility 0.57 (Heavy Snow 600000 particles/s)<br />

Image 3 = > Visibility 0.16 (Very Heavy Snow 900000<br />

particles/s)<br />

38


Results Cont<strong>in</strong>ued…<br />

Snow Model<br />

OSG Snow (Video – osgSnowRender<strong>in</strong>g.mov)<br />

Our snow model<br />

Snow system with all the effects like Gaussian<br />

transparency, scatter<strong>in</strong>g, HDR and fog<br />

39


Summary<br />

1. Sort the particles based on distance from eye OR use additive blend<br />

2. Model snow particle<br />

3. Get the number <strong>of</strong> lights <strong>in</strong> the scene<br />

4. Calculate color for each particle<br />

5. Calculate effect <strong>of</strong> every light on the particle<br />

6. Apply Gaussian Trans<strong>format</strong>ion<br />

7. Apply Scatter<strong>in</strong>g Function<br />

8. Apply snow aggregation to other objects <strong>in</strong> the scene<br />

9. Render scene to a frame buffer us<strong>in</strong>g HDR for light<strong>in</strong>g calculations<br />

10. Render HDR image<br />

11. Down sample and apply Gaussian blur<br />

12. Apply result<strong>in</strong>g bloom mask to orig<strong>in</strong>al image<br />

13. Render f<strong>in</strong>al image<br />

40


Snow Model<br />

Video (snow.mov)<br />

41


Implementation<br />

Implemented on top <strong>of</strong> particle system created by Andrew<br />

Norgren, Pete Willemsen<br />

Implemented <strong>in</strong> C++ with OpenGL and OpenGL Shad<strong>in</strong>g<br />

Language<br />

Tested on 2.4 GHz AMD Dual Core Processor with a<br />

NVIDIA GeForce 8800 Ultra graphics card<br />

128 Stream Processors<br />

Memory – 728 MB<br />

Matlab for snow density calculations<br />

42


Conclusion<br />

A snow doma<strong>in</strong> which is more realistic to outside world<br />

Individual & Aggregate Snow modeled effectively<br />

Interactive Environment (Real Time !)<br />

Future<br />

Tie visibility with real world data<br />

Sharp snow particles <strong>in</strong> the near plane and blurry snow<br />

(gaussian) at a distance<br />

Sort<strong>in</strong>g particles near the viewer<br />

Shadow<strong>in</strong>g<br />

43


Acknowledgements<br />

Pete Willemsen<br />

L. Zimmerman<br />

Andrew Norgren, Michele Olsen<br />

44


Thank You<br />

Questions ?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!