I’d like to render a water-surface, which encloses a small island;
the water, around the island, is realized as grid, consisting of vertices and faces as you can guess, forming the trianlges.
i’like to “simulate” the effect of waves and ripples by rising/lowering some of the vertices of out the water-grid.
I thought of using a velocity/force based-calculation model, which saves the velocity and the actual force in an additional array of float’s, with a size of [watergridx*watergridy].
Now i have to re-calculate the water-force/velocity each frame.
This works…erm…let us call it in a “presentable” manner.
My question now is, which other ways are outside there, which are capable of beeing rendered/calculated in realtime ?
What do you use ?
You may try limiting computations per frame to say 1/60 part of second. Refresh as many as possible control points, when the time comes mark which control point was the one you stopped at, so next frame you can continue from it looping back to 1st and so on…
This may look some odd, but you’re not sure until you didn’t test it.
EDIT: You could also post the piece of your code that does the thing, then it would be easier to think about possible optimizations.
[This message has been edited by MickeyMouse (edited 02-17-2003).]
For ocean waves, you could look into Perlin noise. For smaller waves/ripples, combining a few sine waves should do fine.
For the specific case of your island, I would probably try to use sine waves aligned with the shores for best results on the beach, and then smoothly change to larger noise-based waves as you move out into the open sea.
That could mean a whole lot of CPU work, but you can do incremental updates like MickeyMouse suggested. Personally I’ve had good results with a triple-buffered scheme, where I interpolate between two frames while I’m calculating the third.
You can accelerate lots of it with vertex programs, of course, and you can use bumpmapping to increase the detail levels without having to add insane amounts of polygons.
If you want to keep it simple, just do it with a predefined phase map. In practice, assign an individual phase shift to each water vertex, and then just move them up and down along a sine wave, each vertex phase shifted by it’s own value. You can create many different kinds of effects with different phase maps, including ripples on the shore, ocean waves, and rivers.
Best thing is, that your engine doesn’t have to know what kind of waves it’s doing, it’s all defined in the phase map, which you can draw in a paint program if you can’t come up with anything better. Maybe you could even pull it off with a vertex program. Not too dynamic, though.
If you want to be cool, you can of course add frequency and amplitude maps too…
mmmh, yes i know the article on gamasutra, covering the deep water rendering;
but, as already mentiond, it’s very very complex (and i’m not sure, if i can reduce math.-computations while holding the imageoutput-quality at this high level); i will think about it, but i believe that i will go another way.
your idea with the “phase maps” sounds nice; and it’s new to me - you told about the creation process: i should use a paint program ? is that the right way, because using a paint program (additional with my great artistic ability! ), would result, if i imagine this, in “unconstant repartition” - i think i should use a kind of “syntheic image generator”, but which one ? Is there a tool outside, which you can recommend, to make such “phase maps” ?
>>Best thing is, that your engine doesn’t
>>have to know what kind of waves it’s doing
yes ! this is one of the primary goals of the water-rendering class - combined with your above mentioned way, it would be exposed to a “complete configurable water renderer”
So, please tell: about which tool to generate the phase maps, do you think ?
I don’t think there are tools to create phase maps. Heck, I don’t even know if anyone’s done it before, the idea was just out the top of my head.
I think your options are either to use a paint program or to write your own program, which isn’t much easier. Some nice paint program tips to get you started:
Perlin noise, for the oceans:
Start with a low res image and add heavy noise. Then subsequentially double your image size (with nice filtering) and add more noise. On each step, reduce the amount of noise you add, for example divide the noise factor by 2. Repeat until you reach the desired resolution. The lower res you start from, the bigger wavelength you get.
Draw your island as seen from the above, white on a black background, and apply heavy blur. Then multiply the colors by some number, 10 for example, without color clamping. In Paint shop you would do this with the Image/Arithmetic tool. Result: nice ripples.
Use a picture tube which cycles gradually from a black circle to white. Draw multiple strokes that go through the entire river for best effect.