What Is Real-Time Rendering?
The essence of real-time rendering is the real-time calculation and output of graphics data. The most typical source of graph data is vertices. Vertices include position, normal, color, texture coordinates, and vertex weights. In the first generation of rendering technology (before 1987).
Real-time rendering
- In 2002, the performance of the graphics card has been greatly developed. First of all, AGP8X
Real-time rendering mesh rendering
- Vertex attributes only include position and color. Vertex operations only include simple transformation of vertex positions, cutting and projection of vertices. Vertex colors are also simply interpolated during rasterization, and pixel operations are simple-overlay. Rendering technology developed to the second generation (1987 ~ 1992)
Real-time rendering shadow rendering
- Added normals to vertex attributes for lighting calculations. The second generation of rendering technology introduced a very important concept-depth, a typical application is depth buffering. Depth interpolation has also been added to the rasterization process. Color blending technology has been added to pixel arithmetic. The second-generation rendering technology has enriched the sense of color and layering of the picture, but the entire picture still looks monotonous. The third generation rendering technology solved this problem (1992 ~ 2000)-texture mapping, texture coordinates were added to the vertex attributes, and transformation and interpolation of texture coordinates were correspondingly added to the vertex operations. Added texture coordinate interpolation to the rasterization process. Added pixel addressing and blending and anti-aliasing techniques to pixel operations. The third generation rendering technology makes the picture more colorful. With the rapid development of graphics processing technology, the early fixed-function rendering pipeline can no longer meet the requirements of graphic developers, they need more freedom in the graphics processing process. The fourth generation of rendering technology was born (after 2000)-programmable rendering. In the fourth-generation rendering technology, graphic developers can program vertex operations and pixel operations in the rendering pipeline separately, without having to apply some fixed functions as before. For example, for vertex rendering, you can not only simply apply the SetTransform method to achieve the transformation of vertex positions, but more flexible, you can implement more complex transformations of vertex positions by writing programs (assembler or high-level language programs) In lighting calculations, you can start with the most basic lighting model and write programs to calculate diffuse, specular, refraction, and scattering. More importantly, you can also use the calculation results as input to the pixel rendering program to achieve various A variety of effects. In pixel rendering, in addition to tediously calling a large number of fixed functions to achieve, you can also write programs to obtain parameters and texture resources from external or upstream to perform pixel rendering operations. Pixel rendering requires much more computation than vertex rendering, but the quality of the output picture is very high. Many high-quality pictures are obtained by using pixel rendering instead of vertex rendering.
- When it comes to programmable rendering, it's necessary to talk about programming languages. Earlier programming of the graphics processor used Vertex Shader and Pixel Shader-a programming language similar to assembly language, which has a large workload in writing. With the development of graphics hardware, the number of instructions that can be processed by the graphics processor has grown rapidly, and the workload of programming in an assembly-like manner has reached an unacceptable level. . The Cg language is one of them. Cg language is a by-product of nVIDIA company's development of HLSL language in cooperation with Microsoft. The two are essentially the same. In order to make its products more versatile, nVIDIA's Cg language is cross-platform and cross-API. There are many introductions to HLSL. Here we take Cg as an example to introduce programmable rendering.
- Cg is C for Graphic, which means C language for graphic processing. Its syntax structure is similar to C language, but all instructions are executed by the GPU. C language instructions are executed by the CPU. Based on the C language, Cg has improved and optimized the characteristics of the GPU. With the release of Cg language, nVIDIA provides a complete toolkit, which mainly includes: Cg user manual, Cg language compiler, Cg standard library, Cg runtime library, Cg browser, etc. The user manual provides developers with detailed instructions on the use of Cg language; the compiler allows you to first compile and output the program as assembly code and directly supply the program call; Cg standard library is very similar to the C language standard library, which greatly simplifies programming The Cg standard library includes mathematical functions, geometric functions, texture mapping functions, and some exported functions. The Cg runtime library allows applications to compile and link Cg programs at runtime. The runtime libraries include core runtime libraries and API-related runtime libraries. ; Cg browser is convenient for developers to browse rendering example effects provided by nVIDIA. nVIDIA also supports Microsoft's .fx files. FX files encapsulate rendering instructions and rendering states. There is also runtime library support for FX files. nVIDIA provides a plug-in for DCCs. This plug-in calls FX files to make the effect of offline rendering of the model consistent with the result of runtime rendering.
- nVIDIA proposed the concept of a profile in the Cg language. Different profiles determine whether certain syntax, control instructions, standard library functions, and data precision of Cg programs are supported at compile time. From this point of view, it seems that Profile is more appropriate to be translated into "version". If this "version" is supported by the hardware, the Cg program may be executed normally. Cg supports all profiles supported by the current hardware. This is different from HLSL. Microsoft allows software simulation-the CPU to simulate rendering tasks that should be performed by the GPU. So the version of Vertex Shader and Pixel Shader that allows software rendering in HLSL exceeds the version supported by the hardware. On the other hand, because Cg supports cross-API, Cg also supports Vertex Program Profile and Fragment Program Profile for all versions of OpenGL. HLSL only supports DirectX Vertex Shader and Pixel Shader.
- When discussing programmable GPUs, why separate the Vertex Program from the Fragment Program. Unlike the CPU, which is just one processor, the GPU contains two processors-the vertex processor and the pixel processor. It also includes some non-programmable hardware units (for fixed-function pipeline rendering). So only one C program is required to program the CPU, while two programs are required to program the GPU: the Vertex Program programs the vertex processor, and the Fragment Program programs the pixel processor. Of course, you can also choose fixed function pipeline processing for vertex processing and pixel processing. Cg language can perfectly realize the perfect combination of Cg program and fixed function pipeline.
- The development of programmable rendering technology has also had a profound impact on the development of rendering parts in game engines. Generally, there are two ways to achieve the rendering effect in the game. First, the rendering effect is flexibly implemented by the designer during the level design process. This is mainly due to .FX files. The benefits of this are obvious, designers have more freedom and freedom to play, and the designed scene is consistent with the actual runtime effect. In this approach, care must be taken to avoid frequent switching of the rendering program to reduce the rendering frame rate. Second, select what the game needs from a library of pre-made rendering effects. This requires the programmer to add the necessary C ++ code to reference these renderer modules. Generally, programmers also need to encode the relevant parameters in the rendering program into the model (vertex) or texture to effectively improve the rendering rate. In this way, programmers can more specifically avoid frequent switching of rendering programs to ensure the frame rate when the game is running. Of course, once the engine is determined, the available rendering effects library is also determined. Different game types and different games require different rendering methods. These need to be analyzed and considered when we design the game engine.
- With the continuous improvement of graphics processing requirements in related industries, graphics processors will develop in two directions: faster computing speed and more free programmability. The increase in hardware speed will also continue to spawn some new rendering technologies, and also make it possible for some rendering technologies that are difficult to achieve on current hardware platforms. The amount of calculation required for lighting calculation is very large. At present, it can only be implemented through various indirect ways. It is foreseeable that in the next generation of real-time rendering technologies, such as ray tracing, true shadowing and other technologies may become possible. The realization of these technologies will make the graphics rendering effect more realistic. High realism is a major feature of the future development of real-time rendering technology. The improvement of hardware programmability makes the designer's control of the hardware more flexible and creative. Programmability will be another major feature of future rendering technology development. nVIDIA, while pushing its new-generation graphics processor and Cg language, proposed a concept of Cinematic Render, which raised real-time rendering to a whole new level.
- Real-time rendering technology has continuously promoted the development of the game industry since the day it was born, and I believe it will continue to affect it.