Skip to Main Content
XNA 3.0 Game Programming Recipes: A Problem-Solution Approach
book

XNA 3.0 Game Programming Recipes: A Problem-Solution Approach

by Riemer Grootjans
May 2009
Intermediate to advanced content levelIntermediate to advanced
671 pages
18h 34m
English
Apress
Content preview from XNA 3.0 Game Programming Recipes: A Problem-Solution Approach
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 shadingvalueof0,sothelightwillhaveno
impact on those pixels.
The Code
All the code is available for download at www.apress.com.
Your complete pixel shader was already listed.
IntheDraw method of your XNA code, activate this effect, set its parameters, and render
your scene:
effect.CurrentTechnique ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

XNA 4.0 Game Development by Example: Beginner's Guide

XNA 4.0 Game Development by Example: Beginner's Guide

Kurt Jaegers
Learning LibGDX Game Development - Second Edition

Learning LibGDX Game Development - Second Edition

Suryakumar Balakrishnan Nair, Andreas Oehlke

Publisher Resources

ISBN: 9781430218555Purchase Link