GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex...

13
GPU Water Simulation GPU Water Simulation Jeremy Zelsnack

Transcript of GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex...

Page 1: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

GPU Water SimulationGPU Water SimulationJeremy Zelsnack

Page 2: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

Demo

Page 3: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

Algorithm Overview

Perform water simulation in pixel shaderRender to texture (D3DFMT_A16B16G16R16F)

Render refraction and reflection mapsRender water surface

Use simulation results via VS3.0 vertex texture fetchCompute perturbed texture coordinatesCombine refraction and reflection using Fresnel term

Page 4: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

Simulation

Solve 2D wave equationVerlet Integration

Good stabilityUses previous 2 resultsNo velocity stored

Influence simulationDampening maps

Control simulationRender alpha-blended geometry into simulation

)( 2

2

2

22

2

2

zy

xyc

ty

∂∂

+∂∂

=∂∂

0,04

,2

2

2

2

*4)( yyzy

xy

neighborsji −

∂∂

+∂∂ ∑

Page 5: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

Vertex Texture Fetch (VS3.0)

Vertex shader reads simulation result with vertex texture fetch

Simulation Texture Height Map

Page 6: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

Refraction Map

Render scene from camera viewpoint

If camera is above waterRender underwater geometry

If camera is underwaterRender above water geometry

Page 7: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

Reflection Map

Render scene from reflected camera viewpoint

Reflect view transform about water plane

If camera is underwaterRender underwater geometry

If camera is above waterRender above water geometry

Page 8: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

Perturbed Texture Coordinates

Start at water positionMove along refraction or reflection vectorProject into screen space

Page 9: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

Fresnel Reflection Term

Determines amount of reflection / refractionRoughly pow((1 - dot(eye, normal)), p)

Fresnel term = 0 => all refractionFresnel term = 1 => all reflection

Page 10: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

Demo

Page 11: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

Questions or Comments?

[email protected]

http://developer.nvidia.com

Page 12: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

developer.nvidia.comdeveloper.nvidia.comThe Source for GPU Programming

Latest documentationSDKsCutting-edge tools

Performance analysis toolsContent creation tools

Hundreds of effectsVideo presentations and tutorialsLibraries and utilitiesNews and newsletter archives

EverQuest® content courtesy Sony Online Entertainment Inc.

Page 13: GPU Water Simulation - Nvidia · Render water surface Use simulation results via VS3.0 vertex texture fetch ... Performance analysis tools Content creation tools Hundreds of effects

GPU Gems: Programming Techniques, GPU Gems: Programming Techniques, Tips, and Tricks for RealTips, and Tricks for Real--Time GraphicsTime Graphics

Practical real-time graphics techniques from experts at leading corporations and universities

Great value:Contributions from industry expertsFull color (300+ diagrams and screenshots)Hard cover816 pagesAvailable at GDC 2004

“GPU Gems is a cool toolbox of advanced graphics techniques. Novice programmers and graphics gurus alike will find the gems practical, intriguing, and useful.”Tim SweeneyLead programmer of Unreal at Epic Games

“This collection of articles is particularly impressive for its depth and breadth. The book includes product-oriented case studies, previously unpublished state-of-the-art research, comprehensive tutorials, and extensive code samples and demos throughout.”Eric HainesAuthor of Real-Time Rendering

For more, visit:For more, visit:http://developer.nvidia.com/http://developer.nvidia.com/GPUGemsGPUGems