CHAPTER 6 ■ ADDING LIGHT TO YOUR SCENE IN XNA 3.0
553
calculate the lighting factor, called shading. To weaken the lighting effect close to the borders
of the cone, you take the coneDot value to the power specified in xConeDecay. As a result, the
coneDot value that equals or is smaller than 1 will become smaller for pixels that are far off the
center direction of the cone (see the right image in Figure 6-11).
Pixels that are outside the cone will get a shadingvalueof0,sothelightwillhaveno
impact on those pixels.
The Code
All the code is available for download at www.apress.com.
Your complete pixel shader was already listed.
IntheDraw method of your XNA code, activate this effect, set its parameters, and render
your scene:
effect.CurrentTechnique ...