[Bf-blender-cvs] [4440739699b] master: Fix T72236: UV Stretching Overlay

Jeroen Bakker noreply at git.blender.org
Thu Dec 19 08:35:28 CET 2019


Commit: 4440739699bb237da8126168117e501aec770e89
Author: Jeroen Bakker
Date:   Wed Dec 18 16:10:01 2019 +0100
Branches: master
https://developer.blender.org/rB4440739699bb237da8126168117e501aec770e89

Fix T72236: UV Stretching Overlay

The ratio for area stretching was packed into an unsigned int, but could
contain negative numbers. This flipped the negative numbers to high
positive numbers and rendered the wrong color in the stretching overlay.

I can remember during {T63755} I had to flip the sign to get the
correct result, but couldn't find out why that was needed. Now I know.

Reviewed By: fclem, mano-wii

Differential Revision: https://developer.blender.org/D6440

===================================================================

M	source/blender/draw/intern/draw_cache_extract_mesh.c
M	source/blender/gpu/shaders/gpu_shader_2D_edituvs_stretch_vert.glsl

===================================================================

diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index 7d0cb7c7076..4bd0aac1ecc 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -2721,7 +2721,7 @@ static void *extract_stretch_area_init(const MeshRenderData *mr, void *buf)
 {
   static GPUVertFormat format = {0};
   if (format.attr_len == 0) {
-    GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_U16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
+    GPU_vertformat_attr_add(&format, "ratio", GPU_COMP_I16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
   }
 
   GPUVertBuf *vbo = buf;
@@ -2788,7 +2788,7 @@ static void mesh_stretch_area_finish(const MeshRenderData *mr, void *buf, void *
   /* Convert in place to avoid an extra allocation */
   uint16_t *poly_stretch = (uint16_t *)area_ratio;
   for (int p = 0; p < mr->poly_len; p++) {
-    poly_stretch[p] = area_ratio[p] * 65534.0f;
+    poly_stretch[p] = area_ratio[p] * SHRT_MAX;
   }
 
   /* Copy face data for each loop. */
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_edituvs_stretch_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_edituvs_stretch_vert.glsl
index b0fa9eaed21..3254a7e1508 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_edituvs_stretch_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_edituvs_stretch_vert.glsl
@@ -90,7 +90,7 @@ void main()
   stretch = stretch;
   stretch = 1.0 - stretch * stretch;
 #else
-  float stretch = 1.0 - area_ratio_to_stretch(ratio, totalAreaRatio, -totalAreaRatioInv);
+  float stretch = 1.0 - area_ratio_to_stretch(ratio, totalAreaRatio, totalAreaRatioInv);
 
 #endif



More information about the Bf-blender-cvs mailing list