bevy-cameras
Use when spawning `Camera3d` or `Camera2d`, choosing a `Projection`, rendering to an image with the `RenderTarget` component, adding `Hdr` / `Tonemapping::Linear` / `ScreenSpaceTransmission` to a camera, wiring `FreeCamera`, `PanCamera` or the new `PanOrbitCamera` from `bevy::camera_controller`, ordering views with `Camera::order`, or setting a per-camera `AmbientLight` in Bevy 0.20.
How do I install this agent skill?
npx skills add https://github.com/chrisgliddon/bevy-skills --skill bevy-camerasIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill provides instructional content and Rust code snippets for managing cameras in the Bevy game engine. No security issues were detected.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
What does this agent skill do?
Bevy 0.20 — Cameras
When to use this skill
- Spawning the main game camera.
- Rendering to a texture (mini-map, portal, post-process target).
- Wanting a drop-in free-look, pan, or CAD-style orbit controller.
- Configuring multiple cameras with different
orderfor overlays. - Glass/translucent materials render flat (0.20 made
ScreenSpaceTransmissionopt-in). Tonemapping::Nonesuddenly looks different (0.20 made it a pure passthrough).
Canonical pattern
Controllers are feature-gated. In Cargo.toml:
bevy = { version = "0.20", features = ["free_camera", "pan_camera", "pan_orbit_camera"] }
use bevy::asset::RenderAssetUsages;
use bevy::camera::{Hdr, RenderTarget};
use bevy::camera_controller::free_camera::{FreeCamera, FreeCameraPlugin};
use bevy::core_pipeline::tonemapping::Tonemapping;
use bevy::prelude::*;
use bevy::render::render_resource::{Extent3d, TextureDimension, TextureFormat, TextureUsages};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(FreeCameraPlugin) // adds the input wiring
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
// 1. Main camera with the built-in free-look controller.
commands.spawn((
Camera3d::default(),
Hdr, // `bevy::camera::Hdr` since 0.19
Tonemapping::default(), // TonyMcMapface; `Linear` = no curve, keep grading
FreeCamera::default(),
Transform::from_xyz(0.0, 4.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
));
// 2. A texture target for an off-screen render pass (mini-map, portal).
let size = Extent3d { width: 512, height: 512, depth_or_array_layers: 1 };
let mut image = Image::new_fill(
size,
TextureDimension::D2,
&[0; 4],
TextureFormat::Bgra8UnormSrgb,
RenderAssetUsages::default(),
);
image.texture_descriptor.usage = TextureUsages::TEXTURE_BINDING
| TextureUsages::COPY_DST
| TextureUsages::RENDER_ATTACHMENT;
let image_handle = images.add(image);
// 3. A second camera that draws into the texture.
// `RenderTarget` is a separate component, not a `Camera` field.
commands.spawn((
Camera3d::default(),
Camera { order: -1, ..default() }, // lower order renders first
RenderTarget::Image(image_handle.into()),
Transform::from_xyz(10.0, 5.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}
Choosing a projection
use bevy::prelude::*;
fn _proj(mut commands: Commands) {
// Default perspective.
commands.spawn((Camera3d::default(), Projection::default()));
// Orthographic for top-down or strategy views.
commands.spawn((
Camera3d::default(),
Projection::Orthographic(OrthographicProjection {
scale: 10.0,
..OrthographicProjection::default_3d()
}),
));
}
Pan-orbit camera (new in 0.20)
bevy_editor_cam was upstreamed as PanOrbitCamera. It needs picking for depth-aware
zoom, so add MeshPickingPlugin too.
use bevy::camera_controller::pan_orbit_camera::{DefaultPanOrbitCameraPlugins, PanOrbitCamera};
use bevy::prelude::*;
fn _orbit(app: &mut App, mut commands: Commands) {
app.add_plugins((MeshPickingPlugin, DefaultPanOrbitCameraPlugins));
commands.spawn((Camera3d::default(), PanOrbitCamera::default()));
}
Ambient light: world default vs per-camera
use bevy::light::GlobalAmbientLight;
use bevy::prelude::*;
fn _amb(app: &mut App, mut commands: Commands) {
// World default — applies everywhere unless a camera overrides.
app.insert_resource(GlobalAmbientLight { brightness: 200.0, ..default() });
// Per-camera override — `AmbientLight` is a Component.
commands.spawn((Camera3d::default(), AmbientLight { brightness: 1000.0, ..default() }));
}
Gotchas
0.19 → 0.20
ScreenSpaceTransmissionis opt-in.Camera3dno longer requires it. Addbevy::pbr::ScreenSpaceTransmission::default()to get refraction through transmissiveStandardMaterials.Tonemapping::Noneis a full passthrough. NoColorGrading, noDebandDither, no clamp. Use the newTonemapping::Linearfor "no tone curve but keep the rest".Camera2dnow defaults toTonemapping::Linear.Tonemapping/DebandDithermoved tobevy_render::view. Thebevy::core_pipeline::tonemapping::Tonemappingimport still works via re-export; reflected type paths in scene files changed.- Mixed-
Hdrcamera stacks composite instead of overwrite. Setblend_stateinCameraOutputMode::Writefor the old replace behaviour.SortedCamera::hdris gone. RenderDebugOverlaykeybindings.RenderDebugOverlayPluginjoinsDefaultPlugins(disabled by default) only with thebevy_dev_tools+render_dev_toolsfeatures.
0.18 → 0.19
Hdrmoved tobevy::camera::Hdrand is not extracted to the render world; readExtractedCamera::hdrthere.Camera3d::screen_space_specular_transmission_*fields are gone. They becameScreenSpaceTransmission { steps, quality }inbevy_pbr.Skyboxmoved tobevy::lightandimageisOption<Handle<Image>>.Atmosphereis an entity, not a camera component. The camera keepsAtmosphereSettings.PanCamerapans with the mouse by default. Setmouse_pan_settings.enabled = falsefor keyboard-only.ExtractedView::hdrmoved toExtractedCamera::hdr;TextureFormat::bevy_default()is deprecated — readExtractedView::target_format.ViewTarget::out_texture()returnsOption(Nonewhen the surface is occluded orCameraOutputMode::Skip).- Render graph nodes are systems in the
Core3d/Core2dschedules;RenderSystems::ManageViewssplit intoCreateViews,Specialize,PrepareViews.
Still true
RenderTargetis its own component;Camera { target: ... }does not exist.RenderTarget::Nonerenders prepasses only.AmbientLightis a component; the resource isGlobalAmbientLight.Camera::orderis signed. Lower renders first.- Controllers need their Cargo feature and plugin:
free_camera+FreeCameraPlugin,pan_camera+PanCameraPlugin,pan_orbit_camera+DefaultPanOrbitCameraPlugins. - Imports:
bevy::camera::{RenderTarget, Hdr},bevy::camera_controller::{free_camera, pan_camera, pan_orbit_camera},bevy::light::GlobalAmbientLight. None are in the prelude.
See also
bevy-pbr-materials— materials, lights,ContactShadows, atmosphere.bevy-capture— recording a camera'sRenderTarget::Imageto video.bevy-migration-0-19-to-0-20—Tonemapping::Linear, opt-in transmission.bevy-migration-0-18-to-0-19—Hdr/Skybox/Atmospheremoves.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/chrisgliddon/bevy-skills/bevy-cameras">View bevy-cameras on skillZs</a>