advaypal / raytracer-rust Goto Github PK
View Code? Open in Web Editor NEWA raytracer in Rust
A raytracer in Rust
Currently we instantiate a HitRecord
struct whenever a ray hits a surface. This is created to store certain values when the event occurs.
Perhaps we can abstract the hitting event away to a method as part of the Hittable
trait.
Intuitively hitting a surface should have a function causing a ray to reflect and other effects rather than creating any sort of struct
.
We rely on the following implicit behaviour to keep the pixel values within bounds of 0 - 255
.
Casting floats
to int
rounds the float
to zero
eprintln!("{}", 255.999 as i32);
Output:
255
Consider ways to make this conversion explicit
Upon executing cargo run > image.ppm
,
We trace the ray starting from the lower left corner of our screen.
We do so from left to right, bottom to top row.
Suppose the bottom left corner as RGB value of 255 0 0
.
Each time we trace, we print to stdout
.
The output is piped to image.ppm
.
The first RGB value written to image.ppm
will be 255 0 0
.
This corresponds to the top left pixel in the image.ppm
file.
(Pixels are rendered) in order from top to bottom. Each row consists of Width pixels, in order from left to right.
Following this reasoning, it seems our image is printed upside down.
Currently Color
is an enum value of VectorType
.
Perhaps we can model these separately since a Color
is not a vector
.
The book this project follows models it this way as well, maybe there's a good reason which I am unaware of.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.