Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.59k stars 244 forks source link

Multiple materials for smooth terrain (multiple surfaces) #104

Open blockspacer opened 4 years ago

blockspacer commented 4 years ago

Separate meshes may be useful if game needs to support large number of textures

May require transition meshes for seams between materials like in https://github.com/bw2012/UE4VoxelTerrain/wiki/Draft

Any ideas will be helpful (where to start with implementation?).

related to https://github.com/Zylann/godot_voxel/issues/69 https://github.com/Zylann/godot_voxel/issues/93

TokisanGames commented 4 years ago

This MIT UE4 plugin supports 255 textures. You might also look at this implementation. https://github.com/Phyronnaz/VoxelPlugin

Zylann commented 4 years ago

I thought Phyronnaz's plugin had 255 textures because 1) it uses texture arrays, and 2) because Unreal can make use of a deferred pipeline (so it can do things Godot can't). Texture arrays will definitely be the way to go, and it's also part of the Transvoxel approach. At least, that's what I was planning to do with this mesher.

It is possible to use a large amount of textures with a single material, but if a mesher needs to produce a mesh to be rendered with multiple materials, then it needs to output multiple surfaces. It then becomes obvious those won't blend. VoxelMesherBlocky does that, which allows opaque and transparent surfaces to exist within the same mesh. The only thing the mesher needs to do is to work with two sets of vertex arrays, or more depending on needs. The output struct has room for this.

The transvoxel mesher still has a bit of pending work though (and haven't finalized the depth branch yet). Also, I'm slowing down a bit now, I've been full steam on voxels for weeks but it's on my free time. Knowing myself it's going to stop for a while before the next sprint :p

Edit: another issue I have currently with the transvoxel mesher is that to handle seams between blocks of different LOD I had to use the COLOR attribute completely, which leaves very little room for any texturing information, because Godot's renderer hardcodes available attributes. It is possible that the first attempt at texturing from voxel data will be relatively limited, and won't be the only one (just see how many shaders I had to develop for the heightmap plugin xD) so this is a lot less trivial than it was for blocky meshers.