Procedural ocean

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

Ptolom
Posts: 1559
Joined: Mon Mar 24, 2008 1:55 pm UTC
Location: The entropy pool
Contact:

Procedural ocean

For a game I'm making I need a function which can draw the ocean which varies depending on the weather. The thing is it also has to fit in with the top-down pixel art of the rest of the game. I've been puzzling over this for a while but I can't think of a way of doing it.

The closest I've got, by playing with gimp filters, is to randomise the value of all the pixels, blur, apply perlin noise over the top and then displace everything according to a sine wave across the picture. But I have no idea how to animate that. Does anybody have any idea how I could go about this? The other thing is I'm struggling with writing a suitable noise function.

bocochoco
Posts: 317
Joined: Thu Aug 06, 2009 8:22 pm UTC

Re: Procedural ocean

Ptolom wrote:For a game I'm making I need a function which can draw the ocean which varies depending on the weather. The thing is it also has to fit in with the top-down pixel art of the rest of the game. I've been puzzling over this for a while but I can't think of a way of doing it.

The closest I've got, by playing with gimp filters, is to randomise the value of all the pixels, blur, apply perlin noise over the top and then displace everything according to a sine wave across the picture. But I have no idea how to animate that. Does anybody have any idea how I could go about this? The other thing is I'm struggling with writing a suitable noise function.

Ptolom
Posts: 1559
Joined: Mon Mar 24, 2008 1:55 pm UTC
Location: The entropy pool
Contact:

Re: Procedural ocean

That looks pretty good. I'll see about translating it into C.

anselm_eickhoff
Posts: 13
Joined: Mon Dec 13, 2010 4:49 pm UTC

Re: Procedural ocean

Maybe you can implement some kind of bumpmapping:

Draw a tiling bumpmap of one or several waves.
Then apply this bumpmap to a blue surface (some kind of primitive shading).
It could be overlayed with smaller "raindrop" bumpmaps, when it rains.
Maybe add some noise over that as well.

As of animation I would suggest the following:
1. Moving the tiled wave pattern (obvious)
2. Interpolation of the bumpmap strength from 1 to -1 (resulting in rising and sinking waves)

Movement speed and angle and Interpolation speed could be different for different wind speeds/angles.

All that in your pixel-art style of course.

(might be overkill)

Ptolom
Posts: 1559
Joined: Mon Mar 24, 2008 1:55 pm UTC
Location: The entropy pool
Contact:

Re: Procedural ocean

Now that is a cunning idea, and it doesn't involve animated noise which I can't find a way of doing. In fact I could just use an image file as a noise texture and you wouldn't be able to tell with the distortion from the bump map. I like it, thank you.
The whole thing is overkill of course, but it's my project and I'm going to waste as much time as I want on it.

Moose Hole
Posts: 398
Joined: Fri Jul 09, 2010 1:34 pm UTC

Re: Procedural ocean

Don't forget to have dolphins jumping all over the place and shark fins and frickin' lasers.

anselm_eickhoff
Posts: 13
Joined: Mon Dec 13, 2010 4:49 pm UTC

Re: Procedural ocean

Ptolom wrote:The whole thing is overkill of course, but it's my project and I'm going to waste as much time as I want on it.

That is the right attitude! Looking forward to it something implemented

Amnesiasoft
Posts: 2573
Joined: Tue May 15, 2007 4:28 am UTC
Contact:

Re: Procedural ocean

Ptolom wrote:Now that is a cunning idea, and it doesn't involve animated noise which I can't find a way of doing.

All you need to do for animated noise is to add a dimension to it. If you had 2D noise, move to 3D and use the third dimension as time.