Expand description
§cloudiful-bevy-outline
Small reusable Bevy outline helper crate for geometry-shell outlines.
§What it provides
GpmoOutlinePlugin: initializes default outline assetsGpmoOutlinePlugin::with_default_style(...): installs a custom default outline styleOutlineStyle: configurable color, emissive strength, and shell scaleOutlineAssets: default cached material/style resourceOutlineShell: marker component for spawned outline meshescreate_outline_material(...): build a custom outline material from anOutlineStyleoutline_shell_transform(...): build the transform used for shell scalingspawn_outline_mesh(...): attach an outline mesh with a custom material/stylespawn_default_outline_mesh(...): attach an outline mesh using the plugin’s default style
§What it does not provide
- screen-space outlines
- stencil-based outline passes
- automatic mesh duplication for arbitrary scenes
This crate intentionally stays simple: it supports the common “draw a slightly enlarged backface-only shell” outline technique.
§Usage
Add the plugin:
use bevy::prelude::*;
use cloudiful_bevy_outline::{GpmoOutlinePlugin, OutlineAssets};
let mut app = App::new();
app.init_resource::<Assets<StandardMaterial>>()
.add_plugins(GpmoOutlinePlugin::default());
app.update();
assert!(app.world().contains_resource::<OutlineAssets>());Spawn an outline child with the default material/style resource:
use bevy::prelude::*;
use cloudiful_bevy_outline::{OutlineAssets, spawn_default_outline_mesh};
fn attach_outline(
parent: &mut ChildSpawnerCommands,
outline_assets: &OutlineAssets,
mesh: Handle<Mesh>,
) {
spawn_default_outline_mesh(parent, outline_assets, mesh, Visibility::Hidden);
}Then toggle the outline child’s Visibility.
The full runnable example lives at examples/basic.rs.
§Default Style Flow
GpmoOutlinePlugin creates one default material at startup and stores it in
OutlineAssets.
- use
OutlineAssetswhen many outline shells can share one default look - use
GpmoOutlinePlugin::with_default_style(...)when the whole app should start with a different default style - use
create_outline_material(...)when one outline needs its own material - use
outline_shell_transform(...)when you need the shell scale without spawning through the helper
Custom style example:
use bevy::prelude::*;
use cloudiful_bevy_outline::{GpmoOutlinePlugin, OutlineAssets, OutlineStyle};
let mut app = App::new();
app.init_resource::<Assets<StandardMaterial>>()
.add_plugins(GpmoOutlinePlugin::with_default_style(OutlineStyle {
color: Color::srgb(1.0, 0.6, 0.2),
emissive_strength: 3.0,
scale: Vec3::splat(1.12),
}));
app.update();
let outline_assets = app.world().resource::<OutlineAssets>();
assert_eq!(outline_assets.default_style().emissive_strength, 3.0);§Technique
This crate uses a geometry-shell outline:
- draw the normal mesh
- draw a second mesh with front-face culling
- scale that second mesh slightly larger
- only the outside silhouette remains visible
Structs§
- Gpmo
Outline Plugin - Plugin that creates the default outline material and
OutlineAssets. - Outline
Assets - Shared default outline material and style created by
GpmoOutlinePlugin. - Outline
Shell - Marker component for spawned outline shell meshes.
- Outline
Style - Visual parameters for a geometry-shell outline.
Functions§
- create_
outline_ material - Creates a custom material for one outline style.
- outline_
shell_ transform - Returns the shell transform derived from an
OutlineStyle. - spawn_
default_ outline_ mesh - Spawns one outline shell child using the shared
OutlineAssets. - spawn_
outline_ mesh - Spawns one outline shell child using an explicit material and style.