export declare enum Location { BARYCENTRIC = 0, FRAG_COORD = 1, ABCD = 2, TXTY = 3, POSITION_SIZE = 4, ZINDEX_STROKE_WIDTH = 5, DROP_SHADOW_COLOR = 6, DROP_SHADOW = 7 } export declare const vert = "\nlayout(std140) uniform SceneUniforms {\n mat3 u_ProjectionMatrix;\n mat3 u_ViewMatrix;\n mat3 u_ViewProjectionInvMatrix;\n vec4 u_BackgroundColor;\n vec4 u_GridColor;\n float u_ZoomScale;\n float u_CheckboardStyle;\n};\n\n\n#ifdef USE_WIREFRAME\n layout(location = 0) in vec3 a_Barycentric;\n out vec3 v_Barycentric;\n#endif\n\nlayout(location = 1) in vec2 a_FragCoord;\n\n#ifdef USE_INSTANCES\n layout(location = 2) in vec4 a_Abcd;\n layout(location = 3) in vec2 a_Txty;\n layout(location = 4) in vec4 a_PositionSize;\n layout(location = 5) in vec4 a_ZIndexStrokeWidth;\n layout(location = 6) in vec4 a_DropShadowColor;\n layout(location = 7) in vec4 a_DropShadow;\n#else\n layout(std140) uniform ShapeUniforms {\n mat3 u_ModelMatrix;\n vec4 u_PositionSize;\n vec4 u_ZIndexStrokeWidth;\n vec4 u_DropShadowColor;\n vec4 u_DropShadow;\n };\n#endif\n\nout vec2 v_Origin;\n#ifdef USE_INSTANCES\n out float v_CornerRadius;\n out vec4 v_DropShadowColor;\n out vec4 v_DropShadow;\n#else\n#endif\nout vec2 v_Size;\nout vec2 v_Point;\n\nvoid main() {\n \n#ifdef USE_WIREFRAME\n v_Barycentric = a_Barycentric;\n#endif\n\n\n mat3 model;\n vec2 origin;\n vec2 size;\n float zIndex;\n vec4 dropShadow;\n float sizeAttenuation;\n\n #ifdef USE_INSTANCES\n model = mat3(a_Abcd.x, a_Abcd.y, 0, a_Abcd.z, a_Abcd.w, 0, a_Txty.x, a_Txty.y, 1);\n origin = a_PositionSize.xy;\n size = a_PositionSize.zw;\n zIndex = a_ZIndexStrokeWidth.x;\n dropShadow = a_DropShadow;\n sizeAttenuation = a_ZIndexStrokeWidth.w;\n v_CornerRadius = a_ZIndexStrokeWidth.z;\n v_DropShadowColor = a_DropShadowColor;\n v_DropShadow = dropShadow;\n #else\n model = u_ModelMatrix;\n origin = u_PositionSize.xy;\n size = u_PositionSize.zw;\n zIndex = u_ZIndexStrokeWidth.x;\n dropShadow = u_DropShadow;\n sizeAttenuation = u_ZIndexStrokeWidth.w;\n #endif\n\n float scale = 1.0;\n if (sizeAttenuation > 0.5) {\n scale = 1.0 / u_ZoomScale;\n }\n\n // Set the bounds of the shadow and adjust its size based on the shadow's\n // spread radius to achieve the spreading effect\n float margin = 3.0 * dropShadow.z;\n\n vec2 center = origin + size / 2.0;\n vec2 sizeSign = sign(size);\n size = abs(size);\n\n // Recalculate the origin since the size could be negative\n origin = center - size / 2.0 + dropShadow.xy * sizeSign;\n v_Size = size;\n v_Origin = origin;\n\n origin -= margin;\n size += 2.0 * margin;\n \n v_Point = center + a_FragCoord * (size / 2.0);\n\n gl_Position = vec4((u_ProjectionMatrix \n * u_ViewMatrix\n * model \n * vec3(center + a_FragCoord * (size / 2.0) * scale, 1)).xy, zIndex, 1);\n}\n"; export declare const frag = "\nlayout(std140) uniform SceneUniforms {\n mat3 u_ProjectionMatrix;\n mat3 u_ViewMatrix;\n mat3 u_ViewProjectionInvMatrix;\n vec4 u_BackgroundColor;\n vec4 u_GridColor;\n float u_ZoomScale;\n float u_CheckboardStyle;\n};\n\n#ifdef USE_INSTANCES\n#else\n layout(std140) uniform ShapeUniforms {\n mat3 u_ModelMatrix;\n vec4 u_PositionSize;\n vec4 u_ZIndexStrokeWidth;\n vec4 u_DropShadowColor;\n vec4 u_DropShadow;\n };\n#endif\n\nout vec4 outputColor;\n\n\n#ifdef USE_WIREFRAME\n in vec3 v_Barycentric;\n\n float edgeFactor() {\n float u_WireframeLineWidth = 1.0;\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * u_WireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n }\n#endif\n\nin vec2 v_Origin;\n#ifdef USE_INSTANCES\n in float v_CornerRadius;\n in vec4 v_DropShadowColor;\n in vec4 v_DropShadow;\n#else\n#endif\nin vec2 v_Size;\nin vec2 v_Point;\n\nfloat epsilon = 0.000001;\nfloat PI = 3.1415926;\n\n// A standard gaussian function, used for weighting samples\nfloat gaussian(float x, float sigma) {\n return exp(-(x * x) / (2. * sigma * sigma)) / (sqrt(2. * PI) * sigma);\n}\n\n// This approximates the error function, needed for the gaussian integral\nvec2 erf(vec2 x) {\n vec2 s = sign(x), a = abs(x);\n x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a;\n x *= x;\n return s - s / (x * x);\n}\n\n// @see https://raphlinus.github.io/graphics/2020/04/21/blurred-rounded-rects.html\n// vec2 erf7(vec2 x) {\n// x = x * sqrt(2. * PI);\n// vec2 xx = x * x;\n// x = x + (0.24295 + (0.03395 + 0.0104 * xx) * xx) * (x * xx);\n// return x / sqrt(1.0 + x * x);\n// }\n\nfloat rect_shadow(vec2 pixel_position, vec2 origin, vec2 size, float sigma) {\n vec2 bottom_right = origin + size;\n vec2 x_distance = vec2(pixel_position.x - origin.x, pixel_position.x - bottom_right.x);\n vec2 y_distance = vec2(pixel_position.y - origin.y, pixel_position.y - bottom_right.y);\n vec2 integral_x = 0.5 + 0.5 * erf(x_distance * (sqrt(0.5) / sigma));\n vec2 integral_y = 0.5 + 0.5 * erf(y_distance * (sqrt(0.5) / sigma));\n return (integral_x.x - integral_x.y) * (integral_y.x - integral_y.y);\n}\n\nfloat blur_along_x(float x, float y, float sigma, float corner, vec2 half_size) {\n float delta = min(half_size.y - corner - abs(y), 0.0);\n float curved = half_size.x - corner + sqrt(max(0., corner * corner - delta * delta));\n vec2 integral = 0.5 + 0.5 * erf((x + vec2(-curved, curved)) * (sqrt(0.5) / sigma));\n return integral.y - integral.x;\n}\n\nvoid main() {\n float cornerRadius;\n vec4 dropShadow;\n vec4 dropShadowColor;\n \n #ifdef USE_INSTANCES\n cornerRadius = v_CornerRadius;\n dropShadowColor = v_DropShadowColor;\n dropShadow = v_DropShadow;\n #else\n cornerRadius = u_ZIndexStrokeWidth.z;\n dropShadowColor = u_DropShadowColor;\n dropShadow = u_DropShadow;\n #endif\n\n float blur_radius = dropShadow.z;\n if (blur_radius > 0.0) {\n float alpha = 0.;\n vec2 point = v_Point;\n \n if (cornerRadius > 0.0) {\n vec2 half_size = v_Size / 2.0;\n vec2 center = v_Origin + half_size;\n vec2 center_to_point = point - center;\n\n // The signal is only non-zero in a limited range, so don't waste samples\n float low = center_to_point.y - half_size.y;\n float high = center_to_point.y + half_size.y;\n float start = clamp(-3. * blur_radius, low, high);\n float end = clamp(3. * blur_radius, low, high);\n\n // Accumulate samples (we can get away with surprisingly few samples)\n float step = (end - start) / 4.;\n float y = start + step * 0.5;\n \n for (int i = 0; i < 4; i++) {\n alpha += blur_along_x(center_to_point.x, center_to_point.y - y, blur_radius,\n cornerRadius, half_size) *\n gaussian(y, blur_radius) * step;\n y += step;\n }\n } else {\n alpha = rect_shadow(point, v_Origin, v_Size, blur_radius);\n }\n\n outputColor = dropShadowColor;\n outputColor.a = alpha;\n\n \n#ifdef USE_WIREFRAME\n vec3 u_WireframeLineColor = vec3(0.0, 0.0, 0.0);\n\n outputColor.xyz = mix(outputColor.xyz, u_WireframeLineColor, (1.0 - edgeFactor()));\n if (any(lessThan(v_Barycentric, vec3(0.01)))) {\n outputColor.a = 0.95;\n }\n#endif\n\n } else {\n discard;\n }\n}\n";