anenigmaticbug / raytracer_in_a_weekend Goto Github PK
View Code? Open in Web Editor NEWA multi-threaded raytracer written in Rust
A multi-threaded raytracer written in Rust
A lot of high quality sky-boxes on polyhaven use equirectangular images. It would be nice to be able to use them. Plus, dealing with a single equirectangular image is less hassle than dealing with 6 images for cubemaps.
Textures are a pretty fundamental building block and will allow us to create new types of scenes. Adding textures is also a challenge in "Ray Tracing in a Weekend".
Normal maps will allow us to render more realistic images. Plain Lambertian and metallic (with constant fuzz) materials get boring pretty fast.
We should be able to apply these materials to any object.
This will allow us to add new implementations without modifying the main code every time.
This will be needed for #14.
Not sure how this will impact runtime performance at this point. Right now, in a scene with ~150 randomly placed spheres, most of the time is spent in computing dot products for the ray-sphere intersection logic (the percentage of time will hopefully reduce with #6). So, I am optimistic that the performance hit won't be that significant.
Currently, the camera is configured by the following fields in JSON: pos
, lower_left_corner
, hz
, and vt
. Apart from pos
, none of them are intuitive. This is because they are meant for quick calculations; not ease of understanding. Contrast them with the fields that are needed to create a camera in code:
Camera::with_options(CameraInitOptions {
pos: Vec3::new(0.0, 0.0, 0.0),
look_at: Vec3::new(0.0, 0.0, 1.0),
vup: Vec3::new(0.0, 1.0, 0.0),
vt_fov: 30.0,
aspect: 2.0,
})
We should use the CameraInitOptions
fields in JSON too.
Currently, we have our own Vec3
and Ray3
types. This has worked well till now. But we should also look into using a proper math library like nalgebra or glam. Why?
We might not need to switch any time soon though.
Currently, the sky is just a gradient. This severely restricts the creative possibilities. Adding support for sky maps or sky domes would be pretty cool.
Currently, we generate a random scene every time we run the application. The application should read scenes from config files. This will have the following (obvious) benefits:
Each item has its own unique geometry and material. Each material has its own unique textures. This has 2 problems:
gen_random_balls
binary to load a 8192x4096 texture for each randomly placed lambertian ball (108 such balls)$ /usr/bin/time -v cargo run --release --bin gen_random_balls -- --seed 1822 > inputs/random.json
...
Maximum resident set size (kbytes): 6127440
...
They currently lack the code to compute UV coordinates and AABBs.
I'm thinking of splitting the code into 4 crates:
raytracer_core
(library): defines all the necessary traits + core logic.raytracer
(library): contains basic impls of those traits (for eg: it will contain spheres, planes, etc as geometry impls).raytracer_apps
(bin): contains binaries to perform general tasks like validating scene files, rendering scene files, etc.playground
(bin): contains custom trait impls (if any), code to create custom scenes and render them.The idea is that I (or anyone who wishes to dabble with my raytracer) could depend upon crates 1, 2, and 3 and create our own playground
crates without bundling every new material, geometry, etc into the main crate. This would be really useful for highly unique scenes that require a ton of one-off stuff.
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.