Page 1 of 1

Boat on the water

Posted: Mon Jul 07, 2025 6:16 pm
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?


Re: Boat on the water

Posted: Tue Jul 08, 2025 12:48 pm
by sercero

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


Re: Boat on the water

Posted: Tue Jul 08, 2025 12:57 pm
by slapin

Of course I will if I survive...


Re: Boat on the water

Posted: Tue Jul 08, 2025 1:33 pm
by paroj

enable depth-testing for the water surface?


Re: Boat on the water

Posted: Tue Jul 08, 2025 2:12 pm
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.


Re: Boat on the water

Posted: Tue Jul 08, 2025 2:43 pm
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


Re: Boat on the water

Posted: Tue Jul 08, 2025 9:23 pm
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...


Re: Boat on the water

Posted: Tue Jul 08, 2025 9:32 pm
by paroj

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


Re: Boat on the water

Posted: Tue Jul 08, 2025 9:32 pm
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...


Re: Boat on the water

Posted: Tue Jul 08, 2025 9:34 pm
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.


Re: Boat on the water

Posted: Tue Jul 08, 2025 10:16 pm
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.


Re: Boat on the water

Posted: Wed Jul 09, 2025 10:41 am
by paroj

Re: Boat on the water

Posted: Wed Jul 09, 2025 6:13 pm
by rpgplayerrobin

You can also check this:


Re: Boat on the water

Posted: Thu Jul 10, 2025 9:55 am
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...


Re: Boat on the water

Posted: Thu Jul 10, 2025 4:09 pm
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);

Re: Boat on the water

Posted: Thu Jul 10, 2025 7:05 pm
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...


Re: Boat on the water

Posted: Thu Jul 10, 2025 9:16 pm
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).


Re: Boat on the water

Posted: Fri Jul 11, 2025 8:42 am
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?


Re: Boat on the water

Posted: Fri Jul 11, 2025 12:46 pm
by rpgplayerrobin

Yeah!