From cde933ebd971c4d398ac118f62bd76ee243d08eb Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 18 Jan 2017 16:39:27 +0100 Subject: [PATCH] vulkan: Compute right size for outset shadow We were emitting the box and not the shadow box as the rectangle. So we didn't draw any shadows. Oops. --- gsk/resources/vulkan/outset-shadow.vert | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gsk/resources/vulkan/outset-shadow.vert b/gsk/resources/vulkan/outset-shadow.vert index 7b76e532d5..2b7c94c00f 100644 --- a/gsk/resources/vulkan/outset-shadow.vert +++ b/gsk/resources/vulkan/outset-shadow.vert @@ -17,6 +17,7 @@ layout(location = 3) out flat vec4 outOutlineCornerHeights; layout(location = 4) out flat vec4 outColor; layout(location = 5) out flat vec2 outOffset; layout(location = 6) out flat float outSpread; +layout(location = 7) out flat float outBlurRadius; out gl_PerVertex { vec4 gl_Position; @@ -29,8 +30,16 @@ vec2 offsets[6] = { vec2(0.0, 0.0), vec2(1.0, 0.0), vec2(1.0, 1.0) }; +float radius_pixels(float radius) { + return radius * (3.0 * sqrt(2 * 3.141592653589793) / 4) * 1.5; +} + void main() { - vec4 rect = clip (inOutline); + vec4 rect = inOutline; + float spread = inSpread + radius_pixels(inBlurRadius); + rect += vec4(inOffset - spread, vec2(2 * spread)); + + clip (inOutline); vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex]; gl_Position = push.mvp * vec4 (pos, 0.0, 1.0); @@ -42,4 +51,5 @@ void main() { outColor = inColor; outOffset = inOffset; outSpread = inSpread; + outBlurRadius = inBlurRadius; }