The rendering pipeline is responsible for rendering a 3D scene into a 2D image,which can then be drawn on the screen. You can use shaders to program some stages of the rendering pipeline,and use effects to describe a combination of shaders and configurations for the fixed stages of the rendering pipeline. This flexibility allows you to create custom visual effects,improving the visual aspect of the final image.
Rendering Pipeline
At the beginning of the rendering process,the vertices of the object’s mesh are sent to the rendering pipeline,where they go through the stages of vertex processing,rasterization,and pixel processing. At the end of this process,many pixels are generated,ready to be stored in the scene’s final image. Since many triangles of one object can compete for the same pixels on the screen,the last stage in the rendering pipeline—the output merger—decides which pixels are closest to the camera. The output merger stores those pixels in the final image and decides which pixels are to be discarded. This decision is based on the distance between the camera and the object,so only the closest objects are displayed,but this decision can also be influenced by transparency information.
From DirectX 8.1 onward,it became possible to program some of the stages of the rendering pipeline through the creation of small programs called shaders. Shaders allow you to define which data is input and output from each programmable stage of the graphics processing unit (GPU),and,more important,the processing that is happening within each stage. Using shaders,
you can create many new effects for games that weren’t possible using the fixed pipeline.
In XNA,you use shaders to render any object to the screen. To ease game development without needing to program your own shaders,XNA provides some helper classes that contain a basic set of shaders and effects. For example,you can use the SpriteBatch class to draw 2D sprites,and the BasicEffect class to draw 3D models. These two classes use shaders in a way that’s transparent to you. As their names imply,these classes support only basic rendering. The SpriteBatch class will render your images just as they’ve been saved on disk,but don’t ask it to add any spotlights,reflective objects,or effects like rippling in your images. The BasicEffect class can render your 3D world using only basic lighting. If you want to program some fancier effects,you can create your own shaders.
Shaders
Two shaders are generally applied: a vertex shader and a pixel shader. The rasterization stage is executed between the vertex shader and the pixel shader.
原文链接:https://www.f2er.com/javaschema/286830.html