Following the tutorial in msdn:
https://docs.microsoft.com/en-us/windows/uwp/gaming/render-the-shadow-map-to-the-depth-buffer
The above link is Step 2. You can go to Step 1 if you want from the links to the left in from the above link.
Anyways, it says the following: “The output of this shader is thrown away; it can call discard on every pixel.”
But when I do discard, when I check the graphics debugger and check the shadow map resource, this happens:
![](https://uploads.gamedev.net/forums/monthly_2020_05/16a73c85aa0f470e9e5433425c0dd2d2.NoShadowMap.png)
But if I use
return input.pos.z / input.pos.w
in the pixel shader in the shadow render pass, I get this in the shader resource view:
![](https://uploads.gamedev.net/forums/monthly_2020_05/2e168969a22a41a1ad0dfea0064333f9.WithShadowMap.png)
It results that when I then sample from the ShadowMap, I can detect whether a pixel should be bright or shadowed.
I understand then that of course, since I return a value in the pixel shader, it gets filled with pixel values. That makes sense. So why does MSDN write that “it can call discard” for?
I've sampled the ShadowMap as they wrote in Step 3 like this but with modifications:
lighting = float(shadowMap.SampleCmpLevelZero( shadowSampler, shadowTexCoords, pixelDepth + epsilon ) );
if(lighting > 0)
{
return 1;
}
return 0;
It works as said above, when I return in the pixel shader. So the question again,
why is MSDN saying that “discard” can be used?