locked
Attempting to add shadows to my DirectX app

    Question

  • I've been using this topic to guide me:

    http://msdn.microsoft.com/en-us/library/windows/apps/jj262110.aspx

    This topic is specifically written to get shadows working in a Windows 8 Store app, so I think I should be able to get this to work, unless the docs are wrong. Step 4 says:

    To render objects into the scene with shadows, create sampler state objects that have comparison filtering set.

    Step 6 says:

    And then, to find out the amount of shadow for the current pixel, use  the SampleCmp and SampleCmpLevelZero Texture2D methods to sample from the ID3D11ShaderResourceView created in step 5,  just as you would with Direct3D feature level 10_0 and higher.

    But, SampleCmp requires that I pass it a SamplerComparisonState instead of a normal SamplerState. If I try to define a SamplerComparisonState for step 4, the compiler complains that it isn't supported for 9.x. Am I missing something here?

    Monday, December 17, 2012 8:37 PM

Answers

  • I found the problem: I was trying to use SampleCmp in the vertex shader, which isn't allowed. It works great in my pixel shader.
    • Marked as answer by Steve Otteson Tuesday, December 18, 2012 6:00 PM
    Tuesday, December 18, 2012 6:00 PM

All replies

  • I found the problem: I was trying to use SampleCmp in the vertex shader, which isn't allowed. It works great in my pixel shader.
    • Marked as answer by Steve Otteson Tuesday, December 18, 2012 6:00 PM
    Tuesday, December 18, 2012 6:00 PM
  • Texture fetch operations from a Vertex Shader are not supported by Feature Level 9.1, 9.2, or 9.3. This requires Feature Level 10.0 or later.

    Note that the 9.x support for these instructions requires Windows 8, WDDM 1.2 drivers, and the latest HLSL compiler. It won't succeed prior to that.

    Tuesday, December 18, 2012 7:40 PM