Download

Marching Cubes Material Problems

This is my first post on the forums (Hello! :D)

I am tinkering with Azanor#'s code for marching cubes terrain, but I am a bit confused with how I might go about adding materials to mesh on a marching cubes modeled procedural terrain. Currently, the entire terrain renders with one material which simply shifts between sand and stones based on each face’s normal Z direction (so, steep slopes have rock textures while flat plains have sand). I am trying to figure out how I would shift between multiple materials as I add the functionality for different types of voxels. So, here, I will describe what I know (or at least think I do) and what I am trying to accomplish, in hopes that someone more experienced than me sees a solution :slight_smile:

So, firstly, the mesh itself is stored in a VertexBuffer object, and really doesn’t support multiple materials. Would a different method be better than VertexBuffer? Well, assuming VertexBuffer is fine, here are some of the ways I have been researching on how to achieve multiple “textures” on my terrain, on a per-voxel basis:

  1. Using splat maps from data stored in vertex color, then alternating between textures. This would allow easy smoothing, but realistically limits me to only four different textures, which is a limitation I would rather avoid if possible.

  2. Using a splat map(s) stored separately from the actual vertex data, such as directly referencing the voxel data. My concern with this is lag. In addition, I don’t think you can call C++ functions from a material blueprint, can you?

  3. Separating each material into a different VertexBuffer and applying each VertexBuffer’s material accordingly. This obviously removes the limitation of four textures, but there are a few concerns I have about it. Firstly, it seems like it would be more difficult to smooth between textures, each texture being on a completely different mesh. Also, wouldn’t increasing the number of VertexBuffers increase resource usage, possibly leading to lag in the future?

  4. Rendering each “block” separately. I know this is a terrible solution because it would cause a lot of unnecessary lag, without fixing the problem of smoothing between textures.

So, really what I am looking for is a way that:

  • Has the ability to smooth between textures (no flat borders)
  • Doesn’t have a ridiculously small material limit

I’m not asking for any full solutions, just resources/tips to point me in the right direction, or however much you want to type. Thanks!