HLSL in a Graphics engine
Ok well I am a serious nuub to HLSL and just have a conceptual thing I need to sort out. Can you apply HLSL directly to a specfic mesh or is it a post render type effect using the stencil buffer?
Example of Assumed flow:
1. Begin Draw
2. Draw all objects that are solid and have no effects on them
3. Draw all Objects that are transparent
4. Render HLSL effects for each mesh
5. Render UI
6. End Draw
Anyhelp is much appreciated and many thanks in advance for any help.
HLSL Shaders are blocks of code which control how the object is rendered, for example of you have a vertex shader which deforms a mesh, before rendering the mesh you would tell D3D (he assumes) that you want to use this vertex shader on the following vertices, D3D then tells the gpu thats what you want to use and for every vertex submitted that code gets run.
For pixel shaders its about the same, when you render the mesh you tell D3D that you want to use that pixel shader and D3D then tell the gpu that. Then, for each fragment which is rendered, the pixel shader code is run on the gpu and the effect applied
Your assumed flow is pretty much spot on, when things are rendered they are generaly grouped by things such as shaders and which textures they will be using, in order to avoid unwanted switches.
However, transprant objects are rendered last due to the way the alpha blending works, so put 3 after 4 in your list and that pretty much does it.
For pixel shaders its about the same, when you render the mesh you tell D3D that you want to use that pixel shader and D3D then tell the gpu that. Then, for each fragment which is rendered, the pixel shader code is run on the gpu and the effect applied
Your assumed flow is pretty much spot on, when things are rendered they are generaly grouped by things such as shaders and which textures they will be using, in order to avoid unwanted switches.
However, transprant objects are rendered last due to the way the alpha blending works, so put 3 after 4 in your list and that pretty much does it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement