title: PSSetSamplers doens't work (The Pixel Shader unit expects a Sampler)
body: <p>I'm very new at directx11, and I wanted to add texture to a shader I'm using.
  (until now, I hadn't used any texture yet in directx11)</p>
  
  <p>But sampling doesn't seem to work (it's always float4(0,0,0,0)), and I get the warning: "D3D11 WARNING: ID3D11DeviceContext::DrawIndexed: The Pixel Shader unit expects a Sampler to be set at Slot 0, but none is bound."</p>
  
  <p>I searched for this, but all answers say to use </p>
  
  <pre><code>_d3dContext-&gt;PSSetSamplers(0, 1, &amp;_sampler);
  </code></pre>
  
  <p>But I already do that.
  Does anyone know what could be wrong?</p>
  
  <p>This is my entire shader:</p>
  
  <pre><code>Texture2D tex;
  SamplerState TexSampler : register(S0)
  {
      Texture = (Slope);
      Filter = MIN_MAG_MIP_LINEAR;
      AddressU = clamp;
      AddressV = clamp;
  };
  
  struct PixelShaderInput
  {
      float4 color : COLOR0;
      //.r : slope
      //.g : relative distance on road (compared the the rider)
      //.b : shadow (currently darker on lower parts)
      //.a : cameradepth
      float fogfactor : COLOR1;
  };
  
  float4 main(PixelShaderInput input) : SV_TARGET
  {
      const float4 fogColor = float4(0.9, 0.9, 1, 1);
  
      const float halfWidth = 0.0016f;
  
      float4 color;
  
      if (input.color.g &lt; -halfWidth * input.color.a)
      {
          color = float4(0.5, 0.85, 1, 1);
      }
      else if (input.color.g &lt; halfWidth * input.color.a)
      {
          color = float4(1, 1, 1, 1);
      }
      else
      {
          color = tex.Sample(TexSampler, float2(input.color.r, 0.5));
      }
  
      if (input.color.b &lt; 0.999)
      {
          input.color.b *= 0.94; //makes the sides a bit darker
      }
      color.rgb *= input.color.b;
  
      color.rgb = lerp(color.rgb, fogColor.rgb, input.fogfactor);
  
      return color;
  }
  </code></pre>
  
  <p>And in c++/cx I do this (not the full code, just fragments):</p>
  
  <pre><code>Microsoft::WRL::ComPtr&lt;ID3D11ShaderResourceView&gt;    _slopeGradient;
  Microsoft::WRL::ComPtr&lt;ID3D11SamplerState&gt;          _sampler;
  
  D3D11_SAMPLER_DESC sampDesc;
  ZeroMemory(&amp;sampDesc, sizeof(sampDesc));
  sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
  sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
  sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
  sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
  sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
  sampDesc.MinLOD = 0;
  sampDesc.MaxLOD = D3D11_FLOAT32_MAX;
  _d3dDevice-&gt;CreateSamplerState(&amp;sampDesc, &amp;_sampler);
  
  _d3dContext-&gt;PSSetShaderResources(0, 1, &amp;_slopeGradient);
  _d3dContext-&gt;PSSetSamplers(0, 1, &amp;_sampler);
  </code></pre>