Code Monkey home page Code Monkey logo

planet-generator's Introduction

Planet-Generator Planet-Generator icon

This is a procedural planet generator addon for the Godot Engine using layered noise functions and dynamic LOD (terrain chunks), written in GDScript.

It's licensed unter MIT, so you can use it for pretty much anything as long as you retain the original license file.

Table of Contents

Features and Roadmap

List of completed features and planned features:

  • editor integration
    • configurable ShapeGenerator resource
    • configurable PlanetSettings resource
    • configurable NoiseGenerator resources to layer noise
    • context-aware editor plugin to ease creation of new planets (settings, noise layers, materials?)
    • custom inspector plugin for creating and editing above resources
    • preview texture for NoiseGenerator resource
    • node based editor for terrain shape / noise generators to allow mixing etc.
  • graphics
    • basic terrain coloring based on height using a gradient texture
    • basic atmosphere shader
    • basic water
    • texture mapping (triplanar)
    • better water with reflections and adjustable sea level
    • cloud layer around planet
    • bloom and lens flare effects
  • terrain generation
    • quadtree for automatic LOD subdivision of terrain patches
    • seamless terrain patches
    • terrain collision using PhysicsServer
    • height curve for fine-tuning height levels
    • different types of NoiseGenerators
      • NoiseGenerator (standard)
      • RidgedNoiseGenerator (generates mountainous ridges)
      • simple erosion (morphological erosion, dilation, etc.)
      • generators for other interesting terrain patterns
    • multiple noise maps:
      • height map
      • biome / terrain type map
      • rivers
    • more detail on ground level: vegetation, rocks, etc. using instancing
    • allow generator to output not just straight to geometry but also to heightmaps, values, etc. for offline use
    • allow building terrain from different inputs like procedural noise but also heightmaps, values, files, etc.
    • allow mixing of inputs, see also "editor integration" (e.g. heightmap and noise)
  • documentation
    • installing the addon
    • basic usage
    • creating new planets
    • extending the addon
  • demo scenes with a spaceship to explore planets
  • other improvements
    • allow for larger scale (1 Godot unit = 1m? 1km?)
      • use a scene origin shifter to keep player close to origin and thus mitigate lack float precision
      • enlarge scale, but shrink the universe while inside the editor to make it more maneuverable
      • use another atmosphere shader which doesn't glitch at higher scale
    • add simple planetary orbits
    • add gravity
    • graceful loading and unloading of the addon, solar systems and planets
    • simple benchmark and diagnostics HUD
    • performance optimization:
      • multithreaded terrain generation using WorkerThread
      • JobQueue for TerrainJob which feeds the worker threads with jobs
      • explore computing terrain data on the GPU (shaders, rendering to a viewport)
      • rewrite core parts in C#? (as parallel branch?)
      • rewrite core parts as GDNative module with C or C++? (as parallel branch?)

Usage

You need the Godot Engine to use this addon (tested with Godot 3.x.x).

Quick Start

To quickly get started, open the downloaded folder like a normal project in Godot and run it. You can then navigate a spaceship around the solar system demo scene. The keys are:

  • Mouse to rotate ship
  • WASD for movement
  • hold Shift for faster speed increment
  • hold Control to rotate the camera
  • Esc to release/capture the mouse
  • F1 to switch generating wireframe meshes on/off
  • F2 to switch random coloring of terrain patches on/off

Using the addon

Download and install the addon as described here Installing plugins - Godot Engine documentation.

TODO: Add detailed documentation for setting up planets and their parameters.

For now, check out the solar system demo in demos/solar_system_demo.tscn to see how the planets are configured and play around with the settings. A planets needs a PlanetSettings resource, which contains a ShapeGenerator resource, which in turn has a list of one or more NoiseGenerator resources where you can define what the terrain will look like.

Contributing

  • Found a bug? Please open an issue and add all relevant details.
  • Got an idea for the project? Open an issue or, if you want to implement it, open a pull request with your feature.
  • Want to help out with anything? Clone/Fork the repository and start coding! Pull requests are very welcome.

Screenshots

Click to enlarge:

flight towards earthlike planet a procedural moon appears behind the procedural horizon typical scene the in Godot editor

Credits

planet-generator's People

Contributors

agi-creator avatar creative-brain avatar hoimar avatar reisyukaku avatar ultrazar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

planet-generator's Issues

Applying custom visual shader to the planet?

An idea: A feature which allows users to apply their custom shader to the planet, and allow height map based on that shader. Is something like this possible? I tried changing the material but it doesn't override what was there before as seen in the test below.

image

Below is example of a texture I may try to apply:
image

Doesn't work on HTML5

It simply doesn't patch the terrain, goes completely black.

Specs:

  • GPU: GTX 750 (GLES 3.0)
  • Browser: Opera, Chrome

And throws this error every time that tries to generate the terrain:

  • GL_INVALID_OPERATION: It is undefined behaviour to have a used but unbound uniform buffer.

UV coordinates between different TerrainFace chunks/tiles don't match up

See screenshot below.
This might simply be due to the lower vertex density (which stretches the texture) but could also be caused by an error in the MinMax calculation where the colors / UV coordinates are defined. I'm not yet sure.
Though this is mainly visible in the editor but not as much when viewed from the camera.

Also visible is how the normals don't align where the edges meet, but that's a separate issue which will be fixed.

grafik

Correctly calculate TerrainFace seams

