export declare const overlay_frag = "\nprecision highp float;\nprecision highp sampler2D;\n\nuniform vec2 uTexSizeInv;\nuniform sampler2D tEdgeTexture;\nuniform sampler2D tMaskTexture;\nuniform sampler2D tDimTexture;\nuniform vec3 uHighlightEdgeColor;\nuniform vec3 uSelectEdgeColor;\nuniform float uHighlightEdgeStrength;\nuniform float uSelectEdgeStrength;\nuniform float uGhostEdgeStrength;\nuniform bool uDepthTest;\nuniform float uInnerEdgeFactor;\nuniform vec3 uHighlightFillColor;\nuniform vec3 uSelectFillColor;\nuniform float uHighlightFillStrength;\nuniform float uSelectFillStrength;\nuniform vec3 uDimColor;\nuniform float uDimStrength;\n\nuniform sampler2D tSsaoDepth;\nuniform vec3 uOcclusionColor;\nuniform vec3 uFogColor;\nuniform bool uTransparentBackground;\nuniform vec2 uOcclusionOffset;\n\nuniform sampler2D tBase;\nuniform sampler2D tShaded;\n\n#include common\n\n// mixes toward the SSAO occlusion color, like the postprocessing pass\nvec3 applyOcclusion(const in vec3 color, const in float occlusion, const in float fogAlpha) {\n vec3 occlusionColor = uTransparentBackground ? uOcclusionColor * fogAlpha : mix(uFogColor, uOcclusionColor, fogAlpha);\n return mix(occlusionColor, color, occlusion);\n}\n\n// the path traced occlusion and shadows, i.e. the base image relative to the direct shading\nfloat getTracedShading(const in float baseLuminance, const in float shadedLuminance, const in float fogAlpha) {\n float a = max(fogAlpha, 0.001);\n // undo the fog of the base image\n float l = uTransparentBackground ? baseLuminance / a : (baseLuminance - luminance(uFogColor) * (1.0 - fogAlpha)) / a;\n return clamp(l / max(shadedLuminance, 0.001), 0.0, 1.0);\n}\n\nvoid main() {\n vec2 coords = gl_FragCoord.xy * uTexSizeInv;\n\n // coverage of the visible unmarked geometry, see dim.frag\n float dimAlpha = 0.0;\n float dimFogAlpha = 1.0;\n if (uDimStrength > 0.0) {\n vec4 d = texture2D(tDimTexture, coords);\n dimAlpha = d.r * uDimStrength;\n dimFogAlpha = d.r / max(d.g, 0.001);\n }\n\n // solid fill covering the interior of marked regions, sampled directly from the mask\n vec3 fillRgb = vec3(0.0);\n float fillAlpha = 0.0;\n float fillFogAlpha = 1.0;\n if (uHighlightFillStrength > 0.0 || uSelectFillStrength > 0.0) {\n vec4 m = texture2D(tMaskTexture, coords);\n float coverage = 1.0 - m.r;\n if (coverage > 0.0) {\n vec3 marked = clamp((m.gba - m.r) / max(coverage, 0.001), 0.0, 1.0);\n bool isHighlight = marked.y > 0.5;\n fillRgb = isHighlight ? uHighlightFillColor : uSelectFillColor;\n float fillStrength = isHighlight ? uHighlightFillStrength : uSelectFillStrength;\n fillFogAlpha = marked.z;\n // marked.x: 1.0 = hidden, 0.0 = visible; without depth test every marked texel reads as hidden\n float visibility = uDepthTest && marked.x > 0.5 ? 0.0 : 1.0;\n fillAlpha = coverage * fillStrength * visibility * fillFogAlpha * unpackMarkingOpacity(marked.x);\n }\n }\n\n // keep the shading of the image, so that blending toward the color does not wash it out\n vec3 dimRgb = uDimColor;\n if (dimAlpha > 0.0 || fillAlpha > 0.0) {\n #if defined(dMarkingShading_ssao)\n float occlusion = unpackSsao(texture2D(tSsaoDepth, coords + uOcclusionOffset));\n dimRgb = applyOcclusion(dimRgb, occlusion, dimFogAlpha);\n fillRgb = applyOcclusion(fillRgb, occlusion, fillFogAlpha);\n #elif defined(dMarkingShading_traced)\n float baseLuminance = luminance(texture2D(tBase, coords).rgb);\n float shadedLuminance = luminance(texture2D(tShaded, coords).rgb);\n dimRgb *= getTracedShading(baseLuminance, shadedLuminance, dimFogAlpha);\n fillRgb *= getTracedShading(baseLuminance, shadedLuminance, fillFogAlpha);\n #endif\n }\n\n vec4 e = texture2D(tEdgeTexture, coords);\n vec3 edgeRgb = vec3(0.0);\n float edgeAlpha = 0.0;\n if (e.a > 0.0) {\n // the edge is stored premultiplied, see edge.frag\n vec3 edgeValue = e.rgb / e.a;\n bool isHighlight = edgeValue.z > 0.5;\n edgeRgb = isHighlight ? uHighlightEdgeColor : uSelectEdgeColor;\n edgeRgb = edgeValue.y > 0.5 ? edgeRgb : edgeRgb * uInnerEdgeFactor;\n edgeAlpha = (edgeValue.x > 0.5 ? uGhostEdgeStrength : 1.0) * e.a;\n edgeAlpha *= isHighlight ? uHighlightEdgeStrength : uSelectEdgeStrength;\n }\n\n // premultiplied, so that partially covered pixels are not weighted by alpha twice; dim, fill, edge from bottom to top\n vec3 rgb = fillRgb * fillAlpha + dimRgb * dimAlpha * (1.0 - fillAlpha);\n float alpha = fillAlpha + dimAlpha * (1.0 - fillAlpha);\n gl_FragColor.rgb = edgeRgb * edgeAlpha + rgb * (1.0 - edgeAlpha);\n gl_FragColor.a = edgeAlpha + alpha * (1.0 - edgeAlpha);\n}\n";