Skip to content

Minor clear color doc improvements #19514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/bevy_render/src/camera/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,12 +715,13 @@ impl Camera {
}
}

/// Control how this camera outputs once rendering is completed.
/// Control how this [`Camera`] outputs once rendering is completed.
#[derive(Debug, Clone, Copy)]
pub enum CameraOutputMode {
/// Writes the camera output to configured render target.
Write {
/// The blend state that will be used by the pipeline that writes the intermediate render textures to the final render target texture.
/// If not set, the output will be written as-is, ignoring `clear_color` and the existing data in the final render target texture.
blend_state: Option<BlendState>,
/// The clear color operation to perform on the final render target texture.
clear_color: ClearColorConfig,
Expand Down
11 changes: 9 additions & 2 deletions crates/bevy_render/src/camera/clear_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use bevy_reflect::prelude::*;
use derive_more::derive::From;
use serde::{Deserialize, Serialize};

/// For a camera, specifies the color used to clear the viewport before rendering.
/// For a camera, specifies the color used to clear the viewport
/// [before rendering](crate::camera::Camera::clear_color)
/// or when [writing to the final render target texture](crate::camera::Camera::output_mode).
#[derive(Reflect, Serialize, Deserialize, Copy, Clone, Debug, Default, From)]
#[reflect(Serialize, Deserialize, Default, Clone)]
pub enum ClearColorConfig {
Expand All @@ -21,10 +23,15 @@ pub enum ClearColorConfig {
None,
}

/// A [`Resource`] that stores the color that is used to clear the screen between frames.
/// A [`Resource`] that stores the default color that cameras use to clear the screen between frames.
///
/// This color appears as the "background" color for simple apps,
/// when there are portions of the screen with nothing rendered.
///
/// Individual cameras may use [`Camera.clear_color`] to specify a different
/// clear color or opt out of clearing their viewport.
///
/// [`Camera.clear_color`]: crate::camera::Camera::clear_color
#[derive(Resource, Clone, Debug, Deref, DerefMut, ExtractResource, Reflect)]
#[reflect(Resource, Default, Debug, Clone)]
pub struct ClearColor(pub Color);
Expand Down