You have to define the samplerstate outside of the shader, so your temporal fix is the correct way to do it.
See here
سؤال
I got a shader with an non functioning sampler inside that i currently overwrite with a temporal fix. but i finnaly find the issue and fix this shader.
basically i have my texture and sampler defined like this (using Profile = fx_4_0;
, also tryed many other ways of defining a sampler e.g: dx9 way using sampler_state, etc.):
Texture2D dirtTexture;
SamplerState WrapSampler {
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};
and i also tryed other variations of writing the same sampler but it allways ending up using the default sampler that clamps the texture coordinates.
and for reading the texture:
Output.Color = dirtTexture.Sample(WrapSampler, PSIn.TextureCoords);
my temporal fix, that makes the texture wrap correctly (for whatever reason), is the following:
_effect.Parameters["WrapSampler"].SetResource(GraphicsDevice.SamplerStates.LinearWrap);
full shader if needed: http://pastebin.com/tLJi1Uwd
المحلول
You have to define the samplerstate outside of the shader, so your temporal fix is the correct way to do it.
See here