• Advertisement
Sign in to follow this  

Sampler questions

This topic is 1259 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I got a few questions regarding samplers objects in directx 11.

 

I have the following kind of textures that needs to be sampled:

  • 3D model texture2d (diffuse, normal textures)
  • GBuffer texture2d (position, diffuse, normals)
  • Depth texture2d
  • Depth textureCube

This is how I create my (so far only) sampler:

D3D11_SAMPLER_DESC samplerDesc;
ZeroMemory(&samplerDesc, sizeof(D3D11_SAMPLER_DESC));
samplerDesc.Filter = D3D11_FILTER_ANISOTROPIC;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MaxAnisotropy = anisotropic;			// typically 16
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
DXCALL(mDevice->CreateSamplerState(&samplerDesc, &mTextureSampler));

1. Up untill now, I have sampled the 3d model textures AND GBuffer textures using the same sampler, even though the 3d model textures are mipmapped and the gbuffers are not - and it works, not even any dxgi warnings. How can this be? Shouldnt the gbuffer textures be wrong if they are not mipmapped, yet sampled by a mipmap sampler?

 

2. Which leads me to the following question, if the first two can be sampled using the same sampler, can I also use it for depth 2d and cubemap textures?

Edited by KaiserJohan

Share this post


Link to post
Share on other sites
Advertisement

Interesting. Is there any performance penalty to sample for example a textureCube (for shadowmapping) with no mipmaps with the sampler I posted? Does a sampler with more mipmap filtering incur any extra operations no-mipmap textures?

 

ALSO - you cast the screenPos.xy into uint2. Is this because of precision issues, or why is it?

Edited by KaiserJohan

Share this post


Link to post
Share on other sites

Interesting. Is there any performance penalty to sample for example a textureCube (for shadowmapping) with no mipmaps with the sampler I posted? Does a sampler with more mipmap filtering incur any extra operations no-mipmap textures?

 

 

It depends on the hardware and driver, so I can't say for sure. It's also not something I've tested personally. However using anisotropic filtering is definitely going to add a performance cost.
 

Since it's a shadow map, you should consider making a new sampler that uses D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR or one of the similar variants. If you do this, then you can use SampleCmp in your shader to get hardware PCF.

 

 

 


ALSO - you cast the screenPos.xy into uint2. Is this because of precision issues, or why is it?


The Texture2D array operator takes a uint2 as a parameter, so I use an explicit cast to prevent warnings.

Edited by MJP

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement