Graphics Reference
In-Depth Information
2.
Next, we update the signature of our ExtractGBufferAttributes function to
use Texture2DMS resources and include one additional parameter to control which
sample index will be retrieved as highlighted in the following code snippet:
void ExtractGBufferAttributes(in PixelIn pixel,
in Texture2D MS <float4> t0,
in Texture2D MS <uint> t1,
in Texture2D MS <float4> t2,
in Texture2D MS <float> t3,
in int sampleIndex ,
out GBufferAttributes attrs)
{
int3 screenPos = int3(pixel.Position.xy, 0);
float depth = t3.Load(screenPos, sampleIndex );
attrs.Diffuse = t0.Load(screenPos, sampleIndex ).xyz;
attrs.SpecularInt = t0.Load(screenPos, sampleIndex ).w;
attrs.Normal = UnpackNormal(t1.Load(screenPos, sampleIndex ));
attrs.Emissive = t2.Load(screenPos, sampleIndex ).xyz;
attrs.SpecularPower = t2.Load(screenPos, sampleIndex ).w * 50;
...
}
3.
Our updated pixel shaders will use a similar approach to the multisampling pixel
shader of the screen-aligned quad; in addition, we will use the SV_Coverage pixel
shader input semantic. Let's go ahead and make these changes to each of the
LightRenderer pixel shaders. The following updated point light shader shows
the highlighted changes:
float4 PSPointLight(in PixelIn pixel,
uint coverage: SV_Coverage,
uint sampleIndex: SV_SampleIndex) : SV_Target
{
GBufferAttributes attrs;
// Is sample covered
if (coverage & (1 << sampleIndex))
{
ExtractGBufferAttributes(pixel,
Texture0, Texture1,
Texture2, TextureDepth,
sampleIndex,
attrs);
...
return float4(LightContribution(attrs, V, L, H, D,
attenuation), 1.0f);
}
discard;
return 0;
}
 
Search WWH ::




Custom Search