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
This commit is contained in:
Jeroen Bakker 2019-12-18 16:10:01 +01:00
parent 0971f56bac
commit 4440739699
Notes: blender-bot 2023-02-14 05:41:57 +01:00
Referenced by issue #93084, blender uv stretch with area show full red (on large scale mesh)
Referenced by issue #72236, UV Stretching Area overlay fails when object has small dimensions
2 changed files with 3 additions and 3 deletions

View File

@ -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. */

View File

@ -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