Shader for Game Programmers and Artists Errata (Wrong D3DRS_CULLMODE Render State in Chapter 5)

Just got my first correction for my book (Shaders for Game Programmer and Artists). I'v decided to post most major corrections to my blog for general knowledge and to spread the word out. The erratas are also availible on my homepage.

Jeff Hanna points out : "I've run into a critical error with the render target shader you create at the beginning of Chapter 5, though. I finished your tutorial and ended up with a black viewport in RenderMonkey. After checked and re-checking my work I decided to load up the finished solution from the CD to see if that would help me locate the error. It did, but it turns out the error isn't mine. The third render pass, the one that copies the render target texture to the frame buffer, has a Render State node with the D3DRS_CULLNODE entry set to D3DCULL_NONE in the solution. It turns out that without the render state node containing that setting then the shader will not display anything."
Sebastien Responds: Hi Jeff. You are correct. The D3DRS_CULLMODE state for this (and most shaders which simply display a full screen polygon) should be set to D3DCULL_NONE. When geometry is rendered, the hardware decides which side to render based on the winding order of the vertices within the polygons. The main reason behind this is that polygons on the inside of the object will face the opposite way and they are not visible, there is no point in rendering them. In the case of the render target shader described in this chapter. The intent of the geometry is to simply fill the screen no matter what. In addtition, since the model used is a simple flat piece of geometry, that we did not generate, it might be facing the wrong way. You could deduce which of D3DCULL_CW or D3D_CULL_CCW to use by trial and error but it is generally easier to simlper to just stick with D3DCULL_NONE.

Skip to main content