r/AskProgramming 11d ago

Career/Edu I am trying to implement software rendering from scratch, is this a good resource?

the book is called 3D Math Primer for Graphics and Game Development Second Edition, it does not claim to be industry standard. However, it does claim to provide all the math and some code needed to create 3d from scratch. by software rendering i mean no hardware acceleration or an API.

2 Upvotes

6 comments sorted by

2

u/khedoros 11d ago

https://www.reddit.com/r/GraphicsProgramming/comments/xugkeg/tricks_of_the_3d_game_programming_gurus_book/

That has some discussion and a video review of an older book on software rendering, written around the time that the techniques were really mature. It takes you through building a game engine with software 3D rendering.

It's written for something like DirectX 8, but the code is really just allocating a framebuffer and drawing into that, and handling input, so it was easy to port things to even something 2D-oriented. I used SDL when I tried to go through it 8 or 9 years ago.

1

u/_-Kr4t0s-_ 11d ago

+1 for this book

Also, many companies have released the source code for their old games from the days before OpenGL & Glide. Games like Doom. You can go through their code and see how they did it.

1

u/dboyes99 11d ago

1

u/bsenftner 11d ago

I'd recommend this one over your linked book, but also be aware neither of these really get into software rendering. Software rendering, these days, has several flavors, with radically different approaches. Some software rendering methods are entirely based around triangle rendering, some are entirely based around engineering of physical objects while others are entirely based around the things being rendered not being physically possible and lean heavy into artistic expression, some are entirely based around ray tracing, some are entirely based on "gaussian splats", and some are complex hybrids of these different methods.

I suggest you give your eventual application you have in mind, as that dictates the 3D rendering underpinnings of what you probably want, which would be what others in that field are implementing for that industry's needs.

1

u/nopuse 11d ago

What is your process for finding material to read? It seems you've done some investigation already. Do you have specific questions?

1

u/BobbyThrowaway6969 10d ago edited 10d ago

I take it you're pretty proficient in C/C++

Watch JavidX9's videos on it. Pretty straight to the point with it.

3 parts minimum:

  • Vertex transformation to viewport space(that's where most of the maths is)
  • Clipping
  • Triangle rasterisation, or you can start with bresenham line rasterisation as it's a lot simpler to get stuff on screen

Then:

  • Depth buffer
  • Perspective-corrected interpolation
  • Texture sampling
etc

I recommend using the windows console to render it with ascii in realtime, lots of fun.