Vex 2.0 | Remastered for your Voxel Destruction needs

Vex 2.0 | Complete Rewrite

Hello everybody! A long, long time ago (over 3 years ago) I set out to create a tool for the community. Derived from @Doglord120’s previous module (which is probably lost to time), it was a rough and crude implement of… essentially a 3D rasterizer. I have been reached out to many times and incentivized to fix Vex but grew to ignore it. Today, that ends!

Vex 2.0 is a module created to convert parts to smaller voxel parts. It is a complete back-end solution with the ability to apply forces to voxels, greedy meshing for performance needs, improved grid storage, and plenty more configuration. It is a whole redesign of Vex and intended to be (benchmarks pending) incredibly faster, more efficient, and versatile at it’s job.


What Changed

I rewrote the entire thing from scratch. Here’s the big stuff:

Performance

  • Greedy meshing algorithm - combines adjacent voxels into larger parts instead of spamming thousands of 1x1x1 cubes
  • Object pooling - reuses parts instead of constantly creating and destroying them
  • Sparse grid storage - only stores voxels that actually exist
  • Safety limits so you can’t accidentally crash your server

Features

  • Apply forces to voxels (for explosions and stuff)
  • Auto-cleanup with a lifetime parameter
  • Custom voxel sizes - not stuck at 1x1x1 anymore
  • Voxels inherit material and color from the source
  • Collision group support
  • Actually works with Models now, not just individual parts

Code Quality

  • Clean API that doesn’t suck to use
  • Modular - 5 separate modules instead of one giant mess
  • Input validation so it tells you when you’re doing something wrong

Installation

Get it here: Vex 2.0 - Roblox

Just insert it into your game and put the Vex ModuleScript in ReplicatedStorage. There are 4 child modules inside (Config, VoxelGrid, GreedyMesher, VoxelPool) - don’t separate them.

Optional: Create a collision group called “Debris” and set it to not collide with itself for better performance.


Quick Start

Basic usage:

local Vex = require(ReplicatedStorage.Vex)

local structure = Vex.new(workspace.Building)
structure:Destroy()

With configuration:

local structure = Vex.new(workspace.Building, {
    voxelSize = 2,              -- bigger voxels = better performance
    useGreedyMesh = true,        -- default, keep it on
    maxVoxels = 5000,            -- safety limit
    lifetime = 30,               -- auto-cleanup after 30 seconds
    material = Enum.Material.Concrete,
    collisionGroup = "Debris",
    weldAdjacent = true          -- welds nearby voxels together
})

structure:Destroy()

Explosion effect:

local structure = Vex.new(workspace.Building, {
    voxelSize = 1.5,
    lifetime = 20
})

structure:Destroy()

-- apply force at the explosion point
structure:ApplyForce(
    Vector3.new(0, 800, 0),
    explosionPosition
)

API Overview

I’m not going to list every single parameter here - check the README module that comes with the download for full docs.

Main stuff you need to know

Vex.new(model, config) - Creates a structure. Doesn’t destroy it yet.

structure:Destroy() - Actually breaks it into voxels.

structure:ApplyForce(force, position) - Applies physics force to nearby voxels. Useful for explosions.

structure:Cleanup() - Removes all voxels immediately.

structure:GetVoxelCount() - Returns how many parts are currently active.

Config options:

  • voxelSize - size of individual voxels (default: 1)
  • useGreedyMesh - combines adjacent voxels for performance (default: true, keep it on)
  • maxVoxels - safety limit to prevent crashes (default: 10000)
  • lifetime - auto-cleanup in seconds (default: nil, never cleanup)
  • material - override the source material (default: nil, inherits from source)
  • anchored - whether voxels should be anchored (default: false)
  • weldAdjacent - welds nearby voxel clusters (default: true)

Performance Tips

  1. Keep greedy meshing on - It’s the default for a reason. Reduces part count massively for solid structures.

  2. Use larger voxel sizes for big structures - voxelSize = 2 or 3 makes a huge difference. You don’t need hyper-detailed voxels for everything.

  3. Set maxVoxels limits - Don’t let someone destroy a 500-stud building and spawn 200k parts.

  4. Use the lifetime parameter - Debris accumulates fast. Set it to auto-cleanup after 30-60 seconds.

  5. Collision groups - Make a “Debris” group that doesn’t collide with itself. Physics will thank you.


Examples

Destructible wall
local Vex = require(ReplicatedStorage.Vex)

local wall = workspace.Wall
local structure = Vex.new(wall, {
    voxelSize = 2,
    lifetime = 15
})

