Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.51k stars 236 forks source link

Question: Enclosing and texturing underneath isosurface when using transvoxels #647

Open Ladvien opened 1 month ago

Ladvien commented 1 month ago

When applicable, please describe your setup:

To kick it off, thanks to Zylann and all contributors for such a well put together voxel toolset. I'm a data engineer by trade, so I don't know the game dev world, but I do know good OSS when I set it. Great work! And much gratitude.

With that, I hope I've a simple question. Do you have a recommended way to texture the area below the isosurface when using transvoxels?

Specifically, the area highlighted red in the screenshot. The goal is make the under side of the isosurface look like an enclosed volume, textured to look like a cross-section of undug earth. diggin_skelly

I don't need fine details, but was curious if someone had a recommended route?

Zylann commented 1 month ago

The module doesn't have that feature, and there is no plan to have it. If your camera is looking through meshes, they will be cutoff, and there is no quick way to fill that section the same way the rest of the mesh is generated.

I'm not sure if there is an easy way to do this. It seems that you'd have to implement a custom meshing algorithm (which requires modifying the module or write your own mesher in your own module), where the side would have to use marching squares to be filled in. But that's a lot of work. I wonder if exploiting the background with a shader could work rather than trying to make a mesh that fits exactly, but you'd have to differenciate that from the sky... You could change the generator to actually produce air such that there would be no mesh crossing near the camera, instead there would really be an infinite "gap" through the world that exists just to see through the side. That would probably not be perfect since Transvoxel cannot render sharp corners so the ledge would not be a sharp cut. This would exploit the fact your game has apparently 2D gameplay. But if not, you're stuck with the complex problem.

Ladvien commented 1 month ago

Hey Zylann,

Wow, thanks for the wicked fast reply.

Ah, understood. Yeah, I'm pursuing destructable terrain in fairly controlled viewport for more casual gaming.

I'm not sure if there is an easy way to do this. It seems that you'd have to implement a custom meshing algorithm (which requires modifying the module or write your own mesher in your own module), where the side would have to use marching squares to be filled in. But that's a lot of work.

Meh. I've been looking for an excuse to march some squares. We'll see if I've the time.

Think this would be of interest to anyone else? Or think I'm alone out here?

I wonder if exploiting the background with a shader could work rather than trying to make a mesh that fits exactly, but you'd have to differenciate that from the sky...

That was my first kludge thought, but couldn't think of a good way to execute that'd looked polished. I'll explore it a bit.

You could change the generator to actually produce air such that there would be no mesh crossing near the camera, instead there would really be an infinite "gap" through the world that exists just to see through the side. That would probably not be perfect since Transvoxel cannot render sharp corners so the ledge would not be a sharp cut. This would exploit the fact your game has apparently 2D gameplay. But if not, you're stuck with the complex problem.

Clever. Going to play with this idea a bit.

Ultimately, I'd like to find something that isn't too fragile, looks good, and keeps the brilliant fast nature of the transvoxel implementation you already have. I don't know etiquette for this repo--feel free to close this, but if ok, I'll report back in the thread if I find a solution.

And once again, thanks for the brilliant module!