Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.68k stars 251 forks source link

VoxelGeneratorMultipassCB suggestions #700

Open Shadowblitz16 opened 1 month ago

Shadowblitz16 commented 1 month ago

Is your feature request related to a problem? Please describe. I have tried writing my generation in the voxel graph but I am not very good at it.

As we now have VoxelGeneratorMultipassCB I was thinking about maybe something like starbound's terrain and biome generation could be done.

Describe the solution you'd like Idk how to say this but basically it's defining generation from a array of resource files

here is an example

{
  "name" : "normalCaves",

  "type" : "minmax",
  "sources" : [
    //stringy karst caves
    {
      "type" : "karstcave",

      "layerResolution" : 15,
      "layerDensity" : 0.07,

      "layerHeightVariation" : {
        "type" : "perlin",
        "octaves" : 2,
        "frequency" : 0.009,
        "amplitude" : 60
      },
      "bufferHeight" : 50,

      "caveDecision" : {
        "type" : "perlin",
        "octaves" : 2,
        "frequency" : 0.01,
        "amplitude" : 1,
        "bias" : 0
      },
      "caveTaperPoint" : 0.08,

      "caveHeightVariation" : {
        "type" : "perlin",
        "octaves" : 2,
        "frequency" : 0.032,
        "amplitude" : 24,
        "bias" : 10
      },

      "caveFloorVariation" : {
        "type" : "perlin",
        "octaves" : 2,
        "frequency" : 0.1,
        "amplitude" : 4,
        "bias" : -2
      }
    }
    ,
    //larger karst chambers
    {
      "type" : "karstcave",

      "layerResolution" : 27,
      "layerDensity" : 0.04,

      "layerHeightVariation" : {
        "type" : "perlin",
        "octaves" : 2,
        "frequency" : 0.009,
        "amplitude" : 30
      },
      "bufferHeight" : 50,

      "caveDecision" : {
        "type" : "perlin",
        "octaves" : 2,
        "frequency" : 0.012,
        "amplitude" : 2.4,
        "bias" : -0.9
      },
      "caveTaperPoint" : 0.5,

      "caveHeightVariation" : {
        "type" : "perlin",
        "octaves" : 2,
        "frequency" : 0.05,
        "amplitude" : 24,
        "bias" : 38
      },

      "caveFloorVariation" : {
        "type" : "perlin",
        "octaves" : 2,
        "frequency" : 0.08,
        "amplitude" : 8,
        "bias" : -14
      }
    }
    ,
    //worm caves
    {
      "type" : "displacement",
      "xType" : "perlin",
      "xOctaves" : 1,
      "xFreq" : 0.05,
      "xAmp" : 2,
      "xXInfluence" : 0.2,
      "yType" : "perlin",
      "yOctaves" : 1,
      "yFreq" : 0.05,
      "yAmp" : 2,
      "yYInfluence" : 0.5,

      "source" : {
        "type" : "wormcave",

        "sectorSize" : 64,
        "sectorRadius" : 2,
        "numberOfWormsPerSectorRange" : [0.7, 0.7],
        "wormSpeed" : 1.0,

        "wormSizeRange" : [5, 8],
        "wormLengthRange" : [80, 120],
        "wormTaperDistance" : 15,
        "wormAngleRange" : [0, 6.283],
        "wormTurnChance" : 0.2,
        "wormTurnRate" : 0.08
      }
    }
  ]
}

It could be made more generic but the idea is the same. Instead of defining generation in a graph or in a script we would be able to define generation in a resource files with support for combining and multipass.

Describe alternatives you've considered Nothing idk if its a good idea It just seems easier and more flexable for a modding api.

Additional context If you don't understand what I mean tell me so I can try to explain better. I think that's why most of my issues get closed or downvoted because people don't see the same idea in their head as me.

Zylann commented 1 month ago

That sounds quite similar to a graph with specific operations, laid out in a JSON file instead of a node editor, and more high level.

VoxelGeneratorScript and VoxelGeneratorMultipassCB are actually meant for you to implement such system on top of them. Simply because there are infinite ways in which to make a system like this. I don't place my module to that level, at least not yet. If someone can come up with one that implements this, it could be re-use if it's versatile enough and enough people find it useful for different projects. Though of course, a challenge being, that it would end up very dependent on implementation choices that would either have to be "opinionated" for a particular game idea, or have lots and lots of options and sliders of varying clarity that would have to be maintained for everyone wanting to use X or Y in their game.

I don't have time to work on something like that right now (as many other things, as I can only focus on specific things when I get enough brain time, seems like there have been lots of open issues/questions recently), and I think something like that may have to be implemented on top of the existing system first, but I guess that's something to consider eventually.