Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.63k stars 248 forks source link

Procedurally Generated Planets #219

Open Aurin-git opened 3 years ago

Aurin-git commented 3 years ago

Is it possible to make a custom stream that will generate a planet or am is this tool not that flexible?

Zylann commented 3 years ago

It is possible to generate a planet yes. One of the easiest ways is to use SDF functions: a sphere for the base shape, and layers of 3D noise to create surface features. This is doable with either VoxelGeneratorScript, or VoxelGeneratorGraph. Maybe there are more specialized ways to do it though, which I haven't tried yet.

Here is an example which uses a torus shape instead of a sphere, though the idea is the same: image

Aurin-git commented 3 years ago

I was able to do it. Thank you for taking the time to help me. I really appreciate it.

spiro-angelakis commented 3 years ago

i cant wrap my head around this xD I wish we could get a video tutorial on making planets and asteroids, im sure im not the only one who's been dying to make space games with voxel tools

spiro-angelakis commented 3 years ago

It is possible to generate a planet yes. One of the easiest ways is to use SDF functions: a sphere for the base shape, and layers of 3D noise to create relief. This is doable with either VoxelGeneratorScript, or VoxelGeneratorGraph. Maybe there are more specialized ways to do it though, which I haven't tried yet.

Here is an example which uses a torus shape instead of a sphere, though the idea is the same: image

Every time i try copying what you did in that picture, it crashes my instance of godot, even on a new brand new empty project, using either graph or script generators, on both opengl2 or 3

im using the godot3.2.3 version of voxel tools

Zylann commented 3 years ago

I'm aware of a bug somewhere, it happens very rarely for me so I was not able to find what it was yet. One occurrence was reported in https://github.com/Zylann/godot_voxel/issues/216 but the code has changed a lot since (and the clamp node was fixed). I think it's a known assertion though, it's not a random crash, so having a log showing the error message might help (or better, the call stack)

spiro-angelakis commented 3 years ago

I figure maybe this is a bug fixed in newer branches? I've been trying to get the master branch of voxel tools all day and cant figure out what branch of godot it will successfully build with

spiro-angelakis commented 3 years ago

with the 3.2.3 version of godot & voxel tools, no matter how i try to go about it, even if stream in editor is false, graph crashes the editor immediately whenever a noise or sdf node is connected to outputsdf

spiro-angelakis commented 3 years ago

trying my best to understand, im pretty sure the only way id achieve voxel ore chunks underneath voxel terrain, as well as asteroid fields in space, would be through using voxelgraphs

spiro-angelakis commented 3 years ago

... I think it's a known assertion though, it's not a random crash, so having a log showing the error message might help (or better, the call stack)

if youre asking for a crash report i have no idea where godot would save them if it does generate them

Zylann commented 3 years ago

The module uses the latest of Godot 3.2 branch to build.

I don't know myself how people get call stacks from release_debug versions (the kind of build used by official versions and the CI of my repo), but there should be a message printed in the system console when that happens. Maybe you could try running Godot from a command line so it won't close right away?

Is there a very specific series of steps you are doing to reproduce the crash?

spiro-angelakis commented 3 years ago

Is there a very specific series of steps you are doing to reproduce the crash?

yes, anything connecting to an outputSDF node crashes the editor, meaning i dont think i can use any of the custom gen functionality

Zylann commented 3 years ago

anything connecting to an outputSDF node crashes the editor

I tried that, didn't crash.

https://user-images.githubusercontent.com/1311555/110208187-86a77580-7e7f-11eb-8c19-38e862cdfbc6.mp4

spiro-angelakis commented 3 years ago

Okay so I guess its just when i connect a 3dGenerator node to an outputSDF

spiro-angelakis commented 3 years ago

no matter what, having a 3dGen connected in the chain to outputSDF, it immediately crashes

Zylann commented 3 years ago

What is a 3dGenerator? I tried with Noise3D, did not get a crash.

https://zylannprods.fr/dl/godot/voxel/issue219_0.mp4

spiro-angelakis commented 3 years ago

What is a 3dGenerator? I tried with Noise3D, did not get a crash.

https://zylannprods.fr/dl/godot/voxel/issue219_0.mp4

Im really not trying to be a pest here, sorry, just really want help so I can use the full potential of this awesome module Why does it crash the editor for me? Is there anything I can do, did I build the module into godot wrong? I really dont understand what I could be doing wrong

