FMod and Frac material functions cause seam in texture

Is there any way to get rid of the interpolation seam caused by using Frac or FMod? Coming from writing actual fragment shaders, I find it odd that this seam even exists (why is interpolation happening in the pixel sampling?)

Example, say we have this super simple texture

https://i.stack.imgur.com/yp24q.png

And we want the top right corner to loop instead of the whole texture, something that’s easy to accomplish with an FMod.

https://i.stack.imgur.com/49KRX.png

As you can see, an artifact is now present from when the UV jumps from 0.25 to 0 and I’m not sure why. Is there a way I can disable this interpolation? With the power of MSPaint, here’s what I expected to see:

https://i.stack.imgur.com/mkWb7.png

I’ve found an okay temporary solution. If you disable mip-mapping (via the properties on the texture themselves) then the artifacts disappear. Would love to have another answer that describes how to do this while maintaining mipmaps.

You’d be better off just making a texture that has this set up the way you want, I think.

Alternatively, make a texture that is using up the full UV 0 - 1 space, and then just set your UV tiling to 2.

I think you’re looking into the example a bit too far. I made that example to show the issue I’m talking about in its simplest form. My actual use case is far more nontrivial but is being hampered by the artifacts caused by fmod and frac – basically anything that causes a hard seam of uvs between two nearby fragments will cause it to do a weird interpolation artifact on the boundary between them.

You are right, though. If I needed to do what is in the example, I would just tile it as you described. The question itself is to avoid the artifacts from fmod and frac

I can confirm this solution works. I had a similar problem when using the Flipbook material node in conjunction with the use of absolute world position. Thank you very much.

You don’t need to disable mips, it is pretty bad in all respects. Instead, use an option to provide explicit derrivates, and use DDX DDY, on coordinates, that do not contain frac expression.

Maybe ComputeMipLevel node will help.
This worked for me…unfortunately, i don’t understand why :slight_smile: