bevy_hsl_multiplier

Crates.iobevy_hsl_multiplier
lib.rsbevy_hsl_multiplier
version0.1.0
sourcesrc
created_at2024-01-25 09:37:58.374686
updated_at2024-01-25 09:37:58.374686
descriptionMultiply texture values in HSL color space
homepage
repositoryhttps://github.com/shanecelis/bevy_hsl_multiplier
max_upload_size
id1113606
size1,365,546
Shane Celis (shanecelis)

documentation

README

bevy_hsl_multiplier

Maintenance CI crates-io api-docs

This crate provides a shader that multiplies a texture's color in HSL color space; it can be applied to 2D and 3D objects on the bevy game engine.

hsl multiplier example

Install

Not actually available on crates.io yet.

# cargo add bevy_hsl_multiplier

But you can get it from the repo directly.

cargo add --git https://github.com/shanecelis/bevy_hsl_multiplier.git

Usage

Add plugin to app

use bevy::prelude::*;
fn main() {
    App::new()
        .add_plugins(bevy_hsl_multiplier::HslMultiplierPlugin)
        .run()
}

Add settings to camera

use bevy::prelude::*;

/// Setup a quad and camera.
fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<HslMultiplierMaterial>>,
    asset_server: Res<AssetServer>,
) {
    commands.spawn(Camera2dBundle::default());

    commands.spawn(MaterialMesh2dBundle {
        mesh: meshes
            .add(shape::Quad::new(Vec2::new(1024., 1024.)).into())
            .into(),
        material: materials.add(HslMultiplierMaterial {
            hsla_multiplier: Vec4::new(1.0, 1.0, 1.0, 1.0),
            color_texture: Some(asset_server.load("rust_crab.png")),
            alpha_mode: AlphaMode::Opaque,
        }),
        ..default()
    });
}

Example

Run the "quad" example like so:

cargo run --example quad

This will show a large quad like the one shown at the beginning of this README.

cargo run --example cube

This will show a rotating cube with the shader as its surfaces.

License

This crate is licensed under the MIT License or the Apache License 2.0 or CC0 License.

Acknowlegments

Commit count: 0

cargo fmt