workspace.Projectile.Touched:Connect(function(hit)
    if hit == wall then
        structure:Destroy()
        structure:ApplyForce(
            workspace.Projectile.AssemblyLinearVelocity * 10,
            workspace.Projectile.Position
        )
    end
end)
Timed demolition
local Vex = require(ReplicatedStorage.Vex)

for i = 3, 1, -1 do
    print(i)
    wait(1)
end

print("BOOM!")

local structure = Vex.new(workspace.Building, {
    voxelSize = 2,
    lifetime = 30,
    weldAdjacent = false  -- let pieces fall independently
})

structure:Destroy()
structure:ApplyForce(Vector3.new(0, 1200, 0), workspace.Building.Position)

Known Issues / Limitations

  • Only works with BaseParts right now. MeshParts and Unions aren’t supported yet.
  • Rotated parts work but might have slight alignment weirdness.
  • Extremely large structures (like 50k+ studs³) can still cause issues.
  • Server-side only for now.

What’s Next

Things I want to add eventually:

  • Client-side voxelization with server replication
  • MeshPart/Union support
  • Structural integrity (unsupported blocks collapse)
  • Fire propagation through structures
  • Maybe a Studio plugin for easier setup

No promises on timeline though.


Feedback

Let me know if you:

  • Find bugs
  • Have performance issues
  • Want specific features
  • Build something cool with it

If Vex 2.0 ends up in your game, tag me so I can check it out!


Download: Vex 2.0 - Roblox Model
License: MIT - use it however you want


Thanks to @Doglord120 for the original concept, and everyone who kept asking me to fix the old version. Here it is.

49 Likes

What I may do is have it voxelize on the client, and then when the destruction occurs, it replicates it to the server. And per part, so nothing will be voxelized on the server until it has been destroyed or interacted with in some way.

4 Likes

I may attempt to do some feat in which it voxelizes on the client via remoteevents and a localscript (Although it does change it from just being modules to localscripts, remoteevents, etc.) since I think the main issue is that the server is having a lot of stress having to replicate everything to the client, meaning that lag can occur, etc.

3 Likes

I will be working on doing it, as built-in functionality. I may not release it for a while, depending on if I can get greedy meshing to work. Having it do tons of complex client and server interactions make it difficult for people to put it in the game, and use it, so I would like to favor greedy meshing functionality over it.

4 Likes

Here from the other post, gonna go ahead and give it a try!

3 Likes

UPDATE 1.5

Vex will now support parts of any size, meaning that you can convert any build made out of parts, no matter the size, into voxels!

Note: Some odd sized parts may result in weird gaps on the Y-Axis, this is being fixed and may just be an edge case.

@IncoSlay
@lilsquish08

3 Likes

Do you like it, now that you can actually use it, haha!

4 Likes

I don’t know if I am doing it right or not but whenever I want the model to NOT be anchored, you would type this correct?

destructionWrapper.voxelize(game.Workspace.House, false)

Whenever I playtest, the model is still anchored.

Edit: This also happens in the example game.

4 Likes

That should work, perhaps I changed a setting by accident. Give me one moment.

Edit: I simply had to carry a variable through a few functions, but it should work now. The 2nd parameter will actually change whether or not it is anchored now. You need to get the new module version.

3 Likes

Could we get a Github? Viewing the code without needing to go through the hassle of opening studio would be nice

3 Likes

Whilst I don’t really use it, I can set one up soon. Should be on the post within 1-2 hours.

3 Likes

How come nothing happens when you try to bomb the House or Parts in your test place?

3 Likes

My bad! I have published and updated the game with the fix.

1 Like

Any update on this? I don’t see a GitHub link in the post.

3 Likes

Any chance for this module to use a greedy mesher soon?

3 Likes

Soon. I recently remembered this and have been tinkering. I also have plans for some neat features. Expect a GitHub repository, greedy-meshing, and some cool new features in 1-2 months.

6 Likes

Great! That will increase performance a lot especially for bigger scale destructions. Looking forward to it!

3 Likes

Just WOW!

Definitely go for the client side damage and possibly implement some checks to assure the positions and things where from the correct player and ensure they where definitely shooting and then go for greedy meshing and I can’t see why this wouldn’t work amazingly.

I can imagine fully destructible maps for battle royal’s being a thing eventually with something like this optimised in the correct formula.

I cannot view your place it states I do not have permission please fix this as I don’t really like downloading anything off people until I’m assured that the thing provided is as advertised, safe, working and implemented correctly prior to taking a copy for myself.

This looks really good, will there be more updates?

3 Likes

is there a way to change the size of the voxel itself?

2 Likes

Any plans on continuing this? Its been quite a while sincs you posted this.

4 Likes