This tutorial explains how to apply deferred lighting on custom materials. This means objects with custom materials can receive shadows and lighting. To apply this feature to your custom material follow the instructions below.
Open your material.cs file and locate the custom material definition. Add the line in bold after "mapTo" :
Open your vertex shader code and add the directive in bold:
Add the line in bold to your output VS semantics:
After your vertex transformation add the line in bold:
Open your pixel shader. Add the line in bold in the beginning of the file:
Straight after this add the lines in bold:
Locate your input structure of the pixel shader and add the line in bold:
At the end of your fragment shader paste the code in bold:
This code recalculates the texture coordinates to sample from a 2D buffer lightinfo. Then this color is applied to your lighting model.
*Additional notes: Pay attention to your sampler numeration and rtParams. The example above is setup for S0 register.