Boat on the water

Problems building or running the engine, queries about how to use features etc.
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Boat on the water

Post by slapin »

Hi, all!
How could I render boat on the water so that there is no water seen inside the boat, in most efficient way?

User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 535
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 198

Re: Boat on the water

Post by sercero »

I don't know, but boy you better show us your game afte all these questions :lol:

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: Boat on the water

Post by slapin »

Of course I will if I survive...

paroj
OGRE Team Member
OGRE Team Member
Posts: 2238
Joined: Sun Mar 30, 2014 2:51 pm
x 1217

Re: Boat on the water

Post by paroj »

enable depth-testing for the water surface?

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: Boat on the water

Post by slapin »

Could you please elaborate? Is there some sample? I have depth enabled for all materials. Or did you mean disable depth test for boat? That does have some unwanted effects of it being in front of everything.

paroj
OGRE Team Member
OGRE Team Member
Posts: 2238
Joined: Sun Mar 30, 2014 2:51 pm
x 1217

Re: Boat on the water

Post by paroj »

it is not as easy as I initially thought, you also need some proxy geometry. But the idea is as outlined here:
https://www.minecraftforum.net/forums/m ... -in-1-9-mc

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: Boat on the water

Post by slapin »

Well, I don't really know how to do depth-only rendering in Ogre yet, but it looks like I need draw "cover" of the boat and draw it depth-only. This can be sub-After that I render the boat normally. Both things should render together though... Another advices I got to draw bottom as parallax mapping texture on flat surface and projection decal, but that excludes possibility for something to be in boat, and stencil rendering which I don't know how to approach yet...
All these solutions produce various side effects and limitations, like "cover" approach prevents anything to be in boat, i.e. the sailor sitting on boat's bench will have legs cut off. Needs lots of thinking...

paroj
OGRE Team Member
OGRE Team Member
Posts: 2238
Joined: Sun Mar 30, 2014 2:51 pm
x 1217

Re: Boat on the water

Post by paroj »

just draw the cover after the sailor, but before the water

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: Boat on the water

Post by slapin »

In Godot I solved this my moving some vertices close to camera after projection is applied, but that requires lots of dark magic in preparation.
And that requires doing everything manually... Another approach would be scene reading plane, the same approach as with water refraction - render boat into render target and add plane on main scene which will show boat and what is inside, being cut off on the bottom, and draw full scene on the main camera with that plane. This way the plane will show cut parts and bottom of the boat, and all parts above board tops will render normally. But that is sick and expensive...

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: Boat on the water

Post by slapin »

paroj wrote: Tue Jul 08, 2025 9:32 pm

just draw the cover after the sailor, but before the water

The cover will cut legs of the sailor unless rendering order is implemented.

Last edited by slapin on Tue Jul 08, 2025 10:20 pm, edited 1 time in total.
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: Boat on the water

Post by slapin »

Ah, I see some perspective. Now I have only 2 questions.

  1. How to do depth-only rendering?
  2. How to control render ordering of some entities?

I use OgreBites render loop.

rpgplayerrobin
Orc Shaman
Posts: 788
Joined: Wed Mar 18, 2009 3:03 am
x 447

Re: Boat on the water

Post by rpgplayerrobin »

You can also check this:

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: Boat on the water

Post by slapin »

rpgplayerrobin wrote: Wed Jul 09, 2025 6:13 pm

You can also check this:

Yeah, thanks, been reading this. It depends on render order which becomes complicated in my case. And when it comes to render ordering in Ogre, my brain explodes. People advice me different approach - have small chunk of water attached to boat and render that on top of water while maintaining holes in main water and make sure boats never meet... I'm going insane...

rpgplayerrobin
Orc Shaman
Posts: 788
Joined: Wed Mar 18, 2009 3:03 am
x 447

Re: Boat on the water

Post by rpgplayerrobin »

I would try it by using this compositor (which overrides the default rendering of your game):

Code: Select all

compositor BoatWaterFix
{
    technique
    {
        target_output
        {
            // Step 1: Clear buffers
            pass clear
            {
            }

        // Step 2: Render full scene before water (terrain, props, etc.)
        pass render_scene
        {
            first_render_queue 0
            last_render_queue 51
        }

        // Step 3: Render boat lids with color write disabled (which should be set in the material of the boat lids)
        // This assumes boat lids are assigned to render_queue 52
        pass render_scene
        {
            first_render_queue 52
            last_render_queue 52
        }

        // Step 4: Render water normally (will be clipped by depth)
        // This assumes the water is assigned to render_queue 60
        pass render_scene
        {
            first_render_queue 60
            last_render_queue 60
        }
    }
}
}

And here is how you add it in the code to be used

Code: Select all

Ogre::CompositorManager::getSingleton().addCompositor(viewport, "BoatWaterFix");
Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, "BoatWaterFix", true);
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: Boat on the water

Post by slapin »

Thanks a lot for explanation, I learn every day!

I have quite complex rendering:

  1. I have 4 viewports on one texture (Reflection, Refraction, ReflectionDepth, RefractionDepth) which render scene except water with cutoff planes
    (with sumewhat buggy result but that is another story)
  2. To main camera I render the scene with water.

The scene contains: Terrain and stuff on it (some under water some above water),
boats with varying complexity, NPCs, player character. NPCs can be anywhere. The question is how can I properly put stuff into render queues
to not make it into too manual job which will quickly become a mess...

rpgplayerrobin
Orc Shaman
Posts: 788
Joined: Wed Mar 18, 2009 3:03 am
x 447

Re: Boat on the water

Post by rpgplayerrobin »

You would only have to assign the boat lids and the water to a render queue I think?
Because the default render queue is 50.

It depends of course, but that would be the first step to see if more issues happens later on with the more advanced features of the water (like refraction as you mentioned).

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: Boat on the water

Post by slapin »

Thanks a lot for all the information.
Does it mean that I can assign lids to queue 52 and water to queue 60 and set up compositor?

rpgplayerrobin
Orc Shaman
Posts: 788
Joined: Wed Mar 18, 2009 3:03 am
x 447

Re: Boat on the water

Post by rpgplayerrobin »

Yeah!