mini3d
The 3D software rendering tutorial does not have any performance optimization, and mainly explains to people how to write a fixed pipeline software renderer. Although the main code is only 700 lines, the sparrow is small and has all the internal organs.
【README in English】
characteristic
- Single file: The source code has only one mini3d.c, and a single file implements everything and is easy to read.
- Independent compilation: No third-party library dependencies, no complex engineering directories.
- Model standard: standard D3D coordinate model, left-handed system plus WORLD / VIEW / PROJECTION three matrix
- Implementing cropping: Simple CVV cropping
- Texture support: maximum support for 1024 x 1024 textures
- Depth cache: Use depth cache to determine the image before and after
- Perspective map: Perspective texture mapping and Perspective color filling
- Edge computing: Accurate polygon edge coverage calculation
- Implementation streamlined: The rendering engine has only 700 rows, the modules are clear, and the backbone is prominent.
- Detailed comments: Detailed comments on the main code
Compilation
- mingw: gcc -O3 mini3d.c -o mini3d.exe -lgdi32
- msvc: cl -O2 -nologo mini3d.c
- Compiled version: https://github.com/skywind3000/mini3d/releases
Demo
Texture fill: RENDER_STATE_TEXTURE
Color filling: RENDER_STATE_COLOR
Wireframe drawing: RENDER_STATE_WIREFRAME
Increase lighting and quadratic linear interpolation (screenshot of the lighting effect added by a friend to Mini3D)
Basic homework
- Add back removal
- Add simple light
- Provide more rendering modes
- Implement texture reading of quadratic linear difference
Advanced homework
- Deduce and prove all geometric knowledge used in the program
- Optimize vertex computing performance
- Optimize draw_scanline performance
- Loading texture from BMP/TGA file
- Load the BSP scenario and implement roaming
Principle explanation
- Wei Yixiao: How do OpenGL and DirectX get pixel locations when only vertices are known?
- Wei Yixiao: How does the computer access the graphics card?
Related projects
- RenderHelp: Another streamlined soft renderer implementation that supports programmable rendering pipelines, see the introduction for details.
Donations are welcome
Your donation is the greatest affirmation of this tutorial. You are welcome to use Alipay to scan the QR code above to make a donation. The donation will be used to improve the tutorial documentation and legends, as well as help me write more interesting tutorials.
Welcome to follow
blog: https://skywind.me/blog
zhihu: https://www.zhihu.com/people/skywind3000