@@JordHaj Actually I believe GPT-4 is a greater teacher than Sebastian because you can ask it about anything, it can explain code for you, why you got an error and even fix the errors for you. It can explain in many different ways too if you just ask! 😊 It can also read documentation and lead you through problems step by step too!
@@Danuxsy What is the point of making a ray tracer in less than 5 minute using GPT-4, while you can use already created one ? Sabastian is learning and doing every single thing in this series, you can't imagine how much information he get out of this. For example In this video only, he learned how to perform doing random numbers, how to do communication between CPU and GPU to send mesh information, How to render meshes in ray tracer, How to calculate intersection between sphere and triangles, he learned about probability with normal distribution and uniform distribution, He did very useful visuals to check his work and equation. He did a really amazing work. It's not comparable with doing it using GPT-4.
It always sounds like Sebastian is explaining all this cool stuff with a massive smile on his face. Like you can just hear it in his voice. And his happiness make me happy in a way. I love your work, keep it up :D
It’s just the Scandinavian accent. It’s especially strong for Danish people, who often sound like they are smiling. Evidence for this is that I thought Lague was Danish before I checked the channel info, originally just to check if he might be Scandinavian. This accent results in a “happy” register in English. That being said it requires some level of happiness or concerted effort to sound like this. I assume it’s a bit of both.
@@user-bo5vr1ib6i never mind then. it was anecdotal evidence and even when I posted it I had this nagging feeling that it might be a totally spurious connection. Thanks for the correction.
That probably means a lot of testing that we don’t see. I’m a Java backend developer and writing some simple endpoints for say a Spring Boot server means first write the code that handles a request and then a bunch of tests which usually takes a large portion of the time.
He also gives the impression that he's pretending to come up with these ideas on the fly, together with the testing we don't see, it just becomes more of an ASMR parody. People worry about AI not attributing their creations to human generated training data and here we have a 1M+ YT channel blathering on as if he didn't lift shader code from open source projects like Blender or a million other places or even inspiration from any source. Sure, okay Sebastian - what have you woke up and just randomly thought of to code today? lol
@@thom1218 Maybe you didn't watch the video, but he clearly gave us the name and images of the books he read, and he clearly said that he borrowed code from others, whether it be from stackoverflow, or blender. So no, he didn't wake up with these ideas. He's spend quite some times studying and writing code. Hence why he barely uploads.
I am still in 9th grade and nor do I understand the maths here nor the code, but I love these videos. Whenever i watch a video of yours , I feel better. Thanks
That technical difficulty during the FOV part in the intro had me in stitches, unapologetically showing that even though we have the lofty goal of ray tracing we can still have something so trivial trip us up. I just love how incredibly informative as well as entertaining Sebastian is
I've made a raytracer in c++ as well , it isn't as easy as he shows , he just shows the concept and how the code works he puts a lot of effort than he shows.
I love how relaxing and inspiring your videos are. I’m always getting a humble„No big deal“ vibe, which pushes me to never be too proud of my achievements but accepting them as the next step but not the last. Thanks for your hard work! Very appreciated ❤
Hey Seb, I just wanted to appreciate the extra effort you take to code/setup your visualisations that aren't part of the project but enrich your explanations substanially. Animations, concise statements, music, all of it sparks my sometimes diminishing love and passion for programming. Thank you.
100% Agree. This must be lots of extra work, but even when I'm only understanding a fraction of the code & concepts (I quite enjoy being so lost tbh!) the animated examples and explanations give me something to grip into. I just had a horrible morning btw, and this vid has calmed me down soooo much. Also the images are beautiful!
I love how you walk through stuff like this. You get the audience to ask, "What is the next natural step?" and give them the breathing room to think of an answer. Then you show them what you came up with and sort of hint at why it is a useful concept more generally without saying it explicitly. Your videos are simply fantastic at getting people (specifically me) to think through complex problems in small rational steps. Bravo. Keep it up!
Congratulations Sebastian, you are hereby certified crazy for doing all your animations inside Unity. You may add that to your CV for future job applications.
It's amazing how I am entertained both by a gentleman like Sebastian, with his calm and warm voice, and by characters like The Code Bullet, his cursing and his madness. Different Content Creators, united together with many others by the passion for coding. ❤ thanks
Sebastien is Lawful Neutral, Coding Train is Neutral Good, and Code Bullet is Chaotic Neutral. We need to find the Neutral Evil coding channel to have the minimal alignment axes representation. It would be amazing to fill out a full 3x3 grid of coding youtubers, but I am not sure if there are that many.
As someone who does a lot of technical programs especially like this on Scratch, I love this content for two reasons. 1. It teaches you how to do everything and it is detailed. 2. It gives me ideas for demo scenes for when I share my code.
This is just a frivolous ammount of liquid GOLD! Wh-what the hell? I have been following you for a long time, but this Render Coding was AMAZING! I think it's been five years since I started modeling for a living in 3D and I, of course, understand how ray tracing works, but this level of detail was beyond my expectations, I learned a lot today! Thank you very much!!
Incredible video ! I usually have a hard time understanding these more complicated aspects of computers, games, renderers, basically technical stuff, and while it still is a struggle, your videos make these so much easier to comprehend or at least visualize. This 40min vid felt like a 20min one with how well everything was presented. Incredible stuff, as always ! And these renders are really cool looking !
If you would like some more knowledge about some of the topics in here like matrixes, shaders and general redering I would recommend reading the Free pdf book. LearnOpenGL. The first chapter goes quite in detail.
Absolutely glued to the screen. You produce some of the best balance of technical and visual teaching/adventuring I've ever seen, video after video, and this was by far my favorite! Wonderful work :)
I love your stuff. Your visuals are so clean and satisfying. You also have perfect concise explanation that are still very informational and in deapth. Honestly you are probably my favorite codeing/dev channels. Also, really good at getting me inspired to do similar projects for fun.
I wrote some kind of ray tracer 2 years ago, but for sound sources in a reflecting (reverbing) room. Like a 3D sound simulator. I just tried to figure out everything by myself without any knowledge - and of course i stumbled over some of problems i weren't able to solve by myself. It's really nice to see this video and how you came to every single of my problems and then showed how to solve them :)
I swear because of these types of videos i am learning again why i love to work in this field and how much I just love the sheer wonder and fascination of making math look good. I was grinning the whole time like an idiot during the reflections part and its also partly the fault of the video, because your videos are so well done and cinematic, I could watch them all day and just leave them running in the background
This was a super fascinating watch. Ray trace rendering was always one of those things I just accepted to be magic, but this broke things down in a way that was really incredibly easy to follow. Really great video.
Would highly suggest adding a bounding volume hierarchy to your little renderer! Makes a world of difference in performance. Also if you really want to get into the advanced features of a path tracer, try implementing multiple importance sampling with next event estimation!
I specialised in physically-based rendering during my master's degree, had to do a whole ray-tracing project very similar to this so was very nice to revisit some of the theory along with such wonderful visualisation. Your presentation of the ideas at play here is an absolute joy and your code is pristine as ever - always a pleasure to see what you're working on, thanks for the great content! :)
is this how ray tracing is implemented (bounce around till you reach light source) or people use phong's shading (calculate shadow and reflected ray) to get ray traced results??
13:01 The spherical symmetry is because the joint probability of multiple independent Gaussians e^(-x^2) looks like e^(-x^2) * e^(-y^2) = e^(-x^2-y^2) = e^(-r^2) which only depends on the radius and so is spherically symmetric. So Gaussians are useful here because they exploit the group structure of exponents to recover the radius just by being multiplied together. Thanks for this video, it was very satisfying to see you build a raytracer from scratch with much more success than I ever had! I would love to see a continuation of this with denoising, importance sampling, SDF support (fractals 😍), or any of the other features you mentioned at the end
Running a butter smooth code means a lot of testing and tons of bug fixing that we don’t see. He goes through these issues to create 40min~ long videos for us
Impressive to say the least. You're able to take complex subjects and turn them into easy to understand lessons that are also beautiful works of art. Really enjoyed this
After watching your whole coding adventure series, I start to realize that either you are really good at making this look complicated or I know much less about this stuff then I thought.
Hey man just wanted to post a comment to express my love for your videos. Im currently in school studying software development but my love for programming and technology goes beyond that. I'm not the smartest guy and I'm not going to pretend to understand everything you do or say. But man I've learned ALOT. So far the most fascinating thing you taught me is the HOW math is actually used in creating all sorts of things. I've always heard that math is important but I never got an explanation for why or how. I appreciate and love everything you do and I hope you continue making videos like this for a long time. Much love ❤
I am blown away by this video. You made not only one of the best ray tracing explanations I've seen, but a really cool engine as well! I'd love to see this become a series, maybe touching on performance improvements and code optimization as well.
13:00 You want to create points using a distribution in (x,y,z) that is only a function of (x^2 + y^2 + z^2) = r^2 (that means it has no dependence on direction, which means the points will be evenly spaced across the surface of a sphere). If we take x, y, z separately, the resulting distribution f(x, y, z)dx dy dz = f(x)dx \* f(y)dy \* f(z)dz (this is because the three are independent (because we calculated them separately), so the probability of finding our output position in the range (x, y, z) -> (x+dx, y+dy, z+dz) is equal to the probability of finding x in that range, times the probability of finding y, in that range, times the probability of finding z in that range. Like how the probability of flipping a coin and getting heads three times is the probability of getting heads once, times the probability of getting heads once, times the probability of getting heads once) Intuitively, it seems that we should take x, y, z from the same distribution (because it's independent of direction, we can't treat different directions differently). Applying these, we see: f(r^2) = f(x^2 + y^2 + z^2) = f(x^2)\*f(y^2)\*f(z^2) What type of function is defined by f(a+b) = f(a)\*f(b)? An exponential. So we find our distribution must be f(r^2) = exp(-r^2), which is a normal distribution. I hope that helps, if I have explained anything badly please say so!
Was just watching the new 2Blue1Brown video "Why π is in the normal distribution (beyond integral tricks)" and it basically explained this. Very interesting.
I noticed he did the same thing in the defocus code at 33:00, realistic/"ideal" lens blur tends to follow a gaussian curve, would that mean you'd want your ray distribution from the single pixel in the camera to follow a similar curve?
I think I remember someone doing a straight poisson distribution lookup to a table of pre-calculated coordinates for some of these ray directions. I think the idea was to get solid randomness cheaply as you were looking them up instead of calculating them. It was a disk and for better randomness you could just keep rotating the disk. (for say different ray hits or frame numbers) I didn't do this myself but its a memory of something that might have happened. :D
Very impressive results! And the approach you took on the depth of field effect is really clever! One thing I'd suggest looking into is avoiding branches - particularly if statements and loops that run a different number of times for each pixel. You can use compound assignments in a lot of these cases, even in cases where you conditionally want to leave variables unchanged. The reason for this is that GPUs are optimized for running the same code millions of times with different numbers. They have thousands of cores that are all being handed the same instructions, and if there's a branch, that means the GPU has to discard the results from a lot of its cores and re-do the process again for the other paths the shader code can take. Even if writing branchless code means your GPU is doing more work per pixel, you might end up with a net improvement in performance just because your GPU isn't re-doing the same work several times to handle branches in your code. The RandomDirection function at 12:00 and the new one at 12:50 are a perfect example of this: the first version is, on average, much cheaper, but runs some random number of times before it exits and thus forces the GPU to do a large number of re-dos. The version based on a gaussian distribution is more computationally expensive but lets the GPU get all of its results in one shot, so it's faster. I have a fair bit of experience writing compute shaders in HLSL (and some graphics-related ones with GLSL) and it's often a night-and-day difference. With lots of nested conditions like you have here I wouldn't be surprised to see hundred-fold improvements in performance if you write your code with this in mind. If you'd like some help with this, feel free to shoot me a reply :)
A quick note about the rejection method you used for the random direction originally, while it is true that about half of the time it will find a good candidate, so on the CPU it would only run on average less than 2 times, on the GPU threads are done in groups of 32 (NVIDIA) or 64 (Intel, AMD), and the threads in one of these groups can only continue once all of them does. I did some tests and that results in 6 or so iterations before exiting on average on 32 thread systems.
this is amazing!!! it's so cool how each step builds up to a good-looking ray tracing implementation despite all of them seeming relatively simple compared to how complicated rt seems as a whole. you're really good at explaining things! i understand how it's ray tracing works much better now, thank you :)
I had to rewatch the explanation for the noise like 15 times because I kept getting distracted by the cat. I'm not complaining, I loved that. (Another winner of a video my man)
This is the exact kind of thing that I love about programming. I recently made my first pathfinding program in pygame (using Sebastian's A* video), and seeing it work was the best feeling. I feel like making a game would give you that every once in a while, but with little experiments the whole goal is to get a single system working well.
You have a great understanding of code and programming concepts, and you're able to explain them clearly and effectively. You have a knack for debugging and solving complex issues and your attention to detail and ability to write clean and efficient code is impressive. I take you as an inspiration.
Thank you for producing such a quality work, I have never ever seen someone that explains something which is directly illustrated with a game engine like you! Coding Adventure = Masterpiece. 👏🏼
Ok but the way you sound is so optimistic and calming I never can let go of a smile while watching - its almost like you are grinning while recording the audio!
I cannot imagine how much work it is to write the storyline, code everything, take it apart again to "live" good for the video while perfectly narrating. You are one of my favorit tubers and I always have to restrain myself to not share your video with everyone I know! (Though I have shared them many times anyway)
I just literally had a "click" moment in my brain when you were pulling the knight back and forth and now understand how focal planes work. After decades of DSLR photography where I had an understanding of the effect I wanted to achieve.. it just went click and I understand it at a different level. Anyway, great video :) I love these.
Ray casting instead of ray tracing, which only proves I took computer graphics courses about a decade ago. Ray tracing is the accepted name of the process (e.g., RTX4080). I am making this the year I restart my CG journey. You actually provided a lot of great debugging ideas,. I remember debugging being one of the main hurdles in the courses I took a decade ago. Glad to see you reference the Peter Shirley books as I will use then when I get started.
@@GnuSnu Einstein: My comment were based on his utube post in which (if you are paying attention) the code is on display in addition to the 'pretty pictures'.
It's all ray tracing. There's so many variants it's pointless to try to assign one name to one variant. It all comes down to the maths of calculating intersections between rays and geometry. RTX-based ray tracing is simply hardware-accelerated ray tracing. In other words, the hardware assists in doing the maths of tracing the rays. It's still ray tracing with it's done with dedicated hardware or not.
@@clonkex In CompSci the formal term is ray casting, but ray tracing is the term used. Actual true ray tracing is performed in optical design as rays are traced through an optical system.
This seems like a great way to try out materials that aren't physically possible. - What does a material look like if light always bounces away directly along normal vectors? - Vampire materials -- they're invisible in mirrors (only show in first bounce) - Reverse vampires -- invisible when viewed directly (ignored as a 1st bounce), but show up in reflections
I don't think the basics of the algorithm would be much different, you just cut off the ray after collision and make a new one with same properties starting from the end of the portal, it would be laggy as hell though because of how much more information the renderer needs to account for
Sadly it's way less complicated to do this than most things you see in this video (sad as in it's gonna be trivial in math so that it'd barely be a minute in the video, at least in coding it). It's gonna work the same as perfect refraction or reflection, which we already got.
I've been secretly hoping these videos and topics have all been related to some hidden project. Imagine if once he's done enough of them, a new series starts "Making my own game engine" and then he just starts building things from scratch again.
I have never understood a thing of what you have done - but I have watched a lot of these videos. They are super great to watch to just get a wash of 'I'm still learning' as an adult
Man, this is by far my favorite channel on TH-cam. The stuff you create is always so cool and interesting, and the quality is just out of this world. I honestly wouldn't be surprised if you spent significantly more time coding the visualizations of what your code does than writing the actual code, but that effort really pays off in the final video.
Sebastian and jdh are probably the best programmers on YT when it comes to games, math, graphics and more. Always a pleasure to watch their last creation.
Please! hear this out: when Sebastian tried averaging the pixels over multiple frames, he got really blurry results with moving objects. (Progressive Rendering) But If he stores the ray trace data to a list (per screen pixel), and then averages that, he will get the same effect. But then he should have each frame's data gradually lose the influence it has in it's pixel, until the oldest data has no influence, and is discarded. I think the effect this will have is: Decent real-time ray tracing, and easy motion blur!
Nice job, I'm subscribed and I love your videos. There is a huge inaccuracy I want to correct though, yes coatings/waxes/varnishes are an important aspect of understanding the surface properties (especially in automotive rendering) but a specular that keeps the color of the light source is the default, and is the behavior of all dielectric materials. Metals are the exception, which modify the color of the light when reflecting it back. Most rendering packages will either use a Metallicity property/texture to specify this (allowing for a single texture to have both), or just use different shaders for each.
Oh and another compliment, your depiction of focal planes and focus is a really good demonstration for a principle that people have trouble understanding. I like the circle you are using to show the area of the distribution of offsets from the view origin, which is conceptually the pupil/aperture/f-stop of the lens, which is all at the same point in the original renderer, the demonstration of the pinhole camera model.
Sebastian is really setting a new high standard of coding videos. It's a pleasure to watch, even for an experienced software engineer, with a lot of information and inspiration.
This is amazing. Filled with detail and excitement as you explain, it makes as I want to do it as well. Although could as well be a tutorial, it seems so entertaining and interesting watching what would happen. I subscribed and would like to follow and enjoy while you talk of the capabilities to accomplish. I did not know it could do so much, the programs. Thank you for making this and explaining along the way.
I think I've said this before in a previous video, but even though I have almost no idea what you're talking about on a technical level, I thoroughly enjoy listening to you explain it. Your obvious enjoyment of the subject is clear.
What i find so interesting in these series is that it takes a very complex subject and experiements with them during the development process which really does help in understanding.
Sebastian doesn't upload often, but when he does you know I'm clicking on it immediately
@@Danuxsy Is that supposed to be a flex?
@@Danuxsy weird flex but ok. Did you make a more entertaining and informative video than Sebastian?
@@JordHaj Actually I believe GPT-4 is a greater teacher than Sebastian because you can ask it about anything, it can explain code for you, why you got an error and even fix the errors for you. It can explain in many different ways too if you just ask! 😊 It can also read documentation and lead you through problems step by step too!
@@Danuxsy but that's kinda obvious, it learned from the entire internet.
@@Danuxsy What is the point of making a ray tracer in less than 5 minute using GPT-4, while you can use already created one ? Sabastian is learning and doing every single thing in this series, you can't imagine how much information he get out of this. For example In this video only, he learned how to perform doing random numbers, how to do communication between CPU and GPU to send mesh information, How to render meshes in ray tracer, How to calculate intersection between sphere and triangles, he learned about probability with normal distribution and uniform distribution, He did very useful visuals to check his work and equation. He did a really amazing work. It's not comparable with doing it using GPT-4.
Whenever Sebastian says "How this works is super simple", I pay extra attention.
Ye
Nnyyyyyes
You are the Bob Ross of coding with phrases like "Our little raytracer" and I love it.
What a great analogy
I wanted to say this
There are no bugs only happy accidents
@@stickguy9109 no errors only happy little exceptions
this is so true. its so relaxing. even though I could never code like him :)
It always sounds like Sebastian is explaining all this cool stuff with a massive smile on his face. Like you can just hear it in his voice. And his happiness make me happy in a way. I love your work, keep it up :D
It’s just the Scandinavian accent. It’s especially strong for Danish people, who often sound like they are smiling. Evidence for this is that I thought Lague was Danish before I checked the channel info, originally just to check if he might be Scandinavian. This accent results in a “happy” register in English. That being said it requires some level of happiness or concerted effort to sound like this. I assume it’s a bit of both.
@@aaAa-vq1bd Interesting. Thanks for the info
@@user-bo5vr1ib6i never mind then. it was anecdotal evidence and even when I posted it I had this nagging feeling that it might be a totally spurious connection. Thanks for the correction.
@@aaAa-vq1bd No problem. Have a nice day :)
He is the type of person who would scream in lowercase
Always a good day when a Coding Adventure releases
150
I was a bit skeptical at first because it is april first
Absolutely! It's like getting an unexpected package in the mail, but better because it's code!
@@BenPanna true, already got april fooled 3 times today on youtube
*cooding adventure
"Truly one of the artworks of all time."
Couldn't agree more, it's definitely one of them!
anyway whats going on with this tomato
That's the joke, well done
@@soilcredibility that's the joke, well done
how come i saw this comment the second that he actually said it because i had the video playing in the background
When others code it is frustrating but when Sebastian codes it looks like he is Ballet Dancing like the world is on 0 difficulty
That probably means a lot of testing that we don’t see.
I’m a Java backend developer and writing some simple endpoints for say a Spring Boot server means first write the code that handles a request and then a bunch of tests which usually takes a large portion of the time.
So true
He also gives the impression that he's pretending to come up with these ideas on the fly, together with the testing we don't see, it just becomes more of an ASMR parody. People worry about AI not attributing their creations to human generated training data and here we have a 1M+ YT channel blathering on as if he didn't lift shader code from open source projects like Blender or a million other places or even inspiration from any source. Sure, okay Sebastian - what have you woke up and just randomly thought of to code today? lol
He does take a long time to make these videos, but he is really sharp.
@@thom1218 Maybe you didn't watch the video, but he clearly gave us the name and images of the books he read, and he clearly said that he borrowed code from others, whether it be from stackoverflow, or blender. So no, he didn't wake up with these ideas. He's spend quite some times studying and writing code. Hence why he barely uploads.
I am still in 9th grade and nor do I understand the maths here nor the code, but I love these videos.
Whenever i watch a video of yours , I feel better.
Thanks
Sebastian is the definition of quality over quantity
You’re the definition of an unoriginal commenter
im so confused it says theres one comment to this comment while i see nothing
@@dip8 well hello there. My comment said:
“You’re the definition of an unoriginal commenter”
@@vignotum132 k lol ty
@@dip8 extremely common youtube bug. the number of replies is wrong like 50% of the time
29:53 "Truly one of the artworks of all time"
"Anyway, what's going on with this tomato?"
I died here
The juxtaposition between the calm, confident voiceover and the sudden bugs never fails to make me chuckle
especially the one near the start of this video, bugs and issues USUALLY dont happen that quickly... USUALLy...
He always sounds like hes smiling which makes him so pleasing to watch and listen to
Thats sums up my thoughts on his voice so perfectly lmao
MOM! SEBASTIAN LAGUE DROPPED ANOTHER VIDEO! CANCEL THE DENTIST!
Or watch it while at the dentist! With his soothing voice and fascinating content, It oughta be better than lidocaine
Literally me minus the dentist 😂
how did you comment on this video 10hours ago? (it's been posted just 3minutes ago)
@@GnuSnu probably members only video for a bit or unlisted
I always hated the dentist, yeah, let’s cancel ‘em!
That technical difficulty during the FOV part in the intro had me in stitches, unapologetically showing that even though we have the lofty goal of ray tracing we can still have something so trivial trip us up. I just love how incredibly informative as well as entertaining Sebastian is
The series continues, and I'm very grateful for this Sebastian!
I am grateful for the kity!
I can't even begin to image how much work it must have been to write all these visualizations. Keep up the good work.
how in the world did you make this so nice to watch
the catto, the tomato, and your slight sense of humor is simply perfect
I've made a raytracer in c++ as well , it isn't as easy as he shows , he just shows the concept and how the code works he puts a lot of effort than he shows.
@@hmmmidkkk yes, we know
I love how relaxing and inspiring your videos are. I’m always getting a humble„No big deal“ vibe, which pushes me to never be too proud of my achievements but accepting them as the next step but not the last. Thanks for your hard work! Very appreciated ❤
Hey Seb, I just wanted to appreciate the extra effort you take to code/setup your visualisations that aren't part of the project but enrich your explanations substanially. Animations, concise statements, music, all of it sparks my sometimes diminishing love and passion for programming. Thank you.
100% Agree. This must be lots of extra work, but even when I'm only understanding a fraction of the code & concepts (I quite enjoy being so lost tbh!) the animated examples and explanations give me something to grip into. I just had a horrible morning btw, and this vid has calmed me down soooo much. Also the images are beautiful!
Don't forget the occasional appearance of his cat! Lol
I love how you walk through stuff like this. You get the audience to ask, "What is the next natural step?" and give them the breathing room to think of an answer. Then you show them what you came up with and sort of hint at why it is a useful concept more generally without saying it explicitly. Your videos are simply fantastic at getting people (specifically me) to think through complex problems in small rational steps. Bravo. Keep it up!
I don’t know if I’m disappointed or excited. I was expecting a April fools video but honestly this is the best video released today. ❤
It's a waste of time using TH-cam on April fools. Mostly just unfunny crap.
Good to see a proper video.
True I also thought that
I love how you're keeping these classic sign flip issues and little mistakes in the video - very relatable ❤
"Truly one of the artworks of all time. Anyway, what's going on with this tomato?" is easily one of the transitions I've ever seen.
Congratulations Sebastian, you are hereby certified crazy for doing all your animations inside Unity.
You may add that to your CV for future job applications.
It's amazing how I am entertained both by a gentleman like Sebastian, with his calm and warm voice, and by characters like The Code Bullet, his cursing and his madness. Different Content Creators, united together with many others by the passion for coding. ❤ thanks
I literally came straight from a CodeBullet video to here, and totally agree, it's hilarious!
😂They're the angel and devil on coding's shoulder. You're going to learn through amazing content, but it's either through tranquility or chaos.🤣
Sebastien is Lawful Neutral, Coding Train is Neutral Good, and Code Bullet is Chaotic Neutral. We need to find the Neutral Evil coding channel to have the minimal alignment axes representation. It would be amazing to fill out a full 3x3 grid of coding youtubers, but I am not sure if there are that many.
@@flabort the coding train can be Chaotic Good... 😂
As someone who does a lot of technical programs especially like this on Scratch, I love this content for two reasons.
1. It teaches you how to do everything and it is detailed.
2. It gives me ideas for demo scenes for when I share my code.
On Scratch?? The visual scripting "language" meant for teaching children basic coding principles?
Man i love this 'Coding Adventure' series.
Insane video, as usual
This is just a frivolous ammount of liquid GOLD! Wh-what the hell? I have been following you for a long time, but this Render Coding was AMAZING! I think it's been five years since I started modeling for a living in 3D and I, of course, understand how ray tracing works, but this level of detail was beyond my expectations, I learned a lot today!
Thank you very much!!
I'm happy you enjoyed it so much, thank you!
Incredible video ! I usually have a hard time understanding these more complicated aspects of computers, games, renderers, basically technical stuff, and while it still is a struggle, your videos make these so much easier to comprehend or at least visualize. This 40min vid felt like a 20min one with how well everything was presented. Incredible stuff, as always ! And these renders are really cool looking !
If you would like some more knowledge about some of the topics in here like matrixes, shaders and general redering I would recommend reading the Free pdf book. LearnOpenGL. The first chapter goes quite in detail.
learning about technical stuff could be so visually stunning? 😄 enjoyed the video and were able to keep up
Absolutely glued to the screen. You produce some of the best balance of technical and visual teaching/adventuring I've ever seen, video after video, and this was by far my favorite! Wonderful work :)
I love your stuff. Your visuals are so clean and satisfying. You also have perfect concise explanation that are still very informational and in deapth. Honestly you are probably my favorite codeing/dev channels.
Also, really good at getting me inspired to do similar projects for fun.
Also kity 🐱
@@TheBcoolGuy Definite plus.
his video feels both calm and inspiring, and never boring
I wrote some kind of ray tracer 2 years ago, but for sound sources in a reflecting (reverbing) room. Like a 3D sound simulator. I just tried to figure out everything by myself without any knowledge - and of course i stumbled over some of problems i weren't able to solve by myself. It's really nice to see this video and how you came to every single of my problems and then showed how to solve them :)
I never understand the coding part, but I love watching for the adventure! The way he explains things and his narration is always so soothing.
I swear because of these types of videos i am learning again why i love to work in this field and how much I just love the sheer wonder and fascination of making math look good. I was grinning the whole time like an idiot during the reflections part and its also partly the fault of the video, because your videos are so well done and cinematic, I could watch them all day and just leave them running in the background
Just don't forget to actually do some work in between leaving the video running all day 😉
This was a super fascinating watch. Ray trace rendering was always one of those things I just accepted to be magic, but this broke things down in a way that was really incredibly easy to follow. Really great video.
Would highly suggest adding a bounding volume hierarchy to your little renderer! Makes a world of difference in performance. Also if you really want to get into the advanced features of a path tracer, try implementing multiple importance sampling with next event estimation!
I love that you said “Suzanne enters the Avatar State” as a way of describing making the model’s eyes glow
I specialised in physically-based rendering during my master's degree, had to do a whole ray-tracing project very similar to this so was very nice to revisit some of the theory along with such wonderful visualisation. Your presentation of the ideas at play here is an absolute joy and your code is pristine as ever - always a pleasure to see what you're working on, thanks for the great content! :)
is this how ray tracing is implemented (bounce around till you reach light source) or people use phong's shading (calculate shadow and reflected ray) to get ray traced results??
13:01 The spherical symmetry is because the joint probability of multiple independent Gaussians e^(-x^2) looks like e^(-x^2) * e^(-y^2) = e^(-x^2-y^2) = e^(-r^2) which only depends on the radius and so is spherically symmetric. So Gaussians are useful here because they exploit the group structure of exponents to recover the radius just by being multiplied together.
Thanks for this video, it was very satisfying to see you build a raytracer from scratch with much more success than I ever had!
I would love to see a continuation of this with denoising, importance sampling, SDF support (fractals 😍), or any of the other features you mentioned at the end
Gotta put everything down and watch every time I see the notification for these.
His voice complements his programming and editing style so nicely.
So Marvelous ! The fact he employed real life laws and the fact they actually worked Is truly outstanding !!
I know a lot of people praise your editing, but man... I'll have to join the choir 😂 Your editing is stellar!!
Running a butter smooth code means a lot of testing and tons of bug fixing that we don’t see.
He goes through these issues to create 40min~ long videos for us
i greatly appreciate the cat footage and getting to hear the purring even
Impressive to say the least. You're able to take complex subjects and turn them into easy to understand lessons that are also beautiful works of art. Really enjoyed this
After watching your whole coding adventure series, I start to realize that either you are really good at making this look complicated or I know much less about this stuff then I thought.
He is actually really good at making this look much more easy than it is. xD
Things like this blow my mind. Glad their was people out there who created rendering like this so we could enjoy the fruits of it.
why?
Hey man just wanted to post a comment to express my love for your videos.
Im currently in school studying software development but my love for programming and technology goes beyond that. I'm not the smartest guy and I'm not going to pretend to understand everything you do or say. But man I've learned ALOT.
So far the most fascinating thing you taught me is the HOW math is actually used in creating all sorts of things. I've always heard that math is important but I never got an explanation for why or how.
I appreciate and love everything you do and I hope you continue making videos like this for a long time. Much love ❤
I am blown away by this video. You made not only one of the best ray tracing explanations I've seen, but a really cool engine as well! I'd love to see this become a series, maybe touching on performance improvements and code optimization as well.
I didn't expect a video about programming to be so soothing. I love this.
Your videos never fail to entertain me
That explanation of a normal vector was only a few seconds long and still explained it in the best way possible (sponsored by Viridian)
13:00
You want to create points using a distribution in (x,y,z) that is only a function of (x^2 + y^2 + z^2) = r^2 (that means it has no dependence on direction, which means the points will be evenly spaced across the surface of a sphere).
If we take x, y, z separately, the resulting distribution f(x, y, z)dx dy dz = f(x)dx \* f(y)dy \* f(z)dz (this is because the three are independent (because we calculated them separately), so the probability of finding our output position in the range (x, y, z) -> (x+dx, y+dy, z+dz) is equal to the probability of finding x in that range, times the probability of finding y, in that range, times the probability of finding z in that range. Like how the probability of flipping a coin and getting heads three times is the probability of getting heads once, times the probability of getting heads once, times the probability of getting heads once)
Intuitively, it seems that we should take x, y, z from the same distribution (because it's independent of direction, we can't treat different directions differently).
Applying these, we see:
f(r^2) = f(x^2 + y^2 + z^2) = f(x^2)\*f(y^2)\*f(z^2)
What type of function is defined by f(a+b) = f(a)\*f(b)? An exponential.
So we find our distribution must be f(r^2) = exp(-r^2), which is a normal distribution.
I hope that helps, if I have explained anything badly please say so!
Was just watching the new 2Blue1Brown video "Why π is in the normal distribution (beyond integral tricks)" and it basically explained this. Very interesting.
I noticed he did the same thing in the defocus code at 33:00, realistic/"ideal" lens blur tends to follow a gaussian curve, would that mean you'd want your ray distribution from the single pixel in the camera to follow a similar curve?
I think I remember someone doing a straight poisson distribution lookup to a table of pre-calculated coordinates for some of these ray directions.
I think the idea was to get solid randomness cheaply as you were looking them up instead of calculating them.
It was a disk and for better randomness you could just keep rotating the disk. (for say different ray hits or frame numbers)
I didn't do this myself but its a memory of something that might have happened. :D
The quality of these videos is through the roof. I can imagine how much work goes into each video and I'm honestly floored.
These videos are truly exceptional. Really a part of the few content creators of true excellence.
Very impressive results! And the approach you took on the depth of field effect is really clever!
One thing I'd suggest looking into is avoiding branches - particularly if statements and loops that run a different number of times for each pixel. You can use compound assignments in a lot of these cases, even in cases where you conditionally want to leave variables unchanged. The reason for this is that GPUs are optimized for running the same code millions of times with different numbers. They have thousands of cores that are all being handed the same instructions, and if there's a branch, that means the GPU has to discard the results from a lot of its cores and re-do the process again for the other paths the shader code can take. Even if writing branchless code means your GPU is doing more work per pixel, you might end up with a net improvement in performance just because your GPU isn't re-doing the same work several times to handle branches in your code.
The RandomDirection function at 12:00 and the new one at 12:50 are a perfect example of this: the first version is, on average, much cheaper, but runs some random number of times before it exits and thus forces the GPU to do a large number of re-dos. The version based on a gaussian distribution is more computationally expensive but lets the GPU get all of its results in one shot, so it's faster.
I have a fair bit of experience writing compute shaders in HLSL (and some graphics-related ones with GLSL) and it's often a night-and-day difference. With lots of nested conditions like you have here I wouldn't be surprised to see hundred-fold improvements in performance if you write your code with this in mind.
If you'd like some help with this, feel free to shoot me a reply :)
A quick note about the rejection method you used for the random direction originally, while it is true that about half of the time it will find a good candidate, so on the CPU it would only run on average less than 2 times, on the GPU threads are done in groups of 32 (NVIDIA) or 64 (Intel, AMD), and the threads in one of these groups can only continue once all of them does. I did some tests and that results in 6 or so iterations before exiting on average on 32 thread systems.
The final animation focusing on the knight looked so nice, really great video!
this is amazing!!! it's so cool how each step builds up to a good-looking ray tracing implementation despite all of them seeming relatively simple compared to how complicated rt seems as a whole. you're really good at explaining things! i understand how it's ray tracing works much better now, thank you :)
This channel is a good example of quality over quantity
you've got no idea how much this video means to me, i've been trying to code a ray tracer helplessly for the past few months, thanks a ton :D
I had to rewatch the explanation for the noise like 15 times because I kept getting distracted by the cat.
I'm not complaining, I loved that.
(Another winner of a video my man)
Each of your coding adventures is very inspiring, love your content!
Just wow. Skills in so many fields. Video editing, story telling, coding, voice overs, animation, teaching, just to name a few
Please a part 2 on optimising this and adding more features. It would be so satisfying to get this closer to realtime if even feasible
This is the exact kind of thing that I love about programming. I recently made my first pathfinding program in pygame (using Sebastian's A* video), and seeing it work was the best feeling. I feel like making a game would give you that every once in a while, but with little experiments the whole goal is to get a single system working well.
You have a great understanding of code and programming concepts, and you're able to explain them clearly and effectively. You have a knack for debugging and solving complex issues and your attention to detail and ability to write clean and efficient code is impressive. I take you as an inspiration.
Thank you for producing such a quality work, I have never ever seen someone that explains something which is directly illustrated with a game engine like you! Coding Adventure = Masterpiece. 👏🏼
Man no way this is amazing, im always happy when you release a video
Ok but the way you sound is so optimistic and calming I never can let go of a smile while watching - its almost like you are grinning while recording the audio!
is it just me, or does Seb sound like hes smiling the whole time as he records
it's you
Kind of, that's why his voice is such a good and relaxing sound to listen.
Nah he just has an annoying accent
@@aurelia8028 idk I think his accent is fine. He sounds rly laid-back and it makes the videos much more enjoyable and calm to listen to
I cannot imagine how much work it is to write the storyline, code everything, take it apart again to "live" good for the video while perfectly narrating.
You are one of my favorit tubers and I always have to restrain myself to not share your video with everyone I know! (Though I have shared them many times anyway)
Nice
I always love when new videos are out
I just literally had a "click" moment in my brain when you were pulling the knight back and forth and now understand how focal planes work. After decades of DSLR photography where I had an understanding of the effect I wanted to achieve.. it just went click and I understand it at a different level.
Anyway, great video :) I love these.
Ray casting instead of ray tracing, which only proves I took computer graphics courses about a decade ago. Ray tracing is the accepted name of the process (e.g., RTX4080). I am making this the year I restart my CG journey. You actually provided a lot of great debugging ideas,. I remember debugging being one of the main hurdles in the courses I took a decade ago. Glad to see you reference the Peter Shirley books as I will use then when I get started.
how did you comment on this video 10hours ago? (it's been posted just 3minutes ago)
@@GnuSnu Einstein: My comment were based on his utube post in which (if you are paying attention) the code is on display in addition to the 'pretty pictures'.
It's all ray tracing. There's so many variants it's pointless to try to assign one name to one variant. It all comes down to the maths of calculating intersections between rays and geometry. RTX-based ray tracing is simply hardware-accelerated ray tracing. In other words, the hardware assists in doing the maths of tracing the rays. It's still ray tracing with it's done with dedicated hardware or not.
@@clonkex In CompSci the formal term is ray casting, but ray tracing is the term used. Actual true ray tracing is performed in optical design as rays are traced through an optical system.
@@GnuSnu P.S: I am also on Patreon and may have seen it there. I did not make it up.
Unity in house engineers should be jealous of what you know and how you explain. Take a class of them dude.
Do I understand anything? No. Do I watch it to the end? Yes.
This seems like a great way to try out materials that aren't physically possible.
- What does a material look like if light always bounces away directly along normal vectors?
- Vampire materials -- they're invisible in mirrors (only show in first bounce)
- Reverse vampires -- invisible when viewed directly (ignored as a 1st bounce), but show up in reflections
Can you try raytracing-based portals next time? Like, teleporting the ray instead of bounce.
portal rtx be like
I don't think the basics of the algorithm would be much different, you just cut off the ray after collision and make a new one with same properties starting from the end of the portal, it would be laggy as hell though because of how much more information the renderer needs to account for
@@waker_link At least it's not so laggy that you'd need a supercomputer. Portal RTX runs ok on modern high-end graphics cards.
@@waker_link No, first of all every ray it's technically a new ray, and second is the only thing he needs is offset position and rotation.
Sadly it's way less complicated to do this than most things you see in this video (sad as in it's gonna be trivial in math so that it'd barely be a minute in the video, at least in coding it). It's gonna work the same as perfect refraction or reflection, which we already got.
There aren't enough like buttons to send appreciations to each part of the video
One of these days, Sebastian will accidentally make a triple A level game with procedurally generated everything with lifelike graphics, I swear...
Bold of you to assume we're not already living in that game
I've been secretly hoping these videos and topics have all been related to some hidden project. Imagine if once he's done enough of them, a new series starts "Making my own game engine" and then he just starts building things from scratch again.
I have never understood a thing of what you have done - but I have watched a lot of these videos. They are super great to watch to just get a wash of 'I'm still learning' as an adult
36:49 “My computer is dying, but i think it looks nice.”
Me when I set the game graphics to max on my potato computer
Man, this is by far my favorite channel on TH-cam. The stuff you create is always so cool and interesting, and the quality is just out of this world. I honestly wouldn't be surprised if you spent significantly more time coding the visualizations of what your code does than writing the actual code, but that effort really pays off in the final video.
Oh so you turned your PC into a space heater, interesting
Sebastian and jdh are probably the best programmers on YT when it comes to games, math, graphics and more. Always a pleasure to watch their last creation.
Please! hear this out:
when Sebastian tried averaging the pixels over multiple frames, he got really blurry results with moving objects. (Progressive Rendering)
But If he stores the ray trace data to a list (per screen pixel),
and then averages that, he will get the same effect.
But then he should have each frame's data gradually lose the influence it has in it's pixel, until the oldest data has no influence, and is discarded.
I think the effect this will have is: Decent real-time ray tracing, and easy motion blur!
Nice job, I'm subscribed and I love your videos. There is a huge inaccuracy I want to correct though, yes coatings/waxes/varnishes are an important aspect of understanding the surface properties (especially in automotive rendering) but a specular that keeps the color of the light source is the default, and is the behavior of all dielectric materials. Metals are the exception, which modify the color of the light when reflecting it back. Most rendering packages will either use a Metallicity property/texture to specify this (allowing for a single texture to have both), or just use different shaders for each.
Oh and another compliment, your depiction of focal planes and focus is a really good demonstration for a principle that people have trouble understanding. I like the circle you are using to show the area of the distribution of offsets from the view origin, which is conceptually the pupil/aperture/f-stop of the lens, which is all at the same point in the original renderer, the demonstration of the pinhole camera model.
Why do I want to eat the renders
18:00-18:21
This is why I love this channel
Why does it sound like he's brightly smiling every time he talks? Is it just me?
Stopped everything, paused whole life just to watch new video! Thank you Sebastian!
Sebastian is really setting a new high standard of coding videos. It's a pleasure to watch, even for an experienced software engineer, with a lot of information and inspiration.
Coziest coding videos i have ever seen!
This is amazing. Filled with detail and excitement as you explain, it makes as I want to do it as well. Although could as well be a tutorial, it seems so entertaining and interesting watching what would happen. I subscribed and would like to follow and enjoy while you talk of the capabilities to accomplish. I did not know it could do so much, the programs. Thank you for making this and explaining along the way.
I think I've said this before in a previous video, but even though I have almost no idea what you're talking about on a technical level, I thoroughly enjoy listening to you explain it. Your obvious enjoyment of the subject is clear.
Currently studying a 3D graphics module for a computer science degree and this is explained so much better than my lecturer. Thank you :)
What i find so interesting in these series is that it takes a very complex subject and experiements with them during the development process which really does help in understanding.