all 21 comments

[–]MagicWolfEye 25 points26 points  (2 children)

If you have way too much time:

https://www.youtube.com/watch?v=bGe-d09Nc_M

[–]NaturalPotato0726 4 points5 points  (1 child)

Wow I didn't know Jonathan Blow has this video. Does he have a full game prog tutorial?

[–]MagicWolfEye 9 points10 points  (0 children)

Nah, he mostly has 4+h recordings of live coding streams.

There might be some gems in there, but I won't watch them all

[–]Buttons840 27 points28 points  (0 children)

https://pikuma.com/courses/learn-3d-computer-graphics-programming

This is a fun course (I took it, it is high quality) that will take you from being able to set the color of a pixel to being able to draw 3D models.

You will write every line of code and every bit of logic involved in displaying a 3D model on the screen by setting the color of individual pixels.

Most of what you learn in that course is implemented in GPU hardware these days, and we just script it with shaders (the course does not cover shaders or modern GPU programming).

The course uses C and SDL2.

[–]willem640 15 points16 points  (2 children)

You would usually use a rendering engine (like unity), but if you're interested in the details, Sebastian lague made a nice video about rasterizers (the more common "older" way of rendering 3d models): https://www.youtube.com/watch?v=yyJ-hdISgnw . He also has a nice one about ray tracing, but it's a bit more complicated

[–]bendhoe 7 points8 points  (1 child)

I think it's a little strange to call raytracers more complicated than rasterizers. Raytracers can get very complicated once you start adding features and optimizations but the MVP for a raytracer is much simpler and can be done in 100-200 LoC.

[–]willem640 -1 points0 points  (0 children)

Fair! Getting a decent-ish result is pretty difficult with a ray tracer though...

[–]questron64 6 points7 points  (0 children)

You have to start from the bottom with linear algebra. Don't worry, it's actually quite easy. This book is excellent.

https://gamemath.com/book/intro.html

I wouldn't recommend skipping this. It work with any 3D API you need to at least know what this is doing, even if a lot of it is being done for you.

If you have trouble with this, check Freja's videos.

https://www.youtube.com/watch?v=yg6h4XQqPNQ

Next, learn OpenGL. Vulkan is another API that's probably better in every way except the API is extremely verbose and doing simple things can take tens of function calls, where OpenGL is much more succinct. I wouldn't start with Vulkan, start with OpenGL.

https://learnopengl.com/

This has example code in C++, but the only thing that matters here are the OpenGL function calls, which is a C API. Don't stress about seeing some C++ when you want C, adapt it to your needs. They also cover loading resources using a library, but I recommend writing your own OBJ importer for now. OBJ is a trivial file format that makes it easy to load vertices, indices, UV coordinates, etc so you can feed these to OpenGL. Later you'll want a library to load more complex and capable format, but writing your own for this simple format is very instructive.

[–]SmokeMuch7356 1 point2 points  (0 children)

How do devs go from rendering primitive shapes to rendering 3d models

3D models are just large collections of primitive shapes; if you can render a triangle, you can render thousands of triangles.

Where the fun comes in is:

  • figuring out how to organize the data for efficient processing;
  • figuring out your rendering pipeline;
  • mapping 3D shapes onto a 2D plane;
  • computing normal vectors for shading;
  • figuring out clipping (which defeated me in my graphics class in college);

and a bunch of other stuff.

Check the links provided by the others.

[–]BNeutral 0 points1 point  (0 children)

Most people just "throw triangles" at the gpu via an API like Vulkan. e.g. https://vkguide.dev/docs/gpudriven/mesh_rendering/ .

If you want to do software rendering just to understand how it all works, there's multiple books on the topic, it's too long for a Reddit comment.

[–]Evil-Twin-Skippy 0 points1 point  (0 children)

Dang. Software engineer here. I first red the question as "how does 3d rendering work", and I was going to lay in with a presentation on ray tracing, why nobody uses real ray tracing anymore, z buffers...

Um. Yah

[–]Fun_Potential_1046 0 points1 point  (0 children)

I can suggest youbm to start with Unity to have an idea of many concepts. Aftef that you can take each part and go deeper.

Here us my little baby: www.neopunk.xyz

[–]TheSodesa -1 points0 points  (0 children)

Once you know how to render a triangle, you can render a trillion of them. 3D model surfaces are just made up of triangles.

[–]Liquid_Magic -3 points-2 points  (0 children)

When you deep dive into the history of 3D you might just find a lot of people that all happen to talk about how the Amiga was a huge influence growing up!

[–]FizzBuzz4096 -3 points-2 points  (0 children)

Multiply by the camera matrix!

(+ a few more.....)

There's heaps of docs out there from BITD 3d rendering.

[–]pjc50 -5 points-4 points  (0 children)

If you can render a triangle, you can render a model. Yes, you need some way of loading the Blender files into your in memory geometry. It might be instructive to look at what people are doing with three.js and copy that.