mcpField
B
bevy-pbr-materials

bevy-pbr-materials

github.com/chrisgliddonDevelopment2684 installsUpdated 9w ago
Repository

About bevy-pbr-materials

A skill for Bevy 0.19 developers working with PBR materials, lighting, and mesh primitives. It covers custom materials and version-specific implementation changes.

Key features

  1. 01Use StandardMaterial for shading
  2. 02Implement custom Material types
  3. 03Configure lights and shadows
  4. 04Set up Atmosphere and cameras
  5. 05Work with mesh primitives

Use cases

  1. 01Apply PBR materials to meshes
  2. 02Create stylized or dissolve shaders
  3. 03Configure contact shadows in a scene
  4. 04Add an atmosphere effect

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/chrisgliddon/bevy-skills --skill bevy-pbr-materials

After installing, type/bevy-pbr-materialsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
custom-material.md
lighting.md
mesh-primitives.md

Details

From the project README

Bevy 0.19 — PBR Materials

When to use this skill

  • Texturing a mesh with the built-in physically based shader.
  • Writing a custom Material (e.g. for stylised shading, dissolve effects, world-space shaders).
  • Enabling shadow maps or Bevy 0.19 contact shadows.
  • Spawning an Atmosphere entity and enabling it on a camera.
  • Compiler error on AsBindGroup::label() (now required).
  • Compiler error on MaterialPlugin::<M> { prepass_enabled: ... } (fields removed in 0.18).

Canonical pattern — StandardMaterial

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .run();
}

fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    let mesh = meshes.add(Cuboid::new(1.0, 1.0, 1.0));
    let material = materials.add(StandardMaterial {
        base_color: Color::srgb(0.8, 0.3, 0.2),
        perceptual_roughness: 0.4,
        metallic: 0.1,
        ..default()
    });

    commands.spawn((
        Mesh3d(mesh),
        MeshMaterial3d(material),
        Transform::from_xyz(0.0, 0.5, 0.0),
    ));

    commands.spawn((
        Camera3d::default(),
        Transform::from_xyz(0.0, 2.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
    ));

    commands.spawn((
        DirectionalLight::default(),
        Transform::from_xyz(2.0, 4.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y),
    ));
}

Custom material — Bevy 0.19 shape

Custom materials with the Material trait and AsBindGroup are covered in detail at references/custom-material.md.

Topics

TopicReference
PointLight, DirectionalLight, SpotLight; GlobalAmbientLight; shadow maps, contact shadows, atmospherereferences/lighting.md
Plane3d, Cuboid, Sphere, Circle, Cylinder, Capsule3d, Torus constructors and orientation gotchasreferences/mesh-primitives.md
Material trait methods, AsBindGroup attributes, ShaderRef variants, MaterialPlugin wiringreferences/custom-material.md

Bevy 0.19 gotchas

  • MaterialPlugin::<M> { prepass_enabled, shadows_enabled, ..default() } is gone. Override the Material trait methods instead — see references/custom-material.md.
  • Light fields use shadow_maps_enabled. shadows_enabled was renamed because Bevy 0.19 adds the separate contact_shadows_enabled control.
  • Contact shadows require both sides. Add ContactShadows to the camera and set contact_shadows_enabled: true on participating lights.
  • Atmosphere is its own entity. Keep AtmosphereSettings on the camera and spawn bevy::light::Atmosphere separately.
  • glTF material labels changed. #Material0 loads GltfMaterial; use #Material0/std when you specifically need Handle<StandardMaterial>.
  • AsBindGroup::label() is required. The #[derive(AsBindGroup)] macro generates it automatically; hand-rolled impls must add it.
  • Mesh component wrappers. Use Mesh3d(handle) and MeshMaterial3d(material_handle) — the wrappers are what the renderer queries on.
  • Plane3d::new takes Vec2 for half_size, not a scalar — see references/mesh-primitives.md.
  • Color::rgb(...) is gone — use Color::srgb(...) or Color::linear_rgb(...).
  • Directional light position is ignored — only rotation matters. See references/lighting.md.

See also

Comments

Markdown supported