#compute-shader #noise #perlin-noise #shaders #perlin #bevy #bevy-plugin

bevy_compute_noise

A Bevy plugin for generating tilable 2D/3D noise textures using compute shaders

6 releases (3 breaking)

new 0.4.0 Jan 10, 2025
0.3.0 Dec 10, 2024
0.2.1 Oct 9, 2024
0.2.0 Jul 13, 2024
0.1.0 May 29, 2024

#282 in Game dev

Download history 2/week @ 2024-09-20 2/week @ 2024-09-27 154/week @ 2024-10-04 36/week @ 2024-10-11 3/week @ 2024-10-18 7/week @ 2024-11-01 3/week @ 2024-11-08 2/week @ 2024-11-15 129/week @ 2024-12-06 19/week @ 2024-12-13

148 downloads per month

MIT/Apache

47KB
1K SLoC

Rust 720 SLoC // 0.0% comments WebGPU Shader Language 347 SLoC

bevy_compute_noise

crates.io Doc

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 (This demo currently uses v0.1.0)

bevy_compute_noise

Usage

Add the bevy_compute_noise dependency to Cargo.toml:

[dependencies]
bevy_compute_noise = "0.4.0"

Add Noise Plugin

use bevy_compute_noise::prelude::*;

App::default()
    .add_plugins(DefaultPlugins)
    .add_plugins(ComputeNoisePlugin) // Add compute noise plugin
    .run();

Write Noise to Image

fn setup(
    mut images: ResMut<Assets<Image>>,
    mut noise_queue: ResMut<ComputeNoiseQueue>
) {
    // Create image 
    let image = ComputeNoiseImage::create_image(ComputeNoiseSize::D2(512, 512));

    // Queue noise to be written to image
    noise_queue.write(
        image
        Perlin {
            seed: 0,
            frequency: 5.0,
            flags: (PerlinFlags::default() | PerlinFlags::TILEABLE).bits()
        }
    );
}

Noise Types

  • Perlin
  • Worley

FBM is available for all noise types, use Fbm<T: ComputeNoiseType>.

TODO

  • Add more noise types.
  • Allow combination of noise.
  • Allow writing into specific texture channels.

Version Compatibility

bevy_compute_noise Bevy
0.3, 0.4 0.15
0.2 0.14
0.1 0.13

Dependencies

~39–72MB
~1M SLoC