From 814765d96dc661b1b8b03d4a4029377d5d089aae Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sun, 1 Nov 2026 19:46:15 +0700 Subject: [PATCH] Viewport backdrop in the interface's slate The views' studio backdrop is a cool slate, lighter at the top, matching the panels around them (post pass, CPU and GPU path tracers), and the viewport token and its lettering follow it. --- crates/render/src/shaders/mesh.wgsl | 2 +- crates/render/src/shaders/post.wgsl | 10 ++++++---- crates/render/src/shaders/trace_post.wgsl | 5 +++-- crates/render/src/trace.rs | 6 +++--- crates/ui-egui/src/state.rs | 2 +- crates/ui-egui/src/theme.rs | 13 +++++++------ 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/crates/render/src/shaders/mesh.wgsl b/crates/render/src/shaders/mesh.wgsl index ec6bcdce..6ef69758 100644 --- a/crates/render/src/shaders/mesh.wgsl +++ b/crates/render/src/shaders/mesh.wgsl @@ -4,7 +4,7 @@ // in compose/src/display.rs), the G-buffer of the depth of field and subsurface blur passes, the // 2D UV view, // the background, debug views and the 3D wireframe. Output is scene-linear HDR, premultiplied by -// alpha = scene coverage over the flat studio backdrop; exposure, tone mapping and sRGB encoding +// alpha = scene coverage over the studio backdrop; exposure, tone mapping and sRGB encoding // happen in the post pass (post.wgsl). WebGPU/WebGL2-safe (fragment passes only). struct Globals { diff --git a/crates/render/src/shaders/post.wgsl b/crates/render/src/shaders/post.wgsl index 53a64e59..7a0c7d62 100644 --- a/crates/render/src/shaders/post.wgsl +++ b/crates/render/src/shaders/post.wgsl @@ -1,5 +1,5 @@ // Viewport post processing, appended to util.wgsl (uses `src`, `src_samp`, `vs_full`): the -// resolved scene (linear HDR, premultiplied by scene coverage) → flat studio backdrop, exposure, +// resolved scene (linear HDR, premultiplied by scene coverage) → studio backdrop, exposure, // tone mapping, optional bloom / sharpen / vignette / grain, sRGB encoding. struct Post { @@ -34,10 +34,12 @@ fn tonemap(hdr: vec3) -> vec3 { return min(x, vec3(1.0)); } -// The flat studio gray behind the scene, with a gentle falloff so the stage doesn't look like a hole. +// The studio backdrop behind the scene: the interface's cool slate (#30343b at the top to #1b1e23 +// at the bottom, faintly tinted so colors still read true), a little darker in the corners so the +// stage doesn't look like a hole. fn backdrop(uv: vec2) -> vec3 { - let r = length(uv * 2.0 - 1.0) * 0.35; - return vec3(0.0232 * (1.06 - r * r)); + let d = uv * 2.0 - 1.0; + return mix(vec3(0.0295, 0.0343, 0.0437), vec3(0.0110, 0.0130, 0.0168), uv.y) * (1.0 - 0.09 * dot(d, d)); } // Display-linear color of one pixel (scene over backdrop), without bloom. diff --git a/crates/render/src/shaders/trace_post.wgsl b/crates/render/src/shaders/trace_post.wgsl index d4ddc05b..0c0871d8 100644 --- a/crates/render/src/shaders/trace_post.wgsl +++ b/crates/render/src/shaders/trace_post.wgsl @@ -104,9 +104,10 @@ fn denoise_step(@builtin(global_invocation_id) id: vec3) { } } +// The viewport's studio backdrop (matches post.wgsl). fn backdrop(uv: vec2) -> vec3 { - let r = length(uv * 2.0 - 1.0) * 0.35; - return vec3(0.0232 * (1.06 - r * r)); + let d = uv * 2.0 - 1.0; + return mix(vec3(0.0295, 0.0343, 0.0437), vec3(0.0110, 0.0130, 0.0168), uv.y) * (1.0 - 0.09 * dot(d, d)); } fn tonemap(hdr: vec3) -> vec3 { diff --git a/crates/render/src/trace.rs b/crates/render/src/trace.rs index 22e64d06..1a592a49 100644 --- a/crates/render/src/trace.rs +++ b/crates/render/src/trace.rs @@ -441,10 +441,10 @@ impl Tracer { } } -/// The viewport's flat studio gray with a gentle falloff (matches the post pass). +/// The viewport's studio backdrop: a cool slate, lighter at the top (matches the post pass). fn backdrop(uv: Vec2) -> Vec3 { - let r = (uv * 2.0 - Vec2::ONE).length() * 0.35; - Vec3::splat(0.0232 * (1.06 - r * r)) + let d = uv * 2.0 - Vec2::ONE; + Vec3::new(0.0295, 0.0343, 0.0437).lerp(Vec3::new(0.0110, 0.0130, 0.0168), uv.y) * (1.0 - 0.09 * d.length_squared()) } fn tonemap(hdr: Vec3, d: &TraceDisplay) -> Vec3 { diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index e9cb4933..6030903f 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -76,7 +76,7 @@ pub struct Prefs { /// Viewport texture resolution: 0 full, 1 half, 2 quarter of each texture set's size (lighter /// on GPU memory and uploads for 4K and 8K sets; painting and export keep full resolution). pub viewport_texture: u8, - /// Interface brightness (the views keep their studio grey). + /// Interface brightness (the views keep their studio slate). pub brightness: crate::theme::Brightness, /// The colour of what is on, chosen or focused. pub accent: crate::theme::Accent, diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index 62c7a122..5f7dd33e 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use crate::i18n::n_; /// Settings › Interface › Brightness: the greys of the interface. The 3D and 2D views keep their -/// studio grey in every level (they show a render, not chrome). +/// studio slate in every level (they show a render, not chrome). #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum Brightness { @@ -135,9 +135,10 @@ pub struct Tokens { pub danger: Color32, /// Warnings and the mask-view marker. pub warning: Color32, - /// The 3D and 2D views' background: a neutral studio grey in every brightness. + /// The 3D and 2D views' background (the middle of the renderer's studio backdrop): a dark, + /// faintly cool slate in every brightness, so colors are judged against the same ground. pub viewport: Color32, - /// Lettering drawn over the views (always on their dark grey). + /// Lettering drawn over the views (always on their dark slate). pub viewport_text: Color32, /// The accent drawn over the views (its dark-panel shade, whatever the brightness). pub viewport_accent: Color32, @@ -175,8 +176,8 @@ impl Tokens { tool_active: hex(0x2f3541), danger: hex(0xe0554a), warning: hex(0xe0b040), - viewport: hex(0x2a2a2a), - viewport_text: hex(0x969696), + viewport: hex(0x272b31), + viewport_text: hex(0x9aa1ad), viewport_accent: hex(0xe58a4e), radius: 5, }; @@ -447,7 +448,7 @@ mod tests { assert!(contrast(t.button_border, t.panel) >= 1.6, "{b:?}: rail on panel"); } } - // The views keep their studio grey. + // The views keep their studio slate. assert_eq!(Tokens::for_brightness(Brightness::Light).viewport, Tokens::for_brightness(Brightness::Dark).viewport); } }