Jump to content
  • Advertisement
Sign in to follow this  
Mythar

Making Waves ?

This topic is 4815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I was tyring to expand my Terrain to include water movement. (HightMap style) I used the "The Water Effect Explained" article, but this makes the animation too "jerky" when using a Vertex Grid. Dose any have nice algorithm for a water grid ? (was kinda looking for some smoth rolling ocean waves)

Share this post


Link to post
Share on other sites
Advertisement
Probably just animate the vertexes using a vertex shader add a slightly reflective surface, and wave like watery suface with with something like a pixel shader and then add in a sine/cosine like movement to the waves vertices themselfs. This should work I think rather nicely. [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by DevLiquidKnight
Probably just animate the vertexes using a vertex shader add a slightly reflective surface, and wave like watery suface with with something like a pixel shader and then add in a sine/cosine like movement to the waves vertices themselfs. This should work I think rather nicely. [smile]


First I would like to get the movement going (I can add the other stuff later on) but Im not that strong in the math ...

a sample would be nice :)

Share this post


Link to post
Share on other sites
well, i spend a few days looking at the links you posted and searched the web for wave equations, like the 2D wave equation FFT.
But as i wrote, im not strong in math, so looking at the equations in "Link4", i dont know, how to use them in code.

Dose anyone have a wave equation sample, that would create waves like the "Link2" demo ?
(I did mail the writer of the demo, but got no answer)

Share this post


Link to post
Share on other sites
hmm.... depends on how realistic you want your waves to be. For example a simple regular wave moving along the x-axis would be y = sin(x+t) (A), where x is the x-coordinate of the vertex, and y is its height coordinate.
Another simple example:
y = sin(x² + z² +t) (B) would give you circular waves around the origin of your world, where x,y,z are the coordinates of the vertex.
In both examples t is some kind of time variable. Note also that x in (A) is the distance of the vertex from the origin along the x-axis, which is quite obvious. In (B) x² + z² is the squared distance of your vertex to the origin on the x-z-plane.

However those waves wouldn´t flatten, or do anything realistic waves would do.
If you don´t need realistic waves, I would simply look for some math pages, where you can look at some graphs of common functions, such as the log-function, sqrt-function, sin-, cos- and tan-function and so on. After you´ve seen the graphs you´ll have a rough clue about what that function is going to do, when your coordinates or anything get bigger. With that rough clue I would just experiment in EffectEdit or any other tool for .FX-Editing you like, I´m pretty sure you can come up with something looking good enough after some playing around. At least that´s the way I like to do it ;) Also multiplying the result with some noise in the range of 0.8 to 1.0 or something like that could add some nice effects.

For realistic waves you won´t get around some math and physics, I guess... never done it before, though.

Share this post


Link to post
Share on other sites
Quote:
Original post by matches81
hmm.... depends on how realistic you want your waves to be. For example a simple regular wave moving along the x-axis would be y = sin(x+t) (A), where x is the x-coordinate of the vertex, and y is its height coordinate.
Another simple example:
y = sin(x² + z² +t) (B) would give you circular waves around the origin of your world, where x,y,z are the coordinates of the vertex.
In both examples t is some kind of time variable. Note also that x in (A) is the distance of the vertex from the origin along the x-axis, which is quite obvious. In (B) x² + z² is the squared distance of your vertex to the origin on the x-z-plane.
Yeah I'd try those first. If you get a realsitic shaped wave motion for open water you can then make it look pretty with reflections, shaders etc before putting in a more flexible animation method.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!