OceanMonkey Update

Greetings,

I continued to work on the oceanMonkey prototype and made some progress:

[video]oceanMonkey Techdemo - YouTube

As this is open source the code is available at sourceforge

The water trail of the ship is a cool solution: In a given interval the ship will create a trail point at its current location which results in a little point chain behind it.

These points will fade out over time (like a particle). If they are faded out they are removed again. This array of points is given to the fragment shader. For every fragment the shader checks if it is near a trail point. If yes it will blend in the foam texture. The nearer it is to a point the stronger the blending will happen.

As we don’t have to manage additional textures or geometry for the water trail the solution is extremely effective and cheap.

One interesting question is left: How many points can be given to the shader in every frame? If we have 10 ships and every ship has, let say, 20 trail points we have to pass a vector with 200 points every frame to the GPU. I’m not familiar enough with OpenGL to say if this a wise idea or not. We’ll see.

The physic behaviour of the ship is inspired by huskys work: http://hub.jmonkeyengine.org/forum/topic/buoyancycontrol-code-to-be-used-with-projectedgrid/

So what’s next? I’ll have to improve the collision detection because it is a simple brute force attempt: Currently I just search the whole mesh for the triangle that collides with a given point. As every ship will have at least 8 collision points (and the mesh has several ten thousands of tris) we have hundreds of thousands loop steps for every ship.

to improve the finding I’ll have to determine the index of the tri by using the position of the point I want to check (with some wired math you can calculate an index out of the X- and Z-coords of the point). This is very tricky as the triangles are moving around so you can never say where a triangle is. But if this works the collision detection will be like a hundred times faster.

And now I’ll go to bed…

ceiphren

16 Likes

Looks totally awesome! Great work!

I loved it ! also the technical speak is great :slight_smile: Keep up with this great work! :slight_smile:

This is a sexier looking shader away from being nearly on-level with nvidia gameworks. Good job!
Or at a push you could just make it dark blue instead of gray, that’d work. I know water isn’t really blue, but in games it looks so much better when it’s blue.

Fellow monkeys,it is done. The collision detection is now fast enough to enable a whole fleet on the sea. Fortunately the first idea worked so I hadn’t to bump my head on the keyboard until it works (nethertheless I killed a keyboard last weekend so it doesn’t matter anyway).

Some measurements gave me the following results:
Average runtime of old collision detection: 0.20ms (minimum:0.016,maximum 0.3)
Average runtime of new version: 0.005ms (minimum: 0.003,maximum 0.009).

Currently a ship has 8-10 collision points which means two dozen ships can easily be added (which is quite a few). Also it turned out that it is not necessary to calculate the collision in every frame.

Now I need a ideas for shorelines and sunray reflections.

@fabsterpal: The color can be changed in runtime. So you can colorize it in any way you want and change it when the scenery is changing (like, from a friendly blue to a scary dark red when entering a battle area)

2 Likes
@ceiphren said: Fellow monkeys,it is done. The collision detection is now fast enough to enable a whole fleet on the sea. Fortunately the first idea worked so I hadn't to bump my head on the keyboard until it works (nethertheless I killed a keyboard last weekend so it doesn't matter anyway).

Some measurements gave me the following results:
Average runtime of old collision detection: 0.20ms (minimum:0.016,maximum 0.3)
Average runtime of new version: 0.005ms (minimum: 0.003,maximum 0.009).

Currently a ship has 8-10 collision points which means two dozen ships can easily be added (which is quite a few). Also it turned out that it is not necessary to calculate the collision in every frame.

Now I need a ideas for shorelines and sunray reflections.

@fabsterpal: The color can be changed in runtime. So you can colorize it in any way you want and change it when the scenery is changing (like, from a friendly blue to a scary dark red when entering a battle area)

Perfect! You know, you could add some really cool advanced physics to it such as water pressure at X depth, apply implosion forces when it reaches Y pressure etc.

This is awesome … :slight_smile: Can not give you more thumb up and thank, I will definitely try it my self asap.

Wow I missed this post! awesome work @ceiphren.