Page MenuHome

UVs offsets when using displace-modifier
Closed, ResolvedPublic


System Information
Operating system: Windows-7-6.1.7601-SP1 64 Bits
Graphics card: GeForce GTX 970/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 416.34

Blender Version
Broken: version: 2.80 (sub 74), branch: master, commit date: 2019-07-18 14:52, hash: rB38d4483c6a51
Worked: (optional)

Short description of error
grids UVs offsets when using displace-modifier - in UV-Editing everything looks fine

Exact steps for others to reproduce the error
add > mesh > grid
F9 > grids subdivisions > X=1000 Y=1000
N > Dimension X=1.0 Y=0.8
STRG+A > apply scale
new Modifier > add DISPLACE
Displace Mod > NEW Texture > and switch to Texture-Props
Open the Image Texture (see attached file)
Switch back to Modifier-Props
Displace-Mod > set Texture-Coordinates to UV

Tex-Coordinates are offset in X by Factor 0.5 - in UV-Editing everything looks fine - in 3D UVs are offset

Event Timeline

William Reynish (billreynish) lowered the priority of this task from 90 to 30.Jul 23 2019, 8:39 PM

I cannot reproduce this. Can you create a demo blend file that demonstrates this issue?

Okay, blend file attached.
Here u see the Error in Action, switch to EditMode and you see UVs are straight... mapping is messed up.

INFO: i got the error an all different machines...

I don't understand how you created that object, since you have applied the modifiers.

When I unwrap it using UV > Unwrap from View (Bounds), it works normally. So how you got those wrong UV coords it's impossible to say.

William Reynish (billreynish) raised the priority of this task from 30 to 50.

Ah, I have now been able to reproduce this issue.

Turns out it has nothing at all to do with the displace modifier - the issue is that the Grid primitive's auto-generated UV's go bad if you have more than around 300 segments.

200 segments:

300 segments:

@Campbell Barton (campbellbarton) assigned to you but feel free to re-assign. I assume it's a precision issue somewhere.

The smallest one I could find is 13 by 3.

bpy.ops.mesh.primitive_grid_add(x_subdivisions=13, y_subdivisions=3, enter_editmode=False)

This should solve the problem. An alternative would be to introduce a counter.

diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c
index cf3d6b8bf56..bea437d63d0 100644
--- a/source/blender/bmesh/operators/bmo_primitive.c
+++ b/source/blender/bmesh/operators/bmo_primitive.c
@@ -807,6 +807,7 @@ void BM_mesh_calc_uvs_grid(BMesh *bm,

   const float dx = 1.0f / (float)(x_segments - 1);
   const float dy = 1.0f / (float)(y_segments - 1);
+  const float dx_half = dx / 2.0f;
   float x = 0.0f;
   float y = dy;

@@ -844,7 +845,7 @@ void BM_mesh_calc_uvs_grid(BMesh *bm,

     x += dx;
-    if (x >= 1.0f) {
+    if (x + dx_half >= 1.0) {
       x = 0.0f;
       y += dy;