Task gpu013: Ocean waves (C++)

The task is to simulate ocean waves in a vertex shader (GLSL). You should use Gerstner waves or some other - more advanced - system. You can work further on improving appearance by modifying default Phong fragment shader..

Ocean waves

Template for the task is prepared in the ogl repository. You can start from the sample09 project, there is reasonable GLSL shader setup prepared for you extension and initial scene (water surface) is ready to be modified in your vertex shader. If you are going to use texture for enhancing surface appearance, there is simple texturing code ready as well..

Details

Surface geometry: default surface in the sample09 template has been already shaped using static Gerstner waves (see class Gerstner in functions.*). You have to rewrite the initSurface() function to flatten the initial surface but you might want to keep the varying texture coordinates - to use it in your vertex shader for generating dynamic waves. Another option: you can use [x,z] world-space coordinates for this.

Gerstner waves: you should read some theory - GPU Gems Chapter or J. Tessendorf's "Simulating Ocean Water".
Sample CPU implementation is in functions.h and functions.cpp. Sample GPU implementation (Cg language) is in the project sample11, you can look for an inspiration in the gerstner.cg shader file - all shaders used in the project are in single source file.

Wave parameters: you should be able to parametrize your dynamic waves. For example in Gerstner synthesis you would have a tuple [float amplitude, vec2 direction, float frequency, float phase, float sharpness] for each wave component. Our Cg example is using 4 wave components only, don't be limited by this.

Time dependency: just pass the global (world) time in one of your uniforms (see uniform float time; in Cg example).

Shaders

In the initGLSL() function you should define custom set of shaders assembled into shader programs. You perhaps get by one program (as the template does). Don't forget to define all handles to uniform variables and assemble all the shader pipelines corectly. Look into the log.txt file for eventual error messages.

Your solution

Send all your modifications in complete Visual Studio project, including shader files and larger data files (textures). Write a brief document about your ideas and operating manual.

Deadline

Hand in before: 15. 5. 2016

Points

Basis: 16 points for functional nice looking ocean waves (at least as good as in the Cg example),
bonuses: up to 9 additional points for nicer waves, more parameters, better appearance,
up to 5 points for adding more interactivity (mouse, keyboard, you know..)

Project

Recommended starting point: Visual Studio project sample09 from the ogl repository.


Copyright (C) 2016 J. Pelikán, last change: 2019-05-09 17:52:59 +0200 (Thu, 09 May 2019)