Difference between AnisotropicClamp and AnisotropicWrap in XNA 4.0?


I understand that both are methods of texture filtering but what is the difference between clamp and wrap? Which one is better?

EDIT: I tried both with integrated graphics card and found that AnisotropicWrap showed a lower FPS than AnisotropicClamp. Is it true that AnisotropicWrap renders a better texture than AnisotropicClamp?

The sampler states are responsible for telling the graphics device how to translate texture coordinates into texels. Say you have a quadrilateral polygon with the UV coordinates arranged like this:

(0, 0)     (1, 0)
  |          |
(0, 1)     (1, 1)

Texture coordinates have the range [0, 1]. When this is rendered, the top-left corner of the texture will appear at the top-left corner of the polygon, the bottom-right corner of the texture will appear at the bottom-right corner of the polygon, and so on.

Now say you arrange your UV coordinates like this:

(-1, -1)    (2, -1)
  |          |
(-1, 2)     (2, 2)

What happens? There's no correct way to map these coordinates to the texture, because they're outside of our [0, 1] range!

The answer is that you have to tell the device what the correct way is, by specifying either WRAP or CLAMP sampler states.

A CLAMP state clamps the texture coordinates to the [0, 1] range; pixels with coordinates outside of this range will display the closest valid texel.

A WRAP state, on the other hand, assumes that the texture coordinates are cyclical. A coordinate of 1.5 will be treated as 0.5, a coordinate of -0.25 will be treated as 0.75, and so on. This causes the texture to wrap, giving it a tiled appearance.