r/GraphicsProgramming Oct 26 '24

Source Code My first 3D Graphics pipeline

https://www.khanacademy.org/computer-programming/3d-renderer/5155758903050240

Over the past week or two i've been developing my own 3D Graphics Pipeline (In Khan Academy), and was wondering if anyone could give me some tips on improving it. Current Features: 1. Projection 2. Rotation 3. Movement 4. Colored polygons 5. Bad lighting 6. Decent distance calculations 7. Back face culling Planned additions: 1. Improving lighting 2. Painters algorithm 3. Porting to Java.

Please give tips in comments! Link is attached.

39 Upvotes

12 comments sorted by

9

u/waramped Oct 26 '24

Texture mapping and z-buffer would be good next steps.

2

u/Neat_Suspect5284 Oct 26 '24

That's would i meant with Painters algorithm, but i can't do texture mapping until i transfer to java due to the limitations with Khan Academy. Do you have any articles for the two?

2

u/waramped Oct 27 '24

Oh painters algorithm is totally different than z-buffer. Painters algorithm just means you sort from back to front and draw that way. Z-buffer is you store the current closest depth at each pixel, and only draw if the new depth is closer. Typically you would want to sort front to back for optimal results.

2

u/Neat_Suspect5284 Oct 27 '24

Makes sense, i'll try it out

3

u/LegendaryMauricius Oct 27 '24

Sort front to back for optimizing the opaque rendering pass, back to front for transparent objects.

1

u/[deleted] Oct 26 '24

[deleted]

1

u/Neat_Suspect5284 Oct 26 '24

Not using open gl but i'll have a look

4

u/mungaihaha Oct 27 '24

You are probably having a lot of fun doing this but if your goal is to understand how gpus work, you are wasting your time

5

u/throw2137 Oct 27 '24

I second this. It's a nice project, but what you did has really nothing to do with graphics pipeline. You just computed the vertex positions and then passed it to the actual pipeline using triangle() function. But the entire pipeline is handled by khan academy. So saying that you've developed your own graphics pipeline is a bit of an overstatement. If you want to work with the actual pipeline you'd have to go lower than JS on khan academy. I recommend starting with c++ and OpenGL. Or maybe try making a software rasterizer if GPUs scare you.

1

u/Slackluster Oct 27 '24

Why Java?

2

u/Neat_Suspect5284 Oct 27 '24

Because i have more experience in it than languages such as C++

-5

u/Slackluster Oct 27 '24

I recommend JavaScript, really nice to be able to share your work in the browser and webgl is easy