I created my own Ray Tracing Engine from scratch

Ғылым және технология

I created my own Ray Tacing Engine from scratch!
► Leave a like to help the channel grow 👍
► Every subscription counts! 🎈
► Source code: github.com/carl-vbn/pure-java...
► Resources used: (not all of them are dedicated to ray tracing but the theory is the same)
- Ray tracing concept (Shadows and reflections): • Coding Adventure: Comp...
- Ray tracing shader example code: bit.ly/2VWQm43
- Ray-sphere intersection: • Calculating Ray-Sphere...
- Diffuse lighting theory: • Ray Marching for Dummies! (at 15:31)
- Specular lighting theory: • OpenGL 3D Game Tutoria... (start of the video)
- Gaussian blur theory (for the bloom effect): • OpenGL 3D Game Tutoria... (start of the video)
- Bloom effect theory: • OpenGL 3D Game Tutoria... (start of the video)
- Spherical image unwrapping: en.wikipedia.org/wiki/UV_mapp...
🎵 Bensound - Endless Motion
#RayTracing
#NvidiaRTX

Пікірлер: 230

  • @IchigoFurryModder
    @IchigoFurryModder3 жыл бұрын

    Edit: I almost forgot to point out this is all constructive criticism, I liked the video and the engine, it's some real cool stuff. There's one or two things here that weren't mentioned but should of been, I had written a few short paragraphs about it and i clicked on a View Replies label and then my whole text disappeared so I'm just gonna do summarize it a bit because I don't wanna write the whole thing again, curse you Google developers. He's doing raytracing, alright, path tracing to be specific, because raytracing is any rendering pipeline that involves casting at least one ray, but his engine is not representative of the industry. He's describing all the shapes he's rendering with math equations, similar to the distance fields we use for ray marching, this isn't hard, or expensive to compute, but you do that when you're only gonna render primitives like's doing, if you wanna do a human it's just not practical to make an intersection function for it, and that's not even mentioning deformation and coloring. Games use meshes simply because it's the most practical thing to do, but raytracing meshes is expensive, while doing a single triangle is even more trivial than the spheres he's doing, in games you typically have to do it several dozens, sometimes even millions of times, for *each* pixel, which is why resolution is one of the biggest factors to raytracing performance. There's also the matter of shaders that follow conservation of energy and actually benefit from raytracing for something other than just reflections, and soft shadows that need to be sampled and other stuff that needs a probabilistic engine like Blender Cycles which also introduces the problem of noise, but those are rabbit holes of their own. This engine is pretty cool, you got my like, but it should be mentioned that this engine is not gonna cut it for real applications, it's just the basics of path tracing, it's useful to learn how it works but that's about it, not expecting him to explain this stuff because it isn't the point, but it should be mentioned because then people can be lead undermine stuff like the whole RTX implementation or the DXR stuff as a whole that is meant to solve some really hard problems just because some dude wrote a raytracer engine that uses intersection equations for perfect spheres and planes to do a tiny demo showcasing some very simple path traced reflections, which runs decently at fairly low resolutions.

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    I totally agree with your comment. I should have made it more clear that I wasn't an expert when I made this (I still am not but I know a bit more about this stuff now) but that it was my own way to learn the basics of such a wide an interesting topic. I really didn't expect this video to get so much attention! Thank your for taking the time to mention all of this very clearly.

  • @IchigoFurryModder

    @IchigoFurryModder

    3 жыл бұрын

    It's nothing, I just thought I'd share this stuff because I know there's lots of people who don't know any better about topics like this. If I didn't know any better then I would of surely been overly impressed and tried to bother Linus (as in Linus Media Group owner) about RTX cards and next gen consoles and even the entire DXR part of DX12 being a coordinated scam and convinced everyone that Nvidia cards with triple digits series should be enough or something. tangent taking up most of the entire text L E T S R O C K: I mean, *specifically the RT cores part* of RTX is kind of in a grey zone in that aspect, but that doesn't mean it shouldn't of been a big deal of a technology, just maybe not as much of as it was, and still is somewhat. And also, realtime raytracing (RTRT) as a whole is less of a big deal because it looks good, because you can certainly get results that good with pure rasterization, but, to me personally, the deal with RTRT is that all lightning just works out of the box, the developer doesn't have to spend hooooouuuurs upon hooooouuuurs just passively waiting for the graphics engine to finish baking lightning and directionality textures for the GI of an entire scene, because that's the thing, to make rasterization look good you need to do a lot of setup that takes a lot of time and budget. In my ideal world all games are RT only because the developer doesn't need to setup *anything* other than materials for surfaces and the skybox, the lightning just works, and there's no shenanigans with making some objects static and some dynamic or anything, ambient occlusion? Diffuse shaders are already just ambient occlusion. Reflections? Glossy shaders are already just reflections. Glass? Just glossy shader that sends light a different direction. It *just* works, and games can also be cheaper that way. Overall, I'm not an expert either, got lots to learn, some of which are subtle things -god dang it google, just give me a formula to remap a number so I can use real world accurate IOR values for my shaders that use the dot of the view direction and the normal for fresnel, just a formula Ã̵̌̈́ͅȦ̶͍̠̙͗͋̽͝A̷̛̪͕͙̤͊̅̕A̷̰͗̑̽̀̾̚A̸͈̔͛́A̷͖͑̆͆͠Ä̴͙̃̽͗̽͜À̸̠̼̭͕̇̀̀Â̴͈͉̾Ả̴̞̺̮̙̟̑̿̀̒A̴͙̦̞͆̍Ǎ̴̡͕̻͕͐̽̿͗̚͜A̸̟̲͕̘̥̱͋͌͛Ä̴̡̳̹̗̟́͊̀́ͅA̸̟͍͈̍̈́͋́͘ͅA̴̪͎̻̼͗̈́A̷̝̦͋͆̋A̶͔̖̖͈͌̓̕̕̕A̵̛͉̞̙̩͉̎A̸̧̢̝̎͆̉̇͛͘Ą̴̲̻̔̿A̵̞̼̼͚̞͆̍̉̅͝- but I do know more than most people out there do, and I think it's important to spread your knowledge so that everyone can learn from everyone, specially in the computer engineering field. Anyway, if you maybe want to ask me something, or tell me something, on topic or otherwise, you can message me on discord whenever, my tag is dvwf #1375, definitely expect to see me in your notifications now and then :)

  • @jackaed

    @jackaed

    2 жыл бұрын

    This also isn't really doing raytracing. The reflections are ray-traced, but the rest is just an expensive method of generating shadows (using shadow maps gives similar results, just faster), and regular phong shading (by the looks of things). There isn't any proper bounced lighting going on here, and also doing it entirely in java and not using any compute shaders meant that performance was expectedly terrible. To be fair, writing an entire graphics library seems outside of this project's scope, and this is a pretty cool project!

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    @Jackaed Agreed, but the shadows are still ray traced. This method doesn't support soft shadows, but it's still more precise and accurate than shadow mapping, which is especially tricky to get right. I should soon start working on a sequel which addresses the many flaws of this project, as I now know a lot more about true ray tracing.

  • @WitoEngelke

    @WitoEngelke

    2 жыл бұрын

    Yes, there are some aspects you mentioned which are missing. It can be seen as a good introduction and example video explaining the basic idea and give a hands on experience for this. Its short, its compact and I think it is of great value for people just getting into the topic. It can also act as a base line from where different future videos can emerge from, shining light onto aspects like energy conserving shading models (PBS), acceleration structures, more advanced methods for shadows and so on. A small remark on terminology: He used the term raytracing and this is perfectly fine. It is not called path tracing by any means. In a path tracing approach a large amount of rays after the primary ray hits an object would be considered. This is done to "collect" lighting information from different directions and aggregate their information. The material properties of the hit object would determine the ray distribution. With this indirect lighting and ambient occlusion can be calculated. One can think like: Ray casting - a simple "shooting" of rays into a scene, used for example in volume rendering. Ray tracing - tracing a ray further after the primary hit, makes calculation of mirror-like reflections possible. Path tracing - a more advanced model for calculating additional aspects of light distribution. Tracing a larger amount of rays for each primary ray after first hit. Ray marching - a method to "step along" a ray fast to find a possible intersection, often used in combination with signed distance fields.

  • @ethanoch
    @ethanoch3 жыл бұрын

    Nice! I had to do this in a computer graphics class in college --- I chose to write mine in C, and we used the Blinn-Phong reflection model. It was definitely fun, and I learned a lot about the perks and drawbacks of ray tracing technology. Subbed!

  • @NamePointer
    @NamePointer4 жыл бұрын

    Hey! Thank you for watching :D I hope you've enjoyed the video! This one was really hard to make, as both making the engine and editing took an insane amount of time. If you want to support the channel, please like and subscribe, and if you could share this video, I would really be thankful!

  • @DS-pk4eh

    @DS-pk4eh

    3 жыл бұрын

    Great job (insert your name! I see it is Java. Would the C++ or C# make it even faster? Also, would adding an API that supports raytracing (like DX12 or Vulkan) make this easier or not? I know that point was to make it without using anything else but your code, but if we want to bring this to another level where we can have executable for users to just use them. (Got my sub)

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    @Darko Sola Thanks for the nice comment! Performance wasn't a big priority when making this, in fact everything is running single-threaded on the CPU so it performs terribly (I have to lower the resolution to get an acceptable frame rate) but I will be using OpenGL in C++ in the next video which will be about rasterization (so no raytracing this time)

  • @DS-pk4eh

    @DS-pk4eh

    3 жыл бұрын

    @@NamePointer I saw that. I was imagining it will be a single thread process. Do you have any experience with Unity or maybe Unreal?

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    @@DS-pk4eh ​ Yes I actually use both quite often but here the point was really to make everything from scratch to get a better understanding for all the techniques involved

  • @IchigoFurryModder

    @IchigoFurryModder

    3 жыл бұрын

    @@DS-pk4eh Generally speaking, Java *tends* to be faster than C# I'm told, I know JavaScript is really slow, but I haven't looked into Java and have no interest so do your own research on that end. But C++ though, using C++ gives you the *potential* to get just about as much performance as you can get from the machine because C++ compiles to raw machine code the CPU can read directly, while C# and Java both compile to byte code, MSIL/IL and JVM respectively, the CPU doesn't really understand byte code, so there needs to be an interpreter program that is in machine code that takes care of reading the byte code to know what instructions to send to the CPU, but to be completely honest, you don't usually need the performance C++ offers, C# will be fine because most of the stuff you process will be handled entirely by the graphics card that has absolutely nothing to do with any of this, unless you wanna render on CPU for some reason. Adding an API that supports raytracing is very much required for any practical program, or well, a graphics API in general, because what they do is that they allow your CPU code to communicate with the GPU *at all*, the GPU is called the Graphics Processing Unit for a reason, it's essentially like a CPU, but the instruction set and the architecture are *specifically* designed to do some complex maths with huge amounts of data in parallel, which is great for graphics processing, raytraced or otherwise, it's just a thing of having acceptable performance. But you asked if it makes it easier, yes, it does, they essentially do the rendering for you, you just use it however you like, simplified summary but that's enough information I decided so do your own research on that, but that also applies to rasterization, and if you wanna do it yourself but still use the GPU then you can essentially do the same thing as in the video but using the power of compute shaders instead of using the CPU for something it wasn't designed to do -you can also write your own drivers since the API is just the specification and the real magic is in the drivers but who am I to tell an stranger on the internet to do such a ridiculously hard and unnecessary thing simply because it'd be cool.-

  • @arielvinda6624
    @arielvinda66243 жыл бұрын

    I like how "human understandable" you made it; Others just jump directly onto definitions and the weird math behind it and forget most of us are just humans (not physics phds) trying to get it working just for fun

  • @kyle2034
    @kyle20342 жыл бұрын

    That's awesome! I made something like this when I took a graphics course back in college. Was probably my favorite thing I worked on in college. Creating a ray tracing engine was significantly easier than creating a triangle rasterization engine.

  • @adammoyart6817
    @adammoyart68174 жыл бұрын

    Really helped me for my project. Thank you. You really deserve more views.

  • @GBduds
    @GBduds3 жыл бұрын

    Just subbed, you are underrated and make great content.

  • @johnjackson9767
    @johnjackson97674 жыл бұрын

    Looking good! Here's a sub to help with your channel's growth! Side note: This has made me consider covering some ray tracing techniques for my own channel. Thanks!

  • @beimanonestar
    @beimanonestar3 жыл бұрын

    Nice work man. Subbed!

  • @kabinet0
    @kabinet03 жыл бұрын

    The effort in this is incredible.

  • @butterbn
    @butterbn4 жыл бұрын

    Nicely done. I like it

  • @londongaz2
    @londongaz22 жыл бұрын

    Wow, this looks really great!

  • @waleedalasad1298
    @waleedalasad12983 жыл бұрын

    This man makes it look easy. Great job!

  • @dr20231may
    @dr20231may3 жыл бұрын

    great information as always , but right now i can digest only a few of it ,keep making more such awesome vids

  • @aaronspeedy3087
    @aaronspeedy30873 жыл бұрын

    Wow! That is so cool,I was looking how to make a Raycaster in C,and I got to this video,It's so cool

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Thanks! Good luck with your project!

  • @lucaxtal
    @lucaxtal2 жыл бұрын

    WOW!!! Great Job!!!

  • @joshaustintech
    @joshaustintech8 ай бұрын

    This is very neat! I'm about to build one on my free time using Java 21's goodies, including SIMD instructions and structured concurrency.

  • @orion3254
    @orion32544 жыл бұрын

    I can only say wow man, you've done an incredible job on teaching us how raytracing works. I hope my sub and like helps you out. Stay healthy.

  • @NamePointer

    @NamePointer

    4 жыл бұрын

    Thank you so much, your comment really motivates me! Stay healthy too!

  • @BirinderSingh
    @BirinderSingh3 жыл бұрын

    Now That. Is. Underrated. Period. You really need some exposure mate this talent can't go unnoticed.

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Thanks so much :D Well if you want to, the best way to help would be to share this video with people you think might be interested!

  • @NotTofuFood
    @NotTofuFood3 жыл бұрын

    Wow, absolutely incredible!

  • @wonderfulworld2746
    @wonderfulworld274610 ай бұрын

    You are so talented, thank you for your video !

  • @SapphFire
    @SapphFire3 жыл бұрын

    nice! I like the visualisations you made to explain everything.

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Thanks! I will probably do the same for my next video

  • @eboatwright_
    @eboatwright_2 жыл бұрын

    This is really great! :D

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    Thanks!

  • @OmegaFalcon
    @OmegaFalcon4 жыл бұрын

    that was super cool! dude you deserve way more subs

  • @NamePointer

    @NamePointer

    4 жыл бұрын

    Thank you!

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

    You made a pretty cool software raytracer in one day. You are great

  • @Drmarcus9
    @Drmarcus93 жыл бұрын

    No way you have ONLY 700 subs, this is epic!

  • @realbroksy
    @realbroksy4 жыл бұрын

    Really cool!

  • @Pspet
    @Pspet3 жыл бұрын

    Very interesting, and thanks for the explanation of the algorithms.

  • @Eriak_
    @Eriak_3 жыл бұрын

    great job dude !

  • @alfonsodonotsi6691
    @alfonsodonotsi66913 жыл бұрын

    thats amazing!!! i hope someday do something similar

  • @silvertakana3932
    @silvertakana39324 жыл бұрын

    Please make some more, I’m really excited to see more of these content

  • @NamePointer

    @NamePointer

    4 жыл бұрын

    I'm currently working on a new video. It should be ready by the end of the month! I'm really happy that you enjoyed this one :)

  • @komurokaede122
    @komurokaede1223 жыл бұрын

    My partner was considering with me, adding ray tracing to the project we're working on; and while I don't know much about programming, she was worried about having to learn the Vulkan API. I wonder if this video will inspire her to develop an engine from scratch-- you make it look very easy for a person like her!

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    I wish her good luck!

  • @gryasl6231

    @gryasl6231

    2 жыл бұрын

    after almost 1 year, how is your project going?

  • @abdomohamed4962
    @abdomohamed49623 жыл бұрын

    I tried the demo you made ... and its freiken awesome man

  • @MarkVonBaldi
    @MarkVonBaldiАй бұрын

    This looks really good, I just think you should also add Refraction.

  • @mariovelez578
    @mariovelez5783 жыл бұрын

    Awesome, dude! I did my own project like this in java, but never did any sky boxes, specular lighting, or post processing effects

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Hey calm down man, it was just an experiment and java is much more forgiving for that, even if it runs much slower. Go watch my latest video if you want as I use C++ there

  • @objectful1975
    @objectful19753 жыл бұрын

    guaranteed to blow up. i was surprised you don't have like 300k subs

  • @noot_2
    @noot_23 жыл бұрын

    eheheheheh Had a computer graphics final yesterday and we spoke a lot about this. Great video, it was really well explained!

  • @PlexorF1
    @PlexorF13 жыл бұрын

    This is epic!

  • @khikmatillosultonov2967
    @khikmatillosultonov29673 жыл бұрын

    Tank you bro!!!! The best and is useful !!!

  • @kinggore5229
    @kinggore52293 жыл бұрын

    Good stuff!

  • @cavmangamer
    @cavmangamer3 жыл бұрын

    Insane! well done lad. Consider making a Udemy course, I would love to do this

  • @legitbox
    @legitbox3 жыл бұрын

    Good job, keep it up

  • @xfry
    @xfry4 жыл бұрын

    Awesomeeee!! Man, I would love if you share with us the resources you use to create it. I have been dreaming with create something like this and you have clear all the resources path that are needed to do it real 👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽👏🏽

  • @NamePointer

    @NamePointer

    4 жыл бұрын

    Thanks for the nice comment! The resources used are now linked in the description, have fun!

  • @xfry

    @xfry

    4 жыл бұрын

    @@NamePointer wow awesooomeeee Thank youuuu!!

  • @tameronica
    @tameronica3 жыл бұрын

    Bro, you're so talented and underrated. You've earned a sub from me!

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Thanks!

  • @MrLegarcia
    @MrLegarcia2 жыл бұрын

    Amazing !!!🌎

  • @SashaEgorov88
    @SashaEgorov883 жыл бұрын

    Subscribed! Your content is interesting! Sorry for my bad English.

  • @LlamaMoon_Games
    @LlamaMoon_Games4 жыл бұрын

    Wow that really cool, got a sub from me :3

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

    with java? amazing!

  • @thomas_cornez4679
    @thomas_cornez46792 жыл бұрын

    Impressive!

  • @MrGustavier
    @MrGustavier2 жыл бұрын

    very impressive !

  • 2 жыл бұрын

    there is a paper called "Texture Level of Detail Strategies for Real-Time Ray Tracing" that you can check out for fixing the texture aliasing

  • @paxdriver
    @paxdriver2 жыл бұрын

    I'd watch a 2hr long video of you stepping through the code instead of fast forward. The descriptions are nice, but fall short of awesome when the code is skipped imho seeing all the bits and pieces coming together is what gives people that satisfaction, or aha moment in the end.

  • @3sc4p1sm
    @3sc4p1sm2 жыл бұрын

    The naive implementation is always a good start. If your feeling fancy dig deeper, try rendering complex and detailed shapes, when that is working, try rendering a million of em.

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

    New to the channel. Pretty cool vid. How long did it take you to make the raytracer? 1 day? 1 week? 1 month? a year?

  • @NamePointer

    @NamePointer

    Жыл бұрын

    Welcome! This is an old project that I worked full time on for a few weeks. I recently made an improved version that took about three months of part-time work

  • @nikifaets
    @nikifaets4 жыл бұрын

    Very cool! I'm currently working on a raytracer too. About to start the reflections. I think it would be cool if you left some links to your sources. It would be helpful for interested people to know where to read about the subject.

  • @NamePointer

    @NamePointer

    4 жыл бұрын

    I just added all the resources I used in the description, good luck with your raytracer!

  • @mumbojambini9530
    @mumbojambini95303 жыл бұрын

    great video quality

  • @3DevYT
    @3DevYT6 ай бұрын

    How would one go about raytracing the skybox?

  • @mattheck6470
    @mattheck64703 жыл бұрын

    Well done. If you'd like an older text full of C++ details of raytracing, prior to using any third-party libraries of note, find a copy of "Flights of Fantasy" by Christopher Lampton (1993).

  • @bongsgi95
    @bongsgi953 жыл бұрын

    Wow great work NamePointer! I'm doing a master thesis about sonar detection so I'll need to write a shading algorithm for sonar. Your work is very close to what I'll be working with, so would you mind if I used it for inspiration?

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Of course not, feel free to use whatever you need!

  • @amirhosseindolatkhah2924
    @amirhosseindolatkhah29243 жыл бұрын

    Greatttttttttttttttttttttttttt.................. Thank you so much. please continue java adventures....

  • @ry4n.bg6
    @ry4n.bg62 жыл бұрын

    Great video, but I have a question, when you add perspective, I assume you change each rays direction vector, but how do you calculate which pixel that ray is correlated to on the screen than?

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    The program actually loops through all the pixels and traces a ray for each one. The program therefore knows which pixel to color as one ray is always associated with one pixel when it is created.

  • @ry4n.bg6

    @ry4n.bg6

    2 жыл бұрын

    @@NamePointer Oh ok, tysm! :)

  • @galenburnett9791
    @galenburnett97912 жыл бұрын

    That scene at 6:35 would be a pretty cool BotW Shrine.

  • @S3Kglitches
    @S3Kglitches2 жыл бұрын

    amazing

  • @njdotson
    @njdotson3 жыл бұрын

    This is really cool, I understand most of it but in basic rendering how is the math done where the objects are made in 3d space? Like the camera needs to know when the rays intersect something but how do the objects' locations get stored? (Btw ray tracing can also support soft shadows and light bounces which I think are cooler than reflections

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    There are different intersection functions (which you can find online for primitives) which take an objects position as a 3-dimendional vector (XYZ), the objects size and the ray as another 3D vector and return the point at which the ray should hit the object. And about soft shadows and GI, I would love to create a sequel to this video where I make something much more performant using OpenGL or Vulkan to create a more advanced raytracing engine

  • @ydresssmith459
    @ydresssmith4593 жыл бұрын

    This a great Video

  • @C_Corpze
    @C_Corpze2 жыл бұрын

    I'm impressed, what did you actually use to accelerate the raytracing? Do you use the GPU at all? Since you aren't using any libraries I'm assuming you're not using CUDA, OptiX or anything like that.

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    It's not actually accelerated at all. I had to lower the resolution to get it running in real time and the final renders took a while to process.

  • @keweez8626
    @keweez86263 жыл бұрын

    Hello, Amazing work but may I ask is there anyway for me to push a Car model in to demonstrade instead of using just spheres

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Currently only models with a hardcoded intersection function can be rendered, but you could define an intersection function for a triangle and apply it to all triangles of a car mesh

  • @keweez8626

    @keweez8626

    3 жыл бұрын

    @@NamePointer thankyou for your reply keep doing the great works !!!

  • @ugobenoist2895
    @ugobenoist28954 жыл бұрын

    wow incredible

  • @IsraelSocial
    @IsraelSocial2 жыл бұрын

    Can i do my own ray trqcing code to be implemented on a game like skyrim? Can be archivied on a dx11 engine?

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    If you want to add raytracing to skyrim (or another existing game) yourself, you would have to rewrite its entire rendering engine. It is theoretically possible, but would require extreme amounts of efforts and dedication.

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

    As a side note on your Bloom effect: Actual bloom is usually achieved by taking the threshold image and blurring it, then halving the resolution, then blurring then halving etc, then combining those immages together. That makes the effect a lot better looking. (My explanation is probably not entirely correct, I'm no expert but thsi is the basic idea)

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    Thanks for pointing that out! I recently watched The Cherno's video on Bloom which goes into a lot more details than the resource I was using.

  • @avaze7

    @avaze7

    2 жыл бұрын

    @@NamePointer Yes that is the exact video I learned this from as well :D Maybe you've done this already, but I'd recommend implementing materials for your spheres with the possibility to use textures, especially implementing normal maps. I did that a while ago in Ruby and it was really satisfying to see surface detail when you're only rendering perfect spheres, and the Code is very similar to the skybox Code and it isnt that hard (except for when you have to do matrix multiplication but that's only a few lines aswell)

  • @roboticol6280
    @roboticol62803 жыл бұрын

    earned a sub

  • @forg3214
    @forg32142 жыл бұрын

    Some sunrays or distortions would be cool

  • @demented1010
    @demented10102 жыл бұрын

    Hold on, that low quality look to the circles at the start looks really cool, the background reminds me of the jevil fight too. I'm just saying but that's a really cool game concept

  • @jctemp
    @jctemp2 жыл бұрын

    How did it took you to make the engine?

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    I worked on it during most of my free time back then for about 3 weeks. It was my first time attempting something like that however.

  • @bearfm
    @bearfm2 жыл бұрын

    sick

  • @devzone5924
    @devzone59243 жыл бұрын

    How can you do realtime ray tracing??? I'm making a normal Ray Tracer in C++ wich takes 1 hour to render a single picture!

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    I have a pretty fast CPU and the ray tracer didn't use any fancy features like Global illumination or soft shadows but nonetheless it's only realtime when I lower the resolution which makes it look really blocky.

  • @chris_burrows
    @chris_burrows3 жыл бұрын

    From what you said I understood that you have intersection functions for planes, boxes, and spheres, how does this approach work with more complex models?

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    In theory, you would just need an intersection function for a triangle and you could then test for intersections with all triangles of a model. In practice that would just be too slow, so algorithms use less precise intersection functions (like cubes and spheres around the model) to pin point the area where the ray should it and then check for precise intersection in that area of the model.

  • @chris_burrows

    @chris_burrows

    3 жыл бұрын

    @@NamePointer ah right so realtime real world applications only raycast to lightprobes then?

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    It's still raytracing, but with additional steps to reduce the number of intersection steps. NVIDIA have made videos about it

  • @chris_burrows

    @chris_burrows

    3 жыл бұрын

    @@NamePointer of course, I'm just curious about both yours and the general implementation. Are you on the Graphics Programming discord? A lot of people post a lot of impressive renderers on there.

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Not yet, but I'm gonna join it now

  • @anonymoussloth6687
    @anonymoussloth66872 жыл бұрын

    Hi I am a complete beginner to computer graphics and I am currently learning opengl and I wanted to create a basic ray tracer in opengl. I researched online and people are saying that it is not possible to do this in opengl or I would have to use something like opencl. Is this true?

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    It is technically possible. While OpenGL is intended for rasterization and not raytracing, you can draw a quad covering the entire screen and write the raytracer in the fragment shader.

  • @anonymoussloth6687

    @anonymoussloth6687

    2 жыл бұрын

    @@NamePointer I see. What graphics api are you using in this video?

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    In this video I didn't use any and just drew on the window with Java swing, but you should never do that for obvious reasons. I now use OpenGL with C++

  • @anonymoussloth6687

    @anonymoussloth6687

    2 жыл бұрын

    @@NamePointer I see. I have been researching ways to write a raytracer in opengl and i mainly came across 2 ways. 1 is to use the quad method and the other is to use a compute shader introduced in opengl 4.3. which way would you use or advise if you implemented one?

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    I would go for the quad/fragment shader approach but that's really just because I have no experience with OpenGL compute shaders

  • @hajjex_9086
    @hajjex_90863 жыл бұрын

    Whats the program u used?

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    The point of the video was to make everything from scratch, so I haven't used any engine or so. If you're wondering what IDE I was using to write the code, it's IntelliJ IDEA. The source code is available in the description.

  • @hajjex_9086

    @hajjex_9086

    3 жыл бұрын

    @@NamePointer thanks man your a legend, what I meant to say what language Because you did a glorious job

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Thanks! I used Java because I never expected to get as far as I did. It was a terrible choice though (because of performance) and I would now use C++ like I did in my last video

  • @hajjex_9086

    @hajjex_9086

    3 жыл бұрын

    @@NamePointer yea I see, C++ would be a bit faster but won't be as easy, you know, also, uve got a new subscriber!

  • @tekhiun
    @tekhiun3 жыл бұрын

    You should give it a go to Kotlin , it is fully compatible with any Java API and the language syntax and features makes coding much more readable and with less overhead.

  • @kij6223
    @kij62234 жыл бұрын

    thats the carl i know

  • @ibemper1850
    @ibemper18503 жыл бұрын

    I know you said tha tyou are not going to use any external library, but you could have written this in the compute shader, which is very helpful for things like rendering

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Yup, if you look at my replies to some comments here you'll see that that's what I'm recommending for those wanting to build a more serious application, but I really did not want to use any graphics API. I have however used OpenGL for my last two videos as I want things to run in real time.

  • @kales901
    @kales9012 жыл бұрын

    where is the scratch download?

  • @star80doessdastuff
    @star80doessdastuff2 жыл бұрын

    how do I run it...?

  • @NamePointer

    @NamePointer

    2 жыл бұрын

    There's a link to the GitHub repository in the description!

  • @gabrielpena2070
    @gabrielpena20703 жыл бұрын

    How do I run the code?

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    You should be able to download and just run it in any Java IDE, no libraries required

  • @mlnz2991
    @mlnz29913 жыл бұрын

    nice

  • @ibemper1850
    @ibemper18503 жыл бұрын

    you have written the raytracing engine which is really good, you got a sub from me, but how do you display the final output to the screen??

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    I just used Java Swing draw the rendered imagine to the screen but for a more serious application you would use a shader program to do most of the calculation on the GPU and directly send the result to the screen. That can be done with OpenGL for example.

  • @ibemper1850

    @ibemper1850

    3 жыл бұрын

    @@NamePointer you replied in so little time, was not expecting that, thanks for clarifying it, i don't know much about java but i am thinking of doing something similar in C++, your video has helped a lot

  • @StevJava
    @StevJava3 жыл бұрын

    wow 😳

  • @hugo5097
    @hugo50973 жыл бұрын

    I assume this program is using the GPU, but how are you accessing it? Or can the program run this fast on the CPU alone? Also, great video, really enjoyed it!

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Well actually it runs entirely on the CPU without any optimization so it only runs in realtime with decreased resolution (the final renders where not rendered in realtime). Sorry to disappoint you, but this was just a fun little experiment so I pretty much didn't care about performance

  • @hugo5097

    @hugo5097

    3 жыл бұрын

    @@NamePointer Okay, I understand. I am not disappointed, must say that the renders looked great even if the were not rendered in real time. I have tried real time ray tracing myself in both java and c++ and performance is a constant struggle, but the technique is very interesting. I will definitely keep watching your videos, you are doing a fantastic job!

  • @revolutionstudios5052
    @revolutionstudios50523 жыл бұрын

    Crazy how I'm here not even able to draw a cube with OpenGL, and this guy just makes a Raytracer in Java for fun.

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    To be honest I made this before being comfortable with OpenGL. Raytracing theory really is much easier than Rasterization theory as it's actually pretty intuitive. And if you're interested in OpenGL I would recommend watching my latest video where I use it ;)

  • @revolutionstudios5052

    @revolutionstudios5052

    3 жыл бұрын

    @@NamePointer You did a really good job explaining it! I'll check out that video. Thanks for the recommendation!

  • @mitchg9017
    @mitchg90172 жыл бұрын

    This is insane

  • @hajjex_9086
    @hajjex_90863 жыл бұрын

    Theeeanks

  • @kiszkilukiszki4057
    @kiszkilukiszki40573 жыл бұрын

    How to make it executabe to run it on my pc?

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Import it into IntelliJ or Eclipse and run it from there or export it into a runnable JAR

  • @kiszkilukiszki4057

    @kiszkilukiszki4057

    3 жыл бұрын

    @@NamePointer thank you!

  • @yourboiivan
    @yourboiivan3 жыл бұрын

    u deserve very much

  • @Mauritz5
    @Mauritz53 жыл бұрын

    Correct me if I'm wrong, but your code is all on the CPU, not using Nvidias RTX functionality right now, right? Still great introduction!

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Yes for this project the challenge was to achieve something good looking without using any library or API and performance wasn't really the priority

  • @NickyAnimations
    @NickyAnimations3 жыл бұрын

    My brain just exploded

  • @kinggore5229
    @kinggore52293 жыл бұрын

    Wait... If you used diffuse shading, this is not pure ray tracing. It's a mixture of ray tracing and rasterization. Actually, except reflection, I think the rest are all rasterization.

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    Yes you're right some of the techniques I used don't take full advantage of the power of raytracing, but the main idea behind raytracing is tracing a ray for every pixel from the camera and then back to the light source, which is what I did here. Diffuse and specular lighting are indeed kind of a hack used with rasterization to safe on processing power. Also, I did not mention Raytraced Global Illumination and ambient oclusion, but I'd love to do something more advanced with these techniques in the future.

  • @ericsexton3539
    @ericsexton35393 жыл бұрын

    I was really curious about what language you used and how you got pixels on the screen without an external library. So I paused the video and saw java. Okay, fair enough. I keep going and I finally see it. This is just java swing and you are overriding the paint method to set pixels with the rectangle function. Didn't think something like this could even run in java swing. Mind is blown.

  • @NamePointer

    @NamePointer

    3 жыл бұрын

    It did run, but not that well. As soon as I added reflections, I had to lower the resolution to get an acceptable frame rate. The final renders weren't rendered in realtime. Unless your goal is to do it without any library, you should really be using a GPU based API like OpenGL for something like this!

  • @ericsexton3539

    @ericsexton3539

    3 жыл бұрын

    @@NamePointer Yeah, I could see that! I think it is a really interesting way to teach it though. Feels like there are no smoke and mirrors.

  • @petterlarsson7257
    @petterlarsson72572 жыл бұрын

    i want to download this

  • @2minutosparareir664
    @2minutosparareir6642 ай бұрын

    Que buen video saludos desde bolivia

Келесі