Rays and Spheres: The MATH! // Ray Tracing series

  Рет қаралды 99,176

The Cherno

The Cherno

Күн бұрын

Пікірлер
@TheCherno
@TheCherno 2 жыл бұрын
Thanks for watching this episode! Join the episode discussion thread on my Discord in the #raytracing-series channel: discord.gg/thecherno And of course for all of your math needs, visit brilliant.org/TheCherno to get started learning STEM for free, and the first 200 people will get 20% off their annual premium subscription.
@oamioxmocliox8082
@oamioxmocliox8082 2 жыл бұрын
;)
@guywithknife
@guywithknife 2 жыл бұрын
Is the github version of hazel dead? There hasn't been any content about it in ages, there hasn't been any commits in 9 months, issues and PR's are piling up... I guess it was telling in the video where you talked about the distinction between the patreon version and the github version and you kept calling the patreon one "the real hazel"... :'(
@footballCartoon91
@footballCartoon91 2 жыл бұрын
bro i am really sorry for not finishing up watching your video.. i am stuck at my project myself.. i have a question.. if i have multiple objects or multiple instances of class.. and that objects i want to create on the heap.. how should i store that objects? do i need another class? and then how to store that objects in std::vector or array of pointers(i dont actually know)? if so, then how to delete those objects? do i need to store my objects as smart pointers? i tried to watch your code review.. and nothing is similar to my current project.. btw i code only part time.. just for fun. example: /* class Location{ private: float latitude,longitude=0; public: Location(float latitude, float longitude){ this->latitude=latitude; this->longitude=longitude; } }; class Zone:public Location{ public: using Location::Location; Location** listOfPoints=new Location*[24]; //create array of pointers from what i understand, a pointer is created //on the stack which points to first element of Location object which lives on the heap; //also what i understand for one object i need 8 bytes(because two float) and so i need at least 8*24 bytes=192 bytes // i am so worried that my program exceeds the 1Mb allocated on the stack Location[0]=new Location(4.345,95.245); //error no storage space or class //if i put inside function destructor cannot access bool isInside(){ Location[0]=new Location(4.345,95.245); //do something return false; delete Location[0];//should i do this? } }; */
@paulkanja
@paulkanja Жыл бұрын
bruh expanding brackets and me knowing basic quadratics rules and binomial expansion exists 💀 great videos... this are def a must watch even for people who are not using c++ (i'm following along pretty well with JS and my lovely canvas)
@chillCatto
@chillCatto 2 жыл бұрын
I still have to learn more of computer graphics and c++ itself, but dude, what you're doing is just incredible... I truly love you for your work and all the content. I got so fascinated and motivated by watching your movies. Thank you so much!!!
@valentin6824
@valentin6824 2 жыл бұрын
For me, i kind of hoped that he would go on with a "Higher" Maths.
@fedemartinezdev
@fedemartinezdev 2 жыл бұрын
@@valentin6824 more fun for you ! Also, this is just the SECOND video of his series, what did you expect, jump into differential rendering right out of nowhere?
@_NDC
@_NDC 2 жыл бұрын
Thanks a lot, Cherno! As a little mathematical note, the square root of anything is always positive by definition (exactly to avoid any ambiguity), while it is the quadratic equation x^2 = a, that has 2 solutions: sqrt(a) and -sqrt(a).
@Raj-ts8lw
@Raj-ts8lw 2 жыл бұрын
Cherno: Do you want to learn the math behind Ray Tra- Audience: Yes.
@Fytrzaczek21
@Fytrzaczek21 2 жыл бұрын
Chemo: ok, how much? Audience: YES.
@skilz8098
@skilz8098 2 жыл бұрын
@@Fytrzaczek21 Up next, the rendering of the Mandelbrot Set. Step into the world of Fractals.
@Sondelll
@Sondelll 2 жыл бұрын
This is giving Freya Holmér's stuff a solid run for it's money, definitely worth the watch
@ouo5634
@ouo5634 2 жыл бұрын
fellow Freya viewer! I hope you have an awesome time day.
@seifsallam143
@seifsallam143 2 жыл бұрын
oh my god yes, this comment is literally on point. Freya is one of, if not THE, math godess out there
@aleksszukovskis2074
@aleksszukovskis2074 2 жыл бұрын
Ive seen her videos
@xanzuls
@xanzuls 7 ай бұрын
lmao that's basic stuff every school teaches you.
@pithlyx
@pithlyx 3 ай бұрын
@@xanzuls some people are 10+ years out of school and these equations aren't all commonly used. Also even if its familiar it takes a deeper and wider understanding than school gives imo.
@pxolqopt3597
@pxolqopt3597 2 жыл бұрын
I am still in highschool, so all of this is still fresh in my mind and I found it really straight forward. It was a lot simpler than I thought
@jovianarsenic6893
@jovianarsenic6893 2 жыл бұрын
Important note just to be as correct as possible. The sqrt function does NOT have two outputs. It only gives the positive output, hence the +-. The reason a discriminant of 0 would give only one solution is because +-sqrt(0) = +-0 = 0.
@LimitedWard
@LimitedWard 2 жыл бұрын
This was a great overview. Two critiques that I have for future math videos: 1. Make sure to clearly explain what each variable/constant represents, especially when reusing letters. When you presented the quadratic formula you reused a, b, and c but they mean different things in that context. 2. Try to explain earlier on what values are well-known versus the values we need to solve for. It wasn't until 2/3 of the way through your solution that you explained we were solving for t. Knowing the objective in advance may help to reduce confusion earlier on and prevent people from having to rewind.
@veggieboy1
@veggieboy1 2 жыл бұрын
Indeed, it's a fantastic video and I love the way he explains things, but yes, the way he initially wrote down the quadratic formula is just an expression (not an equation), since it wasn't equal to anything (initially).
@harshfeudal_
@harshfeudal_ 2 жыл бұрын
Luckily I learn this vector math carefully when I was a high school student. But this video still clear for me to know it. Thanks Cherno!
@amayesingnathan
@amayesingnathan 2 жыл бұрын
Hey man, I'd totally recommend writing any z's you write with a horizontal line through the diagonal. It really helps with differentiating between zs and 2s. Especially if you ever have to write 2z. That and writing any variables that are vectors with a line underneath to make it clear. So like write a + bt with a line under a and b. Loving the series, keep it coming!
@ouo5634
@ouo5634 2 жыл бұрын
I usually denote vectors with a line above it ā or â tho hat is usually used to define a Basis ig? im not a mathematician either.
@amayesingnathan
@amayesingnathan 2 жыл бұрын
@@ouo5634 I have a master's in physics and maths and I can safely say there's no standard so don't worry! Making vectors bold is usually most common but only possible in print. I would say yes hat is common for basis vectors though.
@chillCatto
@chillCatto 2 жыл бұрын
@@ouo5634 in my university it depends on faculty how people mark vectors, but in my course im being learnt the way described by Nathan (engineering)
@skilz8098
@skilz8098 2 жыл бұрын
@@ouo5634 Same here. Another convention but usually in Books or Type Setting is to have them as Bold or Italic Capitals depending on which convention that book or written work follows...
@peterfireflylund
@peterfireflylund Ай бұрын
A small arrow above (with an asymmetric arrow head that only has the upper side) is better for handwritten vector variables. A line underneath is easier for (obsolete) typewriters and (primitive) typesetting. Real arrows are easy with LaTeX.
@PugMaxer
@PugMaxer 2 жыл бұрын
I am disappointed you didn't derive the eikonal equation from Maxwells equations then from it derived how light rays should behave. You can't just assume light rays travel in straight lines! They sometimes don't! Also on the side of performance when you need to do reciprocal square roots I would be very interested in how different methods perform. Maybe cover using compiler intrinsics to force rsqrtss/rsqrtps etc... instructions followed by a single Newton Rhapson step as that seems to be the fastest with decent accuracy (if your computing it on the CPU). Or just whatever method you will be using. Also desmos got me through my exams, amazing piece of software. Also I love that your setting homework lol, if you want any help with these maths videos just tell me the maths that needs covering and I'm happy to write an article that teaches it in the context of ray tracing. I've just finished the second year of my physics degree so maths like this isn't a problem and I have lots of time on my hands.
@marknefedov
@marknefedov 2 жыл бұрын
Hi, maybe you could suggest some books / task books to study?
@PugMaxer
@PugMaxer 2 жыл бұрын
@@marknefedov If you get and work through a second year A level pure maths book it should cover everything you need and more.
@paulosantana9607
@paulosantana9607 2 жыл бұрын
Maybe following real light paths would be actually useful if we're going to put black holes in the scene. That would be way cooler, but for mundane scenes, linear algebra seems enough xD
@nullpointer1755
@nullpointer1755 2 жыл бұрын
​@@PugMaxer i know that rays don't always travel in straight lines, but how you (just for curiosity) would implement the math for when rays are curved and is worth for most games than just use vectors?
@PugMaxer
@PugMaxer 2 жыл бұрын
@@nullpointer1755 I would use finite difference methods but that would definetly have a performance impact. Which is why I guess its not widely done as you need some specific circumstances to cuase light to travel in a curve.
@aaronater1088
@aaronater1088 2 жыл бұрын
I'm a Python guy, and watching your matieral is super interesting as I've been curious to learn more of the inter-mechanics of how lower level software works. Thank you for your stuff, and I was one of the first 200 to purchase Brilliant course under your discount ^_~. Looking to improve my math education. So far I like the experience on the platform, feels very tactile.
@razerblade2308
@razerblade2308 2 жыл бұрын
I love seeing the math in anything so yes please math as deep as the ocean! Awesome video. Thank you Sir
@renatoigmed
@renatoigmed 2 жыл бұрын
I know almost nothing. How do I prepare my mind for advanced concepts? Do I have to go over all the material I learned in school (and I've already forgotten it all) or can I skip certain steps?
@kjrl818
@kjrl818 Жыл бұрын
@@renatoigmed Don't overthink it. If you don't understand that math behind raytracing. Just keep studying and learn the functions, after all the Computer is doing the true solving. all we're doing is putting these functions into code. Yes you can do the hard work yourself like The cherno did. But really it just comes down to the concepts and learning to use them. Again. this stuff can be accomplished. Just take your time. Because once you understand this stuff, and know how to implement it in code. The rest is history.
@iippari7
@iippari7 2 жыл бұрын
I've watched fifteen minutes of this so far, and I have some minor corrections: - Rays are generally distinct from lines not only in their representation - for rays, the parameter _t_ is always non-negative, so a ray has a starting point and then moves infinitely in the direction specified by the direction vector, but not in the other direction. Lines, then, extend infinitely in _both_ directions: You can represent a line in exactly the same way with a point, a direction vector, and a parameter _t_ , only that _t_ can be any real value, not just a non-negative one. - While yes, the square root of _x_ _is_ any real number _y_ that satisfies y² = x, what you're actually showing is technically _not_ a square root: rather, you're using the radical symbol (√), which represents the _principal_ _square_ _root_ , i.e. the non-negative solution to y² = x. Since the non-positive solution to the equation is always the additive inverse of the non-negative, we use the plus-minus sign to get both solutions with the radical symbol. I'm not a mathematician either, but these things confused me for a while, and I hope this may clear up the confusion for other viewers like me :)
@user-ic5nv8lj9d
@user-ic5nv8lj9d 2 жыл бұрын
​@@egretfx these kinds of responses to these comments just straight up makes you look like a fool
@gabrieln310
@gabrieln310 18 күн бұрын
I agree with your second point, however I believe your definition of rays is incorrect. All the resources of computer graphics I have seen agree on defining a ray as a parametric equation where a positive t value results in a line in front of the origin of the ray (positive direction), whereas a negative t value results in a line behind it (negative direction). The idea of it being somewhat of a 'half line' is correct because it spans only forwards or backwards from the origin.
@samskarghimiresiddharthae.7773
@samskarghimiresiddharthae.7773 2 жыл бұрын
We : "Deep as the ocean" Him : "BRILLIANT" 🙄 The sponsor of the video 😒
@thedebapriyakar
@thedebapriyakar 2 жыл бұрын
I found the example at 9:28 a little rushed, so here's the explanation if anyone needs: *Question* : If you start out at a point (2,2), where would you land if you moved a distance of 2 units along the direction of the line joining (1,1) and (2,2)? *Solution* : [Position Vector of Landing Point] = [Position Vector of Starting Point] + [Direction of Vector joining Starting and Reference Point]*Scalar Direction vector of line joining (1,1) and (2,2) is [(2-1),(2-1)]=[1,1] Unit vector along this direction would be: Direction/Magnitude = [1,1]/|[1,1]|=[1,1]/sqrt(2)=[0.7,0.7] Going 2 units along line joining (1,1) and (2,2) = Starting out at the Starting Point and tracing the unit vector along line joining those two points twice= 2*[0.7,0.7] => [Postition Vector of Landing Point]=[2,2]+2*[0.7,0.7]=[3.4,3.4]. ○○○○○○○○○○○○○○○○○○○○ 10:13 - Moving 2 units in the x-direction and 2 units in the y-direction implies covering a distance of sqrt(2^2+2^2)=sqrt(8)=2.82 units. 10:40 - Cherno wanted to give a basic example so he skipped the normalization part.
@simaobonvalot9141
@simaobonvalot9141 Жыл бұрын
NIce, thanks for taking the time to explain the mathematical concepts behind the ray tracing implementation. I'am building my own and it really helps a lot to understand what you're doing.
@evan_game_dev
@evan_game_dev 2 жыл бұрын
People asking when they are going to use the quadratic equation. The cherno being a chad and using it for raytracing:
@veggieboy1
@veggieboy1 2 жыл бұрын
Thank you so much for this video! Amazing way to break down a seemingly difficult concept into something that can just be solved by the quadratic equation!
@antiHUMANDesigns
@antiHUMANDesigns 2 жыл бұрын
6:05 Ah, thanks, I've never understood (or bothered to learn) what that notation for describing a line means, but that makes perfect sense, now. I always think of lines, mathematically, as two points in space. Given those points, you can easily get a vector between them by subtracting one point from form the other. And a "ray" would be a point in space (origin) with a unit vector for its direction.
@MrCarburettor
@MrCarburettor Жыл бұрын
It was great! So fun to watch! Only if you divide equation by 2 at 28:19 you could put the calculator away!
@bastelwastel8551
@bastelwastel8551 2 жыл бұрын
Cherno: How much math do you want? We: Yes!
@mastershooter64
@mastershooter64 2 жыл бұрын
yes!
@DomensionStudios
@DomensionStudios Жыл бұрын
Best explanation of parametric line equation ever
@reik2006
@reik2006 2 жыл бұрын
26:30 More generally in vector notation, the sphere (x - x_0)^2 + (y - y_0)^2 + (z - z_0)^2 - radius^2 = 0 becomes (p - p_0)^2 - radius^2 = 0 with p = (x, y, z)^T and p_0 = (x_0, y_0, z_0)^T. The intersection with the ray r = r_0 + t * r_d means p = r. Plugging in and reordering the terms gives the quadratic a * t^2 + b * t + c = 0, where a = r_d^2, b = 2 * r_d^T * (r_0 - p_0) and c = (r_0 - p_0)^2 - radius^2.
@mmtd91
@mmtd91 9 ай бұрын
wow i love how you explain things in detail step by step. big help. thank you!
@DEMIR_TURGUT
@DEMIR_TURGUT 9 сағат бұрын
Woow . You are incredible. Thank you Cherno !!!
@Federico-q1u
@Federico-q1u Жыл бұрын
I am currently understanding this MATH live on stream thanks to your video.
@hariangr
@hariangr 2 жыл бұрын
This half an hour video is better than my half a year lesson back in high school You even give me reasoning behind Discriminant, which was always a mistery to me, I ASKED my teacher, but she didn't answer
@oscareriksson9414
@oscareriksson9414 2 жыл бұрын
Really good, cleared the whole thing up for me, now I am ready to just go and shoot rays
@stejaka
@stejaka 2 жыл бұрын
This was great. Quick enough to not be boring, but not so fast that I couldn't follow along (and that's important, because I'm a moron). You explained all of the math that was relevant and didn't delve into any math minutiae that these videos seem to get stuck into and never recover from. I see some comments asking why you didn't cover this or that equation, and I'm so glad you didn't. What I want from this channel is programming, not math lectures.
@zvxcvxcz
@zvxcvxcz 2 жыл бұрын
Yes, all of the math! Sounds about right. Well that's interesting. We usually did y = mx + b rather than c. It's the same of course, just an interesting curiosity.
@MereddynYT
@MereddynYT 2 жыл бұрын
Even tho I already did know the maths, I still watched it :) I like that series a lot
@isaacmuscat5082
@isaacmuscat5082 2 жыл бұрын
I am super pumped for this series and I have been waiting for this for a while. Thank you Cherno
@gregfoster126
@gregfoster126 2 жыл бұрын
Incredible video, glad theres people interested in this and not just me haha
@guilherme5094
@guilherme5094 2 жыл бұрын
I like your funny words Ray Tracing man.
@RRKS_TF
@RRKS_TF 2 жыл бұрын
One approach you could take is to have some episodes at the end or inbetween programming/conceptual videos that are dedicated to the mathematics
@edu_rinaldi
@edu_rinaldi 2 жыл бұрын
I'm happy that you started this new series! Definitely can't wait to see how you will implement the pathtracer on GPU and I'm curious about the graphics API that you will choose. It would be very cool to see an """old""" approach with OpenGL where you have to implement by yourself the acceleration structure, and a modern one with (for example) Vulkan / Optix / whatever.
@loganabel9321
@loganabel9321 2 жыл бұрын
Its pretty easy to develope a raytracing shader for opengl on shadertoy
@Nikhil-eg9zc
@Nikhil-eg9zc 2 жыл бұрын
9:31 - 2,2 closer to origin than 1,1...? BRILLIANT!! (pun intended, for those who don't get it, look at the video's sponsor)
@koktszfung
@koktszfung 2 жыл бұрын
no, "a" = (2,2) is the position, "b" = (1,1) is the direction, if you draw them as arrows, the tail of "a" is at the origin = (0,0) and the tail of "b" is at "a", that's why "b" is drawn further from the origin
@Kazyek
@Kazyek 2 жыл бұрын
I have absolutely no idea why but I got automatically unsubscribed from the channel so I'm seeing this video only now. I re-subbed and re-set my notification bell, but it's really weird that google would remove my subscription even though it was one of the few channel I had the bell set to "all"... Anyhoo, I love the serie, keep 'em comming!
@satarimar
@satarimar 2 жыл бұрын
well, there's a more elegant solution to ray vs sphere using vectors, assuming the sphere is centered at origin and a relative ray (o = ray origin, d = ray direction, r = sphere radius): (o + t*d)^2 = r^2, then o^2 + 2*t*o*d + t^2*d^2 - r^2 = 0, now for vectors simply replace the multiplication with a dot product and you can solve for any dimension, factoring out: t^2 : d dot d, t ^1: 2*(o dot d), t^0: o dot o - r*r, now simply put those as a (t^2), b (t^1), c (t^0) and solve the quadratic equation and you get the t's for any dimension you want
@GreenDave113
@GreenDave113 2 жыл бұрын
Here for the deep math! Not enough tutorials and resources show the concrete examples.
@loganabel9321
@loganabel9321 2 жыл бұрын
I was a little disapointed at the lacck of geometric connection to the sphere ray intersection, but this did a good job at showing the algebra and a practical solution.
@gernivisser593
@gernivisser593 2 жыл бұрын
Cherno this is awesome please keep on explaining the math .. As this allows us to learn the concepts that allows us to implement it in any language... Thanks man
@acho8387
@acho8387 2 жыл бұрын
Fantastic video as always, Cherno! You'll make a great high-school teacher for sure!
@MahfuzurRahman-xl9pj
@MahfuzurRahman-xl9pj 2 жыл бұрын
Hey, Cherno... It would really great if you make a video on math that we need for engine development, graphics and physics...
@DanKaschel
@DanKaschel 2 жыл бұрын
You're literally watching that video right now.
@skandertebourbi357
@skandertebourbi357 2 жыл бұрын
the cherno I must say that you're a legend
@MarioMartinez_
@MarioMartinez_ 2 жыл бұрын
Such a wonderful refresh math class. Cherno, you are a great teacher. Looking forward next episode
@ernststravoblofeld
@ernststravoblofeld 2 жыл бұрын
If my teachers taught in terms of entry wounds and exit wounds, I wouldn't have sucked at math so much.
@idc20627
@idc20627 2 жыл бұрын
Fucking Cherno man, this dude is a living legend. As a sophomore, you have only helped me grow so much, but not only that but you motivate too!
@ghosthitthose8681
@ghosthitthose8681 2 жыл бұрын
see i knew all the concepts you used its just about connecting the dots(hehe) with all the math that makes this so beautiful
@moskito98
@moskito98 2 жыл бұрын
MUCH LOVE
@Mahm00dM0hanad
@Mahm00dM0hanad 2 жыл бұрын
Yes thanks That’s exactly what I was searching Thanks
@zxuiji
@zxuiji 2 жыл бұрын
3:57, before I continue watching I'll give a rough idea of how I would draw a sphere (or more accurately generate the vertices for it's mesh) so that both I and everyone else can see if I was close to this vid's (minus the actual math) First I would start by generating a buffer for every possible vertex, to do this I would simply cube the max vertices I would ever draw per circle, gives a perfect cubed buffer, this would be a shared lookup buffer for all spheres/ovals/circles etc. Next I would just do a loop from 0 to max vertices and generate a circle of triangle vertices for every section of the buffer that fits max vertices squared and note their count in an another buffer, this ensures simple lookup of ignore every 3rd vertex when using those vertices for generating spheres. Next I would use the intended number vertices for the target sphere to select sections of the shared buffer to generate indices from and send that to the gpu, then it simply a matter of lookup vertex, warp it, shift it, colour it, do anything that's relative to the object to it to get it in the right place, such as: vertex = circle_vertex + joint_position + model_position + scene_position **Edit:** Welp, definitely not the way I would've done it but the end formulas are certainly simpler to write
@benpope10
@benpope10 2 жыл бұрын
I was eagerly looking forward to this video, amazing content as always Cherno!
@Avighna
@Avighna 2 жыл бұрын
Ayyye, let's go! Computers is my fav. subject, closely followed by Math.
@carlossn9511
@carlossn9511 2 жыл бұрын
More math please! Great series so far 💯
@bimDe2024
@bimDe2024 2 жыл бұрын
Was waiting for this episode so long.
@bean_mhm
@bean_mhm 2 жыл бұрын
Super helpful and well explained, thanks Cherno :)
@bear1114
@bear1114 2 жыл бұрын
As someone who voted for no math, this was actually really interesting. Looking forward to what's next
@justcurious1940
@justcurious1940 2 жыл бұрын
i wonder why they are trying so hard to mislead us from the right path
@skilz8098
@skilz8098 2 жыл бұрын
Without math, none of the video games or applications that people use everyday who complain about math wouldn't be possible. In general many people may not know it, every processor that is out there contains an internal ALU which stands for Arithmetic and Logic Unit. It literally performs arithmetic and comparison operations. That's all it is, well that and maybe some memory addressing operations... This is one of the many reasons math is so important.
@justcurious1940
@justcurious1940 2 жыл бұрын
​@@skilz8098 yea but as programmer what do u have to do with the processor u most likely will be dealing with the memory and other computer components if u are targeting them with your code
@skilz8098
@skilz8098 2 жыл бұрын
@Fourier21 No, I get that. But when one studies not just "Software Engineering" but also "Hardware Engineering" it does become important to know what's going on under the hood and how your binaries which becomes instructions for the CPU to do its task can be vital in allowing one to be a better programmer. Why do you think it's important to know about branch predictions, the cache models, vectorized registers, and more... ? At least this is how I feel about it. Computers are more than just a "plug and play" apparatus even though that's what they've become. They are an engineering feat. I don't just stop there, I'll study and dive down to the actual design details of the actual logic gates and the transistors and resistors that make them up as well as how they are designed from various raw materials. That doesn't even account for all of the mathematics that are involved at each level or layer of abstraction down the rabbit hole nor up the tree branches. I don't limit myself to just one compartment. I traverse the entire realm.
@skilz8098
@skilz8098 2 жыл бұрын
@@justcurious1940 Well the idea is knowing how they work under the hood, their interconnects, etc... When you are processing millions to billions of triangles, color data, structures, etc. It then becomes important in the advance of making it more efficient and to reduce bottlenecks. Abstraction is good to a point as you can write a generic algorithm that can work on multiple pieces of hardware. However, it might work really well on one, and not so good on another... This is where understanding the architect and platform comes in handy. This way one can take advantage of some of the instruction sets that are based on the design of the hardware to maximize the throughput as well as the time to execute the computations. Yeah most people don't "write" in assembly except for maybe in some situations such as embedded systems that don't even have a C compiler where you have to explicitly program the device in direct binary, but these are become more rare with time... Yet, I still feel that it is important to know. Why do I say this? Let's say you are making a custom container and a set of algorithms for it such as search, sorting, comparison, etc... And this now involves, indexes, iterators, pointer arithmetic, and loops. If one doesn't understand the cache hierarchies and how the targeted CPU is going to treat your code... How many cache hits and misses are you going to have? How many page fetches are you going to have? Also, memory alignment, padding and alalising become important especially with virtualization. Regardless of what level of abstraction you are at, writing assembly, C, C++, C#, Python, Java, J.S., Perl, Haskel, Cobal, Fortran, Go, etc... you are basically setting and flipping bits! You are changing voltages.
@kurciqs8355
@kurciqs8355 2 жыл бұрын
OK THIS IS EPIC
@TheHighborn
@TheHighborn 2 жыл бұрын
30:15 i'm surprised you didn't go into complex numbers. I guess they're not needed in this case? meaning the ray doesn't touch the circle?
@TheHighborn
@TheHighborn 2 жыл бұрын
oh wow i was actually right lol
@N7Null
@N7Null 2 жыл бұрын
I've done it. I've found a use for that god forsaken quadratic equation that I had to memorize in high school for seemingly no reason.
@RajJaiswal538
@RajJaiswal538 2 жыл бұрын
28:14 you know you've became a nerd when you call a quadratic equation Baby
@lazyemperor5182
@lazyemperor5182 2 жыл бұрын
Pls more frequent uploads, every week pls
@simioncristian7799
@simioncristian7799 2 жыл бұрын
Wow if the video gets so long just for the circle/sphere intersection I'm scared what's gonna happen when you get to probabilities and integrals, but that's what "as deep as the ocean" voters wanted lol. But I think the homework part is going to be confusing for beginners because they may mess up how the rays are generated for the camera, as it's only been glanced over in this video. Btw my master's thesis is gonna be about building a real time ray tracer and your timing couldn't be better, your videos are gonna be extremely helpful to see an implementation by an experienced developer like yourself.
@VRVitaly
@VRVitaly 2 жыл бұрын
Love this series keep it coming!!!
@seapanda7887
@seapanda7887 Жыл бұрын
Great explanation
@charlestheanimator1676
@charlestheanimator1676 2 жыл бұрын
ALLL THE MATH ALL THE TIME PLEASE
@vincentvoillot6365
@vincentvoillot6365 2 жыл бұрын
Lines and rays : insert Doctor Jackson explaining the stargate coordonate system :D
@emerald9054
@emerald9054 2 жыл бұрын
Bro, I have a bachelor's degree in math; you asked for it by giving me that option. I can't speak for everyone else though.. Excited to check this out! Thanks for the awesome videos!
@mastershooter64
@mastershooter64 2 жыл бұрын
What do you do for a living? and why didn't you like go into academia? math research wasn't your thing?
@emerald9054
@emerald9054 2 жыл бұрын
@@mastershooter64 Right now I'm going back to school for a master's in computer science, but I did work as a programmer for a little while (for almost a year directly after finishing undergrad). I'm confident I'll get back to working as a programmer after school, especially since I found a company I really like. As far as academia goes, I didn't click with the people around me mostly. The people around me in the math program just seemed a bit posh; it was almost as if everything they did was just to impress others (except for the young prodigies who just thought learning super fast was normal; I usually liked them though). However, when I started taking CS classes in my senior year, I fell in love with the subject and the people around me were usually much cooler than in math. I generally found people who enjoyed working hard but also liked video games and other "childish" hobbies and weren't afraid to say so. I would've switched my major if it hadn't been so late in my program, so I settled for a minor in CS. Definitely not all math majors are like I described, and maybe I just misread the ones I met. Despite that, it may just be as simple as I didn't click with them and that's ok.
@mastershooter64
@mastershooter64 2 жыл бұрын
@@emerald9054 oh nice, good luck! lol yeah lots of people in academia can be like that, just doing stuff for the sake of impressing others.
@martinschukwu2858
@martinschukwu2858 2 жыл бұрын
wonderful video. Much appreciated
@S41L0R
@S41L0R 2 жыл бұрын
huh cool. might need a few rewatches but it seems informative!
@memesalldayjack3267
@memesalldayjack3267 Жыл бұрын
i actually wanted to see all that math + the z part, anyway, good video
@Ekozaak
@Ekozaak 3 күн бұрын
Got ||a||²t² + 2t -2 - r² = 0, in 3D whith a sphere centered in c.
@andreicn0
@andreicn0 Жыл бұрын
THIS VIDEO IS AMAZING🎉
@mightyman5418
@mightyman5418 2 жыл бұрын
I would have liked to see the quadratic formula simplified down to 3 +- sqrt(2) for a more specific answer, but if you're solving it numerically anyway it's fine like it is in the video
@sripranav
@sripranav 2 жыл бұрын
I would've focused on my math vector class if they said this is used for raytracing
@danger235-jh3cr
@danger235-jh3cr Ай бұрын
Divide that equation by 2 29:17 it will be easier
@kursatyakupkukul7670
@kursatyakupkukul7670 2 жыл бұрын
22:46 @TheCherno literally lmao
@gasparliboreiro4572
@gasparliboreiro4572 2 жыл бұрын
0:25 if your channel becomes all math and becomes hard for people to understand, you are going to have a better community of people that are really passionate about math ( like me :) ), in case you want this just saying this doesn't mean "bad"
@guy6311
@guy6311 2 жыл бұрын
The Ray Tracer Challenge by Jamis Buck - great book
@magellan124
@magellan124 2 жыл бұрын
Something I never considered before this video is that while we have to make certain compromises with 3d rtx, i could totally see an uncompromising 2d game renderer and im curious if it exists.
@GmZorZ
@GmZorZ 2 жыл бұрын
RT is mostly about generating physically accurate scenes, like using hemispherical scattering in 3D for accumulating light and shadows. techniques like these are narrowed down much more when dealing in a 2D space, you could scatter n amount of samples in a single radius π2, rather than having (longitude * latitude) amount of possible scatter directions. 2D ray tracing is definitely used in a lot of games, signed distance fields are essentially following the same principle and they are quite popular. Excluding the Z axis reduces performance cost and is really cheap, the final image just isn't as interesting.
@RajJaiswal538
@RajJaiswal538 2 жыл бұрын
@@GmZorZ "the final image just isn't that interesting" Ooh i have things to say
@GmZorZ
@GmZorZ 2 жыл бұрын
@@RajJaiswal538 what i mean is a 2D path tracer can look cool, but is not groundbreaking like the latest RTX development.
@ΠαναγιώτηςΡήγκος
@ΠαναγιώτηςΡήγκος 2 жыл бұрын
Hell yeah, i voted for 'as deep as the ocean' and i can't understand a thing 😅
@edwardgyampo
@edwardgyampo 2 жыл бұрын
This is great
@Basel-ll8fj
@Basel-ll8fj 2 жыл бұрын
this is great you can explain math better than my professor 😅😅
@ottley32
@ottley32 2 жыл бұрын
God, I love math!
@ray3369
@ray3369 2 жыл бұрын
If anyone is looking for a book that goes over some of the math and gives you a walkthrough for a Ray Tracer. Check out a book called "The Ray Tracer Challenge" by Jamis Buck
@nnatewentmissing4323
@nnatewentmissing4323 Жыл бұрын
when you were writing the equation, the circle was centered at 0, 0. How would you implement the circle's location into the equation if it wasn't at 0, 0?
@spectrm6014
@spectrm6014 2 жыл бұрын
Early! :D Nice video, Cherno!
@justinpakarno4346
@justinpakarno4346 2 жыл бұрын
Dearest Cherno, not sure if you control the subtitles or not, but when you say "a ray" the subtitles print "array". Which is close, but not quite right.
@KeepAnOpenMind
@KeepAnOpenMind 2 жыл бұрын
In NVIDIA ray tracing gems there is a bit more interesting method to finding intersections with spheres which isn’t f32-problematic in different corner cases and doesn’t have the acne.
@DanKaschel
@DanKaschel 2 жыл бұрын
What's the blackboard software you're using?
@aayanilyas4476
@aayanilyas4476 2 жыл бұрын
After finishing pre-calc in school, I just watched this video, which is most of the same things. 🤣
@rabiox6508
@rabiox6508 2 жыл бұрын
What app are you using for this board you're drawing on?
@abdel4455
@abdel4455 2 жыл бұрын
Photoshop I think
@useronuralp
@useronuralp 2 жыл бұрын
What happens when there is a complex mesh on the screen instead of a sphere? How do you calculate an equation that defines that complex mesh in world space to test against rays?
@SirRebonack
@SirRebonack 2 жыл бұрын
Assuming a triangle mesh. Test every triange by creating a plane from the triangle vertices. The normalized cross product of two edges produces a face normal which can be used to construct a plane. Find the intersection point of the ray on the plane. Then check if that point is within the triangle bounds by using barycentric coordinates. There are probably better ways to do this though.
@GmZorZ
@GmZorZ 2 жыл бұрын
like the previous comment stated, every single triangle has to be tested. Which is what makes ray tracing expensive. Using a rasterizer you would test each triangle, then sort it into it's pixels from the viewing frustum. Let's say for a million triangles, about half get discarded due to backface culling, and then the rest will cover maybe 20 pixels each. so 10.000.000 pixel checks which simply register the face color (Not much computation involved). Using a ray tracer you test every single triangle for every pixel. 1920*1080*1000000=2073 *billion* tests, all including a line-ray test. And that is just for whitted-style ray tracing (one ray per pixel). For realistic scenes with hemispherical scattering you would send up to 64 rays, including bounces (which doubles the rays). Pretty nuts, i remember waiting a full day on a render... Luckily acceleration structures like BVHs exists, where the object gets split into 8 "boxes" (which are cheap to intersect), where each box may also contain this spatial split into 8 more boxes (or AABB as they are called). You continue traversal, and only test triangles contained in the final leaf node of this 3d tree-like structure. Nowadays we can upload these BVH structures to the GPU, but we are still limited in the sample count.
@ariss3304
@ariss3304 2 жыл бұрын
I’m watching this whole video so I can study for my optical physics exam 🙂
@m7trffxx_xx166
@m7trffxx_xx166 Жыл бұрын
What's the best resource for Graphics's math?
@shegzy3d377
@shegzy3d377 2 жыл бұрын
As a Nigerian student, this is just elementary junior high school math
@OUTSEET-ti1mt
@OUTSEET-ti1mt 2 жыл бұрын
Cool I love math
@artyomcg
@artyomcg 2 жыл бұрын
*meth
@abdel4455
@abdel4455 2 жыл бұрын
@@artyomcg *moth
@mikk5428
@mikk5428 2 жыл бұрын
So does the Hazel have raytracing already?
Rendering a Sphere Using Ray Tracing! // Ray Tracing Series
38:32
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
I made a better Ray-Tracing engine
17:38
NamePointer
Рет қаралды 257 М.
FASTER Ray Tracing with Multithreading // Ray Tracing series
22:23
Ray Tracing: How NVIDIA Solved the Impossible!
16:11
Two Minute Papers
Рет қаралды 801 М.
How Ray Tracing (Modern CGI) Works And How To Do It 600x Faster
32:06
Josh's Channel
Рет қаралды 584 М.
Path Tracing // Ray Tracing series
23:21
The Cherno
Рет қаралды 52 М.
FAST Random in 3 LINES OF CODE // Ray Tracing series
18:53
The Cherno
Рет қаралды 45 М.
Finding and Fixing Slow Code // Ray Tracing series
29:02
The Cherno
Рет қаралды 47 М.
Emission and Emissive Materials // Ray Tracing series
24:06
The Cherno
Рет қаралды 31 М.
The Math behind (most) 3D games - Perspective Projection
13:20
Brendan Galea
Рет қаралды 429 М.
GRASS RENDERING in OpenGL // Code Review
47:23
The Cherno
Рет қаралды 120 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН