Git Product home page Git Product logo

Comments (10)

Zylann avatar Zylann commented on July 17, 2024

Voxels should be editable but currently the module doesn't update the mesh automatically, you have to do it manually. It's a bit more tedious than it sounds because meshes are split in cubic chunks, and editing a voxel lying at a boundary requires neighbors to be updated as well. But I plan to support it indeed (will work on it when Godot 3 will be more stable).

The idea of editable voxels is that you don't modify the mesh, but the voxel data. Them the mesh has to update according to that, and here it means updating between 1 or 8 chunks depending on the location. That process should be fast enough so framerate doesn't drop.
In a game context, I plan to add a simple voxel raycaster that doesn't need physics to work. It just needs an origin and direction, then gives which voxel you are pointing at. https://github.com/Zylann/zCraft/blob/master/src/engine/core/raycast.cpp#L14

Individual voxel meshes give awful performance, even with same material so the main purpose of the mesher that uses SurfaceTool is to batch cubes into one mesh by also discarding occluded faces (and adding free AO as an option :D). Then I use chunks so that I can make it of any size while taking advantage of frustum culling.
It's currently not the fastest implementation, because SurfaceTool constrains me to repeat vertices I don't need, while I could output indexed vertices straight away. But before changing that I need to see how the Mesh class will change in 3.0 :p

Reduz told me a bit about instancing so I should test this as well to see if some parts of voxel meshes can use it instead of batching.

from godot_voxel.

toger5 avatar toger5 commented on July 17, 2024

Thank you for your detailed reply!!
how can a block affect 8 chunks or do you mean neighbour blocks?
So you regenerate a whole chunk for removing/editing one block? or do you keep the mesh and than search for the verts based on the voxel coordinates which got added/removed (how would that work? do you have a lookup table with pointers to the accruing vests? so you find the right vertices really fast and can modify them?). and than just modify the small part of the mesh which got affected?

I guess you already have some kind of voxel ray caster working? Because I also have made one for my gdScript implementation I could translate to c++. No idea if it's good performance I usually don't make any reasearch and just try what I can come up with so it could be a bad approach...

from godot_voxel.

Zylann avatar Zylann commented on July 17, 2024

Modifying a voxel in a block can affect 8 blocks in case you change a corner whose sides are shared with other blocks, because one single mesh is generated for every block.
I don't attempt to modify only the vertices belonging to that voxel because it would consume a lot of memory for little gain.

The raycaster I have comes from one of my old voxel projects, itself implemented by reusing an existing one. I didn't tested it but I assume it still works :p

from godot_voxel.

toger5 avatar toger5 commented on July 17, 2024

oh you have only one megs for each voxel? this is what was confusing me I thought it would be one mesh for each chunk. like 16*16 blocks this is how I had implemented it. OKay this makes sense than!
shouldn't even be that hard than?

from godot_voxel.

Zylann avatar Zylann commented on July 17, 2024

We have a terminology misunderstanding:

  • A voxel is the lowest-level representation of the terrain's data
  • A block (or chunk) is a set of N * N * N voxels, where N can be 16

So no, I'm not creating a mesh for each voxel, I create a mesh for every block^^

from godot_voxel.

toger5 avatar toger5 commented on July 17, 2024

yea we had a terminology problem ;)
(I'm sorry... was asking stupid things than...) But at least everything makes sense to me now.

from godot_voxel.

Zylann avatar Zylann commented on July 17, 2024

The last updates make it easier to edit the terrain voxel by voxel, see the demo ;)

from godot_voxel.

toger5 avatar toger5 commented on July 17, 2024

Nice! I didnt checked thw repo you did a huge amount of work !! :)

from godot_voxel.

Corruptinator avatar Corruptinator commented on July 17, 2024

Sorry about that, I didn't mean to reference that. What happened is that I was referring to a Youtube video that had the pound number and Six in the "Smooth Voxel" comments, instead I'd inadvertedly caused the reference to occur. It was an accident.

from godot_voxel.

Zylann avatar Zylann commented on July 17, 2024

Voxels are editable as shown in the voxel game demo project. It will be made a bit easier over time, as I also plan to make this module usable in editor, not just with script.

from godot_voxel.

Related Issues (20)

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.