c++directxtexturestexture-wrapping

How can the texture wrapping direction be changed from U to V and vice-versa in DirectX11?


In DirectX 9 it used to be like this: d3dDevice->SetRenderState(D3DRS_WRAP0, D3DWRAPCOORD_0);

That way you could change how Direct3D perceived the shortest route between texture coordinates in the u-direction and v-direction. Very useful for spheres and cylinders textures wrapping.

A good explanation is here https://learn.microsoft.com/en-us/windows/desktop/direct3d9/texture-wrapping

But after a lot of research I'm having a hard time figuring out how to achieve the same results in DirectX11 as it now uses multiple render states an none seems to have a function like that.


Solution

  • This functionality is not implemented in Direct3D 11. You should map the model coordinates to texture coordinates manualy.

    One way is to create an edge on a seam line, where you want the texture to wrap, and process model faces on both sides of the seam independently.

    Another way is to use texture coordinates, that are outside of [0; 1] range together with one of addressing techniques (which you specify in sampler state description structure). This techniques are enumerated in D3D11_TEXTURE_ADDRESS_MODE enum (https://learn.microsoft.com/en-us/windows/desktop/api/d3d11/ne-d3d11-d3d11_texture_address_mode). But there are no options for "shortest route" texture wrapping in d3d11, like that described in MSDN article you provided.