Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Layered Generator #340

Open
4 tasks done
astrsh opened this issue Jul 10, 2022 · 3 comments
Open
4 tasks done

[Feature] Layered Generator #340

astrsh opened this issue Jul 10, 2022 · 3 comments
Assignees
Labels
Platform: All Issue/PR is applicable to all platforms. Status: Accepted Issue/PR is accepted. Subsystem: Generation Issue/PR has to do with all other generation subsystems. Type: Enhancement A request for a new feature or enhancement to be added.

Comments

@astrsh
Copy link
Member

astrsh commented Jul 10, 2022

Pre-Request Checklist

  • I have checked that I am on the latest version of Terra.
  • I have searched github for similar features requests, including closed
    ones, and found none.
  • I believe this is within the scope of Terra.
  • This feature request is for all of Terra, and isn't something that
    should be implemented by a pack or addon.

Feature Description

A generator that generalizes terrain, carving, and ocean, referred to as 'layers'. These layers and their generation behaviour would be config defined rather than hardcoded by the generator.

What Problem Does This Solve?

Adding new aspects of generation to a pack such as aquifers is difficult to do properly without code changes to facilitate it. Data driven generation layers should provide the functionality required for such aspects, and is also in line with the Terra design philosophy, such that concepts like 'ocean' and 'carving' are not hard coded in.

A Solution You'd Like

  • Pack defined generation 'layers'

  • A layer consists of block palette(s) distributed in some way, e.g via sampler:

    • These block palettes and distribution may be determined within the layer definition.

    • In addition individual biomes may define their own specific palettes and or samplers for a layer.

    • Whether a biome or the layer itself determines these parameters could be dependent on what the layer specifies:

      Default palettes and or distribution would optionally be determined within the layer definition, otherwise if not
      specified then biomes would be required to define palettes and distribution for the relevant layers.

      Biome specific palettes and or distribution config keys would dynamically be registered similar to keys under features.

      A layer palette would be analogous to the palettes key, and distribution would be analogous to the parameters under
      terrain.

  • Layers could also determine sampling and interpolation behaviour: see New generation config #126.

  • The way each layer generates would be determined by some kind of pack defined logic, e.g a binary decision diagram based on each layer's distribution.

    For the layers terrain, ocean and carving, the gen logic would be something like the following:

    if terrain
      if carving
        place carving palette (e.g air)
      else
        place terrain palette
    else
      if ocean
        place ocean palette
    else
      some other behaviour, or no op
    

Alternative Solutions

The best alternative available right now would be using features to generate things like aquifers, and underground lava oceans, however doing it that way lacks advantages of this generator such as control over interpolation and sampling, more control over initial chunk generation, etc..

@astrsh astrsh added Type: Enhancement A request for a new feature or enhancement to be added. Status: Pending Issue/PR is currently awaiting approval by a moderator. Status: Accepted Issue/PR is accepted. Platform: All Issue/PR is applicable to all platforms. Subsystem: Generation Issue/PR has to do with all other generation subsystems. and removed Status: Pending Issue/PR is currently awaiting approval by a moderator. labels Jul 10, 2022
@dfsek
Copy link
Member

dfsek commented Jul 10, 2022

This would probably be implemented in a new chunk generator addon, that way we can keep the noise 3d generator addon around for beginners/simple packs.

@astrsh
Copy link
Member Author

astrsh commented Jul 11, 2022

Mockup config for how the layered generator could work

# Layer predicates define a predicate that takes world coordinates
# Not sure how exactly these should be defined
# The functionality of terrain.sampler, terrain.sampler-2d, carving.sampler, and ocean.level would be utilized here
layer-predicates:
  is-terrain:
  is-carving:
  is-aquifer-border:
  is-aquifer-water:
  is-aquifer-lava:
  is-under-lava-level:
  is-under-ocean-level:

# Layer palettes define sets of block placements
layer-palettes:
  terrain:
    type: BIOME_DEFINED # Allows biomes to specify a palette, this would be dynamically registered as a config key
    default: # What the default palette is if a biome doesn't specify a palette
      type: BLOCK # A single block palette
      block: minecraft:stone
  air:
    type: BLOCK
    block: minecraft:air
  ocean:
    type: BIOME_DEFINED
    default:
      type: BLOCK
      block: minecraft:water
  underground-lava:
    type: BLOCK
    block: minecraft:lava
  aquifer-water:
    type: BIOME_DEFINED
    default:
      type: BLOCK
      block: minecraft:water
  aquifer-lava:
    type: BLOCK
    block: minecraft:lava

# Converts to a binary decision diagram
# The 'if' key specifies a layer predicate
# The 'place' key specifies a layer palette
layer-placement: 
  if: is-terrain
  then:
    if: is-carving
    then:
      if: is-aquifer-border
      then:
        place: terrain
      else:
        if: is-aquifer-water
        then:
          place: aquifer-water
        else:
          if: is-aquifer-lava
          then:
            place: aquifer-lava
          else:
            if: is-under-lava-level
            then:
              place: underground-lava
            else:
              place: air
    else:
      place: terrain
  else:
    if: is-under-ocean-level
    then:
      place: ocean
    else:
      place: air

@astrsh
Copy link
Member Author

astrsh commented Jul 11, 2022

The following layer predicates could share the same sampler:

layer-predicates:
  is-aquifer-border:
  is-aquifer-water:
  is-aquifer-lava:

So perhaps there would be another component that is used to construct the predicates, i.e a layer
distributor.

Layer distributors should supersede the capabilities of the biome keys terrain, carving,
and ocean.level, such that you can do things like specify interpolation, combining 2D & 3D samplers, etc

@astrsh astrsh self-assigned this Jul 11, 2022
@astrsh astrsh mentioned this issue Jul 12, 2022
21 tasks
@astrsh astrsh mentioned this issue Oct 1, 2023
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: All Issue/PR is applicable to all platforms. Status: Accepted Issue/PR is accepted. Subsystem: Generation Issue/PR has to do with all other generation subsystems. Type: Enhancement A request for a new feature or enhancement to be added.
Projects
Status: In Progress
Development

No branches or pull requests

2 participants