@cesdk/node-native 1.77.0-nightly.20260610
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +137 -0
- package/README.md +474 -0
- package/ThirdPartyLicenses.md +1041 -0
- package/assets/ly.img.cesdk/fonts/imgly_font_inter_semibold.otf +0 -0
- package/assets/ly.img.cesdk/icons/ErrorAudio.svg +5 -0
- package/assets/ly.img.cesdk/icons/ErrorConnection.svg +5 -0
- package/assets/ly.img.cesdk/icons/ErrorImage.svg +6 -0
- package/assets/ly.img.cesdk/icons/ErrorUnknown.svg +3 -0
- package/assets/ly.img.cesdk/icons/ErrorVideo.svg +6 -0
- package/assets/ly.img.cesdk/icons/Move.svg +3 -0
- package/assets/ly.img.cesdk/icons/RotateIndicator.svg +5 -0
- package/assets/ly.img.cesdk/icu/icudt74l.dat +0 -0
- package/assets/ly.img.cesdk/presets/.keep +0 -0
- package/assets/ly.img.cesdk/shaders/adjustments.sksl +106 -0
- package/assets/ly.img.cesdk/shaders/black_and_white_color_mixer.sksl +152 -0
- package/assets/ly.img.cesdk/shaders/common/ubq_adjustments.sksl +102 -0
- package/assets/ly.img.cesdk/shaders/common/ubq_color_conversions.sksl +354 -0
- package/assets/ly.img.cesdk/shaders/common/ubq_constants.sksl +13 -0
- package/assets/ly.img.cesdk/shaders/common/ubq_hue_constants.sksl +86 -0
- package/assets/ly.img.cesdk/shaders/common/ubq_noise.sksl +82 -0
- package/assets/ly.img.cesdk/shaders/cross_cut.sksl +38 -0
- package/assets/ly.img.cesdk/shaders/dot_pattern.sksl +29 -0
- package/assets/ly.img.cesdk/shaders/duotone_filter.sksl +26 -0
- package/assets/ly.img.cesdk/shaders/extrude_blur.sksl +85 -0
- package/assets/ly.img.cesdk/shaders/glow.sksl +31 -0
- package/assets/ly.img.cesdk/shaders/half_tone.sksl +14 -0
- package/assets/ly.img.cesdk/shaders/linocut.sksl +30 -0
- package/assets/ly.img.cesdk/shaders/liquid.sksl +19 -0
- package/assets/ly.img.cesdk/shaders/lut_filter.sksl +70 -0
- package/assets/ly.img.cesdk/shaders/mask_color.sksl +16 -0
- package/assets/ly.img.cesdk/shaders/mirror.sksl +21 -0
- package/assets/ly.img.cesdk/shaders/outliner.sksl +40 -0
- package/assets/ly.img.cesdk/shaders/pixelize.sksl +10 -0
- package/assets/ly.img.cesdk/shaders/placeholder_overlay_lines.sksl +18 -0
- package/assets/ly.img.cesdk/shaders/posterize.sksl +8 -0
- package/assets/ly.img.cesdk/shaders/radial_pixel.sksl +22 -0
- package/assets/ly.img.cesdk/shaders/recolor.sksl +57 -0
- package/assets/ly.img.cesdk/shaders/sharpie.sksl +74 -0
- package/assets/ly.img.cesdk/shaders/shifter.sksl +22 -0
- package/assets/ly.img.cesdk/shaders/tiltshift.sksl +21 -0
- package/assets/ly.img.cesdk/shaders/tv_glitch.sksl +25 -0
- package/assets/ly.img.cesdk/shaders/vignette.sksl +12 -0
- package/example.js +31 -0
- package/lib/index.d.ts +4072 -0
- package/lib/index.js +4922 -0
- package/lib/index.js.map +7 -0
- package/package.json +59 -0
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M19.0338 16.2054C19.6279 15.6572 20 14.8721 20 14V3L8.48552 5.65709L10.5168 7.68836L18 5.96152V11.1707C17.6872 11.0602 17.3506 11 17 11C16.1279 11 15.3428 11.3721 14.7946 11.9662L19.0338 16.2054Z" fill="#282F35"/>
|
|
3
|
+
<path d="M7 10.4147L9 12.4147V17C9 18.6569 7.65685 20 6 20C4.34315 20 3 18.6569 3 17C3 15.3431 4.34315 14 6 14C6.35064 14 6.68722 14.0602 7 14.1707V10.4147Z" fill="#282F35"/>
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.2914 22.7086L1.29135 4.70865L2.70557 3.29443L20.7056 21.2944L19.2914 22.7086Z" fill="#282F35"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M21.5381 16.7097C21.8351 16.0334 22 15.286 22 14.5C22 12.3572 20.7746 10.5006 18.9864 9.59278C18.777 6.46898 16.1769 4 13 4C11.8111 4 10.703 4.34579 9.7707 4.94227L11.2369 6.40851C11.7692 6.14682 12.3678 6 13 6C15.1171 6 16.8514 7.64592 16.9909 9.72652L17.0669 10.8613L18.081 11.3761C19.2239 11.9564 20 13.1393 20 14.5C20 14.7105 19.9814 14.9168 19.9457 15.1173L21.5381 16.7097Z" fill="#282F35"/>
|
|
3
|
+
<path d="M16.5853 18L18.2881 19.7028C18.1932 19.7354 18.0972 19.7655 18 19.793V20H8C4.68629 20 2 17.3137 2 14C2 11.125 4.02214 8.72222 6.72175 8.13645L8.50391 9.91861L7.5498 10.0249C5.55352 10.2472 4 11.9436 4 14C4 16.2091 5.79086 18 8 18H16.5853Z" fill="#282F35"/>
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.2914 21.7086L2.29135 3.70865L3.70557 2.29443L21.7056 20.2944L20.2914 21.7086Z" fill="#282F35"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M21 16.1716V6C21 4.34315 19.6569 3 18 3H7.82843L9.82843 5H18C18.5523 5 19 5.44772 19 6L19 12.1429L16.6479 8.11066C16.3584 7.61453 15.6416 7.61453 15.3522 8.11066L14.4631 9.63472L21 16.1716Z" fill="#282F35"/>
|
|
3
|
+
<path d="M10.6202 12.0349L7.46517 8.87987C7.17344 9.25931 7 9.73442 7 10.25C7 11.4927 8.00736 12.5 9.25 12.5C9.76562 12.5 10.2407 12.3266 10.6202 12.0349Z" fill="#282F35"/>
|
|
4
|
+
<path d="M5 18V6.4147L3.29221 4.70691C3.10489 5.09847 3 5.53698 3 6V18C3 19.6569 4.34315 21 6 21H18C18.463 21 18.9015 20.8951 19.2931 20.7078L12.163 13.5778L9.00007 19H6C5.44772 19 5 18.5523 5 18Z" fill="#282F35"/>
|
|
5
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.2914 21.7086L2.29135 3.70865L3.70557 2.29443L21.7056 20.2944L20.2914 21.7086Z" fill="#282F35"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.1651 1.5C13.2028 -0.166667 10.7972 -0.166666 9.83496 1.5L0.525189 17.625C-0.437061 19.2917 0.765754 21.375 2.69025 21.375H21.3098C23.2343 21.375 24.4371 19.2917 23.4749 17.625L14.1651 1.5ZM11.7264 15.3062C12.306 15.3062 12.7441 14.827 12.9215 14.2751C12.9295 14.2505 12.9377 14.2261 12.9463 14.2021C13.0625 13.8923 13.2783 13.5962 13.5938 13.314C13.959 12.9709 14.2938 12.6388 14.5981 12.3179C14.9025 11.9969 15.1488 11.651 15.3369 11.2803C15.5251 10.904 15.6191 10.4751 15.6191 9.99365C15.6191 9.30192 15.4725 8.71533 15.1792 8.23389C14.8859 7.74691 14.4626 7.37891 13.9092 7.12988C13.3558 6.87533 12.6917 6.74805 11.917 6.74805C11.2142 6.74805 10.5806 6.86979 10.0161 7.11328C9.45166 7.35124 9.00065 7.71924 8.66309 8.21729C8.54545 8.39177 8.44762 8.58293 8.36958 8.79076C8.11326 9.47333 8.7398 10.0933 9.46892 10.0933H9.68384C10.163 10.0933 10.4985 9.67309 10.7466 9.26318C10.8794 9.0529 11.0482 8.89795 11.2529 8.79834C11.4577 8.6932 11.679 8.64062 11.917 8.64062C12.2048 8.64062 12.4427 8.69596 12.6309 8.80664C12.8245 8.91732 12.9684 9.08057 13.0625 9.29639C13.1621 9.50667 13.2119 9.7723 13.2119 10.0933C13.2119 10.37 13.1566 10.6217 13.0459 10.8486C12.9352 11.07 12.783 11.2858 12.5894 11.4961C12.3957 11.7064 12.1688 11.9277 11.9087 12.1602C11.5988 12.4479 11.3498 12.7384 11.1616 13.0317C10.979 13.325 10.849 13.6543 10.7715 14.0195C10.7574 14.0899 10.7446 14.163 10.7331 14.2387C10.6442 14.8216 11.1368 15.3062 11.7264 15.3062ZM10.7715 16.9912C10.528 17.2236 10.4062 17.5169 10.4062 17.8711C10.4062 18.2142 10.528 18.5047 10.7715 18.7427C11.015 18.9806 11.3415 19.0996 11.751 19.0996C12.1549 19.0996 12.4787 18.9806 12.7222 18.7427C12.9712 18.5047 13.0957 18.2142 13.0957 17.8711C13.0957 17.5169 12.9712 17.2236 12.7222 16.9912C12.4787 16.7533 12.1549 16.6343 11.751 16.6343C11.3415 16.6343 11.015 16.7533 10.7715 16.9912Z" fill="#282F35"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M21 16.1716V7.40139C21 6.80237 20.3324 6.44507 19.834 6.77735L16.9995 8.66698V12.1711L21 16.1716Z" fill="#282F35"/>
|
|
3
|
+
<path d="M15 10.1716V9C15 7.34315 13.6569 6 12 6H10.8284L15 10.1716Z" fill="#282F35"/>
|
|
4
|
+
<path d="M6 8H6.5853L4.82439 6.2391C3.75184 6.69638 3 7.76039 3 9V15C3 16.6569 4.34315 18 6 18H12C13.2396 18 14.3036 17.2482 14.7609 16.1756L13 14.4147V15C13 15.5523 12.5523 16 12 16H6C5.44772 16 5 15.5523 5 15V9C5 8.44772 5.44772 8 6 8Z" fill="#282F35"/>
|
|
5
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.2914 21.7086L2.29135 3.70865L3.70557 2.29443L21.7056 20.2944L20.2914 21.7086Z" fill="#282F35"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M10.8048 3.52862L8.47146 1.19526C8.34644 1.07024 8.17687 1 8.00005 1C7.82324 1 7.65367 1.07024 7.52865 1.19526L5.19531 3.52862L6.13813 4.47142L7.33334 3.2762L7.33333 7.33333H3.2762L4.47142 6.13813L3.52862 5.19531L1.19526 7.52865C1.07024 7.65367 1 7.82324 1 8.00005C1 8.17686 1.07024 8.34643 1.19526 8.47146L3.52862 10.8048L4.47142 9.86198L3.2761 8.66667H7.33333V12.7238L6.13812 11.5286L5.19531 12.4714L7.52865 14.8047C7.65367 14.9298 7.82324 15 8.00005 15C8.17686 15 8.34643 14.9298 8.47146 14.8047L10.8048 12.4714L9.86198 11.5286L8.66667 12.7239V8.66667L12.7239 8.66669L11.5286 9.862L12.4714 10.8048L14.8048 8.47148C14.9298 8.34645 15 8.17688 15 8.00007C15 7.82326 14.9298 7.65369 14.8048 7.52867L12.4714 5.19533L11.5286 6.13814L12.7238 7.33335L8.66667 7.33333L8.66667 3.2761L9.86198 4.47142L10.8048 3.52862Z" fill="#3355FF"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M13.7465 1.3335H12.4131V3.38992C10.8127 1.86067 8.45977 1.20748 6.18428 1.88295C3.40989 2.70652 1.61656 5.24804 1.61768 8.0003L2.95101 7.99976C2.95012 5.82173 4.37074 3.81213 6.56371 3.16116C8.397 2.61695 10.2961 3.16285 11.5637 4.42367L9.46792 4.80456L9.70633 6.1164L13.7465 5.38215V1.3335Z" fill="#3355FF"/>
|
|
3
|
+
<path d="M13.0486 8.00057C13.0495 10.1786 11.6289 12.1882 9.43593 12.8392C7.6027 13.3834 5.7037 12.8375 4.43604 11.5768L6.53177 11.1958L6.29327 9.88393L2.25379 10.6183L2.25379 14.6668H3.58712V12.611C5.18758 14.1398 7.54017 14.7928 9.81536 14.1174C12.5897 13.2938 14.3831 10.7523 14.382 8.00003L13.0486 8.00057Z" fill="#3355FF"/>
|
|
4
|
+
<path d="M7.99984 9.3335C7.26346 9.3335 6.6665 8.73654 6.6665 8.00016C6.6665 7.26378 7.26346 6.66683 7.99984 6.66683C8.73622 6.66683 9.33317 7.26378 9.33317 8.00016C9.33317 8.73654 8.73622 9.3335 7.99984 9.3335Z" fill="#3355FF"/>
|
|
5
|
+
</svg>
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// #include //ly.img.cesdk/shader/common/ubq_adjustments
|
|
2
|
+
uniform shader image;
|
|
3
|
+
uniform float4x4 colorMatrix;
|
|
4
|
+
uniform float4 colorOffset;
|
|
5
|
+
uniform float gamma;
|
|
6
|
+
uniform float shadows;
|
|
7
|
+
uniform float highlights;
|
|
8
|
+
uniform float whites;
|
|
9
|
+
uniform float blacks;
|
|
10
|
+
uniform float clarity;
|
|
11
|
+
uniform float temperature;
|
|
12
|
+
uniform float sharpness;
|
|
13
|
+
|
|
14
|
+
float4 applyClarityAdjustment(float4 color, float2 coord, float clarity) {
|
|
15
|
+
// L = Left, R = Right, C = Center, T = Top, B = Bottom
|
|
16
|
+
float4 colLB = image.eval(coord + float2(-1, 1));
|
|
17
|
+
float4 colLC = image.eval(coord + float2(-1, 0.0));
|
|
18
|
+
float4 colLT = image.eval(coord + float2(-1, -1));
|
|
19
|
+
|
|
20
|
+
float4 colCL = image.eval(coord + float2(0.0, -1));
|
|
21
|
+
float4 colCR = image.eval(coord + float2(0.0, 1));
|
|
22
|
+
|
|
23
|
+
float4 colRB = image.eval(coord + float2(1, 1));
|
|
24
|
+
float4 colRC = image.eval(coord + float2(1, 0.0));
|
|
25
|
+
float4 colRT = image.eval(coord + float2(1, -1));
|
|
26
|
+
|
|
27
|
+
float4 mergedColor = color;
|
|
28
|
+
mergedColor.rgb += colLB.rgb + colLC.rgb + colLT.rgb;
|
|
29
|
+
mergedColor.rgb += colCL.rgb + colCR.rgb;
|
|
30
|
+
mergedColor.rgb += colRB.rgb + colRC.rgb + colRT.rgb;
|
|
31
|
+
|
|
32
|
+
mergedColor /= 9.0;
|
|
33
|
+
|
|
34
|
+
// 1.0 and 0.0 result in white not black, therefore we clamp
|
|
35
|
+
float grayValue = clamp(color.r * 0.3 + color.g * 0.59 + color.b * 0.1, 0.111111, 0.999999);
|
|
36
|
+
|
|
37
|
+
// Here we create a function that will map values below 0.1 to 0. Values above 0.2 will be mapped to 1,
|
|
38
|
+
// and for values between 0.1 and 0.2 it will produce a gradient.
|
|
39
|
+
// The funtion is mirror at 0.5, meaning values between 0.8 and 0.9 will result in a decending gradient.
|
|
40
|
+
// And values above 0.9 will be mapped to 0.
|
|
41
|
+
float frequenceFactor = min(smoothstep(1.0 - grayValue, 0.0, 0.11), smoothstep(grayValue, 0.0, 0.11));
|
|
42
|
+
|
|
43
|
+
// here we apply the high pass filter. Its strength is determined by the uniform ,
|
|
44
|
+
// and the frequence factor. That means the only the mid tones are affected by this filter.
|
|
45
|
+
// Clarity input is ranging from -1 to 1. But we want to strengthen the effect.
|
|
46
|
+
// Therefore we see this little magic number '3.7'.
|
|
47
|
+
color.rgb = clamp(color + clamp((color - mergedColor) * clarity * 3.7 * frequenceFactor, 0.0, 10.0), 0.0, 1.0).rgb;
|
|
48
|
+
|
|
49
|
+
// apply exposure but only to the mid tones.
|
|
50
|
+
color.rgb = color.rgb * pow(2.0, clarity * 0.27 * frequenceFactor);
|
|
51
|
+
|
|
52
|
+
return clamp(color, 0.0, 1.0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
float4 applySharpnessAdjustment(float4 color, float2 coord, float sharpness) {
|
|
56
|
+
float factor = mix(0.2, -1.0, float(sharpness > 0.0));
|
|
57
|
+
float4 sharpenedColor = mix(0.2, 5.0, float(sharpness > 0.0)) * color;
|
|
58
|
+
|
|
59
|
+
sharpenedColor += factor * clamp(image.eval(coord + float2(-1.0, 0.0)), 0.0, 1.0);
|
|
60
|
+
sharpenedColor += factor * clamp(image.eval(coord + float2(0.0, -1.0)), 0.0, 1.0);
|
|
61
|
+
sharpenedColor += factor * clamp(image.eval(coord + float2(0.0, 1.0)), 0.0, 1.0);
|
|
62
|
+
sharpenedColor += factor * clamp(image.eval(coord + float2(1.0, 0.0)), 0.0, 1.0);
|
|
63
|
+
|
|
64
|
+
sharpenedColor = clamp(sharpenedColor, 0.0, 1.0);
|
|
65
|
+
color = clamp(mix(color, sharpenedColor, abs(sharpness)), 0.0, 1.0);
|
|
66
|
+
|
|
67
|
+
return color;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
float luma(float3 color) {
|
|
71
|
+
return dot(color, float3(0.299, 0.587, 0.114));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
half4 main(float2 coord) {
|
|
75
|
+
|
|
76
|
+
float4 color = clamp(image.eval(coord), 0.0, 1.0);
|
|
77
|
+
color = unpremul(color);
|
|
78
|
+
|
|
79
|
+
if (clarity != 0.0) {
|
|
80
|
+
color = applyClarityAdjustment(color, coord, clarity);
|
|
81
|
+
}
|
|
82
|
+
if (sharpness != 0.0) {
|
|
83
|
+
color = applySharpnessAdjustment(color, coord, sharpness);
|
|
84
|
+
}
|
|
85
|
+
if (temperature != 0.0) {
|
|
86
|
+
color = applyTemperatureAdjustment(color, temperature);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Perform
|
|
90
|
+
if (gamma != 1.0) {
|
|
91
|
+
color = applyGammaAdjustment(color, gamma);
|
|
92
|
+
}
|
|
93
|
+
if (shadows != 0.0 || highlights != 0.0) {
|
|
94
|
+
color = applyShadowsAndHighlightsAdjustment(color, shadows, highlights);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
color = applyColorMatrixAdjustment(color, colorMatrix, colorOffset);
|
|
98
|
+
|
|
99
|
+
if (blacks != 0.0 || whites != 0.0) {
|
|
100
|
+
color = applyBlacksAndWhitesAdjustment(color, blacks, whites);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
color.rgb *= color.a;
|
|
104
|
+
|
|
105
|
+
return clamp(color, 0.0, 1.0);
|
|
106
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// #include //ly.img.cesdk/shader/common/ubq_color_conversions
|
|
2
|
+
// #include //ly.img.cesdk/shader/common/ubq_constants
|
|
3
|
+
// #include //ly.img.cesdk/shader/common/ubq_hue_constants
|
|
4
|
+
|
|
5
|
+
/// @brief High-quality black-and-white mixer using the HSP color model for black-and-white conversion and selective
|
|
6
|
+
/// color adjustments.
|
|
7
|
+
///
|
|
8
|
+
/// @details The HSP color model incorporates how humans perceive the brightness of different colors. Without
|
|
9
|
+
/// further selective color adjustments, the resulting black-and-white image is objectively of good quality. The
|
|
10
|
+
/// optional selective color adjustments enable to change the brightness for several color ranges to taste before the
|
|
11
|
+
/// image is converted to black-and-white. Details and results: @ref
|
|
12
|
+
/// <https://www.notion.so/imgly/6d77d05446014b708374692a091320ee#f1d3fd2095e44711a2d8cf73d12e9bd8>
|
|
13
|
+
|
|
14
|
+
// Inputs
|
|
15
|
+
uniform shader image;
|
|
16
|
+
uniform shader getRangePoint;
|
|
17
|
+
uniform float4 perceivedBrightnessRedOrangeYellowGreen;
|
|
18
|
+
uniform float4 perceivedBrightnessAquaBluePurpleMagenta;
|
|
19
|
+
|
|
20
|
+
/// @brief S-curve that smoothly goes from 0 to 1 for x from 0 to 1.
|
|
21
|
+
/// @param x X-value within range [0,1].
|
|
22
|
+
/// @return Y, the smoothed x value in range [0,1].
|
|
23
|
+
float sinusoidal(float x) {
|
|
24
|
+
return (1.0 + cos((1.0 - x) * PI)) / 2.0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Try to get the exact pixel of the lut map image
|
|
28
|
+
float2 sampleRangePoint(int texPosX, int texPosY) {
|
|
29
|
+
float2 pos = 0.5 + float2(float(texPosX), float(texPosY));
|
|
30
|
+
return getRangePoint.eval(pos).xy;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// @brief Returns an amount between 0 and 1 for the adjustment depending on the distance between the hue (h) and
|
|
34
|
+
/// the color. This determines how much the current value needs to be adjusted.
|
|
35
|
+
///
|
|
36
|
+
/// @details A sinusoidal adjustment (see sinusoidal()) is used to smooth the linearly defined ranges (see HSP_RANGES_POINTS).
|
|
37
|
+
/// For a given hue the amounts for all colors add up to 1 (actually, only one or two color indices should result in
|
|
38
|
+
/// an amount larger than zero) as assured by the definition of the ranges and the definition of the sinusoidal.
|
|
39
|
+
/// @param h The hue value (e.g., 242/360 for a bluish value) for which the amount should be calculated.
|
|
40
|
+
/// @param colorRange Index of the selected color range.
|
|
41
|
+
/// @return Zero if the hue value is outside the color range and an interpolated value for every other distance.
|
|
42
|
+
float getAmount(float h, int colorRange) {
|
|
43
|
+
float2 left; // Range points
|
|
44
|
+
float2 right; // Range points
|
|
45
|
+
float amount = 0.0;
|
|
46
|
+
|
|
47
|
+
// Handle red border case
|
|
48
|
+
if (colorRange == RED) {
|
|
49
|
+
// RED range is splitted, determine if RED or RED_2 needs to be used.
|
|
50
|
+
left = sampleRangePoint(0, RED_2);
|
|
51
|
+
right = sampleRangePoint(MAX_RANGE_INDEX, RED_2);
|
|
52
|
+
if (h >= left.x && h <= right.x) {
|
|
53
|
+
// Given hue is not in RED but in RED_2 range, update tempColorRange
|
|
54
|
+
colorRange = RED_2;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
left = sampleRangePoint(0, colorRange);
|
|
59
|
+
right = sampleRangePoint(MAX_RANGE_INDEX, colorRange);
|
|
60
|
+
|
|
61
|
+
// Check if hue is outside the range
|
|
62
|
+
if (h < left.x || h > right.x) {
|
|
63
|
+
// Nothing to do for this hue
|
|
64
|
+
return 0.0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Search range for matching part of the curve and calculate amount
|
|
68
|
+
for (int index = 0; index < NUM_HUE_INDICES - 1; index++) {
|
|
69
|
+
// Note: Out of range index access is handled implicitly as (h <= right.x)
|
|
70
|
+
// with right.x == -1 is false then and break
|
|
71
|
+
left = sampleRangePoint(index, colorRange);
|
|
72
|
+
right = sampleRangePoint(index + 1, colorRange);
|
|
73
|
+
|
|
74
|
+
if (h >= left.x && h <= right.x) {
|
|
75
|
+
// Match found, interpolate between y values
|
|
76
|
+
amount = mix(left.y, right.y, (h - left.x) / (right.x - left.x));
|
|
77
|
+
|
|
78
|
+
// Smooth the '/' and '\' parts of the curve to an s-shape
|
|
79
|
+
if (amount > 0.0 && amount < 1.0) {
|
|
80
|
+
amount = sinusoidal(amount);
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return clamp(amount, 0.0, 1.0);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
float applyPerceivedBrightnessAdjustments(float pOut, int colorRange, float strength, float3 hspColor) {
|
|
90
|
+
if (abs(strength) < EPSILON) {
|
|
91
|
+
return pOut;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
float amount = getAmount(hspColor.x, colorRange);
|
|
95
|
+
|
|
96
|
+
if (abs(amount) < EPSILON) {
|
|
97
|
+
return pOut;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
float weight = 1.0;
|
|
101
|
+
if (hspColor.y < 0.5) {
|
|
102
|
+
// Fade out less saturated colors to prevent glitches
|
|
103
|
+
// As a result, gray values are less influenced by brightness adjustment
|
|
104
|
+
weight = sinusoidal(hspColor.y / 0.5); // Smooth fade (good quality)
|
|
105
|
+
// weight = mix(0.0, 1.0, s / 0.5); // Linear fade (faster)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Sum up results
|
|
109
|
+
// E.g., this adds p for amount==1, strength==1, and weight==1
|
|
110
|
+
// and subtracts p for amount==1, strength==-1, and weight==1
|
|
111
|
+
if (abs(weight) >= EPSILON) {
|
|
112
|
+
pOut += hspColor.z * (amount * strength * weight);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return pOut;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// @brief Adjust perceived brightness by applying adjustments for all color ranges and then converts the image to black
|
|
119
|
+
/// and white.
|
|
120
|
+
half4 main(float2 coord) {
|
|
121
|
+
|
|
122
|
+
float4 rgbaColor = unpremul(image.eval(coord));
|
|
123
|
+
|
|
124
|
+
// Convert to HSP without the alpha channel
|
|
125
|
+
float3 hspColor = rgb2hsp(rgbaColor.rgb);
|
|
126
|
+
float pOut = hspColor.z;
|
|
127
|
+
|
|
128
|
+
// Apply perceived brightness adjustments
|
|
129
|
+
// The same color can be adjusted within one or two color ranges therefore the results are gathered for all color
|
|
130
|
+
// ranges.
|
|
131
|
+
// The uniforms are packed so unpack them in the order
|
|
132
|
+
pOut = applyPerceivedBrightnessAdjustments(pOut, RED, perceivedBrightnessRedOrangeYellowGreen.x, hspColor);
|
|
133
|
+
pOut = applyPerceivedBrightnessAdjustments(pOut, ORANGE, perceivedBrightnessRedOrangeYellowGreen.y, hspColor);
|
|
134
|
+
pOut = applyPerceivedBrightnessAdjustments(pOut, YELLOW, perceivedBrightnessRedOrangeYellowGreen.z, hspColor);
|
|
135
|
+
pOut = applyPerceivedBrightnessAdjustments(pOut, GREEN, perceivedBrightnessRedOrangeYellowGreen.w, hspColor);
|
|
136
|
+
pOut = applyPerceivedBrightnessAdjustments(pOut, AQUA, perceivedBrightnessAquaBluePurpleMagenta.x, hspColor);
|
|
137
|
+
pOut = applyPerceivedBrightnessAdjustments(pOut, BLUE, perceivedBrightnessAquaBluePurpleMagenta.y, hspColor);
|
|
138
|
+
pOut = applyPerceivedBrightnessAdjustments(pOut, PURPLE, perceivedBrightnessAquaBluePurpleMagenta.z, hspColor);
|
|
139
|
+
pOut = applyPerceivedBrightnessAdjustments(pOut, MAGENTA, perceivedBrightnessAquaBluePurpleMagenta.w, hspColor);
|
|
140
|
+
pOut = clamp(pOut, 0.0, 1.0);
|
|
141
|
+
|
|
142
|
+
hspColor.z = pOut;
|
|
143
|
+
|
|
144
|
+
// Set saturation to zero
|
|
145
|
+
hspColor.y = 0.0;
|
|
146
|
+
|
|
147
|
+
// Convert back to RGB leaving the alpha unchanged
|
|
148
|
+
rgbaColor.rgb = hsp2rgb(hspColor);
|
|
149
|
+
|
|
150
|
+
rgbaColor.rgb *= rgbaColor.a;
|
|
151
|
+
return rgbaColor;
|
|
152
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// #include //ly.img.cesdk/shader/common/ubq_color_conversions
|
|
2
|
+
|
|
3
|
+
/// INTERNAL
|
|
4
|
+
|
|
5
|
+
// Luminance calculation term of the RGB to HSL formular.
|
|
6
|
+
float _calculateLuminance(float3 rgb) {
|
|
7
|
+
float4 p = mix(float4(rgb.gb, 0.0, -1.0 / 3.0), float4(rgb.bg, -1.0, 2.0 / 3.0), float4(rgb.g < rgb.b));
|
|
8
|
+
|
|
9
|
+
float4 q = mix(float4(rgb.r, p.yzx), float4(p.xyw, rgb.r), float4(rgb.r < p.x));
|
|
10
|
+
|
|
11
|
+
float croma = q.x - min(q.w, q.y);
|
|
12
|
+
float luminance = q.x - croma * 0.5;
|
|
13
|
+
|
|
14
|
+
return luminance;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Maps values from one range to another
|
|
18
|
+
float _mapFloat(float x, float in_min, float in_max, float out_min, float out_max) {
|
|
19
|
+
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// @brief Apply gamma transform only to a fraction of the brightest/darkest pixels
|
|
23
|
+
/// @param color: the color to be transformed
|
|
24
|
+
/// @param lighten the amount by which to lighten in [-1, 1]. -1 means darkening of the lighter parts of the color, 1
|
|
25
|
+
/// means lightening of these parts
|
|
26
|
+
/// @param darken: analogously to lighten
|
|
27
|
+
/// @param lightnessFraction: the fraction of lightest/darkest value for which the transform is performed.
|
|
28
|
+
/// lightnessFraction = 0.25: only the 25% darkest/lightest pixels get transformed
|
|
29
|
+
float4 _rangeLimitedGammaTransform(float4 color, float lighten, float darken, float lightnessFraction) {
|
|
30
|
+
// we transform into the hsl colorspace and subsequently adjust the lightness
|
|
31
|
+
float3 color_hsl = rgb2hsl(color.rgb);
|
|
32
|
+
// the idea is to use gamma correction, the base is a hyperparameter
|
|
33
|
+
float base = 2.0;
|
|
34
|
+
float lightness = color_hsl.b;
|
|
35
|
+
// adjust the values with a high lightness if the whites parameter is set
|
|
36
|
+
if ((lightness >= (1.0 - lightnessFraction) && abs(lighten) >= 0.0001)) {
|
|
37
|
+
// for gamma correction, one usually chooses a gamma value in [0.0, 2.2]
|
|
38
|
+
// our whites however are in [-1,1], we therefore map them into [1/base, base] (remember, base is a hyperparameter)
|
|
39
|
+
float gamma = pow(base, lighten);
|
|
40
|
+
// we only adjust the lightness value > 0.75, we project them to [0, 1] to stay in the valid range
|
|
41
|
+
float y = _mapFloat(lightness, 1.0 - lightnessFraction, 1.0, 0.0, 1.0);
|
|
42
|
+
// gamma correction in the new space
|
|
43
|
+
y = pow(y, 1.0 / gamma);
|
|
44
|
+
// project back to [0.75, 1.0]
|
|
45
|
+
lightness = _mapFloat(y, 0.0, 1.0, 1.0 - lightnessFraction, 1.0);
|
|
46
|
+
} else if ((lightness <= lightnessFraction && abs(darken) >= 0.0001)) {
|
|
47
|
+
// essentially the same as above but for blacks and the projection is slightly different as we map
|
|
48
|
+
// [0, 0.25] to [0, 1]
|
|
49
|
+
float gamma = pow(base, darken);
|
|
50
|
+
float y = _mapFloat(lightness, 0.0, lightnessFraction, 0.0, 1.0);
|
|
51
|
+
y = pow(y, 1.0 / gamma);
|
|
52
|
+
lightness = _mapFloat(y, 0.0, 1.0, 0.0, lightnessFraction);
|
|
53
|
+
}
|
|
54
|
+
color_hsl.b = lightness;
|
|
55
|
+
color.rgb = hsl2rgb(color_hsl);
|
|
56
|
+
return color;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Maps values from one range to another
|
|
60
|
+
float3 _map(float3 x, float in_min, float in_max, float out_min, float out_max) {
|
|
61
|
+
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// ADJUSTMENTS
|
|
65
|
+
|
|
66
|
+
float4 applyGammaAdjustment(float4 color, float gamma) {
|
|
67
|
+
color.rgb = pow(color.rgb, float3(1.0 / max(gamma, EPSILON)));
|
|
68
|
+
return color;
|
|
69
|
+
}
|
|
70
|
+
/// @brief Apply gamma transform only to a the 33% lightest, darkest pixels
|
|
71
|
+
float4 applyShadowsAndHighlightsAdjustment(float4 color, float shadows, float highlights) {
|
|
72
|
+
return _rangeLimitedGammaTransform(color, highlights, shadows, 0.33);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// @brief Apply gamma transform only to a the 66% lightest, darkest pixels
|
|
76
|
+
float4 applyBlacksAndWhitesAdjustment(float4 color, float blacks, float whites) {
|
|
77
|
+
return _rangeLimitedGammaTransform(color, whites, blacks, 0.66);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
float4 applyColorMatrixAdjustment(float4 color, float4x4 colorMatrix, float4 colorOffset) {
|
|
81
|
+
color.rgb = clamp(color * colorMatrix + colorOffset, 0.0, 1.0).rgb;
|
|
82
|
+
return color;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const float3x3 RGBtoYIQ = float3x3(0.299, 0.587, 0.114, 0.596, -0.274, -0.322, 0.212, -0.523, 0.311);
|
|
86
|
+
const float3x3 YIQtoRGB = float3x3(1.0, 0.956, 0.621, 1.0, -0.272, -0.647, 1.0, -1.105, 1.702);
|
|
87
|
+
const float3 warmFilter = float3(0.93, 0.54, 0.0);
|
|
88
|
+
|
|
89
|
+
float4 applyTemperatureAdjustment(float4 color, float temperature) {
|
|
90
|
+
const float tint = 0.0;
|
|
91
|
+
float3 yiq = RGBtoYIQ * color.rgb;
|
|
92
|
+
yiq.b = clamp(yiq.b + tint * 0.5226 * 0.1, -0.5226, 0.5226);
|
|
93
|
+
float3 rgb = YIQtoRGB * yiq;
|
|
94
|
+
|
|
95
|
+
float3 start = (1.0 - 2.0 * (1.0 - rgb) * (1.0 - warmFilter));
|
|
96
|
+
float3 end = (2.0 * rgb * warmFilter);
|
|
97
|
+
float3 weights = float3(rgb.r < 0.5, rgb.g < 0.5, rgb.b < 0.5);
|
|
98
|
+
float3 processed = mix(start, end, weights);
|
|
99
|
+
|
|
100
|
+
float4 outColor = float4(mix(color.rgb, processed, temperature), color.a);
|
|
101
|
+
return clamp(outColor, 0.0, 1.0);
|
|
102
|
+
}
|