5
\$\begingroup\$

I have a mesh that is computer generated with a texture on top of it with transparancy on one side. The SamplerState is set to LinearWrap because I would like the texture to wrap. The problem I have is that this transparent edge has some weird aliasing. This does not occur when I set the SamplerState to LinearClamp.

I found that when letting the U coordinate go from 0.1 to 0.9 this does not happen. Probably on the transparent side it interpolates U coordinate 1 with U coordinate 0.

What could be the solution to prevent aside from not letting the U coordinate go all the way to 1?

enter image description here

\$\endgroup\$
6
\$\begingroup\$

Create a new SamplerState of your own and set it like this:

mySampler.Filter = TextureFilter.Linear;
mySampler.AddressU = TextureAddressMode.Clamp;
mySampler.AddressV = TextureAddressMode.Wrap;
mySampler.AddressW = TextureAddressMode.Wrap;

The V coordinate will be wrapped (since you want horizontal repeat) and the U will be clamped.

| improve this answer | |
\$\endgroup\$

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.