CH A PT ER 6 A DD I NG LI GHT T O YOUR SC ENE I N XN A 2.0 in Microsoft Word

Drawer Data Matrix ECC200 in Microsoft Word CH A PT ER 6 A DD I NG LI GHT T O YOUR SC ENE I N XN A 2.0

CH A PT ER 6 A DD I NG LI GHT T O YOUR SC ENE I N XN A 2.0
Printing ECC200 In None
Using Barcode printer for Microsoft Word Control to generate, create ECC200 image in Office Word applications.
www.OnBarcode.com
EAN / UCC - 13 Creation In None
Using Barcode encoder for Word Control to generate, create GS1 - 13 image in Office Word applications.
www.OnBarcode.com
This is your complete pixel shader: PixelToFrame MyPixelShader(VertexToPixel PSIn) : COLOR0 { PixelToFrame Output = (PixelToFrame)0; //sample normal from normal map float3 normal = tex2D(NormalMapSampler, PSIn.TexCoord).rgb; normal = normal*2.0f-1.0f; normal = normalize(normal); //sample depth from depth map float depth = tex2D(DepthMapSampler, PSIn.TexCoord).r; //create screen position float4 screenPos; screenPos.x = PSIn.TexCoord.x*2.0f-1.0f; screenPos.y = -(PSIn.TexCoord.y*2.0f-1.0f); screenPos.z = depth; screenPos.w = 1.0f; //transform to 3D position float4 worldPos = mul(screenPos, xViewProjectionInv); worldPos /= worldPos.w; //find screen position as seen by the light float4 lightScreenPos = mul(worldPos, xLightViewProjection); lightScreenPos /= lightScreenPos.w; //find sample position in shadow map float2 lightSamplePos; lightSamplePos.x = lightScreenPos.x/2.0f+0.5f; lightSamplePos.y = (-lightScreenPos.y/2.0f+0.5f); //determine shadowing criteria float realDistanceToLight = lightScreenPos.z; float distanceStoredInDepthMap = tex2D(ShadowMapSampler, lightSamplePos); bool shadowCondition = distanceStoredInDepthMap <= realDistanceToLight - 1.0f/100.0f; //determine cone criteria float3 lightDirection = normalize(worldPos - xLightPosition); float coneDot = dot(lightDirection, normalize(xConeDirection)); bool coneCondition = coneDot >= xConeAngle;
Barcode Drawer In None
Using Barcode generator for Word Control to generate, create Barcode image in Office Word applications.
www.OnBarcode.com
Creating Denso QR Bar Code In None
Using Barcode generator for Microsoft Word Control to generate, create QR Code 2d barcode image in Word applications.
www.OnBarcode.com
CHAPTER 6 ADDIN G LIGHT TO Y OUR SCE NE IN XNA 2.0
Code 3 Of 9 Encoder In None
Using Barcode creation for Word Control to generate, create Code 39 Full ASCII image in Office Word applications.
www.OnBarcode.com
Data Matrix Drawer In None
Using Barcode printer for Office Word Control to generate, create Data Matrix 2d barcode image in Word applications.
www.OnBarcode.com
//calculate shading float shading = 0; if (coneCondition && !shadowCondition) { float coneAttenuation = pow(coneDot, xConeDecay); shading = dot(normal, -lightDirection); shading *= xLightStrength; shading *= coneAttenuation; } float4 previous = tex2D(PreviousSampler, PSIn.TexCoord); Output.Color = previous + shading; return Output; }
Printing EAN / UCC - 14 In None
Using Barcode creator for Microsoft Word Control to generate, create USS-128 image in Word applications.
www.OnBarcode.com
Encoding USD-4 In None
Using Barcode generation for Microsoft Word Control to generate, create USS Codabar image in Microsoft Word applications.
www.OnBarcode.com
The Code
Create Data Matrix ECC200 In None
Using Barcode maker for Font Control to generate, create ECC200 image in Font applications.
www.OnBarcode.com
DataMatrix Recognizer In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
This recipe uses the same code as recipe 6-10, except for the GenerateShadingMap, RenderShadowMap, and AddLight methods. These methods were already listed.
Draw QR Code ISO/IEC18004 In Visual Studio .NET
Using Barcode drawer for Visual Studio .NET Control to generate, create QR Code 2d barcode image in VS .NET applications.
www.OnBarcode.com
Draw Code-128 In VB.NET
Using Barcode drawer for .NET Control to generate, create Code 128B image in VS .NET applications.
www.OnBarcode.com
Adding Sounds to Your XNA 2.0 Project
PDF 417 Maker In None
Using Barcode creator for Font Control to generate, create PDF417 image in Font applications.
www.OnBarcode.com
Create GTIN - 128 In Visual Basic .NET
Using Barcode creation for VS .NET Control to generate, create GTIN - 128 image in VS .NET applications.
www.OnBarcode.com
ven the game with the best game play doesn t feel like a lot of fun if it doesn t have any sounds. If you add a suitable sound to your visual effects together with a background score, your game will immediately feel a lot more finished. This short chapter shows you how easy it is to add sounds to your XNA project and to manage them. Specifically, the recipes in this chapter cover the following: Creating an XAct project to load sound files into your XNA project (recipe 7-1) Looping sounds to add a background score to your game (recipe 7-2) Making your 3D world really come alive by adding 3D sound positioning to your game (recipe 7-3)
Printing UPC Code In .NET Framework
Using Barcode creator for Reporting Service Control to generate, create GS1 - 12 image in Reporting Service applications.
www.OnBarcode.com
PDF417 Encoder In Java
Using Barcode generation for Java Control to generate, create PDF-417 2d barcode image in Java applications.
www.OnBarcode.com
7-1. Play Simple .wav Sound Files
USS Code 128 Generator In None
Using Barcode printer for Software Control to generate, create Code 128 Code Set A image in Software applications.
www.OnBarcode.com
Recognizing ANSI/AIM Code 39 In Visual Basic .NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
The Problem
Read USS-128 In C#.NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Paint EAN13 In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create EAN 13 image in ASP.NET applications.
www.OnBarcode.com
You want to play a sound effect in your game.
The Solution
By using XAct, a free tool that comes with XNA Game Studio 2.0, you can create an XAct project that contains all the sound files you re going to use in your game. You can import this XAct project into your XNA project, after which you can immediately play the sounds stored in your XAct project using a single line of code.
How It Works
First, make sure you have opened an XNA project and saved it somewhere on your disk. To keep things organized, you should create a new folder to store all your audio stuff. In the Solution Explorer of your XNA project, find the Content entry, and right-click it. Select Add New Folder, and name your folder Audio, for example.
CHAPTER 7 ADDIN G SOUNDS TO YOUR XNA 2.0 PROJEC T
Now open XAct by clicking the Start menu and then clicking Programs Microsoft XNA Game Studio 2.0 Tools Microsoft Cross-Platform Audio Creation Tool (XAct). When you start XAct, the first thing you need to do is start a new project by selecting File New Project. Give your project a fancy name, and navigate to the Content\Audio map of your XNA project to save it there. You will be presented with a new, empty project. In the tree structure on the left, find Wave Banks, which contains the waves, which are the audio files. Right-click Wave Banks, and select New Wave Bank. Next, create a new sound bank by right-clicking Sound Banks and selecting New Sound Bank. A sound bank contains sounds, which are objects that can actually be played in your XNA project. A sound points to a wave and can optionally add some kind of effect to the wave. You now should see two panes on the right part of your window. Click the Wave Bank pane. You should see its properties in the bottom-left corner of the XAct window. Find the Name property, and change it from Wave Bank to myWaveBank. Next, click the Sound Bank pane, and change its Name property to mySoundBank. These are the names by which they will be accessible from within your XNA project. You can use your wave bank to store all your .wav files, so right-click somewhere in its pane, and select Insert Wave File(s). Browse to the .wav file on your disk that you want to play in your game, and hit Open. You should see it has been added to your wave bank. It s shown in red, because you haven t yet made a sound in your sound bank that uses the wave.
Tip The location of the file will be stored relative to your XAct project. This can cause trouble if you re
changing the location of either your sound file or your XAct project, so you should first copy the audio files to the Content\Audio map before importing them into your wave bank.
A wave is a reference to the sound file on your disk. A sound uses a wave and allows you to add some kind of effect to it, such as manipulating the volume or pitch. From one wave you can make multiple sounds. However, the programmer uses a cue to access the sounds. So from each sound, you need to make a cue before you can access it from your XNA code. One cue can contain multiple sounds, so a single line of code can play multiple sounds after each other. So, before you can play a wave from your wave bank in your game, you need to make a sound and a cue that uses this wave. You can do this easily by selecting your wave and dragging it into the cue area of the Sound Bank pane, as shown in Figure 7-1.
Caution Make sure you drag the sound(s) immediately into the cue list at the bottom of the Sound Bank
Copyright © OnBarcode.com . All rights reserved.