Adding the Pixel Shader

Once again, this screen is better, but it's still not perfect. What about the texture you have loaded? To use the textures, you have to write a pixel shader. Pixel shaders are just as easy to use as a simple vertex shader. Replace your KartRacers.fx file with the code in Listing 20.5.

Listing 20.5. Your Completed Mesh Shader
 //----------------------------------------------------------------------------- // Global variables //----------------------------------------------------------------------------- // World matrix for object float4x4 worldMatrix : WORLD; // World * View * Projection matrix float4x4 worldViewProjection : WORLDVIEWPROJECTION; float4 lightDirection; // Direction of the light texture SceneTexture; sampler ...

Get Beginning 3D Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.