Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notes on camera coordinate system
- Loading branch information
Showing
3 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# `Camera` coordinate system | ||
|
||
The `Camera` class contains a coordinate system that can be used to generate rays using the thin-lens approximation for depth of field effects. Note: `right`, `up` are just normalized `horizontal`, `vertical` vectors. | ||
|
||
![camera-coordinates](img/camera.jpg) | ||
|
||
```rust | ||
// A WGSL shader example of how to generate a ray using `Camera`. | ||
fn generateCameraRay(camera: Camera, rngState: ptr<function, u32>, u: f32, v: f32) -> Ray { | ||
let randomPointInAperture = camera.lensRadius * randomVec3InUnitDisk(rngState); | ||
let lensOffset = randomPointInAperture.x * camera.right + randomPointInAperture.y * camera.up; | ||
|
||
let origin = camera.origin + lensOffset; | ||
let direction = camera.lowerLeftCorner + u * camera.horizontal + v * camera.vertical - origin; | ||
|
||
return Ray(origin, direction); | ||
} | ||
``` |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters