godot_voxel icon indicating copy to clipboard operation
godot_voxel copied to clipboard

Implement Fluid Support

Open zauberparacelsus opened this issue 4 years ago • 8 comments

This is probably going to come up as a feature request at some point (if it hasn't already), so I'm going to create an issue page for it so that it implementation details and potential problems can be discussed.

Would probably depend on #69

zauberparacelsus avatar Sep 21 '19 17:09 zauberparacelsus

I don't play minecraft, so what does fluid support mean and what does it look like?

TokisanGames avatar Sep 21 '19 20:09 TokisanGames

Okay yeah, the original post was vague. To clarify, I was mainly referring to support for a liquid flowing mechanic.

Details on how fluids spread in minecraft can be found here: https://minecraft.gamepedia.com/Liquid#Spread

But to summarize: Water is divided between source blocks and flow blocks. Flow blocks will spread outward, preferring to flow downward if they can. If two or more source blocks are adjacent to a flow block, then the flow block is converted into a new source block.

zauberparacelsus avatar Sep 22 '19 01:09 zauberparacelsus

This is getting close to gameplay features so I'm not sure if that should be implemented directly in this module. There are countless features like that which could be implemented in various ways, I just don't feel they should be necessarily built-in. Also that fluid mechanic can only apply to blocky terrain, so as such it would not depend on #69.

Anyone is free to implement this, but I would like it to be doable with a minimal amount of changes so that it can be made modular and doable in different ways. Which means, it won't have to be built-in as "the only way to do fluids". It might even be doable from a script, as fluids are basically cellular-automata that read and write voxels.

Zylann avatar Sep 22 '19 15:09 Zylann

I've played a lot of minecraft. To implement something like the water in minecraft, a few things are necessary (which I'm not sure yet if this module supports):

  • Custom mesh voxels (water blocks sit a bit below other blocks height-wise)
  • Animated texture voxels (flowing water blocks have animated textures)
  • Transparent voxels (water is slightly transparent, allowing blocks behind it to be seen)

There might be other things I'm not aware of that would be required.

I've also played modded minecraft and some weird interactions with how water is drawn seem to indicate it is a difficult problem to solve (e.g. water sometimes draws over some in-game particle effects or UI textures)

voxelv avatar Mar 02 '20 07:03 voxelv

Custom mesh voxels (water blocks sit a bit below other blocks height-wise)

This is supported, although there is no "auto-tiling" to choose orientation or level, you need to handle that at the moment.

Animated texture voxels (flowing water blocks have animated textures)

Supported by giving those blocks a specific material (the amount is limited but you can find ways to re-use it, in Minecraft there is a material just for any kind of animated block).

Transparent voxels (water is slightly transparent, allowing blocks behind it to be seen)

Also supported, there is a transparent flag on Voxel to affect face culling. Then again, a material is needed.

water sometimes draws over some in-game particle effects or UI textures

That's a rendering problem, which is not specific to this module.

Zylann avatar Mar 02 '20 10:03 Zylann

This is supported ... Supported ... Also supported ...

WIth this information, I would argue that Minecraft-like fluid can be implemented project-side.

voxelv avatar May 12 '20 16:05 voxelv

The least obvious thing to implement is probably the fluid simulation itself. It can also be done project side since there is an API already to modify voxels, but it's unclear what extra requirements would arise depending on the game.

Zylann avatar May 12 '20 17:05 Zylann

I thought this was about smooth voxels and im not sure if this is a thing that has been done but physics based voxels that would rely on other solid voxels for positioning would be insane with the smooth generator, i dont know how it could be done and it would probably be too intensive to run anyway though

im gonna try to just make smooth voxel lakes that will be static and float if the land voxels are removed

spiro-angelakis avatar Dec 24 '21 01:12 spiro-angelakis