OpenGL Water Rendering

Started by
6 comments, last by Trexioas Xavier 4 years, 7 months ago

I am quite new to OpenGL (C++) and I want to learn how I can make water. I am wondering if there are any tutorials that are simple to understand. The water doesn't need to be HD or a AAA game quality just something simple. Please link a tutorial that I can read/watch on. 

Advertisement

I assume you mean a sea surface with something resembling moving waves ? Animated or static ? With some realism or just a sine ? A calm day or Saffir-Simpson 5 ? ?

One can start with a sine wave. That would be simple. Any thing else involves some math and a few algorithms.

The next step after a sine i can think of would be a noise function. Search "Perlin noise ocean waves", e.g. https://flafla2.github.io/2014/08/09/perlinnoise.html or http://libnoise.sourceforge.net/index.html

If it is meant to be real time and animated, it involves techniques like vertex displacement (i found this, but i can't judge it, and attention, this is outdated code !) or generation of geometry on the gpu. So, with a graphics api at hand, one could use a vertex- or geometry shader to generate the waves (displacement from a 2D mesh or directly through 3D noise) in real time. With a noise function again or something more naturally correct. Here's some work on it, for example, but it is not simple. Anything chaotic is not simple ...

I may be wrong, but if it is more than a sine wave, it needs a little more dedication than a video. Valid until proven otherwise ?

 
1 hour ago, Green_Baron said:

I assume you mean a sea surface with something resembling moving waves ? Animated or static ? With some realism or just a sine ? A calm day or Saffir-Simpson 5 ? ?

One can start with a sine wave. That would be simple. Any thing else involves some math and a few algorithms.

The next step after a sine i can think of would be a noise function. Search "Perlin noise ocean waves", e.g. https://flafla2.github.io/2014/08/09/perlinnoise.html or http://libnoise.sourceforge.net/index.html

If it is meant to be real time and animated, it involves techniques like vertex displacement (i found this, but i can't judge it, and attention, this is outdated code !) or generation of geometry on the gpu. So, with a graphics api at hand, one could use a vertex- or geometry shader to generate the waves (displacement from a 2D mesh or directly through 3D noise) in real time. With a noise function again or something more naturally correct. Here's some work on it, for example, but it is not simple. Anything chaotic is not simple ...

I may be wrong, but if it is more than a sine wave, it needs a little more dedication than a video. Valid until proven otherwise ?

 

Yeah kinda resembling moving waves. To give an example, something like from the Quake games and Half Life/Counter Strike. Thank you with the links your provided so far. I will check them out now.

1 hour ago, Trexioas Xavier said:

To give an example, something like from the Quake games and Half Life/Counter Strike.

Are you talking about 'old-school' effects like from Quake 1-3 or Half Life 1? Or something more modern?

If the former, if I recall correctly, (some) liquids in e.g. Quake 3 just use a sort of swirling 'morph' shader. 'Shader' here doesn't refer to the current usage of the term, but rather to the Quake engine's built-in system.

I think that particular 'shader' just modifies the texture coordinates or vertex positions of a grid mesh. You can find some information on the shader system here (based on a quick look, it looks like the shader may modify vertex positions and not texture coordinates). The 'swirling' effect could be combined with texture coordinate modifications such as scaling or translation to create a more dynamic effect.

Obviously those effects are outdated, technically speaking, but could certainly still be used (e.g. as a stylistic choice). Since you said you're not necessarily looking for 'AAA' effects, maybe that or something like it would be an option. If you want something more sophisticated, maybe Green_Baron's suggestions will help.

Gonna try to be short this is a large subject.

Link to some of the work on the subject.
http://vterrain.org/Water/

Book that covers most of the grid bases simulations with code available:
https://epdf.pub/fluid-simulation-for-computer-graphics.html
https://github.com/tunabrain/incremental-fluids (C++)
https://github.com/g-amador/incremental-fluids-java(Java)

My suggestion to you:
Surface water (Shallow Water Equations)
Running water with foam https://experiments.withgoogle.com/fluid-particles

This is a very small quick overview of really relevant info to make you do something. This is not a easy field, but you can just go directly to what you want to simulate.

On 8/16/2019 at 9:19 PM, Trexioas Xavier said:

I am wondering if there are any tutorials that are simple to understand.

I guess this means that you don't want scientific papers and theory ;)

I liked this tutorial series: https://www.youtube.com/playlist?list=PLRIWtICgwaX23jiqVByUs0bqhnalNTNZh. It's in Java, so you won't get usable C++ code, but it explains the concepts well, everything you need to get from nothing to simple water. 

 

On 8/19/2019 at 4:33 AM, 1024 said:

I guess this means that you don't want scientific papers and theory ;)

I liked this tutorial series: https://www.youtube.com/playlist?list=PLRIWtICgwaX23jiqVByUs0bqhnalNTNZh. It's in Java, so you won't get usable C++ code, but it explains the concepts well, everything you need to get from nothing to simple water. 

 

Thank you i appreciate your help. ill check the links you sent. Thank you for your time.

On 8/18/2019 at 10:29 AM, Gon said:

Gonna try to be short this is a large subject.

Link to some of the work on the subject.
http://vterrain.org/Water/

Book that covers most of the grid bases simulations with code available:
https://epdf.pub/fluid-simulation-for-computer-graphics.html
https://github.com/tunabrain/incremental-fluids (C++)
https://github.com/g-amador/incremental-fluids-java(Java)

My suggestion to you:
Surface water (Shallow Water Equations)
Running water with foam https://experiments.withgoogle.com/fluid-particles

This is a very small quick overview of really relevant info to make you do something. This is not a easy field, but you can just go directly to what you want to simulate.

I appreciate you being short with this. Thank you too for taking your time with guiding me to a few links that I can read upon. I will check them out.

This topic is closed to new replies.

Advertisement