RENDERING

You've created your vertex data, set the vertex shader interface, set up the vertex streams, assembled and loaded your vertex and pixel shaders. You've set the textures and shader constants. You've set the necessary render states. You've selected the shaders you want. What's left? Only a call to one of the rendering functions to put everything in motion.

If you're using one of the higher order primitive calls, your vertex shader will be called on each vertex that is created by the primitive call. If you're using a DrawPrimitive call, then each vertex will get passed to your vertex shader. Once a triangle is passed through a vertex shader, the rasterization process will start generating pixels. Each of these pixels will get passed to your pixel shader routine. Some data (like texture coordinates) will get interpolated from the vertex data before it gets passed to the pixel shader depending upon the settings of render states. For the best speed possible, you should sort your objects by texture so that objects that share a texture get rendered together. After textures sort by vertex buffer, the next thing to sort by are objects that share shaders. You should also try to batch up setting shader constants and not set them singly. That's it! There's a lot to keep track of, but there are plenty of samples in the DirectX SDK, and the DirectX programming documentation covers many of these functions in greater detail. Render on!



Real-Time Shader Programming(c) Covering Directx 9. 0
Real-Time Shader Programming (The Morgan Kaufmann Series in Computer Graphics)
ISBN: 1558608532
EAN: 2147483647
Year: 2005
Pages: 104
Authors: Ron Fosner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net