Bevy Toon Shader 调研
Date: 2026-05-13 Topic: Bevy Engine Cartoon/Toon Shader Implementation Bevy Version: 0.18 Status: Existing crates lag behind; custom Material implementation required
Existing Crates
bevy_toon_material
- Author: AndrewDanial
- Repo: https://github.com/AndrewDanial/bevy_toon_material
- crates.io: https://crates.io/crates/bevy_toon_material
- Bevy Support: 0.15 only (v0.1)
- Features: Toon shading, specular highlight, rim effects, banding
- Limitations: No shadow receiving, single light source, no existing texture support
- Implementation: Custom
MaterialwithAsBindGroup, internal WGSL asset - License: MIT/Apache-2.0
bevy_toon_shader
- Author: tbillington
- Repo: https://github.com/tbillington/bevy_toon_shader
- crates.io: https://crates.io/crates/bevy_toon_shader
- Bevy Support: up to 0.12
- Status: Outdated, unmaintained
- Note: Referenced as prior art by bevy_toon_material
bevy_shader_mtoon
- Repo: https://github.com/kayh/bevy_shader_mtoon (via bevy_vrm)
- crates.io: https://crates.io/crates/bevy_shader_mtoon
- Bevy Support: up to ~0.14
- Features: MToon shader (VRM standard) implementation
- Downloads: 15,930+ all time
bevy_wind_waker_shader
- Docs: https://docs.rs/bevy_wind_waker_shader
- Style: Two-color toon (highlight/shadow) with slight gradient edge
Bevy 0.18 Built-in Shader APIs
Custom Material (Material Trait)
- Example: https://bevy.org/examples/shaders/shader-material/
- Source: https://github.com/bevyengine/bevy/blob/main/examples/shader/shader_material.rs
- Key Traits:
Material,AsBindGroup,TypePath - WGSL Imports:
bevy_pbr::forward_io::VertexOutput,#{MATERIAL_BIND_GROUP}macro - Bindings:
@group(#{MATERIAL_BIND_GROUP}) @binding(N)
Extended Material (MaterialExtension)
- Example: https://bevy.org/examples/shaders/extended-material/
- Source: https://github.com/bevyengine/bevy/blob/main/examples/shader/extended_material.rs
- Key Traits:
MaterialExtension+ExtendedMaterial<Base, Extension> - Binding Offset: Extension bindings must start at slot 100
- Use Case: Extend
StandardMaterialwithout rewriting PBR pipeline - Deferred Support: Requires
deferred_fragment_shader()override
Reference: bevy_toon_material WGSL Shader
Source: https://github.com/AndrewDanial/bevy_toon_material/blob/main/src/toon.wgsl (raw)
Key techniques observed:
VertexOutputwithworld_normal,world_position,uv- Banding:
round(n_dot_l * band_count) / band_count - Smooth fallback:
smoothstep(0.0, 0.01, n_dot_l) - Specular: Blinn-Phong with
pow(n_dot_h * light_intensity, glossiness^2) - Rim:
smoothstep(rim_amount - 0.01, rim_amount + 0.01, rim_dot * pow(n_dot_l, rim_threshold)) - UV fallback pattern for meshes without UVs
Reference URLs
| Resource | URL |
|---|---|
| bevy_toon_material GitHub | https://github.com/AndrewDanial/bevy_toon_material |
| bevy_toon_material WGSL raw | https://raw.githubusercontent.com/AndrewDanial/bevy_toon_material/main/src/toon.wgsl |
| bevy_toon_material lib.rs raw | https://raw.githubusercontent.com/AndrewDanial/bevy_toon_material/main/src/lib.rs |
| bevy_toon_shader GitHub | https://github.com/tbillington/bevy_toon_shader |
| bevy_shader_mtoon crates.io | https://crates.io/crates/bevy_shader_mtoon |
| Bevy Material Example | https://bevy.org/examples/shaders/shader-material/ |
| Bevy Extended Material Example | https://bevy.org/examples/shaders/extended-material/ |
| Bevy 0.18 Release Notes | https://bevy.org/news/bevy-0-18/ |
| Roy Stan Toon Shader Tutorial (Unity) | https://roystan.net/articles/toon-shader/ |