Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.66k stars 249 forks source link

Implement Transparent/Translucent Voxels #69

Open zauberparacelsus opened 5 years ago

zauberparacelsus commented 5 years ago

One useful feature to have would be support for voxels that are transparent, translucent, etc. So, I'm creating an issue report for it.

In the context of implementing the geometry generation, it would be relatively simple. The mesh for opaque voxels would produce surface geometry along where opaque voxels border either transparent or empty voxels (instead of only empty voxels). As well, transparent voxels of differing materials (eg: water, ice, crystal, etc.) would generate as separate meshes.

In the context of rendering, that's a bit out of my ballpark.

TokisanGames commented 5 years ago

Blocky Voxels already support multiple materials. Godot supports translucent materials. See #66.

What else does this issue bring up that is not already supported?

zauberparacelsus commented 5 years ago

@tinmanjuggernaut The main issue is what I highlighted in the middle paragraph, the need for making sure that opaque voxels remain solid when viewed through a transparent section of mesh.

The image below demonstrates what I'm talking about:

8a7084fe9a468bbd4bff68d7cc67d458

Both spheres are the same: each is divided in half, with one half being opaque and the other being transparent. But the one on the right has an extra face against the transparent half, so that it is solid.

Zylann commented 5 years ago

It looks like this is exclusively for smooth voxels, since blocky meshing supports this already (see https://github.com/Zylann/godot_voxel/issues/66#issuecomment-530088499).

It could be interesting to use the TYPE channel in such a way cell polygonization would append geometry to different surfaces of the mesh, like the blocky mesher does. That would basically implement multimaterials (without blending of course). I'm just not sure how to handle face culling at the boundary of two different types of surfaces. A super naive way to do this would be to run the meshing as many times as there are materials, resulting in independent volumes but not cleanly connected and without face culling between them...

I'm also not sure about the consequence on edition, considering that a single voxel cannot have multiple materials.

I also realise that on your screenshot with the two spheres, you are showing a clean, sharp separation between the two parts. But marching cubes or transvoxel can't represent sharp features, so it's likely the result won't be as clean.