Currently when TerrainFace meshes meet, they only match up when they have the same resolution, as the same noise value will be sampled for all vertices in the same position. When different LOD levels meet however, between two vertices in the coarser mesh there will be an extra vertice in the finer mesh (see screenshot) which samples a different value.

The first solution I'll try is to use the median between the left and right vertice for every odd edge vertice in the finer mesh to align to the coarse mesh. This way I won't have to deal with creating additional geometry and/or stitching the meshes (for now at least, will see how this works out).

grafik

Save the patches in cache?

I think that the performance of the plugin it's good more or less, talking about the GPU.
The problem comes with the CPU, when you get near the planets surface, the CPU process goes extremaly high, because needs to patch a lot of terrain with only a little movement.

I think it would be a good idea to save every patch in the ram (or disk too) so it will not be necessary to load it every time.

Should I try to implement it?

Planet's mustn't move

When I move the planets (cause I want them to rotate around the Sun), they don't patch the Terrain when ship aproximing to them.
I think that is because every quadnode stores his position when loaded and they don't refresh it.

Atmosphere with clouds

Hi, I just pushed a new branch with improved atmosphere and water. I am now working on implementation of optional clouds. In the meantime you can check the changes I made and do some corrections if you want.

Generating planet(s) frequent crashes the Godot Editor or the application

This happens randomly and is definitely related to the multithreaded generation of the TerrainFaces. I'm probably accessing non-thread safe APIs (e.g. the scene tree or my own variables) from multiple threads.
Started working on this issue. Help would be appreciated, but I'm not stuck (yet).

Planetary collisions

Any idea, how to implement fast enough collisions? I've managed to generate a convex collision shape from mesh, but it's slow and inaccurate. I am now trying to add a CollisionShape on runtime using PhysicsServer but with no luck so far?

Occasional multithreading related crashes (especially benchmark scene)

When running the benchmark scene, it sometimes crashes it's running Godot process. This happens with one worker thread but is amplified when using more. It also seems to happen independently from using or not using the "feeder thread" in JobQueue.

Next steps would be to make a minimal reproduction project to narrow down what makes it crash. Perhaps it's a missing mutex or something else that could lead to memory corruption, or even an engine bug.

Edit: This also sometimes happens when launching the editor and when saving scripts in the editor (hot reloading related). I also had a crash once in the running solar system demo scene that may be related.

The crash usually looks like this:

Iteration 1 finished in 12.598ms.
Iteration 2 finished in 488.927ms.
Iteration 3 finished in 5.576ms.
Iteration 4 finished in 19.339ms.
Iteration 5 finished in 284.263ms.
Iteration 6 finished in 15.944ms.
Iteration 7 finished in 299.750ms.
ERROR: _ref: Condition "!success" is true.
   At: core/array.cpp:55.
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
Iteration 8 finished in 17.251ms.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7f7cb12d3210] (??:0)
Iteration 9 finished in 299.121ms.
[2] /path/to/Godot() [0x1fc9233] (/godot-source/./core/cowdata.h:138)
Iteration 10 finished in 250.297ms.
Generated 10 times in 1693.066ms.
[3] /path/to/Godot() [0x20e384c] (/godot-source/core/variant_op.cpp:2991)
[4] /path/to/Godot() [0x4ee2bf] (/godot-source/modules/gdscript/gdscript_function.cpp:1442 (discriminator 3))
[5] /path/to/Godot() [0x49d740] (/godot-source/modules/gdscript/gdscript.cpp:1208)
[6] /path/to/Godot() [0x202eae6] (/godot-source/core/object.cpp:898 (discriminator 1))
[7] /path/to/Godot() [0x20984b8] (/godot-source/core/variant_call.cpp:1149 (discriminator 1))
[8] /path/to/Godot() [0x4e8400] (/godot-source/modules/gdscript/gdscript_function.cpp:1089)
[9] /path/to/Godot() [0x49d740] (/godot-source/modules/gdscript/gdscript.cpp:1208)
[10] /path/to/Godot() [0x202eae6] (/godot-source/core/object.cpp:898 (discriminator 1))
[11] /path/to/Godot() [0x20984b8] (/godot-source/core/variant_call.cpp:1149 (discriminator 1))
[12] /path/to/Godot() [0x4e8400] (/godot-source/modules/gdscript/gdscript_function.cpp:1089)
[13] /path/to/Godot() [0x49d740] (/godot-source/modules/gdscript/gdscript.cpp:1208)
[14] /path/to/Godot() [0x202eae6] (/godot-source/core/object.cpp:898 (discriminator 1))
[15] /path/to/Godot() [0x20984b8] (/godot-source/core/variant_call.cpp:1149 (discriminator 1))
[16] /path/to/Godot() [0x4e8400] (/godot-source/modules/gdscript/gdscript_function.cpp:1089)
[17] /path/to/Godot() [0x49d740] (/godot-source/modules/gdscript/gdscript.cpp:1208)
[18] /path/to/Godot() [0x202eae6] (/godot-source/core/object.cpp:898 (discriminator 1))
[19] /path/to/Godot() [0x21dea93] (/godot-source/core/bind/core_bind.cpp:2758)
[20] /path/to/Godot() [0x2124d4d] (/godot-source/core/os/thread.cpp:76)
[21] /path/to/Godot() [0x23804d4] (thread.o:?)
[22] /lib/x86_64-linux-gnu/libpthread.so.0(+0x9609) [0x7f7cb15dd609] (??:0)
[23] /lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x7f7cb13af293] (??:0)
-- END OF BACKTRACE --

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.