Sure there's something I'm missing about wrap/repeat textures in D3D 9. I've tried setting the sampler in the shader, i.e. :

sampler DiffuseSampler = 
    Texture = <DiffuseMap>;

    MipFilter = NONE;
    MinFilter = POINT;
    MagFilter = POINT;

    AddressU = WRAP;    // Repeat on X
    AddressV = WRAP;    // Repeat on Y.

, and I've also tried doing it in code before I render the object:


I thought there might be something screwy with my texture coordinates too, so I hard coded them to be 0.0, 0.0 on the left and 2.0, 2.0 bottom right. I expected x 2 repeat but got a similar result to the screenshot, with the texture top left and then what looks like clamp across the rest of the image.

What mistake have I made here? (Note that the screenshot isn't the 0.0, 0.0 -> 2.0, 2.0 experiment I did, it's the general case I get as I'm panning my image around).

Here's a screenshot of the resulting image (it's just a checker texture)

  • \$\begingroup\$ You are setting a sampler for the vertex shader in the second piece of code is this what you want? \$\endgroup\$ – János Turánszki Feb 18 '14 at 17:26
  • \$\begingroup\$ In the vertex shader? No, the only place the sampler is used is in the pixel shader. I think I see what you're getting at here... that's for vertex texture fetch isn't it. Hmmmm... \$\endgroup\$ – Robinson Feb 18 '14 at 17:31
  • \$\begingroup\$ D3DVERTEXTEXTURESAMPLER0 is indicating you are setting it to the first sampler slot of the vertex shader state. \$\endgroup\$ – János Turánszki Feb 18 '14 at 17:32
  • \$\begingroup\$ OK, not sure whether to delete this question as unbelievably stupid or ask you to add that as the answer so I can give it a cookie. It now works as I changed it to 0. I need to pay attention to what I copy and paste from the internet :p. Thanks János \$\endgroup\$ – Robinson Feb 18 '14 at 17:35
  • \$\begingroup\$ No problem I think this question can stay on the site, I am gonna answer it. :) \$\endgroup\$ – János Turánszki Feb 18 '14 at 17:38

The problem here is that you are setting a sampler for the vertex shader stage (D3DVERTEXTEXTURESAMPLER0 means the first slot) but you want to use it in your pixel shader. You should change it to null.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.