TextureWrapMode repeats despite UV being 1
I create a mesh with 4 x 4 vertices and create a Texture2D with 5 x 5 pixels (set the TextureWrapMode to Repeat). Then in vertex shader I simply read the pixel values from the texture, based on each vertex's UV value, and displace the mesh in Y-direction based on the simple texture:
v.vertex.y = tex2Dlod (_MainTex, float4(v.texcoord.xy, 0, 0));
The problem is the texture will start repeating immediately, even though the UV value at the bottom corner of the mesh is (1,1). I've verified in the debugger that the actual UV values are in exact range {0,1}.
The documentation states that textures will start repeating outside this range: https://docs.unity3d.com/ScriptReference/TextureWrapMode.Repeat.html
I've run extensive tests to prove this problem, if I simply subtract some small float like 0.01f from the UV coordinates when they equal 1 - the texture stops repeating and problem is solved.
This is so dirty though and I need exact control over the repeating. Is the documentation simply wrong and the texture should infact start repeating if a UV component is 1 (i.e. the range is inclusive despite doc stating it's not)? This seems horrible though since you want the texture to align perfectly for 0-1 UV mapping, outside this range the texture should start repating.
Can the problem be related to the vertex teture fetch function tex2Dlod?
Your answer
Follow this Question
Related Questions
How to load a folder of textures automatically to an array of Raw Images? 2 Answers
1024x1024 Texture2D Takes up over 8MB of memory 0 Answers
Convert Texture to Texture2d takes a lot of time in android device. 0 Answers
How do I use a sliced 2D sprite as the repeating texture on a 3D object? 0 Answers
shader graph messes up the texture (2D) 0 Answers