Sign in to follow this  
_damN_

Creating a new sampler state without a shader?

Recommended Posts

Hi! Im trying to create a new sampler state using D3D10,so i can add texture filtering but i dont want to do it within a shader. I dont think its working because i cant seem to see a difference at all? This is what it looks like...
Quote:
ZeroMemory(&samplerDesc, sizeof(D3D10_SAMPLER_DESC)); samplerDesc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP; samplerDesc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP; samplerDesc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP; samplerDesc.ComparisonFunc = D3D10_COMPARISON_NEVER; samplerDesc.Filter = D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR; samplerDesc.MaxAnisotropy = 0.0f; samplerDesc.MaxLOD = FLT_MAX; samplerDesc.MinLOD = 0.0f; samplerDesc.MipLODBias =0.0; ID3D10SamplerState* samplerState; m_pD3DDevice->CreateSamplerState(&samplerDesc,&samplerState); m_pD3DDevice->PSSetSamplers(0,1,&samplerState);
I cant find any decent DX10 examples on the net and if i do find one they use a shader. Can anybody help? Thanks!

Share this post


Link to post
Share on other sites
I find your question a bit confusing - Since DX10 only allows rendering to be done through shaders what would you do with a device with texture filtering applied?

Secondly the sampler creation below doesn't require a shader interface, only a functional device.

Could you try and specify what exactly you need to do.

Share this post


Link to post
Share on other sites
I think he wants to specify the sampler state in C++ code as opposed to in a D3D10 Effects file.

When you declare the sampler in HLSL did you specify a register to put it in?

Share this post


Link to post
Share on other sites
Apologies... Let me try and clear things up. Im pretty new to directX. I want to turn on texture filtering so i can render my cube using the filter D3D10_FILTER_MIN_MAG_POINT_MIP_LINEAR or D3D10_FILTER_ANISOTROPIC and play around with texture qualities.

Are you saying i will only be able to do this in a shader? There are so few tutorials on DX10 on the net its difficult to know how to do this properly. I have a book which shows you how to do this in a shader but i dont really wanto do it in a shader, i wanto do it it my code(source file) itself. There has to be a way, surely!

Does that make a bit more sense? How would i fill the descriptor and set it to active?

Thanks

Share this post


Link to post
Share on other sites
I nice code example would be greatly apreciated!

Quote:

I think he wants to specify the sampler state in C++ code as opposed to in a D3D10 Effects file.

When you declare the sampler in HLSL did you specify a register to put it in?


What do you mean? Isnt that only when i use a shader? You are right, i want to do it in C++ code instead of in an effect file.

Share this post


Link to post
Share on other sites
Well, the code sample you showed is correct, but you still need a pixel shader and you need to refer to the sampler state in it even if you set it in code.

If you're new to all of this, I would just stick to declaring states in a .fx file. The Effect Framework is there to make your life easier.

Share this post


Link to post
Share on other sites
Your code for filling out the D3D10_SAMPLER_DESC looks okay. However you want to create sampler states at initialization time, not at runtime. At runtime you only want to set states. Make sure you set the sampler state after applying an effect pass, otherwise the effect pass will override your state. Also, make sure that you're setting the sampler state to the correct sampler index. You can manually bind a sampler to an index in your HLSL like this:

SamplerState LinearSampler : register(s0);

Share this post


Link to post
Share on other sites
Quote:
Original post by _damN_
You mean like so...

SamplerState gTriLinearSam: register(s0)
{
Filter = MIN_MAG_MIP_LINEAR;
};

???


That is effects code when you include the initializer data. The pure HLSL bit is just


SamplerState gTriLinearSam: register(s0);



You don't need anything else in the HLSL code. The creation and binding will all happen in the runtime code by you.

Share this post


Link to post
Share on other sites
Sorry, i thought it was working because i saw a change in texture quality, but its not working. If i change the filter value, there is no difference.

I done as you said and put the
SamplerState LinearSampler : register(s0);

in the effect file. What could the problem be?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this