Code-It-Yourself! 3D Graphics Engine Part#2 - Normals, Culling, Lighting & Object Files

  Рет қаралды 326,282

javidx9

javidx9

Күн бұрын

Пікірлер: 553
@Jonathan2222Dark
@Jonathan2222Dark 6 жыл бұрын
The 's off' in the obj file, describes if smooth shading should be used or not.
@dehrk9024
@dehrk9024 10 ай бұрын
she s off when she see my smoothe model
@ArtumTsumia
@ArtumTsumia 3 жыл бұрын
I'm starting a new personal project with the goal of writing virtually everything myself, so when I saw this, it was the perfect thing to check out. This series is a fun little refresher as I haven't really written graphics code this low level since learning to code. Going back to basics, and really diving into some of the low level stuff like rendering, networking, etc. rather than simply relying on existing libraries is a welcome break from focusing on the game logic side of things. A wire-frame isn't necessarily as exciting to show off as a more complete project, but there's a different kind of satisfaction from building it, along with the understanding gained.
@francescosorce5189
@francescosorce5189 6 жыл бұрын
To anyone who wants to understand the math/maths better I raccomend 3blue1brown's "the essence of linear algebra" series. It basically gives a geometric intuition to a lot of the linear algebra operations that are very weird untill you understand at least a little about them like why on earth does the dot product have anything to do with similatity or why the cross product it's that vector or how a matrix is a guide for a transformation ecc...
@francescosorce5189
@francescosorce5189 6 жыл бұрын
also, nice video as always, I still didn't know how to read files and finally I do, I thought it was going to be something really hard but in the end it wasn't, thanks.
@barmetler
@barmetler 5 жыл бұрын
Ah, I see you're a man of culture as well.
@spetsnatzlegion3366
@spetsnatzlegion3366 5 жыл бұрын
At this point, combined with school physics work I’m diving into such a massive maths sinkhole that I’m considering watching through the entire video list of all those good maths channels to learn all of maths
@luisendymion9080
@luisendymion9080 4 жыл бұрын
Yeah, 3blue1brown is an amazing channel. The animated graphics used to make the concepts more accessible are mind-blowing.
@Cypekeh
@Cypekeh 3 жыл бұрын
Khan Academy course on linear algebra is good too. (in my opinion easier to understand than 3b1b)
@MJLangdon175
@MJLangdon175 4 жыл бұрын
Finding out that the Blender software exist is a massive relieve! I was getting worried that I would have to work the coordinates out for every shape :) Going from learning C++ to actually using it to make something animate across the screen is making everything that I have learnt so far, click into place. It has given me an even bigger list of things to learn as well. Thanks Javid.
@jockinafrock
@jockinafrock 6 жыл бұрын
Stunning, Javidx9, simply stunning. I'm in awe of your way of explaining this. Can't wait until I have 6 free hours to transcribe this code into VS and watch it come together. Much appreciated.
@javidx9
@javidx9 6 жыл бұрын
lol thanks jockinafrock, 6 hours? I wish I had a free 6 hours to just code :D
@Mrjcowman
@Mrjcowman 6 жыл бұрын
I sat here beating my head against a wall for 2 hours because my triangle culling code wasn't working. The triangles would pop in and out of existence seemingly at random! Turns out I was summing the x component of vectors in my vector subtraction method instead of subtracting them. In the interim, though, I improved a lot of risky code and even wrote a quick surface normal visualization tool, so all in all I think it was time well wasted! Thank you for these guides and everything in your channel. I truly feel like I'm learning so much more about programming in c++ than I ever have from a book or typical guide.
@javidx9
@javidx9 6 жыл бұрын
Hey Jacob, thanks man, sounds like you fixed a bug you'll never make again :D
@gregblastfpv3623
@gregblastfpv3623 6 жыл бұрын
23:14 Minecraft players unsubscribed.
@javidx9
@javidx9 6 жыл бұрын
No big loss... XD
@ed_iz_ed
@ed_iz_ed 6 жыл бұрын
Hahahh
@ehkpnwvthuvibaoibx
@ehkpnwvthuvibaoibx 5 жыл бұрын
you wouldn't say that if you play minecraft the way I do!
@TheBypasser
@TheBypasser 5 жыл бұрын
They are too stupid to deal with anything tougher than their cubed crap anyway. Sh, I still have no idea why, should you want to _build_ something, wouldn't you simply choose some CAD of your choice over this crap...
@Malkovith2
@Malkovith2 5 жыл бұрын
Gamers must rise up!
@dynamagon
@dynamagon 2 жыл бұрын
Progress going well so far in rewriting your 3D application in C with standard libraries! Great videos by the way. You are very well mannered, entertaining, and most importantly, an extremely good teacher.
@robertboran6234
@robertboran6234 6 жыл бұрын
The more closer we get into the nature of reality the math becomes more alien and beautiful.Nice explanation as always !
@javidx9
@javidx9 6 жыл бұрын
Thanks Robert - another original lone coder! Quite a few in this thread now
@keithrobinson2016
@keithrobinson2016 2 жыл бұрын
Without a doubt, the best coding channel on KZbin, in terms of topics, content and presentation.
@gregorymeadows3572
@gregorymeadows3572 6 жыл бұрын
I quite like this Developer version of Russel Crowe
@javidx9
@javidx9 6 жыл бұрын
Are you not entertained?? XD
@johnhammer8668
@johnhammer8668 4 жыл бұрын
Indeed. Captain of Master and Commander: The far side of Z-axis .
@luisendymion9080
@luisendymion9080 4 жыл бұрын
OMG hahahah. Made my day ;)
@voytechj
@voytechj 6 жыл бұрын
You don't need normals for culling triangles. It can be done in window coordinates after projection. There is formula for calculating signed area of a triangle: A = 1/2 * (x1*y2 - x2*y1 + x2*y3 - x3*y2 + x3*y1 - x1*y3) You need only a sign: front_ccw = ((xw_1*yw_2 - xw_2*yw_1 + xw_2*yw_3 - xw_3*yw_2 + xw_3*yw_1 - xw_1*yw_3) > 0) ? true : false; // xw, yw - points in window space for 3 vectors [v1,v2,v3], front_ccw face is visible when normal vector is pointing towards camera and vertex are in Counter-Clock-Wise (CCW) direction. CCW order determines direction of the normal as well: normal = cross( v2 - v1, v3 - v1 ) ps. if area is 0, then triangle is thin and you decide how to draw it. For less than 0, back of a triangle can be drawn with darker colour or rejected.
@javidx9
@javidx9 6 жыл бұрын
Hi voytechj, no I dont need normals for culling, but I do need normals, and since I generate them anyway I just kept it simple.
@voytechj
@voytechj 6 жыл бұрын
Hi, that "Shoelace formula" came from glspec33.core.pdf (chapter 3.6.1 Basic Polygon Rasterization, page 116). Its good to know that clipping in OpenGL and graphics cards happen in rasterization step. It always works and don't depends on how crazy camera and projection transformation you have :-). Of course in own renderer everything is permitted. In addition I want to say, that lots of things depends on what kind of normals you calculate: per-vertex or per-triangle. Per-vertex usually are for lighting purposes and they don't have to be perpendicular to a triangle (its a useful feature for grass, tree branch lightning, smooth shading, etc.). For that reason visibility can't rely on that kind of normals. Per-triangle are perpendicular but they don't fit well in VertexBuffer that can be sent to GPU (if used of course). You have to store them 3 times with each vertex in triangle or probably calculate in geometry shader. Sometimes this can be a problem. Don't remember if You mention that but normals have an extra feature: Ax + By + Cz + D = 0 vector [A,B,C] from that plane equation is a normal to that plane. I used them while ago for simple collision detection for convex objects. Just solve Ax+By+Cz+D>0 for checking if a point (x,y,z) is in front of a plane. Ps. I can not wait for next episode about camera projections. So far great series
@AinurEru
@AinurEru 5 жыл бұрын
hmm... Wouldn't doing it before projection save on the matrix multiplication on all verticies of all back-facing triangles? Sounds like doing it after projection would be more expensive - especially considering that he needs the normals anyway...
@andrewdunbar828
@andrewdunbar828 5 жыл бұрын
This is how I did it on my Speccie in the early '80s in BASIC. I knew what normals were but I never grokked vectors, which seemed too obvious to require their own concept, and matrices still baffle me with how they make sin and cos vanish. Hidden surface removal was as far as I got. I wanted hidden line removal but that became pointless once filled polys and then texture mapping came along. I stuck with convex models because I foresaw the problems with z-sorting to render from back to front, but I couldn't foresee the solution. I always hated breaking everything down into triangles. Too much practical, not enough interesting, and for hidden line removal you have to distinguish explicit and implicit edges. But without them you have to deal with concave polys. Don't mess with raw concave polys (-:
@nasserghoseiri4934
@nasserghoseiri4934 4 жыл бұрын
Frankly, this tutorial series contain as much information as a university semester. Congratulations, and thanks for providing this tutorial...
@sorceryengine
@sorceryengine 2 жыл бұрын
not rly, math semester material at uni makes you wanna quit at finals sometimes, it pays off later though
@truesoundwave
@truesoundwave 3 жыл бұрын
You are a blessing to a student studying graphics. This has taught me so much.
@ameerabdallah5429
@ameerabdallah5429 4 жыл бұрын
This is great, I absolutely love this series because as soon as you mention something about some method that we have used in my linear algebra class, it's like it just clicks how useful it was that I learned it. I am completely astonished by how many problems are able to be solved by simply using the cross product of dot products.
@mojoofc9528
@mojoofc9528 5 жыл бұрын
It’s normally normal to normalize the normal! Wish we were friends, again thank you for this, it really helps me grasp cpp more then just plain generic tutorials, just mwah
@XoIoRouge
@XoIoRouge Жыл бұрын
Thank you for EXPLAINING THE MATH! And actually walking through it, explaining it, and telling us why and how it works. I've been jumping through hoops in KZbin as people kept sayin WHAT to do, then when it didn't work, I didn't know WHY it didn't work.
@johnhammer8668
@johnhammer8668 4 жыл бұрын
Huh. This is what the creators of the universe must have felt like in their early days. Thanks Javid.
@rhydermike
@rhydermike 4 жыл бұрын
This series is great. I'd had a curiosity about this type of engine ever since I first played Elite on the BBC Micro in 1985. Thanks for making it.
@Rearendoftrain
@Rearendoftrain 4 жыл бұрын
I’m a software engineer who works in health insurance, and I’m mostly baffled at the complexity of 3D calculations. Maybe it’s because I was bad at trigonometry.
@javidx9
@javidx9 4 жыл бұрын
Thats good honest work though Brian, the complexity of insurance baffles me 😁
@efraimibasco9162
@efraimibasco9162 Жыл бұрын
​@javidx9 eqww🎉 we w 🎉w 😢w😢😢😢😢😢🎉🎉🎉🎉😢😢😢🎉🎉🎉w🎉e and 🎉🎉ww🎉😢🎉w😢
@multitimmytiger2
@multitimmytiger2 5 жыл бұрын
I've successfully made a rotating cow! This is awesome. Didn't even know I was interested in this stuff - and now I'm hooked! Thanks a lot for this video! :)
@00mongoose
@00mongoose 5 жыл бұрын
One of the best tutorials I've ever seen. Excellent balance between, detail, simplicity and clarity.
@laurin__
@laurin__ 11 ай бұрын
0:00 - 17:15 Only draw triangles facing the camera 17:15 - 22:53 Simulate unidirectional light 22:53 - 32:30 Load mesh from .obj file 32:30 - 39:39 Draw closer triangles on top of further
@BenJones-g3p
@BenJones-g3p Жыл бұрын
Just started learning C++ and this has blown my mind. You are a wizard.
@joshlovesfood
@joshlovesfood 3 жыл бұрын
This series is golden, and so is the content of this video
@javidx9
@javidx9 3 жыл бұрын
I'm pleased you're enjoying it! If you fancy giving it a go, the console game engine has been replaced with the olcPixelGameEngine now, but they are 99% compatible so you can still follow along.
@joshlovesfood
@joshlovesfood 3 жыл бұрын
@@javidx9 I will be giving this a go, but I’ll start with Tetris and some of the easier games you have videos for. Thank you for sharing your knowledge, skills, and experience!
@joshlovesfood
@joshlovesfood 3 жыл бұрын
@@javidx9 I am learning C++ first, then I am definitely going to watch these. I'm a hobby programmer in C# using Unity, I'd like to get into making my own game engines with C++ for retro game creation
@davidsullivan7455
@davidsullivan7455 6 жыл бұрын
Excellent! I ported an old, OLD 3d engine (Michael Abrash's early Doom stuff) to c# . The engine couldn't deal with complex shapes. Your z-sorting was a great help!
@javidx9
@javidx9 6 жыл бұрын
Thanks David, my Z-sorting only works well for small polygons though, so be careful if using large ones.
@davidsullivan7455
@davidsullivan7455 6 жыл бұрын
@@javidx9 not a problem. When I say complex, that engine couldn't handle your space fighter...
@alangrant5278
@alangrant5278 3 жыл бұрын
Oh man that rotating cube takes me back to the first program I made on my Sinclair spectrum back in 1982 (ish).
@laurin__
@laurin__ 11 ай бұрын
Javid is like a father figure introducing me to complex things in a fun way
@clonkex
@clonkex 5 жыл бұрын
Best explanation of dot product I've ever seen! I finally understand it intuitively!
@javidx9
@javidx9 5 жыл бұрын
Thanks David!
@PCarew
@PCarew 6 жыл бұрын
I notice that at 7:04 through 9:0, you calculate the normal prior to projection, and then spend considerable effort over the next 8 minutes to resolve the issue of projection anomalies. I simply calculated the normal ***after*** applying the projection matrix. Problem solved, no further action/calculation/ray determination was necessary. The correct faces were removed appropriately.
@javidx9
@javidx9 6 жыл бұрын
Correct Paul, but I go on to need my normals prior to projection for the following videos. You can also transform your normals with a normal matrix (which I dont do either) rather than calculate them from your projected geometry, if you have them to begin with.
@evanotoole787
@evanotoole787 2 жыл бұрын
I always love it when I give myself challenges such as the "Try to Convert the Old ConsoleGameEngine Code Into PixelGameEngine Code". The GetColor(float lum) function is kicking my ass lmao
@javidx9
@javidx9 2 жыл бұрын
Heh. When you get that one, you'll kick yourself 😉
@kazenohito7641
@kazenohito7641 5 жыл бұрын
HOLY CRAP! BLENDER IS AMAZING!
@RatoCavernaBR
@RatoCavernaBR 6 жыл бұрын
Where are the mecha unicorns?
@thomashenrydavies
@thomashenrydavies 2 жыл бұрын
Just brilliant. You are to coding what Paul Sellers is to woodworking. Incredibly high quality stuff.
@jponter
@jponter 6 жыл бұрын
these videos are fun to watch, bit of a nostalgia trip for me - my last 3d coding was when I was in my mid 20's (almost 20 years ago!) :) - Thanks for making them, your explanations are extremely clear and no doubt will help lots of people get their head around the subject!
@javidx9
@javidx9 6 жыл бұрын
nostalgia? This is cutting edge stuff isn't it?? :D Thanks jponter!
@wyrdaen
@wyrdaen 6 жыл бұрын
I don't know why, but you have used the "right-handed" definition of the cross product, but you drew all your coordinate systems as a left-handed ones... A part from this minor feature I really enjoy your videos, keep up the good work!
@javidx9
@javidx9 6 жыл бұрын
Hey thanks luigi! You know, I never considered that - and it goes someway to explaining a few things too, lol :D
@NavyCuda
@NavyCuda Жыл бұрын
Oh man what a headache! I started part one and got a bit into part 2 on my pc. I prefer my mac. So after hours of screwing around to figure out how to get SDL to work, I started coding along again. However my cube wouldn't form up right. Just figured it out... on the windows machine, I didn't have to initialize the camera with { 0,0,0 } but I did on my mac!
@muckymcfly
@muckymcfly 6 жыл бұрын
You deserve to be a much bigger channel, keep up the amazing work.
@javidx9
@javidx9 6 жыл бұрын
Hey thanks MuckyMcFly! So long as people find the content useful - I'm happy.
@jean-naymar602
@jean-naymar602 6 жыл бұрын
I just watched ep1 and was asking myself when ep2 would come. I hit refresh and *boom* there it was. Also it was a long time since I last commented but I was focusing on my studies lately so I didn't really have time to watch all of your videos, but now that i'm on holydays, i'll take care of changing that
@jean-naymar602
@jean-naymar602 6 жыл бұрын
I realised I keep commenting like this channel was still no more than a few hundred subs, but you have multiple thousands now. Congrats ! (See, I told you you'd have a lot more subs)
@javidx9
@javidx9 6 жыл бұрын
Hi Jean-Nay, long time! Studies are more important than these videos, but its nice to hear from you again. One of the first Lone Coders!
@jean-naymar602
@jean-naymar602 6 жыл бұрын
*/me blushes*
@jean-naymar602
@jean-naymar602 6 жыл бұрын
Also I must say I really enjoy videos going into details like that (also like the 1st episode). I really think that deriving the formulas and what not is what makes you have a strong understanding of what you're doing (with practice of course), even if the math seems harsh at first. Just to give my opinion
@dheerparekh1305
@dheerparekh1305 7 ай бұрын
I'm a Btech EnTC student from India who has just completed 1st year of college and am looking forward to creating interesting projects in my 2.5-month summer/internship break I wanted to create a 3D engine as I found it interesting and stumbled upon this series; I have watched only the previous video and this one and had to refer other videos on YT to understand the math better. Would like to thank you for creating this series as I found no other videos on KZbin explaining in such detail how to build a 3D engine and guiding through the process. It would really help if you could provide guidance on how to approach building a 3D engine by suggesting which videos should I watch to get the whole picture like rasterizing the triangles. I would also like to create a drawing program like the game console you are using to draw
@vladimirlazarevic9792
@vladimirlazarevic9792 6 жыл бұрын
Just found your channel today from some guy recommending it in comments. Anyway, I rarely comment but I have to say that your content is amazing, so it's an easy sub from me. Keep up the good work!
@javidx9
@javidx9 6 жыл бұрын
Hey Vladimir, thats really nice of you to say so, so thank you!
@ridespirals
@ridespirals 3 жыл бұрын
That is the best explanation of the dot product I've seen yet. Really helps give you an intuition for what the dot product _means_
@barmetler
@barmetler 5 жыл бұрын
I went from not knowing anything about C++ to at least knowing how to implement simple things, purely because of your videos! :D I knew some java before, that obviously helped. But operator overloading alone is enough to make me like C++ more than Java XD I actually have an addiction to it now
@wWvwvV
@wWvwvV 5 жыл бұрын
I heard "unfortunately" twice till what I've seen so far. Both times meant "and fortunately".
@MakotoIchinose
@MakotoIchinose 5 жыл бұрын
If you're a total newbie to this but opting to use PixelGameEngine instead of the ConsoleGameEngine, simply put this argument in FillTriangle function you called for rastering the triangles: olc::Pixel(dp*255, dp*255, dp*255) As you've might guess, this'll do the shaded coloring job without the console's limitation.
@dynstinn
@dynstinn 11 ай бұрын
when he said especially games made from cubes are boring. it hit me hard cuz we have minecraft. yeah now it is boring but it certainly wasnt back then. great tut btw. helped me a lot.
@Hardwarenerd
@Hardwarenerd 2 жыл бұрын
Okay, the past days I was making a 2d "paint" like application in Java for a university assignment. When I finished the project I was surprised with how much actually Java offers as far as graphics go! (yes you can connect it with OpenGL etc.). But the spark came when I thought "hey how hard could it be to make primitive" first person shouter " type of game. I searched an I knew that unity and blender for models was basically what I would need, but I wanted to furthermore explore how game engines work. So what better start to learn from these videos. Nice understandable math, clean code and pretty good explanation. Time to implement the theory in Java
@Oplaner
@Oplaner 4 жыл бұрын
It was absolutely cool that you had mentioned the way of inputting more complex models into the engine. Thank you.
@saeklin
@saeklin 6 жыл бұрын
Alright, now to simulate protein folding.
@bartek7165
@bartek7165 4 жыл бұрын
Now it got sense ( ͡° ͜ʖ ͡°)
@luisendymion9080
@luisendymion9080 4 жыл бұрын
Nah, the next logical step in complexity would nuclear reactors simulations. I'm sure @javidx9 is already working on it lol
@user-dh8oi2mk4f
@user-dh8oi2mk4f 3 жыл бұрын
@@luisendymion9080 the next step is to simulate an entire universe.
@apostoloskatranitsas6063
@apostoloskatranitsas6063 3 жыл бұрын
@@user-dh8oi2mk4f He already started doing that!
@wojtekburzynski654
@wojtekburzynski654 4 жыл бұрын
25:03 When tutor looks up tutorial. Amazing video as always.
@NeilRoy
@NeilRoy 6 жыл бұрын
Very nicely explained. Took me a long time to understand all this stuff. I'm still having problems loading textured 3D models using modern OpenGL. I have often thought about implementing a classic 3D game, without textures. The type of things we seen before Wolf3D and Doom. If you ever played around with the Virtual Reality studio from a lonnng time ago, you know what I mean. Flat shaded 3D graphics like you have created. Loved them back in the day.
@javidx9
@javidx9 6 жыл бұрын
Thanks Roy - I know the Virtual graphics you are referring too, and those massive headsets XD
@javidx9
@javidx9 6 жыл бұрын
Whoops, Neil, lol, my bad XD
@PhilBoswell
@PhilBoswell 6 жыл бұрын
Nice work, but I have a couple of optimisation points: one very minor, one potentially major but only a vague memory. The first, rather pedantic point, is that if you're simply going to compare the magnitude of two numbers (for the sorting) you don't need to divide both of them by 3 o.O I know that in this case the extra division might not be massively expensive but it all adds up;-) The second is a dim recollection of reading a journal article years (decades) ago describing an algorithm for pre-processing an object made up like yours to sort the facets into the appropriate order so that regardless of orientation the later ones never obscure the earlier ones: it included a procedure for splitting up facets which "cross" each other to eliminate possible intersections. So providing you check the normals for whether the face is actually pointing towards the camera, you never have to sort the faces dynamically, just fire them off in the same order each time. If I knew the name of the algorithm I would give it you, but all I can do is google and hope: possibly someone will recognise my description and find it quicker (or at all ;-)for the edification of the OLC Gang ^_^
@javidx9
@javidx9 6 жыл бұрын
Hi Phil, you're right, and I think the algo you are looking for is Binary Space Partition trees!
@GodofWar1515
@GodofWar1515 6 жыл бұрын
Hey javidx9. Thanks for another great video. I learned a lot about 3d engines and how they work from within the code which is something I have been wondering about for a long time.
@javidx9
@javidx9 6 жыл бұрын
Thanks Lucas, my implementation is one of many ways of doing this
@random_company
@random_company 11 ай бұрын
You definitely deserve a like, bro!
@oscark5127
@oscark5127 5 жыл бұрын
This is the most interesting programming video I've ever watched. Thanks so much for making it!
@bianggulugulu6972
@bianggulugulu6972 5 жыл бұрын
awesome!I am a Chinese student, and I'm so excited to watch this video! Thank u! 谢谢
@andrewkreisher689
@andrewkreisher689 5 ай бұрын
Love this series, reminds me of topics from my computer graphics course in uni and helps me learn c++ at the same time :D
@robertjr.kibble8053
@robertjr.kibble8053 3 жыл бұрын
You literally are just teaching exactly everything I've been trying to figure out for like three years (idk just for fun I'm a CS major and I thought a graphics engine would be a cool project for some reason). This is perfect. I've been looking through math tutorials on linear algebra, coding functions with linear algebra, tutorials like this, and a lot of videos had mistakes and completely through me off course. Your videos show everything, explain everything and it works exactly like it should every single time. Thank you. I'm going to make minecraft 2 now.
@javidx9
@javidx9 3 жыл бұрын
Thanks Robert, I'm pleased you're finding the videos useful!
@pikuma
@pikuma 5 жыл бұрын
"Fill Triangle" is a very interesting problem. It would be nice to go over it sometime.
@pikuma
@pikuma 5 жыл бұрын
...aaaaaand I just noticed you went over it in a later video. Thanks. :)
@cblbopotka3915
@cblbopotka3915 5 жыл бұрын
Such cumbersome code. You can make your life easier after defining simple operations under vectors and triangles.
@goga.games18
@goga.games18 2 жыл бұрын
"lets face it games made with cubes are incredibly boring" Minecraft sweating intensifies
@sketchwarehelper2721
@sketchwarehelper2721 Жыл бұрын
23:18 [sobs in minecraft]*
@aodfr
@aodfr 6 жыл бұрын
I didn't know you could do a painter algorithm sort like that. That pretty cool. I would suggest implementing a depth buffer because it would make sorting of triangles easier and its cheap and all of the glitches would disappear.
@javidx9
@javidx9 6 жыл бұрын
You can get away with it "to a certain extent", and providing your polygons are small enough. You'll see I address the issues in a later part of this series.
@aodfr
@aodfr 6 жыл бұрын
@@javidx9 Sorry for the late reply. Yes I saw it. It was quite informative. Thanks for the series keep up the good work.
@TastyPurpleGum
@TastyPurpleGum 3 жыл бұрын
Lol @ 2:13 that minecraft roast! Great video, I appreciated every second of it :)
@ZeroPlayerGame
@ZeroPlayerGame 4 жыл бұрын
Note: the calculation you do for normals can be reasonably simplified by calculating a normal in screen-space, and looking at its Z component. Projective geometry is nice like that. EDIT: this only makes limited sense mathematically, for example, if you'd need the non-normalized normal, it wouldn't really work. But it's apt enough for this case; after all, the Z direction in screen space is exactly line of sight.
@GeorgesChannel
@GeorgesChannel 5 жыл бұрын
I always wanted to program my own graphics engine in BASIC on a commodore plus/4, my first computer. I realized my little dream now, because of your great programming series. I really enjoy them. Thank you so much!
@immortalsofar5314
@immortalsofar5314 3 жыл бұрын
I used assembler on the C64 but used a completely different approach to wring every last CPU cycle and memory location out of it.
@stutteringcris468
@stutteringcris468 4 жыл бұрын
It's like watching Picasso paint! I'm in awe! :O
@compaqdisc6362
@compaqdisc6362 6 жыл бұрын
If you are having issues with different triangles being rendered on different launches, then initialize vCamera to { 0.0f, 0.0f, 0.0f }
@pilotandy_com
@pilotandy_com 3 жыл бұрын
I'm just going through this now. Thank you! it makes my normal culling work great!
@crossity
@crossity 2 жыл бұрын
I think it is one of the best 3D game engine creating video
@accuwau
@accuwau 2 жыл бұрын
paused this to just start getting good at math on some weird website thank you for finally giving me a reason
@Deadener
@Deadener 3 жыл бұрын
"We'll have to use a hack to render our triangles without a depth buffer" [The PS1] has entered the chat
@molnez
@molnez 2 жыл бұрын
Programming around mid-day?! Clearly you are not a real programmer, but an imposter. No, but in all seriousness this is really great. Learning a lot, thank you!
@daggerone3370
@daggerone3370 2 жыл бұрын
If you go to the line were we normalize the normal, and divide all axis by one, the result is going to be the same if we divide by the variable L above, but this works only when the camera is static.
@crusaderanimation6967
@crusaderanimation6967 3 жыл бұрын
23:15 ANGRY MINECRAFT PLAYERS NOISES XD
@bunabyt3
@bunabyt3 3 жыл бұрын
These videos are so relaxing. I love following along with the explanations, it's not so slow that I get bored, and it isn't so fast I can't follow along. Great videos!
@jonslaco9020
@jonslaco9020 6 жыл бұрын
Great stuff, I found this video when trying to find how to fill triangles, the only part you didn't write from scratch!!
@javidx9
@javidx9 6 жыл бұрын
Hi Jon, thanks buddy - I do talk about filling triangles from scratch in a later part of this series when it comes to texturing the triangles.
@Adrischa
@Adrischa 3 жыл бұрын
@jon slaco did you ever find a good way to fill out those triangles?
@kaylenbates5010
@kaylenbates5010 6 жыл бұрын
"Games made from cubes are incredibly boring..." Are you jabbing at Minecraft? Lol
@javidx9
@javidx9 6 жыл бұрын
Meeeeee?
@sidtheloser
@sidtheloser 3 жыл бұрын
@@javidx9 😂😂 yesssss yoooooou 😂😂
@laenprogrammation
@laenprogrammation 4 жыл бұрын
6:41 z component should be the other side. because if you make your cross product in these coordinates, XxY will be on the -z axis
@SilverHaze5X
@SilverHaze5X 5 жыл бұрын
Sir, you deserve more suscribers, your content is amazing! Here, have 1 more.
@charactername263
@charactername263 4 жыл бұрын
You don't need to view the normals in blender, you can just enable backface culling in the viewport options, clockwise is the industry standard so it'll match.
@JacobMoen
@JacobMoen 4 жыл бұрын
"It's normally normal to normalize a normal" - well done, mate :)
@drjubierre
@drjubierre 4 жыл бұрын
Really amazing series, thanks for creating such an interesting content. By the way, I was also surprised that you used the left-hand rule for vector direction when explaining the cross-product!!
@chillindog5059
@chillindog5059 Жыл бұрын
26:17 I can previwe the file in visualstudio but when i run the code nothign shows up? Am I supposed to add the file somewhere in the file structure of the project? Please help
@DiamondANDI
@DiamondANDI 4 жыл бұрын
2:00 The first 2 arrows should be perpendicular to the line representing the bottom of the right face of the cube
@aptech2933
@aptech2933 6 жыл бұрын
Reminds me of a documentary I saw about the guys who made the video game elite in 1984 I think the first true 3D graphics game.
@javidx9
@javidx9 6 жыл бұрын
It definitely has an elite vibe! One of the first games I ever played :D
@aptech2933
@aptech2933 6 жыл бұрын
Did you see the short documentary on the making of the game? they programmed the whole thing in assembly. :D
@aptech2933
@aptech2933 6 жыл бұрын
kzbin.info/www/bejne/faG6oHlrqruamKM
@gabrielsilverio1192
@gabrielsilverio1192 6 жыл бұрын
I hadn't seen this documentary, but Elite was the first thing that crossed my mind also. Thank you for sharing!
@Ruxify
@Ruxify 6 жыл бұрын
I seem to have a good understanding of the 3D rasterization pipeline and have written a few software renderers with lighting, shadow mapping, and texturing... but triangle clipping is something I can't seem to understand/haven't figured out how to do properly yet. Can't wait for next video!
@javidx9
@javidx9 6 жыл бұрын
lol Ruxify, clipping is a little confusing, hopefully I can demonstrate an algorithm that clears it up...
@Ruxify
@Ruxify 6 жыл бұрын
Well I'll be damned, I think I just figured it out; and of course it would be insanely simple.
@FUNktshnl
@FUNktshnl 3 жыл бұрын
Typically, coordinate systems are defined the other way around, so that if x is to the right and y is up, the z-axis is towards you (out of the screen, not further in). Nevertheless this is just a minor detail - thank you very much for this 3d series, the insight is mind-blowing!
@immortalsofar5314
@immortalsofar5314 3 жыл бұрын
It's funny. My 8 bit version didn't do hidden line removal but if it had, my representation of points as angles from an origin of a given radius would have meant that finding the normal would have been very efficient combining 8 bit angles and then adding 64 to the result. By doing most of my calculations in angles and then fixing them up at the end, it certainly made the math easier! Of course, repeated addition and subtraction is the least efficient form of multiplication/division _unless_ you want to do something (eg plot a pixel) at every step. So by keeping angles as angles and scalars as fractions, there was no duplication of overheads.
@immortalsofar5314
@immortalsofar5314 3 жыл бұрын
Thinking about it, it was probably my goal that led to this vector approach. The rolling angles (viewing orientation + container orientation + content orientation...) also helped animate the body I was drawing just by changing a few of the angles within a range. It meant that I could start from a point of friction and work through where everything would be without having to recalculate everything. The results were surprisingly effective - especially when a program bug caused the knee to bend the wrong way. EUUUURGH!!!! Sines were a 16 byte lookup table (8-fold symmetry) and cosines were just flipping bit 6 of my 1/256 angle (a 2 byte instruction at an alternative entry point) so I used those wherever possible. Clipping was simply stopping at the edge at draw time.
@RoddyDev
@RoddyDev 6 жыл бұрын
I don't program on that language at all, but it's gonna be helpful in the day I'll start learning it, thanks for the awesome video!
@javidx9
@javidx9 6 жыл бұрын
Hey thanks Roddy! I try to make my videos "reasonably" language independent, its more about the method than the syntax, so hopefully people can still take ideas from them.
@TheRojo387
@TheRojo387 2 жыл бұрын
Right-handed systems point their normals toward camera from faces whose vertices are listed anticlockwise, of course.
@saltyyolk9934
@saltyyolk9934 6 жыл бұрын
I was thinking for couple of years to make video on this. But you did it.
@nomoturtle1788
@nomoturtle1788 4 жыл бұрын
This is incredible. Thanks so much for sharing, I'm learning a lot by following along. Really interesting.
@javidx9
@javidx9 4 жыл бұрын
Thanks man!
@Cole-ek7fh
@Cole-ek7fh 5 жыл бұрын
27:45 "s off" stands for "smooth shading off". just a guess.
@anandsuralkar2947
@anandsuralkar2947 5 жыл бұрын
I came up with my own algorithm for sorting triangles for depth order never knew that its already there for me
@almicklee
@almicklee 2 жыл бұрын
I’m having trouble viewing model files in the engine. where should my files be saved in order to reference them via string with your function?
@javidx9
@javidx9 2 жыл бұрын
Typically the model file needs to be in the working directory when you launch the executable. In visual studio, this is your project folder by default.
@Uterr
@Uterr 4 жыл бұрын
death buffer, it sounds so cool, i wanna be programmer now!
@NeilRoy
@NeilRoy 4 жыл бұрын
Watching this again two years later... "s off" means "smooth shading off" (en.wikipedia.org/wiki/Wavefront_.obj_file)
@abirneji
@abirneji 5 жыл бұрын
I spent about 10 minutes tryna figure out why my ship wasn't appearing, turns out it was on the wrong folder
@seditt5146
@seditt5146 3 жыл бұрын
This is why it is always extremely important to double check that a file has been correctly opened every time you attempt to load something from file. It's a simple check but can save one a world of pain.
@MacShrike
@MacShrike 6 жыл бұрын
WOhoo! shwishing through this with you. And yes, I am encapsulated =)) Thanks again.. again
@molnez
@molnez 2 жыл бұрын
23:14 Sick Minecraft burn.
The Math behind (most) 3D games - Perspective Projection
13:20
Brendan Galea
Рет қаралды 428 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Line Of Sight or Shadow Casting in 2D
50:23
javidx9
Рет қаралды 144 М.
Programming Pseudo 3D Planes aka MODE7 (C++)
27:16
javidx9
Рет қаралды 105 М.
Coding Challenge #112: 3D Rendering with Rotation and Projection
33:13
The Coding Train
Рет қаралды 208 М.
Let's Program Doom - Part 1
25:13
3DSage
Рет қаралды 459 М.
9 Extremely Satisfying Ball Machines
16:06
Engineezy
Рет қаралды 7 М.
Let's code 3D Engine in Python from Scratch
14:55
Coder Space
Рет қаралды 404 М.
Procedural Generation: Programming The Universe
41:57
javidx9
Рет қаралды 207 М.
olcPixelGameEngine
20:17
javidx9
Рет қаралды 164 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН