godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.69k stars 20.11k forks source link

Builtin voxel support #16300

Closed MirceaKitsune closed 4 years ago

MirceaKitsune commented 6 years ago

I'll start off by saying that I'm aware this is an advanced suggestion, which may take time to develop and is potentially not ideal as a builtin capability at this stage. As such, I do not expect this to get done anytime soon... at the same time however I support its implementation, hence why I'd like to start an issue for discussion early on.

One of the most important advances in digital 3D worlds remains voxels: The ability to define a model as a series of points in space, rather than just an outer mesh. This allows surfaces to be destructible, and lays at the foundation of most modern sandbox games. Currently Godot doesn't offer an easy way to set up such a world, which may be possible using advanced scripting but likely very difficult and poorly optimized.

My suggestion covers both blocky voxels (in the same style as MineCraft) as well as smooth voxels (using algorithms such as marching cubes). While I'm not trying to encourage the use of Godot for creating exact clones of Minecraft per say, the ability to have its terrain and world building system as a ready option for game developers seems like a very welcome idea which may even encourage new innovation. Smooth voxels meanwhile can be used to achieve the same abilities (building and digging through terrain) with realistic looking surfaces.

I was able to find a video showcasing a Godot 3.0 plugin which seemingly implements precisely this functionality. Currently I'm not able to find a code source, but you can watch the video here:

https://www.youtube.com/watch?v=2mCMUMI1AQk

toger5 commented 6 years ago

The module is available here: https://github.com/Zylann/godot_voxel

It's created by @Zylann and he used go dots module system, hence you have to recompile godot to get it to work. The advance is, that it is written in c++ and performs accordingly.

About your proposal to make it builtin. Godot is a really small binary and that has a lot of advantages. AFAK product idea is to have a small stable core with a lot of really good ways of extending it. so that the binary will stay small but the community has all kinds of options to make it as feature rich as the user desires. so having built in voxel system is not that realistic. (although I could imagine it as an extension to the 3d grid map... even though the 3d grid map is not designed for infinite terrains I think)

To sum up: It's improbable that there will be a built in voxel system, It is now possible to make @Zylann 's voxel module an Addon thanks to gdnative. So it might be super simple to add it to a project in the future so that it is almost as if it is builtin.

MirceaKitsune commented 6 years ago

Thank you for the info. Having to recompile Godot in order to install a plugin sounds a little problematic, although for something as advanced as voxel support I can see why such is the case. Isn't it possible for C++ addons to be distributed as dll (Windows) or so (Linux) files and dynamically linked at runtime? I imagine many users won't know how to recompile, which is another reason why I'd prefer to see such features builtin personally.

That being said, I should first clarify that I'm not a Godot developer although I've been into software development for over a decade. However the argument that adding code features to an engine is not desired due to increasing its binary size sounds a little odd to me: I can see the point on one side, especially with the engine also being intended for mobile platforms... however that also sounds like putting limits on how far the engine will be able to evolve, because features that increase the size of the program would then be discounted. Why isn't this the case with the Bullet physics engine for instance, which is a library of its own and surely increases Godot by quite a few MB?

Lastly, there's also the option of Godot only providing the simpler basics for voxel functionality but not an entire system per say. As in, don't add a full voxel editor or ready-to-use voxel object if that's too much, but offer the fundamental features so that a relatively simple script can get it working. I assume some of those abilities could be reused for multiple purposes and optimizations... such as being able to cheaply generate and update polygon structures using scripting, or hiding the intersecting faces of cubes in a grid to get rid of hidden polygons and improve performance.

toger5 commented 6 years ago

Thank you for the info. Having to recompile Godot in order to install a plugin sounds a little problematic, although for something as advanced as voxel support I...

This is what is possible with GdNative read: https://godotengine.org/article/dlscript-here if you are interested.

That being said, I should first clarify that I'm not a Godot developer although I've been into software development for over a decade. However the argument that adding code features to an engine is not desired due to increasing its binary size sounds a ...

That is a good point. And maybe I choose my words wrong before. It's not that features get abandoned because of the binary size. It's just that it is amazing to keep it small and it will be taken in consideration. And features since Godot makes it simple to add features which are only necessary for specific kinds of games as assets from the asset store. This might be the way to go for the specific topic of voxel support. Especially with gdnative!

Lastly, there's also the option of Godot only providing the simpler basics for voxel functionality but not an entire system per say. As in, don't add a full voxel editor or ready-to-use voxel object if that's too much, but offer the fundamental features so that a relatively simple script can get it working. I assume some of those abilities...

This is somehow allowed through immediate geometry... but I guess you mean even simpler.

And depending what you are trying to do. If it's just a voxel style finite (not infinite) terrain/map than the 3d grid map is already really great for that. don't know how good it holds up performance wise. Don't really know how it is implemented... But it is easy to change blocks of the grid map... http://docs.godotengine.org/en/3.0/classes/class_gridmap.html#class-gridmap-set-cell-item

so that could work pretty well (at least it would be simple) as long as you work in finite environment I guess...

I know you are doing a feature request and I'm kind of just pointing at work arounds. But the best bet is to hope on Zylanns module to become a really simple to use Addon (watch the vr Addon video to see how easy it would be to use it: https://www.youtube.com/watch?v=267dRjEYliU)

MirceaKitsune commented 6 years ago

I was thinking of the existing grid map for this purpose: Currently it's only used to position mesh segments as tiles, but maybe later it will also offer the ability to convert virtual points into optimized cubes or skin such points into a smooth surface? If the ability to generate or update geometry is exposed to the scripting engine, I imagine this wouldn't be too hard.

aaronfranke commented 6 years ago

Before we add this, we should add structures for dealing with integer positions: https://github.com/godotengine/godot/pull/22205

Zylann commented 6 years ago

@aaronfranke yup, it should be available in general though, not just C# https://github.com/godotengine/godot/issues/3286 (it says 2D but 3D should naturally follow)

MarcusElg commented 5 years ago

Imo it's great that the binary is small but their should be an in-engine way to download official plugins instead of the community ones being found on different websites, github pages etc. Having them in the same place would be great

aaronfranke commented 5 years ago

@MCrafterzz For hosting them, there is an official website: https://godotengine.org/asset-library

But I don't know how often they check this, I submitted something last week and it isn't on there yet.

MarcusElg commented 5 years ago

Oh that's good so that it's all in the same place.

dark-penguin commented 4 years ago

It is now possible to make @Zylann 's voxel module an Addon thanks to gdnative. So it might be super simple to add it to a project in the future so that it is almost as if it is builtin.

@Zylann I remember a discussion in Godot issues about this, but I can't find it. I remember you were going to port this to GDNative, but I think you were waiting for some roadblock to be cleared first (probably the 3.1 or 3.2 release with finalized GDNative support). What was it, and has it changed since then? (I want to follow closely and not miss it! ^_^ )

Zylann commented 4 years ago

@dark-penguin I didn't catch up yet with GDNative improvements. I have an issue mentionning GDNative here https://github.com/Zylann/godot_voxel/issues/89 In addition, as far as I remember, last time I used GDNative (a long time ago) it had a lot of leaking, safety issues and difficulty to do some operations (such as downcasting or recognizing your own classes when a function receives one).

Calinou commented 4 years ago

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!