WATER SURFACE RENDERING.pdf
(
2046 KB
)
Pobierz
Budapest University of Technology and Economics
Faculty of Electrical Engineering and Informatics
Department of Automation and Applied Informatics
Zsolt Mátyás
WATER SURFACE RENDERING USING
SHADER TECHNOLOGIES
Consultant
Tamás Rajacsics
BUDAPEST, 2006
Abstract - Introduction
CONTENTS
Abstract......................................................................................... 6
1 Introduction ............................................................................. 7
2 Water Mathematics .................................................................. 9
2.1
2.2
Introduction .............................................................................................................................9
Optical Effects of Water Surfaces ............................................................................................9
Reflection .........................................................................................................................9
Refraction .......................................................................................................................10
The Third Dimension ......................................................................................................11
Critical Angle ..................................................................................................................11
Multiple Reflection and Refraction ................................................................................12
The Reflection-Refraction Ratio: the Fresnel Term........................................................12
2.2.1
2.2.2
2.2.3
2.2.4
2.2.5
2.2.6
2.3
Moving Water ........................................................................................................................14
About Waves ..................................................................................................................14
Compound Systems – Summation of Different Waves ..................................................15
Gerstner Waves ..............................................................................................................17
The Navier-Stokes Equations .........................................................................................17
2.3.1
2.3.2
2.3.3
2.3.4
2.4
Various Water Phenomena ....................................................................................................18
Specular Lights ...............................................................................................................18
Caustics ..........................................................................................................................19
Godrays ..........................................................................................................................20
Whitecaps and Foam......................................................................................................21
The Kelvin Wedge...........................................................................................................21
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
3 Shaders ................................................................................... 23
3.1
3.2
3.3
3.4
3.5
3.6
3.7
Background ............................................................................................................................23
Tessellation of the Virtual World ...........................................................................................23
Shaders ...................................................................................................................................24
The Actual Pipeline.................................................................................................................24
The Vertex Shader ..................................................................................................................25
The Pixel Shader (Fragment Shader) ......................................................................................28
High Level Shader Language ..................................................................................................30
2
Abstract - Introduction
3.7.1
3.7.2
3.7.3
3.7.4
3.7.5
3.7.6
3.7.7
3.8
Variable Declaration .......................................................................................................30
Structures .......................................................................................................................31
Functions ........................................................................................................................31
Variable Components .....................................................................................................31
Samplers .........................................................................................................................32
Effects .............................................................................................................................32
Techniques .....................................................................................................................32
Conclusion ..............................................................................................................................32
4 Alternative Solutions ............................................................... 33
4.1
4.2
Introduction ...........................................................................................................................33
Water Representations ..........................................................................................................33
3D Grids ..........................................................................................................................33
2D Grids - Hightmaps .....................................................................................................33
4.2.1
4.2.2
4.3
Performance Optimization .....................................................................................................34
Classical LOD Algorithms ................................................................................................34
LOD Algorithms on Water Surfaces................................................................................35
Using Projected Grid ......................................................................................................37
4.3.1
4.3.2
4.3.3
4.4
Water Simulation Approaches ...............................................................................................38
Coherent Noise Generation - the Perlin Noise...............................................................38
Fast Fourier Transformations .........................................................................................39
The Navier-Stokes Equations .........................................................................................39
Particle Systems .............................................................................................................41
4.4.1
4.4.2
4.4.3
4.4.4
4.5
Rendering Reflections ............................................................................................................42
Static Cube-map Reflections ..........................................................................................42
Dynamic Cube-maps ......................................................................................................43
Reflection Rendering to Texture ....................................................................................43
4.5.1
4.5.2
4.5.3
4.6
Calculating the Fresnel Term .................................................................................................44
Accurate Approximation of the Fresnel Term................................................................44
Simpler Solution .............................................................................................................45
A Realistic Compromise..................................................................................................46
Using Texture Lookup.....................................................................................................46
4.6.1
4.6.2
4.6.3
4.6.4
4.7
Rendering Various Water Phenomena ..................................................................................46
Generating Spays Using Particle Systems ......................................................................46
Creating Choppy Waves .................................................................................................47
Rendering Caustics .........................................................................................................49
4.7.1
4.7.2
4.7.3
3
Abstract - Introduction
4.7.4
4.7.5
Foam generation ............................................................................................................52
The Kelvin wedge ...........................................................................................................53
5 Lake Water Shader .................................................................. 54
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
5.10
Preconditions .........................................................................................................................54
Before Using the Shader ........................................................................................................54
HLSL Code ...............................................................................................................................55
Rendering Reflections ............................................................................................................56
Rendering Refractions ............................................................................................................59
Fresnel Term Approximations ................................................................................................60
Creating Waves ......................................................................................................................61
Adding Dull Color ...................................................................................................................63
Specular Highlights .................................................................................................................63
Summary ................................................................................................................................64
6 Ocean water shader................................................................. 65
6.1
6.2
Introduction ...........................................................................................................................65
Water Shader in WWII Online: Battleground Europe ............................................................65
Optimizations .................................................................................................................66
Combining layers ............................................................................................................66
Coastal Wave Formation ................................................................................................66
HLSL code .......................................................................................................................67
6.2.1
6.2.2
6.2.3
6.2.4
6.3
Ocean Shader Demo Application ...........................................................................................67
Introduction ...................................................................................................................67
Vertices of the Water Surface ........................................................................................68
Waves - Getting Everything in Motion ...........................................................................69
Optical Effects ................................................................................................................71
Summary ........................................................................................................................72
6.3.1
6.3.2
6.3.3
6.3.4
6.3.5
7 Conclusion ............................................................................... 73
7.1
7.2
General ...................................................................................................................................73
Future Work ...........................................................................................................................73
4
Abstract - Introduction
8 References .............................................................................. 74
9 Source of the Images ............................................................... 77
10 Appendix ................................................................................. 79
10.1
10.2
Appendix A – DirectX and Supported Shader Versions..........................................................79
Appendix B – Shader Version Comparison.............................................................................80
Pixel Shader Comparison ...............................................................................................80
Vertex Shader Comparison ............................................................................................80
10.2.1
10.2.2
10.3
10.4
Appendix C – Shader Code of the Lake Water Demo Application .........................................82
Appendix D – Ocean Shader Code by [KRI] ............................................................................85
Startup part ....................................................................................................................85
10.4.1
10.4.2 Fastest Water shader – 20 instructions using only cub map, Fresnel term and fog
computation ...................................................................................................................................85
10.4.3
10.4.4
10.5
10.6
10.7
High quality water shader with 8 textures and 55 instructions .....................................86
Foam shader: 4 waves, with dry coast, 4 textures. 28 instructions altogether .............87
Appendix E – Shader Code of the Ocean Demo Application..................................................88
Appendix F – Screenshots of the Lake Water Demo Application ..........................................91
Appendix G – Screenshots of the Ocean Demo Application ..................................................92
5
Plik z chomika:
p.pablo
Inne pliki z tego folderu:
Real-time Realistic Ocean Lighting.pdf
(16848 KB)
Real-Time Synthesis and Rendering of Ocean Water.pdf
(7696 KB)
Realistic Real-time Underwater Caustics and Godrays.pdf
(3422 KB)
Screen Space Foam Rendering.pdf
(3910 KB)
Real-time Animation and rendering of whitecaps presentaion.pdf
(5498 KB)
Inne foldery tego chomika:
[Game Developer]
Archiwum Blender Art Magazine
Game Developer Magazine
ImagineFX - Issue 76 - 2011-12 (December) Materials - DVD + PDF
ImagineFX - Issue 80 - 2012-03 (March) Materials - DVD + PDF
Zgłoś jeśli
naruszono regulamin