Crates.io | bevy_compute_noise |
lib.rs | bevy_compute_noise |
version | |
source | src |
created_at | 2024-05-29 11:48:51.008305 |
updated_at | 2024-12-10 08:00:31.172476 |
description | A Bevy plugin for generating tilable 2D/3D noise textures using compute shaders |
homepage | |
repository | https://github.com/jadedbay/bevy_compute_noise |
max_upload_size | |
id | 1255324 |
Cargo.toml error: | TOML parse error at line 21, column 1 | 21 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A plugin for bevy 0.15
for generating tilable 2D/3D noise textures using compute shaders.
Check out a demo of the plugin here: https://jadedbay.com/demo/bevy_compute_noise (Chrome only)
Add the bevy_compute_noise
dependency to Cargo.toml
:
[dependencies]
bevy_compute_noise = "0.3.0"
use bevy_compute_noise::prelude::*;
App::default()
.add_plugins(DefaultPlugins)
.add_plugins(ComputeNoisePlugin::<Perlin2D>::default()) // add new plugin for each type of noise needed
.run();
fn setup(
mut images: ResMut<Assets<Image>>,
mut perlin_2d_queue: ResMut<ComputeNoiseQueue<Perlin2D>>
) {
// Create and queue noise image
let noise_image: Handle<Image> = perlin_2d_queue.add(
&mut images,
ComputeNoiseSize::D2(128, 128), // Use ComputeNoiseSize::D3 for 3D noise
Perlin2d {
seed: 0,
frequency: 5,
octaves: 4
}
);
}
Alternatively, you can add ComputeNoiseComponent<T: ComputeNoise>
to an entity and it will be automatically queued whenever it has been updated:
fn setup(
commands: Commands,
mut images: ResMut<Assets<Image>>,
) {
// Manually create noise image, so it can be used elsewhere.
let noise_image = ComputeNoiseImage::create_image(ComputeNoiseSize::D2(128, 128));
commands.spawn(ComputeNoiseComponent::<Perlin2d> {
image: noise_image.clone();
noise: Perlin2d {
seed: 0,
frequency: 5,
octaves: 4
}
});
}
bevy_compute_noise |
Bevy |
---|---|
0.3 |
0.15 |
0.2 |
0.14 |
0.1 |
0.13 |
If you need to readback the noise texture to the CPU, you can clone the readback branch and view the example in there. I'm not completely happy with the implementation and it's better to just generate the noise on the CPU using another crate anyway.