RAY TRACING! // Code Review

The first 1,000 people to use this link will get a 1 month free trial of Skillshare: skl.sh/thecherno09211
Patreon ► / thecherno
Instagram ► / thecherno
Twitter ► / thecherno
Discord ► / discord
Code ► github.com/holoskii/RayTracing
Ray Tracing in One Weekend ► raytracing.github.io/books/Ra...
Send an email to chernoreview@gmail.com with your source code, a brief explanation, and what you need help with/want me to review and you could be in the next episode of my Code Review series! Also let me know if you would like to remain anonymous.
This video is sponsored by Skillshare.
#CodeReview

Пікірлер: 296

  • @TheCherno
    @TheCherno2 жыл бұрын

    Thank you all for watching, hope you enjoyed this one! Don't forget that the first 1,000 people to use this link will get a 1 month free trial of Skillshare: skl.sh/thecherno09211

  • @jeffreydolemite1922

    @jeffreydolemite1922

    2 жыл бұрын

    programming raytracing while having no basic understanding of working dir... I'm lost for words

  • @mathewsjoy8464

    @mathewsjoy8464

    2 жыл бұрын

    Please do more university assignments! they are so informative

  • @achtsekundenfurz7876

    @achtsekundenfurz7876

    2 жыл бұрын

    The two ingredients of disaster: (1) putting a \ between root path and file name/path evn if rootpath is empty (2) leaving the rootpath empty when the current directory can be referenced via "." -- note that "./subdir/file.ext" would have worked flawlessly Tbf, "." is far less well known than the parent directory "..", so this is ultimately a failure to interface due to lack of documentation. There should be a comment somewhere that "." rather than "" should be used to specify the current dir.

  • @andreasibona7995
    @andreasibona79952 жыл бұрын

    Remember Anakin, only a sith deals in absolute paths

  • @igorthelight

    @igorthelight

    2 жыл бұрын

    You should have to delete() them - not join() them! :-)

  • @garageman2236

    @garageman2236

    2 жыл бұрын

    Cherno debug review!

  • @Futureblur
    @Futureblur2 жыл бұрын

    Plot twist: They send you broken code to test your debugging skills 😂

  • @brawldude2656

    @brawldude2656

    2 жыл бұрын

    xD exactly!

  • @TheReferrer72

    @TheReferrer72

    2 жыл бұрын

    The code was not broken, no debugging would have been needed if it was put in the path specified in the code. The author is a one man band, who obviously has not worked in an organization like "The Cherno" were you have to learn about sharing your code. Being a Dev is much more than writing and debugging code.

  • @TheFlynCow

    @TheFlynCow

    2 жыл бұрын

    @@TheReferrer72 If i hit f5 and it doesnt run, its broken.

  • @Futureblur

    @Futureblur

    2 жыл бұрын

    @@TheFlynCow exactly, thank you.

  • @postmodernmarxistnihilist4282

    @postmodernmarxistnihilist4282

    2 жыл бұрын

    @@TheReferrer72 It's still broken. If you were to develop a game and sell it but then all the specified paths in the code is from the dev's computer, the game will not run on other computers, the game is broken.

  • @that_kaii
    @that_kaii2 жыл бұрын

    "we're back on Windows yes!" "what's this your computer will restart" I died laughing

  • @HDSQ
    @HDSQ2 жыл бұрын

    It's nice to see how many of the bad habits you're pointing out. Things like that are so important yet so often overlooked. Particularly the thing with using int64_t instead of long long is a thing I didn't learn until I went to university and lost style marks on an assignment because of it. Loving this series!

  • @YeloFelo

    @YeloFelo

    2 жыл бұрын

    You must have had a great professor. I wasn't even taught that these fixed types exist, and only learned this by watching Cherno videos.

  • @jamesmnguyen

    @jamesmnguyen

    2 жыл бұрын

    I started using the fixed size types when I started to get annoyed about how big my data types were.

  • @DFPercush

    @DFPercush

    2 жыл бұрын

    I thought the point of "short" and "long" was that they are a known size, as opposed to int which, back in the old days, could be 16 bits. Very curious that a long might not be 32 bits, but a "long long" should always be 64, unless they start making 128 cpus or something? idk, seems like a weird thing to trip over. I like the "i32, u32, f32" etc... convention anyway.

  • @baileyharrison1030

    @baileyharrison1030

    2 жыл бұрын

    @@jamesmnguyen Generally ‘int’ will be faster that ‘int8_t’ since it is usually the size of registers on the CPU. When you use int8_t, there’s a good chance your compiler is just bitwise ANDing an int with 0xFF whenever it’s used.

  • @jamesmnguyen

    @jamesmnguyen

    2 жыл бұрын

    @@baileyharrison1030 I think you missed the point of my comment. I was annoyed at the ambiguity of the size of my data types. Not the performance. Which is mostly orthogonal to my problem.

  • @leerodger9197
    @leerodger91972 жыл бұрын

    I made a ray tracer as part of my dissertation at uni and seeing other people's just emphasises how much mine was lacking 😂

  • @Bonniebelle_00__

    @Bonniebelle_00__

    2 жыл бұрын

    well you can always improve it. as a beg i see code as situational and it is a bias as it can get , humans improve code

  • @crumbled9774
    @crumbled97742 жыл бұрын

    Definitely a fan of a series on the raytracing in one weekend focused on speed improvements. The debugging your application for performance improvements is a rare resource!

  • @Bonniebelle_00__

    @Bonniebelle_00__

    2 жыл бұрын

    love to see us in the foreground lol

  • @soft384
    @soft3842 жыл бұрын

    30:00 Yeah definitely, the book is really well written + your explanation would be really helpful.

  • @edu_rinaldi

    @edu_rinaldi

    2 жыл бұрын

    Not so good! He does not explain the true basics of raytracing! I strongly suggest you pbrbook for learning in a better way raytracing

  • @soft384

    @soft384

    2 жыл бұрын

    @@edu_rinaldi Thanks for the recommendation. I’ll check it out.

  • @Muzzleflash1990
    @Muzzleflash19902 жыл бұрын

    When parallelizing the work load should be divided as equally as possible. However, the easiest way to do that is to make the work pieces as small as possible because the work itself may not be spread evenly. In Uni there was a session to parallelize Mandelbrot set image generation using pthreads. I managed to get %200 speed using two threads (in 2012), and splitting the work more did not yield improvement, which was disappointing because I had 4 cores. My instructor took one quick look, and told me to try splitting on each row of the image (instead of splitting the work of a 800 pixel tall image into 200-400 tall chunks, it would be 1 or 2 pixels tall chunks). When a thread had finished a row of pixels, it would process the next one. This gave another boost giving me 398% performance using 4 cores. In retrospect, if one looks at the Mandelbrot set, it becomes apparent that splitting on the vertical it in the middle works fine for two, but anything else and you get uneven loads since the outer areas are much faster to compute. I have not messed much with raytracing, but imagine that certain parts of an image might require more attention, eg. glass refraction and reflection.

  • @dealloc

    @dealloc

    2 жыл бұрын

    Yeah, the idea is that you want your threads to finish as soon as possible. In the case of this code, using vertical strips, results in each worker taking longer than they need to for specific areas. One way to counter that is by splitting them up in chunks of equally sized squares. This will free up threads as quick as possible and can tremendously speed up the processing time, since some chunks are likely to take longer (e.g. rendering lighting on a model) than other chunks (e.g. rendering a skybox).

  • @jonohiggs

    @jonohiggs

    2 жыл бұрын

    I think splitting center out is also a good idea. Most of the detail in a scene will be in the centre and if you have some GUI that can display partial renders as they are updated then that detail is displayed more quickly so if there is something wrong on a long render you can cancel faster

  • @Asdayasman

    @Asdayasman

    2 жыл бұрын

    If utilisation and execution time are the criteria, why not divide the work into very small pieces and have the workers grab tasks from a pool? Think blender rendering, it goes in squares. Stuff that completes faster completes faster, and the worker goes to get work sooner.

  • @dealloc

    @dealloc

    2 жыл бұрын

    @@Asdayasman That's the idea. The benefit is also that if any worker fails, it's a lot less damage and makes it quicker to correct.

  • @notuxnobux

    @notuxnobux

    2 жыл бұрын

    Did your threads wait for all other threads to finish before working on new pixels or what?

  • @kumartatsat868
    @kumartatsat8682 жыл бұрын

    I've learned more C++ by watching 2-3 code review videos of yours, than I ever learned in high school and CS undergrad combined. thanks a lot Cherno, for these videos. and please keep making them from time to time, really appreciate it

  • @pikuma
    @pikuma2 жыл бұрын

    In older 16-bit machines and older compilers I saw sizeof int being 2 bytes. Fun times.

  • @stolenlaptop

    @stolenlaptop

    Жыл бұрын

    I used to hate c style ints when I came from assembly where you work with sizes explicitly (byte, word, dword, etc..) stdint changed my c life.

  • @BillySpelchan
    @BillySpelchan2 жыл бұрын

    As a TA, when I was teaching the labs, I would demo how to use relative paths to my students. The problem is that only a fraction of the students would bother showing up for the labs unless they were made mandatory (and then for the rest of the term you would have to listen to complaints about mandatory labs yet strangely the lab's grade average was higher with mandatory labs).

  • @mabroorahmad2182
    @mabroorahmad21822 жыл бұрын

    Thank you so much for teaching me programming. Today i landed my very first big job as a software engineer. You made my life. I can't thank enough. Love you. 🥰

  • @Futureblur
    @Futureblur2 жыл бұрын

    Yes, please do a video on ray tracing in one weekend, I would be more than interested 😁

  • @jairoacosta8940
    @jairoacosta89402 жыл бұрын

    props to the programer for sharing, and props to you Cherno. have learned so much from you.

  • @harrison1508
    @harrison15082 жыл бұрын

    45:05 cracked me up for no reason lol, excellent video as always and amazing quality. Love the amount of effort you put into your videos, worth the bell icon for sure :)

  • @erictodd9051
    @erictodd90512 жыл бұрын

    29:52 I would love to see something like that! I've been exploring raytracing for a while and that blog and your videos have been a huge help. It would be great to see them together!

  • @siddharthasarmah9266
    @siddharthasarmah92662 жыл бұрын

    You're gonna hit 400K soon! Congo in advance

  • @ianknowles
    @ianknowles2 жыл бұрын

    That start-in was a useful nugget of info.

  • @makarivashko1463
    @makarivashko14632 жыл бұрын

    Thank you so much for your review! Learned so much from it, already started to fix the code ;)

  • @judedavis92

    @judedavis92

    2 жыл бұрын

    did you write that specific code?

  • @makarivashko1463

    @makarivashko1463

    2 жыл бұрын

    @@judedavis92 yeah, it was shown in the intro

  • @yunjiehong4649

    @yunjiehong4649

    2 жыл бұрын

    @@makarivashko1463 Bravo! I also took the 3d rendering class but didn't write it from scratch.

  • @rm-fs1xr
    @rm-fs1xr2 жыл бұрын

    YES please a video series about ray tracing!!

  • @Lin_The_Cat_
    @Lin_The_Cat_ Жыл бұрын

    5:37 Using relative paths vs absolute paths was like one of the first things I was taught when learning about file io. If anything, it was for making sure we wouldn't get a zero on any assignments that involved file io streams.

  • @KyleHarrisonRedacted
    @KyleHarrisonRedacted2 жыл бұрын

    31:50 "like json or yaml, I would use yaml for this" TOML: "B-but.. its basically ME ALMOST!"

  • @DmC944
    @DmC9442 жыл бұрын

    34:46 This is so true! Was about to write pretty much what Cherno said in the video. This can seriously cause/hide bug especially for others. Or for the writer that wrote it after a few weeks/months.

  • @seandarcy2612
    @seandarcy26122 жыл бұрын

    This is amazing! Got so much out of this review

  • @xsandre-l
    @xsandre-l2 жыл бұрын

    I would love too see the raytracing in one weekend

  • @gillesvismara5228
    @gillesvismara52282 жыл бұрын

    A mini series on raytracing by the cherno? Count me in!

  • @harshgandhi100
    @harshgandhi1002 жыл бұрын

    I think the developer had a "Oh, didn't think that :p" moment when Cherno just made a shortcut and changed the Start in in the executable folder.

  • @mehmetakyuz5290
    @mehmetakyuz52902 жыл бұрын

    +1 for the raytracing in one weekend tutorials!

  • @mr.anderson5077
    @mr.anderson50772 жыл бұрын

    Yes Cherno, please do a ray tracing series from the scratch. Thanks

  • @Bobbias
    @Bobbias2 жыл бұрын

    I never thought to make a shortcut with the intended working directory. That's a really neat trick. I kinda feel dumb since I knew the option was there but never understood when I'd need to use that feature.

  • @isaacmuscat5082
    @isaacmuscat50822 жыл бұрын

    I would love to see you do a 3D rendering series with raytracing and stuff

  • @tokyospliff

    @tokyospliff

    2 жыл бұрын

    yeah, the people want 3D, we've always wanted 3D

  • @charlesdorval394
    @charlesdorval3942 жыл бұрын

    I really like that series, I'm binge watching over christmas vacation :) As an amateur programmer (overstatement of the year...) I find it quite interesting not only to have your opinion, but more importantly the reason why. I particularity appreciated the compiler directive part, it made a lot of things clearer, as well as the breakpoint/if statement. Nice to see my use of "obvious" variable types isn't frown upon, I just apprec iate seeing right away how large it is. :)

  • @gabrielsaliba2273
    @gabrielsaliba22732 жыл бұрын

    I would be tottaly up to a raytracer in one weekend series

  • @DridriLaBastos
    @DridriLaBastos2 жыл бұрын

    30:00 I read the book too and I will really love to see you go through it and explain stuffs

  • @jammeri
    @jammeri2 жыл бұрын

    Thanks for that shortcut trick for changing working directory!

  • @Jihazak
    @Jihazak2 жыл бұрын

    Another thing about relative paths is that files like the input files could also store paths relative to the input file rather than cwd, both of course works, but with multiple nested objects like this one might consider either of the pattern. The logic goes like if I read a file, I assume the paths in the file are relative to this file I'm reading, not the entire project

  • @ricardoalcantara5846
    @ricardoalcantara58462 жыл бұрын

    One of the best Code Review!

  • @DanielLopez-up6os
    @DanielLopez-up6os2 жыл бұрын

    Simply amazing stuff.

  • @obinator9065
    @obinator90652 жыл бұрын

    36:00 also another pitfall for that: if(...) if(...) x = 10; else x = 15; I think some code analyzers even annotate such misleading intendations.

  • @igorthelight

    @igorthelight

    2 жыл бұрын

    Oof! That is very easy to misunderstood if you would see it only for a second :-)

  • @swiftcodey

    @swiftcodey

    2 жыл бұрын

    @@igorthelight I think it can be misleading no matter how long you look at it if you don't know the language's grammar

  • @jamesmnguyen

    @jamesmnguyen

    2 жыл бұрын

    Dang, that took me 5-10 seconds before I noticed what was misleading about that code snipet. I had to basically run that code to check.

  • @MsJavaWolf

    @MsJavaWolf

    2 жыл бұрын

    In my company we have to use braces, even for 1 line ifs, It sounds pedantic but I think it does actually reduce bugs.

  • @jamesmnguyen

    @jamesmnguyen

    2 жыл бұрын

    @@MsJavaWolf I recently made that part of my coding style. It annoys my urge to compact my code. But I know it's better in the long run.

  • @avaze7
    @avaze72 жыл бұрын

    I'd love to see you follow the Raytracing in one weekend and explain it a bit! ABout a year ago i started programming a raytracing engine in Ruby for a school assignment (ony language i knew by that time) and i eventually got it to render normal maps, soft lights etc but only infinite planes and perfect spheres, since anything above that would have exploded render times since wasnt thinking about optimization a lot and ruby definitely isnt the way for such heavy processing :D If you were to upload that series id try to reimplement my rendere in c++, because i think i really need to learn more about low-level optimization and stuff like that. Also i always wanted to do more with c++, ive only programmed an audio plugin with JUCE, but i didnt know where to start for a custom project. I'd also love to see a follow up video of how to build a Visual Inerface to create Scene and render them!

  • @Saturn2888
    @Saturn28882 жыл бұрын

    It sounds like your argument on a single file is that each file consists of a class and separating classes and trying to pull them together can be tough. I agree with you, needless separation makes things difficult. On the other hand, I also think a 20K line file is impossible to sort through and insanely hard to unit test since you typically have one file of unit tests per file. That'd probably be a 100K file of unit tests. The way I'd do this in JavaScript is to separate each method into a function that you can run independently so long as they belong in separate places. Makes it super easy to unit test and each one would be self-contained. But I also wouldn't be creating separate classes, interfaces, and data types for each one. I don't know what you were dealing with in the DX11 renderer, but when I looked at game engines in C++ years ago, it was insanely hard to follow as an amateur. On the other hand, I remember making some caching class in the past and remember how difficult it was to read in 6 different files with classes. I think the key here is classes. If you have smaller, reusable components, it's a lot easier to follow so long as each one is self-contained.

  • @MorganC-zz1bg
    @MorganC-zz1bg2 жыл бұрын

    Seeing your take on Ray Tracing in One Weekend would be very interesting to see!

  • @jasonsharp4950
    @jasonsharp49502 жыл бұрын

    Yes on the ray tracing in one weekend!

  • @hardikphalet5714
    @hardikphalet57142 жыл бұрын

    EXCITED!!!

  • @hereticstanlyhalo6916
    @hereticstanlyhalo69162 жыл бұрын

    A question about your Hazel engine, how do you have it so the play button works? As in, in what way do you save the state of the game to return to after done testing? I have my engine at a state of rendering a pre-defined mesh with a simple gravity system, but I wann add a play button so I can test and revert to, my guess is that you have a duplicated version of your map, and you use the main version, then load back in the duplicated version when done. Now if that's so, it might be a little harder then expected as I use unique_ptrs and idk how exactly I can work around that lol.

  • @radoslavdimitrov7505
    @radoslavdimitrov75058 ай бұрын

    32:27 I had just those kind of problems when I was writing an algorithm for parsing JSON files in the C++98 standard that OpenWATCOM 1.9 uses and it was really painful to figure out how to process truncated values, invisible symbols and I haven't yet figured out how to convert pointer addresses to strings and how to process anomalies like if there is another curly braces range in the current range of strings between current curly braces and if I implement more fixes it will fuck the previous algorithms up

  • @Diamonddrake
    @Diamonddrake2 жыл бұрын

    Would love to see the ray tracing in one weekend video

  • @migueldejesustavares4168
    @migueldejesustavares41682 жыл бұрын

    YES, do the raytracing in 1 weekend video!

  • @kuhluhOG
    @kuhluhOG2 жыл бұрын

    6:28 yeah, I once had the case of somebody circumventing our "no absolute paths" linter by using ".." until he was at his root...

  • @alphaios7763
    @alphaios77632 жыл бұрын

    As someone who writes lots of one-liners, I’ve come across a neat shortcut for debugging exactly what I need (in Visual Studio). You can place your cursor on what you want to debug and then press F9, this will make sure it only breaks at that specific statement. I mostly use this within LINQ lambdas in C# and haven’t tested on inline if statements, but I believe it should work. Also, I completely agree they should be avoided in favor of readability. The more experience I get in programming, the more I try to make code that is very readable, but as simple as possible. In the past I would write 5 files with lots of complications to cover every edge case, but nowadays I stray towards simpler solutions that get the job done and that my team can actually understand the code quickly. One small thing that bugs me :) why do you write member variables with m_ prefix? Isn’t the _ enough to let you know that a variable is a member variable?

  • @jarekmyszko3332
    @jarekmyszko3332 Жыл бұрын

    @The Cherno Great review. I agree with everything besides your point at 53:26. When I read the code I do not want to see extra 3-5 lines of code that may or may not influence the algorithm directly. The whole point of the function is to encapsulate some problem and return solution to that problem. The real problem with the "illuminate" function is the name, it updates direction, intensity and distance() of the ligh, it should be called update or genarally something more descriptive.

  • @Rohan-bg8ci
    @Rohan-bg8ci2 жыл бұрын

    Thanks Cherno!!!

  • @kwkfortythree39
    @kwkfortythree392 жыл бұрын

    No advise for changing all those new[] for std::vector?

  • @InfernoTNT
    @InfernoTNT2 жыл бұрын

    Interested in the raytracing in a weekend thing!

  • @xeridea
    @xeridea2 жыл бұрын

    For assets, I put them in the release folder, and set working dir of debug and release to be the release folder. If you want to run debug outside the IDE, you can create a symlink, and git ignore it, but generally if I am not in IDE, I don't need the debug exe.

  • @FalconSmart
    @FalconSmart Жыл бұрын

    hi, is there a way to use .obj (or other 3D model file) as real world scene, and also apply similar ray tracing code? So, it is more universal. Thanks.

  • @moskito98
    @moskito982 жыл бұрын

    id be extremely interested in your RayTracing series

  • @aotein
    @aotein2 жыл бұрын

    There's also another trick using files, the first argument of the main method array is the path of the executable.

  • @LightRayTracer

    @LightRayTracer

    2 жыл бұрын

    And he could have set the path in the debug options in VS. Nonetheless, great vid!

  • @sator666666
    @sator6666662 жыл бұрын

    I really like it!

  • @bogdanflorescu8338
    @bogdanflorescu83382 жыл бұрын

    40:08 on the arduino platform (and maybe other avr microcontrollers) int is 2 bytes. I recently had an annoying bug caused by this :))

  • @maxi-g
    @maxi-g2 жыл бұрын

    Hey Yan, could you give us/me a quick rundown of your hardware(keyboard, monitor, pc, etc) looking for some inspiration for my setup! thanks!

  • @shanesimms1043
    @shanesimms10432 жыл бұрын

    At 32:00 he suggests using a YAML library for scene file parsing, but I'm having a hard time finding a good one. Does anyone have any recommendations for a good library to be used specifically for scene files?

  • @realGeobor
    @realGeobor2 жыл бұрын

    What text color theme do you use? Can I download it somewhere or would I have to input it in manually? I really like the look.

  • @MirrorsEdgeGamer01

    @MirrorsEdgeGamer01

    2 жыл бұрын

    It’s part of Visual Assist, I think, but slightly modified.

  • @littlecurrybread
    @littlecurrybread2 жыл бұрын

    Video was worth it just for the absolute paths talk alone lol

  • @xernerac
    @xernerac2 жыл бұрын

    This is so creepy... I'm working on my path tracing engine right now and thought about your code review show, and the notification pops up.

  • @mateuszabramek7015

    @mateuszabramek7015

    2 жыл бұрын

    😱

  • @isaacmuscat5082

    @isaacmuscat5082

    2 жыл бұрын

    What’s crazier is that I finished raytracing in one weekend yesterday

  • @RustigMusic

    @RustigMusic

    2 жыл бұрын

    My university assignment is a raytracer and I just finished it an hour before this video released...

  • @MempoEdits

    @MempoEdits

    2 жыл бұрын

    are you doing real-time or single image? I'm working a path tracer while watching this video :D

  • @xernerac

    @xernerac

    2 жыл бұрын

    @@MempoEdits I'm doing single image. I'm trying to make an engine that can render both polygon ray traced, and distance function ray marched geometry. Currently, doing really solid progress. I plan on implementing it into blender as a plugin. Don't know how I'll handle the ray marching scene in blender yet... What type of path tracer are you working on?

  • @thesupercomputer1
    @thesupercomputer12 жыл бұрын

    Little hint, at least on my system on Linux and 3900X manually written intrinsics is quite a lot slower, as what the compiler does. g++ and clang will optimize SIMD instructions in, when the compiler knows it can with the right flags like -mavx2 -march=x86_64 -m64 - O3 and so on.

  • @jerrya17
    @jerrya172 жыл бұрын

    Let’s see dem rays!

  • @nraynaud
    @nraynaud2 жыл бұрын

    Funny you pointed the file size, I have the same issue, I like my files in the 500-1000 line range, and I get grumpy when the code convention forces me to put one class per file.

  • @CLSKyoung
    @CLSKyoung Жыл бұрын

    is it possible to use raytracing in openGL are is it not possible at all? I have heard it is only on direct X i just want to confirm.

  • @BossBeneBaby
    @BossBeneBaby2 жыл бұрын

    In the end its all about the efficiency of the acceleration structure that holds all the polygon data. Vulkan really does a great job in providing a very capable acceleration structure that is somewhat easy to use and invredibly fast. My prof at uni couldnt believe how much fastet the vulkan BVH structure is than anything his students and colleges could do in the past. Of course Raytracing Hatdware Acceleration also has a massive impact of 30-50% and is (at least with a 2080, 3080 or 6900xt) very usable in a realtime scope. Anyway a render to texture aproach with the cpu is the best way to learn raytracing and can be accelerated with the gpu quite easy.

  • @Bobbias

    @Bobbias

    2 жыл бұрын

    It also means you have to write all the code to set Vulkan up. I thought getting OpenGL going sucked until I checked out what a minimal Vulkan program looked like.

  • @BossBeneBaby

    @BossBeneBaby

    2 жыл бұрын

    @@Bobbias Yes you are right but there is already a lot of information and tutorials on how to setup vulkan and on the other hand you do not need to program an acceleration structure :)

  • @notuxnobux
    @notuxnobux2 жыл бұрын

    41:13 this part has some bad issues depending on the platform. It writes size_t to the BM file but size_t is 32-bits on 32-bit systems and 64-bit on 64-bit systems so the code wont work for 32-bit systems, although it seems to coincidentally work here because of little endian and overwriting the previous bytes. Also it does unaligned memory writes, which might be fine for x86 (there is a performance penality) but for some other cpu architectures it can cause a program crash. The solution is to use int32_t/uint32_t instead of size_t and use memcpy(header + 0x2, ...) instead of *(size_t*)(header + 0x2) = ... The code wont work for big endian either, but I guess thats fine because big endian is not common.

  • @neekfenwick

    @neekfenwick

    2 жыл бұрын

    Cool story, bro.

  • @DanielLiljeberg
    @DanielLiljeberg2 жыл бұрын

    Remember around 2000 or something I decided to have some fun and use macros in C++ to basically be able to write Visual Basic code that became C++ code. It was funny for a short while and I got some old VB code to run... But I also felt it was super stupid while doing it :)

  • @danejohnson8657
    @danejohnson86572 жыл бұрын

    If you don't want to have to change the code to get it running have people send in projects in a VM image

  • @yunjiehong4649
    @yunjiehong46492 жыл бұрын

    Cool! Hope you can rewrite the ray tracing renderer from scratch one day with c++

  • @ABaumstumpf
    @ABaumstumpf2 жыл бұрын

    int - i have seen it really just covering the specified range - aka +- 32767 (yes, NOT -32768 but -32767) - some signal processing equipment. And on smaller platforms it is quit common for int to be 16bit. (But nothing hinders a platform from int being 16 byte large either) As for int64_t - similar story - that is NOT a fundamental type, the standard says (for all "int*N*_t") it only exists if and only if the system does have a 64bit 2's complement type with no padding. And it can cause problems with conversion and overloads as int64_t might be a long on one system, and long long on another. I really wished that they are not defined as basically type-defs cause i really like to have data-types where i know exactly how large they are and how that will behave with my code. For the atomic: calling load()/store() without further parameters has no advantages and behaves the same as if using the variable directly. They do come in handy (and can significantly reduce the performance-impact) when you are using different memory-orders.

  • @alexmathewelt7923
    @alexmathewelt79232 жыл бұрын

    Since you told, that you have never seen sizeof(int) != 32 bits, I wanna give you an example: the arexx rp6 robot uses an 8bit processor and its int size is 16 bit, seen on page 64 of the manual. Well it's just C, but there are few cases, where int is not 32 bits. But no one would run a raytracer on these kind of systems. Keep on making such interesting content 🙂

  • @TheCherno

    @TheCherno

    2 жыл бұрын

    Yeah, I figured that embedded systems would probably be the ones with non-32-bit ints. Thanks for the example!

  • @ilyboc
    @ilyboc2 жыл бұрын

    is Hazel gonna include ray tracing in the future?

  • @luisburgos2811
    @luisburgos28112 жыл бұрын

    im just on the c++ series but i come and like the video to support the channel

  • @techdiver6074
    @techdiver60742 жыл бұрын

    You are a saint!

  • @S41L0R
    @S41L0R2 жыл бұрын

    I love your channel (:

  • @mario7501
    @mario75012 жыл бұрын

    I fully agree with the statement about using custom file formats. I'm a researcher and almost every research application uses a custom file format for their Config file. It's an absolute nightmare. I tend to use json or yaml for Config files in all my applications.

  • @Sanelora1
    @Sanelora1 Жыл бұрын

    I think the issue with file paths/working directory setup not being taught properly is mostly due to the assumption that programming students already know about this by the lecturers. Self-taught people seemingly only come up against it when deploying/distributing projects and so a lot of the early stuff that they use to learn develops and embeds bad habits. As an IT Pro, I've been dealing with this subject my entire career (as simple as it sounds) but since I have started studying development this year, it has become all to clear that a lot of the more basic IT concepts such as this just seemingly aren't taught with the rigor that they should considering their relevance in the overall ecosystem.

  • @CraftMine1000
    @CraftMine10002 жыл бұрын

    Cherno: "were doing a ray tracing code review!" Also cherno: spends the first 5 minutes ranting about working directories

  • @somdudewillson
    @somdudewillson2 жыл бұрын

    22:28 I'm fairly certain that's not reflection, but rather refraction.

  • @DakkyW
    @DakkyW2 жыл бұрын

    100% into a video on the Ray Tracing in One Weekend

  • @chien461
    @chien4612 жыл бұрын

    do you review C code as well?

  • @sunnydev394
    @sunnydev3942 жыл бұрын

    LETS GOO

  • @m3taldragon1
    @m3taldragon12 жыл бұрын

    Can you please do a video on coroutines in C++20?

  • @Bazarack
    @Bazarack2 жыл бұрын

    Learning from someone else's code is good, but it has to be good code. A learner is not always able to judge it :)

  • @Pyrohawk

    @Pyrohawk

    2 жыл бұрын

    Indeed. Asking a beginner to interpret some esoteric uncommented ramblings is probably a waste of time, and may reinforce bad habits.

  • @hugopeters6627
    @hugopeters66272 жыл бұрын

    Not multithreading in debug mode makes a lot of sense to me. Breakpoints are annoying because you will be jumping between threads.

  • @Decco6306
    @Decco63062 жыл бұрын

    I had this dream three weeks ago where you made this video and i was screaming at the top of my lungs "THANK YOU THANK YOU" in public at a bus stop. but the weird part is that ive never ridden a bus before

  • @AhmedMohamed-xx1kx
    @AhmedMohamed-xx1kx2 жыл бұрын

    we want to know what theme you use

  • @ssmall8870
    @ssmall88702 жыл бұрын

    0:23 , HAHA, I understood that reference.

  • @basicallybrand
    @basicallybrand2 жыл бұрын

    I have been programming for a few months in pygame and even I know how path works

  • @severgun
    @severgun2 жыл бұрын

    38:00 Seems like detached braces are only Unreal thing. LLVM, Google style always attached.

  • @enshk79
    @enshk792 жыл бұрын

    The thumbnail makes me lose my shit. So funny

  • @deadirl5980
    @deadirl59802 жыл бұрын

    i love u. fr fr

  • @krzysztof-ws9og
    @krzysztof-ws9og2 жыл бұрын

    I love that there is #ifdef _WIN32 at 41:53 as if it was meant to be cross platform but filenames are using backslashes and D:\\...

  • @lucasmorais3694
    @lucasmorais36942 жыл бұрын

    "We are back on Windows! Yes! Wait, your computer will be restarted?" LOL fomrced umpdat