react-native-mask-segment-c.../dist/shaders/regionPaint.sksl.d.ts
a1518 acd6d3a73d feat: add MaskSegmentApp source code and config
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 00:27:28 -07:00

3 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** SkSL分区上色保留原图明暗与纹理按 paintColorMap 叠色) */
export declare const REGION_PAINT_SKSL = "\nuniform shader originTex;\nuniform shader paintColorTex;\nuniform shader lowFreqTex;\nuniform shader highFreqTex;\n\nuniform float colorBaseOpacity;\nuniform float lLightOpacity;\nuniform float textureOpacity;\nuniform float showOrigin;\n\nfloat luminance(half3 c) {\n return dot(c, half3(0.2126, 0.7152, 0.0722));\n}\n\nhalf3 setLuminance(float lum, half3 base) {\n float diff = lum - luminance(base);\n return base + diff;\n}\n\nhalf3 luminosityBlend(half3 base, half3 blend) {\n return setLuminance(luminance(blend), base);\n}\n\nhalf3 overlayBlend(half3 base, half3 blend) {\n half3 low = 2.0 * base * blend;\n half3 high = 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);\n return mix(low, high, step(half3(0.5), base));\n}\n\nhalf4 main(float2 coord) {\n half4 origin = originTex.eval(coord);\n if (showOrigin > 0.5) {\n return origin;\n }\n\n half4 paintEntry = paintColorTex.eval(coord);\n // The paintColorMap uses Unpremul alpha: painted pixels \u2192 (R,G,B,255),\n // transparent pixels \u2192 (0,0,0,0). GPU bilinear sampling interpolates\n // straight-alpha values, so at boundaries rgb = trueColor * sampled.a\n // (contaminated with black from the transparent neighbour).\n //\n // Unpremultiply to recover the true paint color:\n // trueColor = sampled.rgb / sampled.a\n // This eliminates dark fringing at region boundaries.\n float pa = paintEntry.a + 0.0001;\n paintEntry.rgb /= pa;\n\n // Gate sub-pixel alpha to kill residual sampling noise.\n // Thresholds are deliberately low (\u22481.3\u20133.8 in byte space) because\n // post-unpremul the RGB is correct at any alpha \u2265 0 \u2014 we only need\n // to suppress samples that contribute negligibly to the final blend.\n // Using *= preserves the smooth edge; higher-alpha samples pass through.\n paintEntry.a *= smoothstep(0.005, 0.015, paintEntry.a);\n\n half3 paintRgb = paintEntry.rgb;\n half lowL = lowFreqTex.eval(coord).r;\n half highL = highFreqTex.eval(coord).r;\n\n half3 base = paintRgb * colorBaseOpacity;\n half3 lit = luminosityBlend(base, half3(lowL));\n half3 withLight = mix(base, lit, lLightOpacity);\n half3 tex = overlayBlend(withLight, half3(highL));\n half3 finalRgb = mix(withLight, tex, textureOpacity);\n\n // Soft edge blend using the (feathered) alpha from the paint color map as coverage.\n half3 blended = mix(origin.rgb, finalRgb, paintEntry.a);\n return half4(blended, 1.0);\n}\n";
//# sourceMappingURL=regionPaint.sksl.d.ts.map