GPU: Ensure Absolute Ratio During SDF-Widget Drawing

In the GPU_SHADER_2D_WIDGET_BASE the deriviates were assumed to be
positive. This is not always the case. In Vulkan this leads to
incorrect rendering of the widgets due to incorrect SDF values.

This change will ensure that the shader make the ratio variable
absolute.

Pull Request: https://projects.blender.org/blender/blender/pulls/107327
This commit is contained in:
Jeroen Bakker
2023-04-25 12:08:43 +02:00
parent eda88466ee
commit 5fde2b34ba

View File

@@ -8,7 +8,7 @@ vec3 compute_masks(vec2 uv)
/* Correct aspect ratio for 2D views not using uniform scaling.
* uv is already in pixel space so a uniform scale should give us a ratio of 1. */
float ratio = (butCo != -2.0) ? (dFdy(uv.y) / dFdx(uv.x)) : 1.0;
float ratio = (butCo != -2.0) ? abs(dFdy(uv.y) / dFdx(uv.x)) : 1.0;
vec2 uv_sdf = uv;
uv_sdf.x *= ratio;