export declare enum Location { BARYCENTRIC = 0, POSITION = 1, UV_OFFSET = 2 } 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\nlayout(std140) uniform ShapeUniforms {\n mat3 u_ModelMatrix;\n vec4 u_FillColor;\n vec4 u_StrokeColor;\n vec4 u_ZIndexStrokeWidth;\n vec4 u_Opacity;\n vec4 u_DropShadowColor;\n vec4 u_DropShadow;\n vec2 u_AtlasSize;\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 vec3 a_Position;\nlayout(location = 2) in vec4 a_UvOffset;\n\nout vec2 v_Uv;\n\nvoid main() {\n \n#ifdef USE_WIREFRAME\n v_Barycentric = a_Barycentric;\n#endif\n\n\n #ifdef USE_INSTANCES\n float zIndex = a_Position.z;\n #else\n float zIndex = u_ZIndexStrokeWidth.x;\n #endif\n\n float strokeWidth = u_ZIndexStrokeWidth.y;\n float fontSize = u_ZIndexStrokeWidth.z;\n float sizeAttenuation = u_Opacity.w;\n\n float scale = 1.0;\n if (sizeAttenuation > 0.5) {\n scale = 1.0 / u_ZoomScale;\n }\n\n v_Uv = a_UvOffset.xy / u_AtlasSize;\n vec2 offset = a_UvOffset.zw;\n\n gl_Position = vec4((u_ProjectionMatrix \n * u_ViewMatrix\n * u_ModelMatrix \n * vec3(a_Position.xy + offset * 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\nlayout(std140) uniform ShapeUniforms {\n mat3 u_ModelMatrix;\n vec4 u_FillColor;\n vec4 u_StrokeColor;\n vec4 u_ZIndexStrokeWidth;\n vec4 u_Opacity;\n vec4 u_DropShadowColor;\n vec4 u_DropShadow;\n vec2 u_AtlasSize;\n};\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_Uv;\nuniform sampler2D u_Texture;\n\nfloat epsilon = 0.000001;\n\nfloat median(float r, float g, float b) {\n return max(min(r, g), min(max(r, g), b));\n}\n\n#define SDF_PX 8.0\n\nvoid main() {\n float strokeWidth = u_ZIndexStrokeWidth.y;\n vec4 fillColor = u_FillColor;\n vec4 strokeColor = u_StrokeColor;\n float opacity = u_Opacity.x;\n float fillOpacity = u_Opacity.y;\n float strokeOpacity = u_Opacity.z;\n float shapeSizeAttenuation = u_Opacity.w;\n vec4 dropShadow = u_DropShadow;\n vec4 dropShadowColor = u_DropShadowColor;\n float shadowDist;\n float shadowBlurRadius = u_DropShadow.z;\n \n #ifdef USE_SDF_NONE\n outputColor = texture(SAMPLER_2D(u_Texture), v_Uv);\n #else\n float dist;\n lowp float buff;\n vec2 shadowOffset = u_DropShadow.xy / u_AtlasSize;\n\n #ifdef USE_SDF\n #ifdef USE_EMOJI\n fillColor = texture(SAMPLER_2D(u_Texture), v_Uv);\n #endif\n dist = texture(SAMPLER_2D(u_Texture), v_Uv).a;\n buff = (256.0 - 64.0) / 256.0;\n\n #ifdef USE_SHADOW\n shadowDist = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).a;\n #endif\n #endif\n\n #ifdef USE_MSDF\n vec3 s = texture(SAMPLER_2D(u_Texture), v_Uv).rgb;\n dist = median(s.r, s.g, s.b);\n buff = 0.5;\n\n #ifdef USE_SHADOW\n vec3 shadowSample = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).rgb;\n shadowDist = median(shadowSample.r, shadowSample.g, shadowSample.b);\n #endif\n #endif\n\n float fontSize = u_ZIndexStrokeWidth.z;\n fillColor.a *= fillOpacity;\n strokeColor.a *= strokeOpacity;\n\n highp float gamma_scaled = fwidth(dist);\n if (strokeWidth > 0.0 && strokeColor.a > 0.0) {\n float fillAlpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); \n float strokeThreshold = buff - strokeWidth / fontSize;\n float strokeAlpha = smoothstep(strokeThreshold - gamma_scaled, strokeThreshold + gamma_scaled, dist);\n\n vec4 finalColor = mix(strokeColor, fillColor, fillAlpha);\n outputColor = finalColor;\n opacity *= strokeAlpha;\n } else {\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n opacity *= alpha;\n outputColor = fillColor;\n }\n #endif\n \n outputColor.a *= opacity;\n\n #ifdef USE_SHADOW \n // gamma_scaled = fwidth(shadowDist) * 128.0 / shadowBlurRadius;\n gamma_scaled = shadowBlurRadius / 128.0;\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, shadowDist);\n dropShadowColor.a *= alpha;\n outputColor = mix(dropShadowColor, outputColor, outputColor.a);\n #endif\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\n if (outputColor.a < epsilon)\n discard;\n}\n"; export declare const physical_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\nlayout(std140) uniform ShapeUniforms {\n mat3 u_ModelMatrix;\n vec4 u_FillColor;\n vec4 u_StrokeColor;\n vec4 u_ZIndexStrokeWidth;\n vec4 u_Opacity;\n vec4 u_DropShadowColor;\n vec4 u_DropShadow;\n vec2 u_AtlasSize;\n};\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_Uv;\nuniform sampler2D u_Texture;\n\nfloat epsilon = 0.000001;\n\nfloat median(float r, float g, float b) {\n return max(min(r, g), min(max(r, g), b));\n}\n\n\n \n \n float aastep(float threshold, float value) {\n float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757;\n return smoothstep(threshold - afwidth, threshold + afwidth, value);\n }\n\n \n vec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n \n vec2 mod289(vec2 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n \n vec3 permute(vec3 x) {\n return mod289(((x*34.0)+1.0)*x);\n }\n \n float snoise(vec2 v)\n {\n const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0\n 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)\n -0.577350269189626, // -1.0 + 2.0 * C.x\n 0.024390243902439); // 1.0 / 41.0\n // First corner\n vec2 i = floor(v + dot(v, C.yy) );\n vec2 x0 = v - i + dot(i, C.xx);\n \n // Other corners\n vec2 i1;\n //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0\n //i1.y = 1.0 - i1.x;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n // x0 = x0 - 0.0 + 0.0 * C.xx ;\n // x1 = x0 - i1 + 1.0 * C.xx ;\n // x2 = x0 - 1.0 + 2.0 * C.xx ;\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n \n // Permutations\n i = mod289(i); // Avoid truncation effects in permutation\n vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))\n + i.x + vec3(0.0, i1.x, 1.0 ));\n \n vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);\n m = m*m ;\n m = m*m ;\n \n // Gradients: 41 points uniformly over a line, mapped onto a diamond.\n // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)\n \n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n \n // Normalise gradients implicitly by scaling m\n // Approximation of: m *= inversesqrt( a0*a0 + h*h );\n m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );\n \n // Compute final noise value at P\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n }\n float absorb(float sdf, vec2 uv, float scale, float falloff) {\n float distort = sdf + snoise(uv * scale) * falloff;\n return aastep(0.5, distort);\n }\n\n\n // float ink(float sdf, vec2 uv) {\n // float alpha = 0.0;\n // alpha += absorb(sdf, uv, 1000.0, 0.1) * 0.3;\n // alpha += absorb(sdf, uv, 50.0, 0.2) * 0.3;\n // alpha += absorb(sdf, uv, 500.0, 0.2) * 0.3;\n // return alpha;\n // }\n\n // float ink(float sdf, vec2 uv) {\n // float alpha = 0.0;\n // alpha += absorb(sdf, uv, 80.0, 0.02) * 0.1;\n // alpha += absorb(sdf, uv, 50.0, 0.02) * 0.1;\n // alpha += absorb(sdf, uv, 500.0, 0.05) * 0.2;\n // alpha += absorb(sdf, uv, 1000.0, 0.05) * 0.2;\n // alpha += absorb(sdf, uv, 3000.0, 0.1) * 0.2;\n // alpha += absorb(sdf, uv, 1000.0, 0.3) * 0.15;\n // return alpha;\n // }\n \n float ink(float sdf, vec2 uv) {\n float alpha = 0.0;\n alpha += absorb(sdf, uv, 600.0, 0.1) * 0.2;\n alpha += absorb(sdf, uv, 300.0, 0.1) * 0.2;\n alpha += absorb(sdf, uv, 20.0, 0.05) * 0.2;\n alpha += absorb(sdf, uv, 400.0, 0.05) * 0.2;\n alpha += absorb(sdf, uv, 100.0, 0.2) * 0.2;\n return alpha;\n }\n\n\n#define SDF_PX 8.0\n\nvoid main() {\n float strokeWidth = u_ZIndexStrokeWidth.y;\n vec4 fillColor = u_FillColor;\n vec4 strokeColor = u_StrokeColor;\n float opacity = u_Opacity.x;\n float fillOpacity = u_Opacity.y;\n float strokeOpacity = u_Opacity.z;\n float shapeSizeAttenuation = u_Opacity.w;\n vec4 dropShadow = u_DropShadow;\n vec4 dropShadowColor = u_DropShadowColor;\n float shadowDist;\n float shadowBlurRadius = u_DropShadow.z;\n \n #ifdef USE_SDF_NONE\n outputColor = texture(SAMPLER_2D(u_Texture), v_Uv);\n #else\n float dist;\n lowp float buff;\n vec2 shadowOffset = u_DropShadow.xy / u_AtlasSize;\n\n #ifdef USE_SDF\n #ifdef USE_EMOJI\n fillColor = texture(SAMPLER_2D(u_Texture), v_Uv);\n #endif\n dist = texture(SAMPLER_2D(u_Texture), v_Uv).a;\n buff = (256.0 - 64.0) / 256.0;\n\n #ifdef USE_SHADOW\n shadowDist = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).a;\n #endif\n #endif\n\n #ifdef USE_MSDF\n vec3 s = texture(SAMPLER_2D(u_Texture), v_Uv).rgb;\n dist = median(s.r, s.g, s.b);\n buff = 0.5;\n\n #ifdef USE_SHADOW\n vec3 shadowSample = texture(SAMPLER_2D(u_Texture), v_Uv - shadowOffset).rgb;\n shadowDist = median(shadowSample.r, shadowSample.g, shadowSample.b);\n #endif\n #endif\n\n float fontSize = u_ZIndexStrokeWidth.z;\n\n highp float gamma_scaled;\n highp float alpha = ink(dist - 0.2, v_Uv);\n \n opacity *= alpha;\n\n outputColor = fillColor;\n #endif\n \n outputColor.a *= opacity;\n\n #ifdef USE_SHADOW \n // gamma_scaled = fwidth(shadowDist) * 128.0 / shadowBlurRadius;\n gamma_scaled = shadowBlurRadius / 128.0;\n alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, shadowDist);\n dropShadowColor.a *= alpha;\n outputColor = mix(dropShadowColor, outputColor, outputColor.a);\n #endif\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\n if (outputColor.a < epsilon)\n discard;\n}\n";