It takes three weeks for the hand-written CPU raster rendering pipeline to be completed. Today, it is finally completed. There are three major versions, one being vertex change, the vertex of the imported 3DS model is transformed to the world coordinate system, then to the camera coordinate system, and finally to the screen through the projection transformation and the viewport transformation. It seems that the process is clear,In addition, the entire process is actually to set several matrices and set several parameters of the matrix. However, due to lack of mathematical knowledge, this understanding process is not that simple. In the second version, the vertex is interpolated into the outlet box and the texture ing of the line frame. Although it was done quickly, it was later known that the obtained element is incorrect. In the third version, a deep buffer is written to describe zbffer.Algorithm. At the beginning, the linear interpolation depth was corrected. Later, I continued to write texture ing,Lighting, Gourand coloring, Phong shading, has many problems and has to write a small test.ProgramMany triangles are tested. The program basically implements these functions, and does not implement the entire flow. I will add more in the future!
I have gained a lot of knowledge, mathematics, graphics, and some testing methods and skills: I have used a lot of macro switches in the program, A lot of data is printed for easy comparison, and a small triangle is used to check whether the calculation is correct. The algorithm should be less efficient, and there are also many problems in the design when gourand and Phong are added later.CodeToo large, many of which are rewritten, but basically satisfies the principle of separating resources from object instances. The entire framework structure is clear and solves the memory problem.
In the past, I also wrote a game demo that is too small. I don't have to worry about how to raster it, give vertices, normal, map coordinates, and color, fixed vertex rendering pixel rendering channels are all made. However, if you want to write good results, it will be difficult to use a programmable rendering channel. Many principles do not understand how to write good results. It is estimated that we will be engaged in graphics work in the future. As a qualified graphics programmer, we should clarify the Internal principles of graphics, there will always be benefits for the future study of new technologies and good results.
There are not many algorithm principles in computer graphics for the whole program design, and a large number of knowledge systems need to be established.
The following are some simple functions of this project:
Gourand coloring
Texture ing:
Phong Shading:
This is a release version of the program http://files.cnblogs.com/hellohuan/bin.rarcode, there are too many questions, and we need to continue to modify it!