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

bevy_toon_shader

bevy_shader_mtoon

bevy_wind_waker_shader


Bevy 0.18 Built-in Shader APIs

Custom Material (Material Trait)

Extended Material (MaterialExtension)


Reference: bevy_toon_material WGSL Shader

Source: https://github.com/AndrewDanial/bevy_toon_material/blob/main/src/toon.wgsl (raw)

Key techniques observed:

  • VertexOutput with world_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