Skip to content

Commit c48b5b5

Browse files
committed
Flip image
1 parent 9ba8f22 commit c48b5b5

3 files changed

Lines changed: 3 additions & 7 deletions

File tree

TODO.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ Once CPU-side camera is working:
8181

8282
## Technical Debt
8383

84-
1. [ ] **Ray tracer flips image left-to-right**: The interactive camera controls have inverted signs on movement and mouse look to compensate. The ray tracer appears to be rendering the image mirrored horizontally. The workaround is in `host/src/main.rs` (`update_camera`). The root cause should be investigated - likely in `Camera::new()` or `Camera::get_ray()` in `rtx-util/src/cam.rs`, possibly related to how pixel coordinates map to ray directions.
85-
86-
2. [ ] **Crash when camera enters an object**: The program sometimes crashes, likely when the camera position moves inside geometry. This may cause issues with ray-object intersection tests (e.g., negative t values, NaN from inside-surface calculations). Needs investigation.
84+
1. [ ] **Crash when camera enters an object**: The program sometimes crashes, likely when the camera position moves inside geometry. This may cause issues with ray-object intersection tests (e.g., negative t values, NaN from inside-surface calculations). Needs investigation.
8785

8886
2. [ ] `Array<T, N>` currently requires `T: Copy + Default` because we use `[Default::default(); N]` for initialization. This is overly restrictive. Ideally, `T` would only need to be "zeroable" (all zero bytes is a valid default). This would allow types like `Sphere` that aren't `Copy` but can be safely zero-initialized. The goal is something like `core::array::from_fn(|_| Default::default())` but in a form rust-gpu accepts.

crates/host/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ impl RustShaderSandboxApp {
144144
self.last_cursor_y = self.cursor_y;
145145

146146
// Update yaw/pitch from mouse (sensitivity factor)
147-
// Signs inverted to compensate for ray tracer's left-right flip
148147
let sensitivity = 0.003;
149148
self.cam_yaw -= mouse_dx * sensitivity;
150149
self.cam_pitch -= mouse_dy * sensitivity;
@@ -163,7 +162,6 @@ impl RustShaderSandboxApp {
163162
let speed = 5.0 * dt;
164163

165164
// Apply movement based on held keys
166-
// Signs inverted to compensate for ray tracer's left-right flip
167165
if self.keys_held.w {
168166
self.cam_pos[0] += forward_x * speed;
169167
self.cam_pos[2] += forward_z * speed;

crates/rtx-util/src/cam.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ impl Camera {
121121
let viewport_width = viewport_height * aspect_ratio;
122122

123123
let w = (lookfrom - lookat).normalize();
124-
let u = vup.cross(w).normalize();
125-
let v = w.cross(u);
124+
let u = w.cross(vup).normalize();
125+
let v = u.cross(w);
126126

127127
// Calculate the vectors across the horizontal and down the vertical viewport edges.
128128
let viewport_u = viewport_width * -u;

0 commit comments

Comments
 (0)