How to make a 3D Renderer [Explained Simply]
Vložit
- čas přidán 11. 09. 2024
- Hey guys, in this video I'm gonna explain simply how to make a 3D renderer/engine in C++ but this can also be applied to Java, Python, JavaScript, Rust or C. After this video you will be able to create a simple 3D projection of a cube and map it into a 2D screen.
This is my first video about computer science in the style of javidx9, The Cherno, Nemean and jdh. I wanted to make an engine, not like Unreal Engine or Unity but a lot simpler. This video uses some cool programming, math, algorithms and data structures
The videos by 3Blue1Brown about linear algebra:
• 3Blue1Brown: Linear Alg
[I'm trying to fit as many keywords as possible in this description, that's why it's so weird]
What you call vertices are usually called edges. They specify the connections between different points, - which are usually called vertices btw :D And a face (in 3D) would be a list of at least 3 vertices. If you want to draw (filled-in) triangles you would list the 3 vertices. (You might already know that by now, so this is just to give some context for your viewers.)
Some funny naming conventions aside I really liked your video though! Wish you the best with your future CZcams content :)
The focal length is optional right?
How can i get the suitable FOV for my frame?
Also i use java language Graphics 2D library
thanks for this comment. I created this channel a while back and kind of abandoned it, hopefully nobody was mislead by my mistakes. Working on next video btw
@@m7trffxx_xx166 DISHONORED PFP FOUND DISHONORED PFP FOUND, AWESOME GAME
@@graverdev Aw man sucks to hear you abandoned it :(
did he say he created a renderer in scratch
Yes you can create a 3d renderer in scratch
I mean, you can
It’s not hard
@@DR_Sam_CZcams do it in a few hours then without tutorials, record it, then post it
@@CardboardRaider Wdym without tutorials, I don’t have the math equations memorized my boy. If you mean video tutorials then, sure, I could do that.
this is amazing
ive always been fascinated by how 3d renderers work, and ive always wanted to be able to build one, but it all seemed so complex. i
ive started studying trigonimetry which has always been my weakest subject, and i must say that noticing some concepts from trigonometry used in this video feels so satisfying. You have really given me a hope that i can attempt thi and possibly get a deeper understanding of renderers. thank you for the simple, intuitive explanation
holy shit it feels nice to see people enjoy this video, thanks!
Calling the focal length the FOV (field of view) is very strange, they are separate things.
true, there is a story behind this but whatever
I also noticed this. Really does need correcting as it was quite wrong.
🤓
@@CoolJosh3kVERY, that's fov/2 and to actually get the wanted effect of fov, you'd need the inverse of tan(fov/2) in the projection matrix.
@@CoolJosh3kwell we know who the autist are😅
Nice topic to start! Awaiting for the next one, too!
Very simple and straight forward. Good job explaining it! Very clear! Thanks for the vid!
thank you!
Very helpful. I was gonna try and make a 3D render in javascript for fun but wasn't sure what concepts I needed to understand. Thanks
Thanks for the kind words! Good luck and I hope you stick around for the future content
did you do it?
Im a sucker for this stuff, I worked it out in my own in visual basic in highschool for fun and this really reminds me of it, so now im gonna try rewritting it in c++ and adding other features like being usable and not wireframe
Thanks so much for this tutorial it was simple and straight forward!it helped me make it work on my arduino display :D
Bro when are you coming back? I just found this channel for something I am working on, but your quality is so nice! Please come back soon!
I have one video partially written, though it is more of an video essay and with an unusual topic. I'll try to incorporate some of my interests to make a channel mostly about technology... without really making a usual tech channel.
Great video. I’m waiting for the next one.
i think i've never subbed to a person this quick. im literaly less than 1 min in 🤣🤣
wow thanks! Will try not to dissapoint you with my future content
"Not very technical* bruh.
But this is very interesting.
Thanks for the eplanation. Is there a repository where anyone can check the code you wrote?
No there isn't and I probably shoul've made one but unfortunetly I lost my hard drive. Next videos will have repos tho
the formula explanation is epic
Thanks you this video is very helpful.
glad you enjoyed it! Good luck with your project
you need to make more stuff, i dont think i was expecting sdl to pull off 3d drawing for some reason lol at least smooth anyways.
Thanks! I will, I'm working on some interesting projects and will be happy to share them. I'm also open to ideas if you have any
Thank you very much, bro!
I think when you said vertexes, I think you you meant indices which describe the draw order, because some sides share the same points and you would end up drawing the same point more than once
You explain gud in ms paint = i like video. simple.
THANK YOU BROOOOOOOO
I think you kinda did the perspective matrix weird it's smaller in front and bigger in the back
This video is great! It explained the 3d concept in a way that i can understand. I've coded this using javascript and the formulas you provided, but i'm encountering a problem. When points goes behind the camera, the 3d points will still be shown on the screen instead of dissapearing behind the camera. The points appear to be mirrored too. Can you help me?
what is the actual difference between weak projection and regular one? i cant find any vid or article with comparison or any explanation which is which
wikipedia for 3D projection has some information about that. "Weak projection" is just a part of a broader term "projection". Also I don't know why it's "weak"
@@graverdev i've read Wikipedia article but it doesn't really expain whats the difference. I mean, every 3d projection application uses weak projection, right? So what could regular even do? Is it the one with projection matrices?
Amazing🎉
what's the name of the second background song? the one after doom's
"Lena Raine - Otherside (Lofi Remix)" by Speck
i get werid clipping when a block is behind the camera
i was hoping to see an explanation on how to not draw whats far in the same spot as what's near after drawing what's near
You're gonna need a depth sorting algorithm for that
Wow 😍
nice
it starts glitching when objects go behind camera, what do I do?
i wonder why you didn't do any next videos
Hi
Mine just shows a black screen and idk what i did wrong since i copied everytinh exaclty as you showed :(
Hi! Hit me up on discord (@graverman), will try my best to help
can you design the graphics card for this too
Actually a really awesome video and it helped me a lot, however the window was rendering solid black and yeah idk what's really going on. I tried printing the errors to console and it just says "Out of Memory". Any idea why?
perhaps u had a memory leak somewhere
great content!
Thanks!
you deserve more subs@@graverdev
@@TacitMarmot27121yt thank you! I have to finally make another video, I have a bunch of cool ideas so I hope everyone will enjoy them
i bet i will because this video was interesting and very helpful@@graverdev
:3
can you give us the link to your scratch project.
Let me clarify, is a renderer just a program projecting 3D object to the 2D screen?
Rendering in general refers to generating an image of a 2D or 3D object. This particular technique I used is called projection and it projects, but there are other ways to do that.
Is there a way to add textures?
not that I am aware of, if you want to make a 3D engine - like a real one - I suggest learning OpenGL
@@graverdev k thx mate ill look into that :)
You can do a lot with SDL and there are plenty of tutorials. However, you’ll eventually want to get the real work happening on the GPU.
thx
Is there anywhere the source code for this project?
unfortunately I lost access to the machine I had this saved on :(
But why and how is PX being divided by FOV when we get projected X?
By using concept of similar triangles. Both triangles make same angle.
3:22 ah yes, z sim θ
how exactly is this 'rendering" ? it's more like a bunch of lines
do you know what rendering means
How to check if points is invisible ( covered by faces)?
this is a very primitive method mainly for learning, I don’t think anyone uses it in real world. I will try to look for something like this, but if you plan to do something big, consider using OpenGL or Vulcan if you feel ambitious
Can you please provide the source code
If the image is behind cam it is weirrd
nice video, you had a cold ?
I think it was bad mic, combined with bas boosting and childish voice
Excellent video nonetheless, do you have any content coming up soon ? :)
@@morph_systems thank you! I am working on one video, though it won't be about coding. I plan to mix things up to fit my current interests, which are difficult to explain lmao. Coding videos will come too, if I continue working on what I planned
Can you share the music
Its just a remix of Otherside by Lena Raine.
"explained simply"
add textures in the next video
where code?
figure it out yourself
it's sin(theta), not sim(theta).
shake my grimace😢 1:46 1:46 1:46
Wow very impressive but i code it with ascii
that actually sounds fun, wanna share the code?
F*ck you for saying FOV is focal length and calling lines vertecies but the prespective projection explanation was really nice on point and easy to follow
haha yeah there were some embarrassing mistakes made here, gl;ad you found the video easy to follow though
Can't blame anyone this tutorial is for free.
Where can I copy your c++ code?? Literally useless video imo, learnt nothing
thanks!
you learnt nothing because it isnt possible for you to learn if dont know the math research into the equations he pointed out in the video and you will start to understand everything better
@@Jxhsxn You need to learn how to properly write coherent sentences
@@Krullfath theres nothing wrong with my comment you just need to learn how to learn copying code wont teach you anything.
simple🤣🤣
yeah that’s primary school level math and c++ basics
@@graverdev yes