diff --git a/src/lib.rs b/src/lib.rs index 1dc927b..111ea41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,7 @@ pub struct RedrawArgs { impl Default for RedrawArgs { fn default() -> Self { Self { - background: vec4(0.05, 0.20, 0.85, 1.00), + background: vec4(0.25, 0.49, 0.93, 1.00), cam_yaw: std::f32::consts::FRAC_PI_4, cam_pitch: std::f32::consts::FRAC_PI_6, cam_distance: 3., @@ -71,6 +71,31 @@ fn cube(a: f32, b: f32) -> render::mesh::CpuMeshIndexed { mesh } +fn srgb_to_linear(color: Vec3) -> Vec3 { + color.map(|x| { + if x > 0.04045 { + ((x + 0.055) / 1.055).powf(2.4) + } else { + x / 12.92 + } + }) +} + +fn srgba_to_linear(color: Vec4) -> Vec4 { + let alpha = color.w; + let color = srgb_to_linear(vec3(color.x, color.y, color.z)); + vec4(color.x, color.y, color.z, alpha) +} + +fn color_to_wgpu(color: Vec4) -> wgpu::Color { + wgpu::Color { + r: color.x.into(), + g: color.y.into(), + b: color.z.into(), + a: color.w.into(), + } +} + impl Core { pub fn new(gpu: Gpu, pixel_size: UVec2) -> Self { let Gpu { @@ -133,12 +158,7 @@ impl Core { depth_slice: None, resolve_target: None, ops: wgpu::Operations { - load: wgpu::LoadOp::Clear(wgpu::Color { - r: args.background.x.into(), - g: args.background.y.into(), - b: args.background.z.into(), - a: args.background.w.into(), - }), + load: wgpu::LoadOp::Clear(color_to_wgpu(srgba_to_linear(args.background))), store: wgpu::StoreOp::Store, }, })], diff --git a/ui/src/main_window.ui b/ui/src/main_window.ui index ee6bd40..71fced1 100644 --- a/ui/src/main_window.ui +++ b/ui/src/main_window.ui @@ -168,8 +168,8 @@ 0 - 32 - 60 + 99 + 133