# Looking for ideas for oceans

4 replies to this topic

### #1Stainless

Member

• Members
• 610 posts
• LocationSouthampton

Posted 19 March 2013 - 09:21 AM

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 here http://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?

### #2TheNut

Senior Member

• Moderators
• 1718 posts
• LocationCyberspace

Posted 19 March 2013 - 11:48 AM

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.
http://www.nutty.ca - Being a nut has its advantages.

### #3fireside

Senior Member

• Members
• 1618 posts

Posted 19 March 2013 - 12:57 PM

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.

Currently using Blender and Unity.

### #4Vilem Otte

Valued Member

• Members
• 362 posts

Posted 19 March 2013 - 01:58 PM

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 .
My blog about game development (and not just game development) - http://gameprogramme...y.blogspot.com/

If you don't know how to speed up application, go "roarrrrrr!", hit the compiler with the club and use -O3 :D

### #5Stainless

Member

• Members
• 610 posts
• LocationSouthampton

Posted 19 March 2013 - 05:38 PM

@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.

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users