Rendering boats with Simple Water

Hello, I will soon need to add boats to a game I am working on. There will be water applied to a custom mesh with the Simple water system already in JME. The issue is that the bottom halfish of the boats (that players can walk inside) will be under this water. I do not want the water border to appear inside the boats. I originally thought this could be accomplished by simply not rendering water on any pixels where a boat will be rendered. But, this will cause issues when someone looks at the boat externally (or looks at an external part of the boat from some location on the boat). Even if this would work, I would have no idea how to implement it. I can’t simply not render water when a player is in a room that can see the water layer since the boats are effectively randomly generated by an external program and may contain windows that allow the water border to be visible.

I assume that I am not the first person to want to add explorable boats to a JME game. As such, I would like to know of a good method that would allow these boats to be rendered correctly without causing significant performance issues.

Don’t take my word 100% on this, but I don’t think there is a way to do this with the Simple Water system. I haven’t looked, but there might be a more advanced water system out there. And if not, it would most definitely be an interesting thing to make. Water simulation with physics support… that’s going to be one heck of an adventure.

Hm but you can only be in one boat at the same time?
So advanced water could work, it can do some shapes instead of infinite plane.

Here is some older stuff related to that

Does not classic hack with fully transparent cover for top of a boat work?

The physics part of it (ie. moving the boat around) isn’t difficult. I’ve already worked out how to do that. Rendering is where I’m stuck. I can’t use the advanced SeaMonkey filter since I need to have the lakes be arbitrary shape and size and it should also render correctly for vertical faces.

That is correct, the player can only be in one boat. There will be multiple boats though and I need it to look correct if a point on another boat is below the water line and is visible from outside said boat.

That link is very interesting. I considered modifying the SeaMonkey filter myself but I couldn’t find any documentation on how exactly filters are implemented in JME/OpenGL. Are you aware of any such documentation?

I’m not aware of any such hack. Could you elaborate?

Hack is implemented on geometry level - you add fully transparent surface fully enclosing all gaps where unwanted water could be seen and in a such manner that camera can’t get below this surface. I’m not sure if it will help in your particular situation though.

It won’t help since players can go below that surface. Also, the boats are effectively randomly generated so determining such a surface would be very difficult.

But that means that player head is almost below water level as well and in this case you could disable water filter completely for him.

As long it’s not a noise that is used to generate parts of a boat you should have all the required data to generate such a surface along boat generation.

It simply should be a bit above highest water level and I hope you know what water level is highest for your boat in normal conditions.

And be creative :chimpanzee_winktongue:

It’s important that however I choose to render works with every possible boat (below a certain as yet undetermined size). I’m not just saying this so I can be thorough, but since it is very likely that this game will end up having to render very oddly shaped boats.

The above diagram shows one particularly difficult example. I suspect that if something can render a few boats like this in a single scene that it would be sufficient for my purposes. There is a player who’s head is at the water line (the same holds true if a player’s head is below the water line). As such, they will either see the boat as if they are underwater or as if the boat is actually a pool. Even if I managed to somehow get the actual boat to be empty, there is a window that they must see through correctly as well.

Oh, well, if you want to have submerged windows - I’m out from this thread. Wish you good luck and some calming pills - you’ll need a lot of them on this path. :chimpanzee_lobotized:

Even without the windows players can punch holes in the sides of the ship. If you can come up with a good solution that works without the windows it would at least serve as a starting point.

Looks like you’ll have to regenerate the water geometry every time the boat moves… or find compromises in your requirements.

What is the best way to regenerate the water geometry then (ie. without lagging the player to a significant degree).

Also, to explain why I have such requirements I’ll give some more details about how this will be used. The game allows players to build their own buildings out of a variety of materials (ie. wood, stone, glass, etc.) and I would like boats to be buildable as well. The player is this “external program” I mentioned in the OP.

Hole in a side means water coming in if below water level. And anything above water level is not important as being on water level you can’t see water through hole above water level.

And as long there are no holes below water level you could just disable water filter completely as long as two conditions are met:

  1. player is inside a ship
  2. player head is below water level

And while player head is above water level you could just rely on hack I described before.

Hardest thing will be if boat could look like this and you have no means to detect if player is really inside or outside right now

The boat could look like anything since they are player built.

Perhaps I could somehow disable the water rendering if it is in a cube and have a secondary water geometry that moves with the boat that is recalculated upon the boat being changed. Is there some way to tell the SimpleWaterRenderer (or the SeaMonkey filter) to not render water inside a rectangular prism?

Throwing an idea into the mix… make a big water plane, cut out a boat shape hole in the middle, put the boat in the hole, move the water plane with the boat and tweak the shader use world uv mapping rather than local, so the water textures will not move with the boat.

I know its not the solution, but it may spark an idea in someone else’s head.

This is certainly interesting but the lakes/oceans are of arbitrary shape and size (they can be player built as well :/) and there can be multiple boats.

Sorry, but I finally withdraw from this thread… Your project is thousand times harder to implement than minecraft as it’s actually minecraft mixed with water and proper water is not that simple. Have fun.