Open KMastroluca opened 1 year ago
Hey Kasene, it's really great to hear from you. I saw you pop up on GitHub recently and was really happy to learn that you're back - and focusing on Rust - and it's great to know that you are doing well.
It's cool that you are trying to learn Ray tracing just from reading and following my code, but please know that I totally cheated and despite working on graphics for 25 years I could never have written this code entirely on my own. This repo a straightforward Rust port of the examples from the free book our colleague Pete Shirley, you can find it here: https://raytracing.github.io/. I read the book one weekend a few months ago after Pete joined Activision, because I had seen other people do this and always wanted to try it myself, and because I would feel guilty working with Pete if I hadn't spent one silly weekend on his book. I hope you can meet him sometime, he's a great guy and I think you would hit it off.
Anyway, if you have the time, I'd highly recommend spending a weekend reading the book and building out your own version of the code as you go. You'll end up with something a bit like mine (I made some minor tweaks), and when you are done you've got a launchpad to go a lot further (RT the rest of your life).
If I had more time to play with this I would also be trying my own version of NeRFs and InstantNGP from https://github.com/NVlabs/instant-ngp which I think is probably the future of graphics, but I don't really work on graphics anymore, instead I'm focused on trying to make our artist tools better.
I'll keep following you on GitHub and feel free to leave me a comment anytime. Good luck!
Thats awesome. I totally check that book out and go thru the process. Graphics programming is still extremely daunting and Im still not that great at math. Still, I wont feel like Im a decent programmer until I write a raytracer.
Fun fact: I am currently a resident at the Maine State Prison and Ive shown them that I can write code, so i work building internal tools here for Maine Dept of Corrections. Theres three of us here of a skill level suitable to do this and its been really fun. They give me a laptop, access to the internet and Github and all the tools I need. Its been great and ive been writing code everyday preparing for my release on December 8th. Ive been here for 4 years...I wrote a POS System for cannabis dispensaries because they are forced to operate as cash based businesses. I want to expand it to help manage compliance and stuff like that. Its live right now in one dispensary in maine and we're getting feedback and bug reports. Also, I'm about to start working at UnlockedLabs as a paid developer working on a LMS data aggregation software.
It looks like Im gonna get out with a Job so I pretty happy about that. I can't ever thank you enough for what you did for me when I was younger. Are you still working out of the same office with Mike? If so, tell him I say hi.
It feels good to be back!
I want to learn how to build that Ray Tracer you used to tell me was required to be considered for an internship. I write a fair amount of rust these days, and I've honestly defeated my impostor syndrome recently so I've been more confident to take on more difficult challenges. But I read main.rs and my brain turned directly into scrambled eggs.
I see that you've written a 3D vector structure and implemented various functions for manipulating and transforming its values and in the case of a ray tracer these vectors represent beams of light (i think?) which is why you have this
Which, im sure is some textbook light refraction and algo, that I don't understand even a small tiny bit. Im sure reflect just bounces it off in whatever direction physics dictates.
Then, you implement traits for Adding, Subtracting, and Multiplying these vectors. Simple enough.
Then you implement your Sphere structure along with a function that, clearly does math stuff determining if the object is being hit with a ray of light, and then returning some Hit structure containing data about where it was hit, what kind of material the sphere is made out of which I assume somewhere down the line determines how the light is supposed to behave when reflecting or refracting light.
Next you define the attributes of your spheres:
I've got no idea what this is, other than the fact that you defined it under Materials, so....must be a material.
same with this
EDIT: You explained these ^^^^ in the Readme which I did not read, So, I'm just an egghead.
You implement the 3D camera and on Camera::new() you setup the camera in some position looking down on your spheres
Then you implement the light scattering behaviors for the different materials, and then in main() you setup the camera and loop thru all the pixels of the image and do more complicated algorithm math stuff.
I really wish I could understand this better. btw, I hope you're doing well, I went thru alot of bad stuff and now I'm doing pretty good and trying to get me a programming job somewhere. I've been working on a bunch of cool projects and making Open Source contributions. I'm not allowed to email you rn for some interesting reasons that ill gladly fill you in on later, so the only place I can talk is Github for now. But I'm glad to see that you're still the successful genius you've always been and I owe you a lot for teaching me C the hard way when I was a kid, and I'm eternally grateful for that.