spiro-angelakis commented 3 years ago

I appreciate the replies sorry I will try running from a command line to get you some sort of error at least

spiro-angelakis commented 3 years ago

At: modules\voxel\generators\graph\voxel_graph_runtime.cpp:748 ERROR: The graph has no SDF output

it spammed this like a thousand times before the crash as soon as a Noise3D was connected to an OutputSDF node

spiro-angelakis commented 3 years ago

this is the only other info cmd provided:

Godot Engine v3.2.3.stable.custom_build - https://godotengine.org -------- VoxelMemoryPool ----------

C:\Users\Angel\HDD Documents\GODOT>OpenGL ES 3.0 Renderer: GeForce GTX 560 Ti/PCIe/SSE2

Zylann commented 3 years ago

At: modules\voxel\generators\graph\voxel_graph_runtime.cpp:748 ERROR: The graph has no SDF output

Strange, voxel_graph_runtime.cpp only has 654 lines, line 748 does not exist. Maybe you're not using latest version?

Based on the message, it could be either line 501 or line 603. It means the graph is being executed while it's not in a valid state. Looks like a bug coming from the graph editor, but I need to know more precisely how you are making this happen, because when I try, it does not happen. If needed, reproduction steps should start from the moment you launch Godot to the moment it crashes, without using pre-existing scenes or resources, because I don't have them myself when I reproduce the steps.

creative-brain commented 3 years ago

I've tried Noise3D and it doesn't crash on my machine, but doesn't work either. When I use FastNoise3D I get it working in the editor. However, when I start the game itself, nothing shows. Screenshot from 2021-03-21 17-03-47

Zylann commented 3 years ago

Your scene is missing VoxelViewer under the camera, maybe that's why you don't see it in game?

creative-brain commented 3 years ago

That solved the problem. Thanks!

creative-brain commented 3 years ago

I think there might be a bug in SdfSphere - it produces weird artifact on each face (see the image bellow). Any idea what can cause this?

Screenshot from 2021-03-22 15-37-07

Zylann commented 3 years ago

That graph should not produce a bug like this. Do you also get the artifacts if you remove the Constant, and instead assign the radius on the default inputs of the SdfSphere node?

creative-brain commented 3 years ago

Event with the radius on the default inputs of the SdfSphere node it still produces artifacts. I also tried SdfSphereHeightmap and it just did the same thing.

Zylann commented 3 years ago

Do you still get it if you remove the Add node and connect directly the sphere node to OutputSDF? Also, do you get a dent inside the geometry? Or is it only the shading that looks like that?

creative-brain commented 3 years ago

I've re-create the issue again with x,y,z inputs, a plain SdfSphere with radius set to 100 and OutputSdf. The artifact looks like dent inside the geometry - see the image.

Screenshot from 2021-03-22 16-30-30

Zylann commented 3 years ago

I may have a look later but I think I know what that is. try to increase that 0.2f constant here: https://github.com/Zylann/godot_voxel/blob/fe968f17aa6d1e08e5565d237a3fa94bdd2bbdb6/generators/graph/voxel_generator_graph.cpp#L231 It's going to be exposed as a property soon

creative-brain commented 3 years ago

I've recompiled godot with the plugin using values 0.5f and 1.0f but the dent is still there. Also I've noticed that when I change the LOD_split_scale to a higher value (4 or 5) the dent gets smaller.

Screenshot from 2021-03-22 16-53-24

Zylann commented 3 years ago

I've recompiled godot with the plugin using values 0.5f and 1.0f but the dent is still there

Still there, as in, exactly the same? It doesnt get smaller? I think it's the cause of your issue because this constant drives early-rejection of voxel blocks if the SDF does not cross zero. This tremendously increase performance, however if it is too small then at some LOD levels a dent might appear due to the discontinuity it creates. So I'm guessing if you increase the value further it will eventually disappear. I haven't noticed this so far though because all planets I make are never perfectly round anyways

creative-brain commented 3 years ago

It disappeared when I changed the value to 2.0. Thanks ;)

spiro-angelakis commented 3 years ago

months later after grabbing releases from here instead of trying to build it myself i finally made a voxel planet super quick and simply, thank u zylann u are the best!