Graphics Reference
In-Depth Information
{
ftoat4 ScreenPos : SV_Position;
float2 TexCoord
: TEXCOORD;
};
// Vertex shader for final pass of light prepass deferred rendering
VSOutput VSMain( in VSInput input )
{
VSOutput output;
// Calculate the clip-space position
output.PositionCS = mul( input.Position , WorldViewProjMatrix );
// Pass along the texture coordinate
output . TexCoord = input.TexCoord;
return output;
}
// Pixel shader for final pass of light prepass deferred rendering
float4 PSHain( in PSInput input ) : SV_Target0
{
// Sample the diffuse map
float3 diffuseAlbedo = DiffuseMap.Sample( AnisoSampler, input . TexCoord ).rgb;
// Determine our indices for sampling the texture based on the current
// screen position
int3 sampleIndices = int3( input.ScreenPos.xy, 0 );
// Sample the light target
float4 lighting = LightTexture. Load( samplelndices );
// Apply the diffuse and specular albedo to the lighting value
float3 diffuse = lighting.xyz * diffuseAlbedo;
float3 specular = lighting. w * SpecularAlbedo;
// Final output is the sum of diffuse + specular
return float4( diffuse + specular, 1.0f );
}
Listing 1 1 .6. Shader code for final pass.
It should be noted that other terms that contribute to the final pixel color can also be
added in, such as emissive lighting (glow), Fresnel/rim lighting, or reflection maps. This
makes light pre-pass deferred rendering more natural for implementing these sorts of mate-
rial variations.
Search WWH ::




Custom Search