I’ve been programming for quite a long time now, though I have never bother to look into shaders (except about 5 years ago when I was messing about with PS 1.0 on the original Xbox for about a week!).
I understand what they do, where they go in the rendering pipeline and why they are used, but one thing I can’t seem to understand fully is what they replace in the host application.
I know you can have a mix of fixed and programmable pipelines in applications, but what exactly would a fully programmable pipeline replace?
I have been looking into Cg over the past few days (especially regarding the DX component), and the minimal and extended interfaces are just confusing the matter - so any expereinces of that would be appreciated.
For example, would a fully programmable pipeline negate the need to call DirectX’s SetTransform functions (as we would do all the transformations in the vertex shaders) for all matrices? Would we just store them as shader constants?
Would the shader be expected to control render state changes or should that be controlled by the host application? And finally, the extended Cg interface (and I think DX HLSL) can functions to set the texture for specific stages. Should this no longer be done in the host application (but when I used PS1.0, you just used a stage lookup!)
As you can probably make out, I have gotten a tad confused about where the line is between the application and shader, and if anyone can straighten it out, I would really appreciate it.
Thanks
Spree
Scarily Newbie Question About Shaders
Started by SpreeTree, Mar 06 2006 05:25 PM
2 replies to this topic
#1
Posted 06 March 2006 - 05:25 PM
#2
Posted 06 March 2006 - 06:18 PM
Basically, shaders replace everything that is done by the actual graphics hardware, but not what is done by the CPU (i.e. your application and the graphics driver). So shaders do not control the setting of renderstates or the loading of textures and other resources; they also cannot create or remove vertices (although this will change with DX10).
A vertex shader is a program that is executed for each vertex, and is responsible for carrying out all tasks that the GPU would normally do for each vertex. In the fixed functionality, this means transformation into clip space and lighting; in a vertex shader you would normally do the same transformation yourself, but you don't have to (so you could ignore the matrices that are set by the application if you like). A pixel shader replaces everything the GPU would normally do for each pixel. The GPU still does linear interpolation for you, so you can set values like texture coordinates for each vertex using the vertex shader and those values will be interpolated across each triangle and pop out in the pixel shader for you, at which point you can do any calculations you want to determine the final color of the pixel (normally lighting and shading).
A vertex shader is a program that is executed for each vertex, and is responsible for carrying out all tasks that the GPU would normally do for each vertex. In the fixed functionality, this means transformation into clip space and lighting; in a vertex shader you would normally do the same transformation yourself, but you don't have to (so you could ignore the matrices that are set by the application if you like). A pixel shader replaces everything the GPU would normally do for each pixel. The GPU still does linear interpolation for you, so you can set values like texture coordinates for each vertex using the vertex shader and those values will be interpolated across each triangle and pop out in the pixel shader for you, at which point you can do any calculations you want to determine the final color of the pixel (normally lighting and shading).
reedbeta.com - developer blog, OpenGL demos, and other projects
#3
Posted 07 March 2006 - 08:08 AM
Thanks for that, it does clear a few issues that I have been having, and should hopefully allow me to look at Cg with a fresher pair of eyes :)
Spree
Spree
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












