Jump to content

[Library] CEWBS - Voxel Mesher and Helper Utilities


Recommended Posts

CEWBS - Fast Voxels in Motion

CEWBS is a MIT-Licensed library for BabylonJS which provides a VoxelMesh object for creating optimized (greedy) voxel meshes.

It currently provides methods to create, update, poll, color, and pick voxels. (See README.md)

 

The goal is to separate voxel meshes from the world 'grid' by allowing them to be rotated, scaled, moved, affected by collisions, physics, and generally treated as normal meshes. while still letting them be manipulated and accessed easily.

 

(In the demo, the voxel mesh you are standing on is rotating, along with it's children.)

 

The speed of the mesher is such that you can create a fast animation (Changing the blocks every frame) in a 16x16x16 mesh with almost no impact on FPS. (Demonstrated in the demo)

 

Textures, Ambient Occlusion, and per-voxel lighting are currently not supported due to the difficulty of implementing them alongside the meshers. Feel free to help out with those. :)

 

Projects Using CEWBS:

None, yet.

 

Enjoy!

 

Sorry for the rushed post, I'll flesh it out more later.

Link to post
Share on other sites

Are you interested in being part of babylon.js extensions? (or even better add it to the core?)

Glad you like it!

 

Perhaps it would fit as part of BabylonJS extensions, but not part of the core. I don't use/know how to use TypeScript, and the code quality is admittedly terrible, though that will change in the future once everything is nailed down.

 

EDIT: Update 0.2.2:

  • Removed monotone mesher, as it is generally slower and too complex for the slight benefits it gives. (Especially with more vertices available for use now in BabylonJS.)
  • Added (buggy) support for non-integer types as voxel ids. Arrays (so long as they don't contain objects), Strings, and Integers work for now. This may be reverted if it affects performance too much. This is buggy (and slower for non-ints) because Arrays and Strings are converted to Integers for a necessarry part of the comparison process, which may result in them accidentally becoming equal.

Should the method above not be decent for comparison, then a more reliable way would be to use an id to compare voxel types, while adding an extra argument for additional metadata. (Any type.)

Link to post
Share on other sites

Update 0.2.3:

  • Reverted non-integer types change and added support for custom metadata in a separate argument, from which a numerical id can be inferred. This is probably the best way to go about it.
  • Added partial support for transparency, colors can either be a 3-length array of RGB values, or a 4-length array of RGBA values. Mesh must have the hasVertexAlpha property set to true. (Transparency is not meshed differently yet, so it still clips through the mesh)
  • Added a few utility functions.
  • Zoxel importer-exporter now has support for transparency.
Link to post
Share on other sites

Update 0.2.4:

  • Minor changes to Zoxel import.
  • Supports voxel transparency properly (through use of a custom evaluateFunction), except for a bug in BabylonJS itself. (So far as I can tell anyways)
  • Example #1 is kind of usable, though quite buggy.

Update 0.2.42:

  • Proper transparency now, using a child mesh. evaluateFunction fixed.
  • Example #1 now has transparency and shouldn't break every few times loading it.
Link to post
Share on other sites
  • 3 months later...

Slightly speed up position calculation by using a flat array instead of an array of arrays.

 

Hey, if you ever do more with this, consider using a library called ndarray, gettable from npm. It simulates an n-dimensional array using a flat array underneath, and lets you easily get dynamic views into the data (a transposed version, say) without the data changing. There's also a bunch of ops libraries for doing stuff to the contents of an ndarray (filling, sorting, etc.) while minimizing cache misses.

Link to post
Share on other sites

Hey, if you ever do more with this, consider using a library called ndarray, gettable from npm. It simulates an n-dimensional array using a flat array underneath, and lets you easily get dynamic views into the data (a transposed version, say) without the data changing. There's also a bunch of ops libraries for doing stuff to the contents of an ndarray (filling, sorting, etc.) while minimizing cache misses.

I've looked into it, but for some reason it never really caught on for me. I might try using a modified version of your mesher in the next version btw, AO would be quite nice.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...