Making Specular Highlights Per Pixel

To address this issue, you can make the highlights appear per pixel rather than per vertex. Doing so requires a more complicated pixel shader. Back in your KartRacers.fx file, add the new shader functions in Listing 23.3.

Listing 23.3. A Per-Pixel Shader
 //----------------------------------------------------------------------------- // Transformation with single directional light plus per pixel specular //----------------------------------------------------------------------------- struct PER_PIXEL_OUT { float4 Position : POSITION; float2 TexCoords : TEXCOORD0; float3 LightDirection : TEXCOORD1; float3 Normal : TEXCOORD2; float3 EyeWorld : TEXCOORD3; }; PER_PIXEL_OUT TransformSpecularPerPixel(float4 pos : ...

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.