How does minecraft render water? Is it possible in godot

Godot Version

v4.2.2.stable.official [15073afe3]

Question

I’m working on a voxel game and need to be able to render water similar to how minecraft does it, where the blocks behind one are discarded.

To my understanding Bedrock edition renders all the water in one pass, opaque and then blends it but I also have no clue how to do that.

Images for demo
Imgur
Imgur

Tommorow morning I’ll try adding another layer to each chunk for transparent blocks, i’ll post update here

Thanks For Share This Blog !!

I’m not sure how Minecraft does it in their backend, but maybe this will be of some help: Occlusion culling — Godot Engine (4.2) documentation in English

It seems the basic principle of the idea is to hide certain objects once they’re out of the player’s view. It’s most used for opaque models, like walls, but I could see it potentially being used for more translucent objects like water. I’ve not touched occlusion yet in my project though, so all I know is what I’ve heard in passing.

Also, I provided the 4.2 version of the documentation because that’s what your post says you were on. But since you posted this before the 4.3 update, you might have updated since then. Here’s the latest doc: Occlusion culling — Godot Engine (stable) documentation in English

1 Like

I don’t know how any of this works but I’m aware Viewports exist - Using Viewports — Godot Engine (stable) documentation in English

You might be able to use a second Viewport to draw only the water (opaquely) and then transluscently overlay that Viewport on top of the main Viewport. This would only work if:

  • The water occlusion culls itself on Viewport 2
  • The non water occlusion culls water on Viewport 2
  • The non water does not draw on Viewport 2
  • The water does not occlusion cull or draw itself on Viewport 1

I have no idea if these conditions are possible all together. If you can have water occlusion cull itself (but not non-water) anyway, without a second Viewport, as @WannaKnowMorePls suggested, then that would be better.

its all about SubViewport node and its SubViewport.get_texture() method.
You may create a scene with moving lines and subviewport renders texture from it