Skip to content

Commit 463435c

Browse files
committed
Set skybox fallback clear color
1 parent bbabae0 commit 463435c

5 files changed

Lines changed: 48 additions & 7 deletions

File tree

crates/renderide/src/color_space.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
//! Shared color-space conversion helpers for host-authored values.
1+
//! Shared color constants and color-space conversion helpers for host-authored values.
22
33
use glam::{Vec3, Vec4};
44

5+
/// Linear RGBA fallback color used when a skybox-backed view has no material sky to draw.
6+
pub(crate) const DEFAULT_SKYBOX_CLEAR_COLOR: Vec4 = Vec4::new(0.1, 0.1, 0.1, 1.0);
7+
58
/// Converts one sRGB channel to linear-light space.
69
///
710
/// The transfer function is applied directly to the input value without clamping.

crates/renderide/src/passes/world_mesh_forward/skybox.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ impl SkyboxRenderer {
140140
pipeline_state: &WorldMeshForwardPipelineState,
141141
) -> Option<PreparedSkybox> {
142142
match frame.view.clear.mode {
143-
CameraClearMode::Skybox => {
144-
self.prepare_material_skybox(device, uploads, frame, pipeline_state)
145-
}
143+
CameraClearMode::Skybox => self
144+
.prepare_material_skybox(device, uploads, frame, pipeline_state)
145+
.or_else(|| self.prepare_clear_color(device, uploads, frame, pipeline_state)),
146146
CameraClearMode::Color => {
147147
self.prepare_clear_color(device, uploads, frame, pipeline_state)
148148
}

crates/renderide/src/render_graph/frame_params.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::sync::Arc;
1313
use parking_lot::Mutex;
1414

1515
use crate::camera::{HostCameraFrame, ViewId};
16+
use crate::color_space::DEFAULT_SKYBOX_CLEAR_COLOR;
1617
use crate::gpu::{GpuLimits, MsaaDepthResolveResources};
1718
use crate::materials::MaterialSystem;
1819
use crate::mesh_deform::{GpuSkinCache, MeshDeformScratch, MeshPreprocessPipelines};
@@ -40,7 +41,7 @@ impl FrameViewClear {
4041
pub fn skybox() -> Self {
4142
Self {
4243
mode: CameraClearMode::Skybox,
43-
color: glam::Vec4::ZERO,
44+
color: DEFAULT_SKYBOX_CLEAR_COLOR,
4445
}
4546
}
4647

@@ -250,7 +251,7 @@ mod tests {
250251
fn main_view_clear_defaults_to_skybox() {
251252
let clear = FrameViewClear::default();
252253
assert_eq!(clear.mode, CameraClearMode::Skybox);
253-
assert_eq!(clear.color, glam::Vec4::ZERO);
254+
assert_eq!(clear.color, glam::Vec4::new(0.1, 0.1, 0.1, 1.0));
254255
}
255256

256257
#[test]

crates/renderide/src/scene/coordinator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::collections::HashSet;
99
use glam::Mat4;
1010

1111
use crate::assets::texture::{HostTextureAssetKind, pack_host_texture_id};
12+
use crate::color_space::DEFAULT_SKYBOX_CLEAR_COLOR;
1213
use crate::ipc::SharedMemoryAccessor;
1314
use crate::shared::{
1415
BlitToDisplayState, FrameSubmitData, RenderSH2, RenderSpaceUpdate, RenderingContext,
@@ -372,7 +373,7 @@ impl SceneCoordinator {
372373
Some(BlitToDisplayState {
373374
renderable_index: -1,
374375
texture_id: packed_texture_id,
375-
background_color: glam::Vec4::new(0.0, 0.0, 0.0, 1.0),
376+
background_color: DEFAULT_SKYBOX_CLEAR_COLOR,
376377
display_index: PRIMARY_DESKTOP_DISPLAY_INDEX,
377378
flags: 0,
378379
_padding: [0; 1],

crates/renderide/src/scene/coordinator/tests/queries.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use glam::{Mat4, Quat, Vec3};
66

77
use crate::camera::{view_matrix_for_world_mesh_render_space, view_matrix_from_render_transform};
8+
use crate::color_space::DEFAULT_SKYBOX_CLEAR_COLOR;
89
use crate::scene::CameraRenderableEntry;
910
use crate::scene::blit_to_display::BlitToDisplayEntry;
1011
use crate::scene::overrides::RenderTransformOverrideEntry;
@@ -227,6 +228,41 @@ fn active_blit_for_display_ignores_overlay_dash_camera() {
227228
assert!(scene.active_blit_for_display(1).is_none());
228229
}
229230

231+
#[test]
232+
fn desktop_blit_for_display_uses_skybox_clear_for_synthesized_dash_blit() {
233+
let mut scene = SceneCoordinator::new();
234+
let overlay = RenderSpaceId(3);
235+
scene.spaces.insert(
236+
overlay,
237+
RenderSpaceState {
238+
id: overlay,
239+
is_active: true,
240+
is_overlay: true,
241+
cameras: vec![CameraRenderableEntry {
242+
renderable_index: 0,
243+
transform_id: 0,
244+
state: CameraState {
245+
projection: CameraProjection::Orthographic,
246+
render_texture_asset_id: 77,
247+
selective_render_count: 1,
248+
flags: 1,
249+
..Default::default()
250+
},
251+
selective_transform_ids: vec![5],
252+
exclude_transform_ids: Vec::new(),
253+
}],
254+
..Default::default()
255+
},
256+
);
257+
258+
let state = scene
259+
.desktop_blit_for_display(0)
260+
.expect("primary desktop display should synthesize dashboard blit");
261+
262+
assert_eq!(state.background_color, DEFAULT_SKYBOX_CLEAR_COLOR);
263+
assert!(scene.desktop_blit_for_display(1).is_none());
264+
}
265+
230266
#[test]
231267
fn world_matrix_excludes_render_space_root() {
232268
let mut scene = SceneCoordinator::new();

0 commit comments

Comments
 (0)