locked
How to set Sampler State properties used in a pixel shader for Direct2D Custom Effect?

    Question

  • I want to create a custom Direct2D effect with reference to this sample

    http://code.msdn.microsoft.com/windowsapps/Direct2D-custom-image-7a1f2cb5

    And since i started write pixel shader code, i find

    SamplerState S  : register(s0)
    {
     Filter = MIN_MAG_MIP_POINT;
     AddressU = Wrap;
     AddressV = Wrap;
    };

    When the pixel shader is executing, the Filter Property, Address Properties are not the one i specified in hlsl code?

    Any idea how to change these settings?

    I tried PSSetSamplerState over the ID3D11DeviceContext, seems not working unless i missed something?

    Wednesday, January 15, 2014 9:31 AM

All replies

  • I'll ask James to check this out.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, January 16, 2014 9:16 PM
    Moderator
  • Thanks a lot.

    I will have the project ready.

    Friday, January 17, 2014 9:23 AM
  • Any updates?
    Wednesday, February 5, 2014 11:44 AM
  • I think you should set the sampler state in c++ code but not the hlsl code.

    // Create the sampler state
    	D3D11_SAMPLER_DESC samplerDesc;
    	ZeroMemory(&samplerDesc, sizeof(samplerDesc));
    	samplerDesc.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
    	samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_BORDER;
    	samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_BORDER;
    	samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_BORDER;
    
    	DX::ThrowIfFailed(
    		device->CreateSamplerState(
    		&samplerDesc,
    		&m_samplerState)
    		);

    Wednesday, March 19, 2014 12:53 PM