Procedural ocean

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

Moderators: phlip, Moderators General, Prelates

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

Procedural ocean

Postby Ptolom » Fri Dec 10, 2010 5:29 pm UTC

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.

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

Re: Procedural ocean

Postby bocochoco » Fri Dec 10, 2010 7:35 pm UTC

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.


What about this perlin noise function?
Image

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

Re: Procedural ocean

Postby Ptolom » Fri Dec 10, 2010 7:46 pm UTC

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

Postby anselm_eickhoff » Mon Dec 13, 2010 5:40 pm UTC

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)

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

Re: Procedural ocean

Postby Ptolom » Mon Dec 13, 2010 6:36 pm UTC

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

Postby Moose Hole » Mon Dec 13, 2010 7:09 pm UTC

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

Postby anselm_eickhoff » Mon Dec 13, 2010 7:33 pm UTC

Glad I could help.

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 ;)

User avatar
Amnesiasoft
Posts: 2573
Joined: Tue May 15, 2007 4:28 am UTC
Location: Colorado
Contact:

Re: Procedural ocean

Postby Amnesiasoft » Tue Dec 14, 2010 10:05 pm UTC

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.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 3 guests