Looking for ideas for oceans

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Mar 19, 2013 at 09:21

I’m working on a game which uses a new feature of AGP, it allows you to use any other device as a remote control.

I’ve decided to do a game based on the artic convoys of world war 2

I’ve put up some screenshots herehttp://stainlessbeer.weebly.com/convoy.html

My problem is the ocean, I’m working in OpenGLES 1, so no shaders.

The approach I’m using at the moment is a view aligned height map with logarithmic scaling, so I get more detail at the front of the screen than at the back.

It’s 128 * 8 verts, but every vert is on screen so it looks and animates really nicely.

To give you an idea of how it works, I’ll put in a few code snippets.

The z coordinate of each row of verts is taken from this table.

const float zcoords[]={0,-4,-8,-16,-128,-256,-512,-2048};

The x coord is calculated from the z coord

      z   = zcoords[j];      // Start z
      x   = z *0.5f;           // Start x
      sx = -z/64;             // X step

I animate the height field using a simple trig function based on the verts position.

for (int j=0; j<8; j++)
{
      float t = start_time[j] + time;
      for (int i=0; i<128; i++)
     {
            float y = (1.25f * kdSinf(t+(i*0.5)*(j+1)*0.15));
            verts[pos]= y;

This looks really good, a lot like deep ocean waves.

The trouble is without any shaders it is difficult to make the height map look like water.

I scroll the water texture against time to give it some feel, and I calculate the vertex colour based on height, but it’s still not good enough.

Any ideas?

4 Replies

Please log in or register to post a reply.

6837d514b487de395be51432d9cdd078
0
TheNut 179 Mar 19, 2013 at 11:48

Instead of using the sin function, try using fBm noise. It’s a bit expensive to calculate each frame, so if your target hardware can’t do this in real-time, you could always just pre-compute them into a seamless animation cycle in memory and then apply that to the verts at runtime.

A638aa42130293f319eda7fa4ba121f4
0
fireside 141 Mar 19, 2013 at 12:57

Need to look at a video. The waves lines converge. Waves don’t converge. Well, they probably do, but not that soon. You might need to blur the back ones or something. I have an ocean view on windows 8 and you cant even see the wave lines, they just look randomly choppy. The lines will almost always become horizontal in the far background.
p86i6.jpg

B20d81438814b6ba7da7ff8eb502d039
0
Vilem_Otte 117 Mar 19, 2013 at 13:58

Huh… what about precomputing sequence of height fields like in Tessendorf’s paper on ocean. I will also post some ideas on how could you render water, but right now I must go to shop, because I’m very hungry :D.

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Mar 19, 2013 at 17:38

@fireside

Water behaves a lot differently in the deep ocean, that view above is close to land and displays many characteristics of shallow water.

I read Tessendorf’s paper, and decided it was over complex for what I need, the water animation looks good, it’s just the rendering that’s crap.

This is the sort of thing I want to end up with.

1027322620\_f638092db2\_z.jpg