Merge pull request #31 from storytold/ui/viewport-backdrop

Viewport backdrop in the interface's slate
This commit is contained in:
BFlat authored and GitHub committed 2026-11-01 20:12:36 +07:00
commit 17cedbcfc0
6 files changed
+21 -17

No files matched your search

+1 -1
View File
@@ -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 {
+6 -4
View File
@@ -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<f32>) -> vec3<f32> {
return min(x, vec3<f32>(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<f32>) -> vec3<f32> {
let r = length(uv * 2.0 - 1.0) * 0.35;
return vec3<f32>(0.0232 * (1.06 - r * r));
let d = uv * 2.0 - 1.0;
return mix(vec3<f32>(0.0295, 0.0343, 0.0437), vec3<f32>(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.
+3 -2
View File
@@ -104,9 +104,10 @@ fn denoise_step(@builtin(global_invocation_id) id: vec3<u32>) {
}
}
// The viewport's studio backdrop (matches post.wgsl).
fn backdrop(uv: vec2<f32>) -> vec3<f32> {
let r = length(uv * 2.0 - 1.0) * 0.35;
return vec3<f32>(0.0232 * (1.06 - r * r));
let d = uv * 2.0 - 1.0;
return mix(vec3<f32>(0.0295, 0.0343, 0.0437), vec3<f32>(0.0110, 0.0130, 0.0168), uv.y) * (1.0 - 0.09 * dot(d, d));
}
fn tonemap(hdr: vec3<f32>) -> vec3<f32> {
+3 -3
View File
@@ -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 {
+1 -1
View File
@@ -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,
+7 -6
View File
@@ -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);
}
}