0
\$\begingroup\$

I'm trying to texture my procedurally generated terrain. Previously I used an array of textures e.g. Texture tex[8], however in the shader you can't access this by index unless you chain if statements (ew), so I switched to using a Texture2DArray where instead you use a 3D UV where the Z component is the texture index. I use texassemble to generate a DDS file containing the Texture2DArray so it can be loaded in with ease.

For whatever reason, DirectX(11) seems to interpolate the Z component whenever the Z changes, resulting in seeing a slice of other textures in the array. I should add I'm trying to change the texture on the same piece of geometry. But I need to do this due to having multiple procedurally generated biomes.


I sample the texture in the pixel shader like so

float4 texCol = Tex.Sample(Sampler, v.UV);

My sampler is set up like this

CD3D11_SAMPLER_DESC samplerDesc(D3D11_FILTER_ANISOTROPIC,
    D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_WRAP, D3D11_TEXTURE_ADDRESS_CLAMP,
    0.f, maxAnisotropy, D3D11_COMPARISON_NEVER, border, 0.f, FLT_MAX);

The unwanted interpolation in question

Texture boundary interpolates?

\$\endgroup\$
  • \$\begingroup\$ DirectX interpolates your Z because you have triangles which have different Z's on different corners. Fix your UVs. \$\endgroup\$ – tkausl Mar 18 at 1:03
  • 1
    \$\begingroup\$ I will add to the above comment, at the seams where there are different texture indices (z value in this case), you will need to have seperate vertices for each different texture at the seam to ensure you do not get interpolation. \$\endgroup\$ – ErnieDingo Mar 18 at 1:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.