Graphics Reference
In-Depth Information
output.PositionWS = mul( input.Position, WorldMatrix ).xyz;
// Calculate the clip-space position
output.PositionCS = mul( input.Position, WorldViewProjMatrix );
// Pass along the texture coordinate
output.TexCoord = input.TexCoord;
return output;
}
// G-Buffer pixel shader for light prepass deferred rendering
PSOutput PSMain( in PSInput input )
{
//.Normalize the tangent frame after interpolation
float3x3 tangentFrameWS = float3x3( normalize( input.TangentWS ),
normalize( input.BitangentWS ),
normalize( input.NormalWS ) );
II Sample the tangent-space normal map and decompress
float3 normalTS = NormalMap.Sample( AnisoSampler, input.TexCoord ).rgb;
normalTS = normalize( normalTS * 2.0f - 1.0f );
// Convert to world space
float3 normalWS = mul( normalTS, tangentFrameWS );
// Output our G-Buffer values
PSOutput output;
output.Normal = float4( normalWS, SpecularPower );
output.Position = float4( input.PositionWS, l.0f );
return output;
}
Listing 11.4. G-buffer generation shader code for light prepass deferred rendering.
11.3.3 Rendering the Light Buffer
For the lighting pass, we will only evaluate a portion of the lighting equation, and will the
result to the render target. The simplified equations that we will use are listed below in
Equation (11.2):
(11.2)
Search WWH ::




Custom Search