Crates.io | bevy_vox_scene |
lib.rs | bevy_vox_scene |
version | 0.15.0 |
source | src |
created_at | 2024-01-07 23:09:43.311974 |
updated_at | 2024-10-15 21:27:34.859715 |
description | A Bevy engine plugin for loading Magica Voxel world files and render materials directly in Bevy as a scene graph. |
homepage | |
repository | https://github.com/Utsira/bevy_vox_scene |
max_upload_size | |
id | 1092077 |
size | 239,558 |
bevy_vox_scene
A plugin for the Bevy Engine which allows loading Magica Voxel .vox
files directly into a Bevy scene graph.
bevy_vox_scene
is forked from the excellent bevy_vox_mesh
crate.
bevy-vox-scene
?Whereas other voxel crates load a single model with voxel colors but no other material properties, bevy_vox_scene
can load an entire scene graph from a Magica Voxel world file, and it attempts to recreate the material properties from Magica Voxel's render tab. This means you can produce a scene in Bevy that approximates Magica Voxel's raytraced renders, but at Bevy's real-time interactive framerates.
Use Magica Voxel as your Bevy level editor.
Here is the study example scene as rendered by Magica Voxel's raytracer:
And this is the same scene in Bevy:
All Magica Voxel material types except "cloud" are supported. Bevy's screen space transmission does a great job of rendering glass materials.
bevy_vox_scene
achieves this by generating a series of texture atlases for the scene to capture the differing color, metalness, roughness, emission, and transparency for each Voxel type in the scene.
cargo add bevy_vox_scene
) or by adding it to Cargo.toml
:[dependencies]
bevy_vox_scene = "0.15.0"
Then in code:
use bevy::prelude::*;
use bevy_vox_scene::VoxScenePlugin; // 2.
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
VoxScenePlugin::default()
)) // 3.
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands, assets: Res<AssetServer>) {
commands.spawn(SceneBundle { // 4.
scene: assets.load("study.vox#workstation/desk"),
..default()
});
}
SceneBundle
. Alternatively, spawn any node of the scene graph, down to individual models, using the name you assigned to the node in MagicaVoxel.Take a look in the examples/
directory for complete working examples. To run an example, type the following into the terminal:
cargo run --example <example name>
modify-scene
example.emissive-model
example.ssao-model
example.transmission-scene
example.Bevy version | Magica Voxel version | bevy-vox-scene version |
---|---|---|
0.12 | 0.99.6 | 0.9, 0.10, 0.11, 0.12 |
0.13 | 0.13 | |
0.14 | 0.14, 0.15 |
assets.load("study.vox#desk")
), you'll need to ensure that the name you have given it in Magica Voxel is unique within the file. Avoid names that begin with the word material
or model
as these are reserved for the various subassets that make up the scene.bevy_vox_mesh
crate instead.TLDR: split up models containing glass voxels into convex chunks using Magica Voxel's world editor.
Magica Voxel tip: you might need to manually move the transmissive models to last in Magica Voxel's render order for other models in the scene to be visible through them. Tap "Order -> Last" on the model that has the glass voxels. Although the scene hierarchy will be imported into Bevy with
VoxelSceneBundle
, the ordering of sibling nodes in Magica Voxel files has no effect on bevy rendering.
Forked from the excellent bevy_vox_mesh
crate by Lucas A.
Like bevy-vox-mesh
, bevy-vox-scene
uses dot-vox
to parse the vox files and the greedy mesher from [block-mesh-rs
] (https://github.com/bonsairobo/block-mesh-rs) to create efficient meshes.