pub struct RayMarchRenderer {
pub width: usize,
pub height: usize,
pub fov: f64,
pub camera_pos: [f64; 3],
pub camera_target: [f64; 3],
}Expand description
A simple camera/renderer that generates rays and produces image buffers via ray marching.
Fields§
§width: usizeImage width in pixels.
height: usizeImage height in pixels.
fov: f64Vertical field of view in radians.
camera_pos: [f64; 3]Camera position in world space.
camera_target: [f64; 3]Point the camera looks at.
Implementations§
Source§impl RayMarchRenderer
impl RayMarchRenderer
Sourcepub fn new(
width: usize,
height: usize,
fov: f64,
camera_pos: [f64; 3],
camera_target: [f64; 3],
) -> Self
pub fn new( width: usize, height: usize, fov: f64, camera_pos: [f64; 3], camera_target: [f64; 3], ) -> Self
Construct a new renderer.
Sourcepub fn generate_ray(&self, px: usize, py: usize) -> Ray
pub fn generate_ray(&self, px: usize, py: usize) -> Ray
Generate the primary ray for pixel (px, py).
Pixel coordinates are measured from the top-left corner.
Sourcepub fn render_depth(&self, sdf: &dyn Sdf) -> Vec<f64>
pub fn render_depth(&self, sdf: &dyn Sdf) -> Vec<f64>
Render the scene as a depth buffer.
Returns a flat width × height Vecf64where each element is thetvalue at the nearest surface hit, orf64::INFINITY` on a miss.
Trait Implementations§
Source§impl Clone for RayMarchRenderer
impl Clone for RayMarchRenderer
Source§fn clone(&self) -> RayMarchRenderer
fn clone(&self) -> RayMarchRenderer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RayMarchRenderer
impl RefUnwindSafe for RayMarchRenderer
impl Send for RayMarchRenderer
impl Sync for RayMarchRenderer
impl Unpin for RayMarchRenderer
impl UnsafeUnpin for RayMarchRenderer
impl UnwindSafe for RayMarchRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more