When I use my own vertex shader do i have to redner lights, fog and apply transformation in my shader's code or can i still set render states for those operations?
Posted on 2003-08-28 08:47:19 by Vaxon
Vertex shaders replace the fixed function vertex transformation and lighting pipeline. So your vertex shader must:

a) transform vertices passed to it into the proper homogenous clip space, and
b) light, color, and otherwise modify the vertex properties however you need.

As a result, the following actions have their results overwritten after you activate your homemade vertex shader (and will erase your shader, if you use them after setting one):

- Calling SetFVF with anything. (This function will not erase your shader, but it will fail unless you unload your shader first by calling SetVertexShader with NULL.)
- Calling SetTransform or MultiplyTransform with anything.
- Calling SetLight, SetMaterial, or LightEnable with anything.

The vertex shader takes effect after tesselation is performed (so the vertices created by tesselation can be lit and processed too... be careful that your vertex format can be handled by the tesselator unit, if you use it!), and before the vertex operations of backface culling, clipping to frustrum and user clip planes, homogenous divide, and viewport mapping are performed, so you don't have to worry about any of these things; they are handled by the fixed function pipeline, just like normal. You just have to transform and light the vertices, and (if you like) alter their positions, colors, texture coordinates, and so on however you like.
Posted on 2003-09-19 12:23:52 by Tatterdemalian