Ocean Simulation

Blitz3D Forums/Blitz3D Programming/Ocean Simulation

MIK(Posted 2005) [#1]
I want to make a U-Boat game.
I've tried to simulate the ocean, but I don't know how to simulate a very big piece of water with waves using level of detail algorithms.
I wanted to implement the Pierson-Moskowitz sea formula to an enormous LOD ocean.

How would you do this?


Erroneouss(Posted 2005) [#2]
Here's some nice looking moving water.
The code archives are your friend.

http://www.blitzbasic.com/codearcs/codearcs.php?code=364
http://www.blitzbasic.com/codearcs/codearcs.php?code=991


MIK(Posted 2005) [#3]
This only works for small surfaces with stored vertex heights.
I want to make a very big piece of water with LOD management.


aCiD2(Posted 2005) [#4]
Not asking for much then are you? I recommend using a sin based solution. GPU Gems has a chapter dedicated to water simulation, so if you want to do it well, I highly recommend that book.

As for LOD... well firstly your going to need to learn about quad trees or other large scene management techniques (I dont see Oct-trees being neccissary :) ) and to use this you'll be needing to have sliced meshs. The LOD technique you use I can't help you about - haven't tryed any LOD. But there is a book dedicated to LOD techniques....

You should probably start with a terrain system because its static.


Ross C(Posted 2005) [#5]
If your looking to simulate waves, you could also use animated normal maps, for the smaller waves. As long as you don't get too close, it should look decent. Trouble is getting an animated normal map that tiles :D


Chad(Posted 2005) [#6]
Hey MIK, I was workin on somethin similar awhile back, I've got something you might be interested in.

Email me at stangekopf@... and we'll have a chat.


jfk EO-11110(Posted 2005) [#7]
Blitz Terrains have built in LOD, you will even be able to use a high optimation since water MAY pop in and out (a known problem of LOD terrains).

All you have to do is editing the terrains heights in realtime. For this you may load an animated texture and copy the brightness of each pixel and frame to arrays or banks. Then you can access them quickly to modify the terrain in realtime. Check out the "Texture Wobbler" (toolbox section), a tool that was designed to create animated water textures.

So you could do both, use an animated texture for the terrain, and animate it in the same time, using the information extracted from the said texture-frames. Of course, the (tiled) terrain-height animation should be scaled larger than the texture.


IPete2(Posted 2005) [#8]
MIK,

I cannot help you with the LOD stuff, but I dont know if you need it or not because it is very possible to make nice looking ocean expanses in realtime, but you have to cheat a little and use multiple layers to generate the effect, here's what I would suggest you look at...

You can use a cube map to provide reflectivity off the sky, but alpha that layer down because the sea rarely looks like a lake or mirror, so you have to reduce the effect to make it look more realistic.

There is a piece of code in the archives called ripple mesh - check that out, and tweak the parameters a bit, use multiple meshes and alpha them. Beware though, the meshes become out of control after about 10 mins, so you need to refresh them on a regular basis. By that I mean alpha them away and introduce a new mesh - a replacement - to keep the density of the effect going.

I am in the middle of developing a simulation which requires this effect, but I can't post any shots just yet. I will release shots once the sim is in place, I may even release a little movie because still shots do not do it justice - watch out for those shots in the gallery in about a month or so.

IPete2.


Strider Centaur(Posted 2005) [#9]
Well the good news about doing a ocean surface is that after about 1 mile you cant really decern any signifacant changes in the sureface texture of the sea. If you design for 17" to 19" nmonitors, the LOD only needs to extend a few hundred meters in any direction.

For this reason you could simply design a animated mesh and center your view in it. Then mover it with you, but do not rotate it relative to the world when you turn. You dont want the waves changing firections with you.

For much rougher sees it gets even easier, as wall of water will usually only provide you good vision out to something a good bit less than a couple hundered meters for the magority of the time.

Now you will want to use something alot less detailed out past the max range. This level of detail is simple, and should be fast enough, simply render the wave mesh you created with a camera view set behind where the view camera sill be set and then save that image to a image buffer. Then useing a cube that in entity flipped and centers on you, just paint that image as textures, increasing the X scale while reducing the Y scale. You wont need to update that texture nearly as oftern as you do the animation of the wave mesh. Since things at a distance always seem to mover slower. You will need to play around with the second camera position to get the right view reletive to the players view, but once you have it it should be fairly consistant. This does require rendering part of a sceen twice( I say part, becaue you will be setting up Waves ahead of time then rendering them, then adding the other objects and rendering them with the waves.).

Anyway, its just an idea


MIK(Posted 2005) [#10]
Thanks.
I will use quad trees for the LOD.
I planed to use the Pierson-Moskowitz formula for the sea movement, but it seems imposible to use it with the LOD because you need to store the actual height of each vertex (and this would make useless the LOD, because you would still need to store the height of each possible vertex to move the water properly).


RGR(Posted 2005) [#11]
;--


jfk EO-11110(Posted 2005) [#12]
Never heared of that, but I shurely would test what's faster. yes, with a terrain, an ocean with nice waves should be real easy, although an ocean is real big and probably it would be better to use a fake ocean that fades to a simple plane at some point. But then it would be smart to use an offset for a tiled animation for the visible ocean "patch", and that offset would be calculated from the players moving direction etc.

It's a fascinating topic and since I worked on underwater fx lately, I probably gonna give it a try soonish.

EDIT: Does anyone remember the last level of NOLF2, that plays on a little island? That was a great ocean! watched from the hills, the waves around the islands coast where looking very nice, one of the sweeter candies of the lithtech engine IMHO.


Chad(Posted 2005) [#13]
Keep us informed MIK..

I would really love to see another U-boat sim :-)