加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

XNA--Rendering Pipeline, Shaders, and Effects

发布时间:2020-12-13 20:05:26 所属栏目:百科 来源:网络整理
导读: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 shader

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读