From 65413a2c2a82f415c4f2216f4e01cfd6b2b47ae6 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Tue, 23 Jun 2026 18:15:49 +0300 Subject: [PATCH] refactor(render): drop dead camera_pos from the shared uniform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No GPU pipeline reads camera_pos any more — lighting and all transforms moved to the relative-to-eye path (view_rot + eye_high/eye_low). Remove the field from the shared Uniforms and every shader struct, plus the now unused Camera::position_vec4. view_proj stays: the CPU frustum-cull / scissor / LOD passes still project offset-relative AABBs with it (it is no longer part of any GPU draw). Co-Authored-By: Claude Opus 4.7 --- src/scene/pipeline/uniforms.rs | 6 ++++-- src/scene/view/camera.rs | 3 --- src/shaders/face3d.wgsl | 1 - src/shaders/hatch.wgsl | 1 - src/shaders/hatch_batched.wgsl | 1 - src/shaders/image.wgsl | 1 - src/shaders/mesh.wgsl | 1 - src/shaders/wire.wgsl | 1 - 8 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/scene/pipeline/uniforms.rs b/src/scene/pipeline/uniforms.rs index e54c8935f..30a4a20da 100644 --- a/src/scene/pipeline/uniforms.rs +++ b/src/scene/pipeline/uniforms.rs @@ -4,8 +4,11 @@ use iced::Rectangle; #[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)] #[repr(C)] pub struct Uniforms { + /// Full view-projection (with translation) — GPU rendering no longer uses + /// this; it remains for the CPU-side frustum-cull / scissor / LOD passes + /// that project offset-relative AABBs to screen. The GPU draws via the + /// relative-to-eye `view_rot` + `eye_high`/`eye_low` below. pub view_proj: glam::Mat4, - pub camera_pos: glam::Vec4, pub viewport_size: [f32; 2], /// World units per screen pixel at the current zoom. Used by the /// hatch shader to substitute solid fill when pattern line spacing @@ -52,7 +55,6 @@ impl Uniforms { let (eye_high, eye_low) = camera.eye_high_low(); Self { view_proj: camera.view_proj(bounds), - camera_pos: camera.position_vec4(), viewport_size: [bounds.width, bounds.height], world_per_pixel, lwdisplay_enable: if lwdisplay_enable { 1.0 } else { 0.0 }, diff --git a/src/scene/view/camera.rs b/src/scene/view/camera.rs index fe73043d0..92bb82bdb 100644 --- a/src/scene/view/camera.rs +++ b/src/scene/view/camera.rs @@ -228,9 +228,6 @@ impl Camera { } } - pub fn position_vec4(&self) -> glam::Vec4 { - glam::Vec4::from((self.eye(), 0.0)) - } // ── ViewCube rotation matrix ─────────────────────────────────────────── diff --git a/src/shaders/face3d.wgsl b/src/shaders/face3d.wgsl index 84439bd44..bb5028aa0 100644 --- a/src/shaders/face3d.wgsl +++ b/src/shaders/face3d.wgsl @@ -6,7 +6,6 @@ struct Uniforms { view_proj: mat4x4, - camera_pos: vec4, viewport_size: vec2, world_per_pixel: f32, lwdisplay_enable: f32, diff --git a/src/shaders/hatch.wgsl b/src/shaders/hatch.wgsl index fbebc1ddf..7db44d6dd 100644 --- a/src/shaders/hatch.wgsl +++ b/src/shaders/hatch.wgsl @@ -14,7 +14,6 @@ struct Uniforms { view_proj: mat4x4, - camera_pos: vec4, viewport_size: vec2, world_per_pixel: f32, lwdisplay_enable: f32, diff --git a/src/shaders/hatch_batched.wgsl b/src/shaders/hatch_batched.wgsl index f0a1880c3..c4841e386 100644 --- a/src/shaders/hatch_batched.wgsl +++ b/src/shaders/hatch_batched.wgsl @@ -19,7 +19,6 @@ struct Uniforms { view_proj: mat4x4, - camera_pos: vec4, viewport_size: vec2, world_per_pixel: f32, lwdisplay_enable: f32, diff --git a/src/shaders/image.wgsl b/src/shaders/image.wgsl index d4356335a..79c77e9bb 100644 --- a/src/shaders/image.wgsl +++ b/src/shaders/image.wgsl @@ -5,7 +5,6 @@ // Must match the shared `Uniforms` struct (scene::pipeline::uniforms, 112 B). struct Uniforms { view_proj: mat4x4, - camera_pos: vec4, viewport_size: vec2, world_per_pixel: f32, lwdisplay_enable: f32, diff --git a/src/shaders/mesh.wgsl b/src/shaders/mesh.wgsl index 654b6fc86..c94cf7ab5 100644 --- a/src/shaders/mesh.wgsl +++ b/src/shaders/mesh.wgsl @@ -11,7 +11,6 @@ struct Uniforms { view_proj: mat4x4, - camera_pos: vec4, viewport_size: vec2, world_per_pixel: f32, lwdisplay_enable: f32, diff --git a/src/shaders/wire.wgsl b/src/shaders/wire.wgsl index b00a0a72a..0dc07e32c 100644 --- a/src/shaders/wire.wgsl +++ b/src/shaders/wire.wgsl @@ -15,7 +15,6 @@ struct Uniforms { view_proj: mat4x4, - camera_pos: vec4, viewport_size: vec2, world_per_pixel: f32, // LWDISPLAY toggle: 0.0 = force 1 px (half_width 0.5), 1.0 = use the