@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.
Files changed (47) hide show
  1. package/LICENSE.md +137 -0
  2. package/README.md +474 -0
  3. package/ThirdPartyLicenses.md +1041 -0
  4. package/assets/ly.img.cesdk/fonts/imgly_font_inter_semibold.otf +0 -0
  5. package/assets/ly.img.cesdk/icons/ErrorAudio.svg +5 -0
  6. package/assets/ly.img.cesdk/icons/ErrorConnection.svg +5 -0
  7. package/assets/ly.img.cesdk/icons/ErrorImage.svg +6 -0
  8. package/assets/ly.img.cesdk/icons/ErrorUnknown.svg +3 -0
  9. package/assets/ly.img.cesdk/icons/ErrorVideo.svg +6 -0
  10. package/assets/ly.img.cesdk/icons/Move.svg +3 -0
  11. package/assets/ly.img.cesdk/icons/RotateIndicator.svg +5 -0
  12. package/assets/ly.img.cesdk/icu/icudt74l.dat +0 -0
  13. package/assets/ly.img.cesdk/presets/.keep +0 -0
  14. package/assets/ly.img.cesdk/shaders/adjustments.sksl +106 -0
  15. package/assets/ly.img.cesdk/shaders/black_and_white_color_mixer.sksl +152 -0
  16. package/assets/ly.img.cesdk/shaders/common/ubq_adjustments.sksl +102 -0
  17. package/assets/ly.img.cesdk/shaders/common/ubq_color_conversions.sksl +354 -0
  18. package/assets/ly.img.cesdk/shaders/common/ubq_constants.sksl +13 -0
  19. package/assets/ly.img.cesdk/shaders/common/ubq_hue_constants.sksl +86 -0
  20. package/assets/ly.img.cesdk/shaders/common/ubq_noise.sksl +82 -0
  21. package/assets/ly.img.cesdk/shaders/cross_cut.sksl +38 -0
  22. package/assets/ly.img.cesdk/shaders/dot_pattern.sksl +29 -0
  23. package/assets/ly.img.cesdk/shaders/duotone_filter.sksl +26 -0
  24. package/assets/ly.img.cesdk/shaders/extrude_blur.sksl +85 -0
  25. package/assets/ly.img.cesdk/shaders/glow.sksl +31 -0
  26. package/assets/ly.img.cesdk/shaders/half_tone.sksl +14 -0
  27. package/assets/ly.img.cesdk/shaders/linocut.sksl +30 -0
  28. package/assets/ly.img.cesdk/shaders/liquid.sksl +19 -0
  29. package/assets/ly.img.cesdk/shaders/lut_filter.sksl +70 -0
  30. package/assets/ly.img.cesdk/shaders/mask_color.sksl +16 -0
  31. package/assets/ly.img.cesdk/shaders/mirror.sksl +21 -0
  32. package/assets/ly.img.cesdk/shaders/outliner.sksl +40 -0
  33. package/assets/ly.img.cesdk/shaders/pixelize.sksl +10 -0
  34. package/assets/ly.img.cesdk/shaders/placeholder_overlay_lines.sksl +18 -0
  35. package/assets/ly.img.cesdk/shaders/posterize.sksl +8 -0
  36. package/assets/ly.img.cesdk/shaders/radial_pixel.sksl +22 -0
  37. package/assets/ly.img.cesdk/shaders/recolor.sksl +57 -0
  38. package/assets/ly.img.cesdk/shaders/sharpie.sksl +74 -0
  39. package/assets/ly.img.cesdk/shaders/shifter.sksl +22 -0
  40. package/assets/ly.img.cesdk/shaders/tiltshift.sksl +21 -0
  41. package/assets/ly.img.cesdk/shaders/tv_glitch.sksl +25 -0
  42. package/assets/ly.img.cesdk/shaders/vignette.sksl +12 -0
  43. package/example.js +31 -0
  44. package/lib/index.d.ts +4072 -0
  45. package/lib/index.js +4922 -0
  46. package/lib/index.js.map +7 -0
  47. package/package.json +59 -0
@@ -0,0 +1,354 @@
1
+ // #include //ly.img.cesdk/shader/common/ubq_constants
2
+
3
+ /// @file ubq_color_conversions.glsl
4
+ /// @brief Color conversions for different color models.
5
+ ///
6
+
7
+ /// @brief Convert an RGB color to an HSV color.
8
+ ///
9
+ /// HSV is a cylindrical color space.
10
+ /// HSV stands for Hue, saturation, value.
11
+ ///
12
+ /// Hue goes from red primary at 0°, passing through the green
13
+ /// primary at 120°, the blue primary at 180°, and then wrapping
14
+ /// back to red at 360°.
15
+ /// Saturation goes from unsaturated at 0% to full saturated at 100%.
16
+ /// Value goes from black at 0% to white at 100%.
17
+ /// See: @ref https://en.wikipedia.org/wiki/HSL_and_HSV
18
+ ///
19
+ /// Note: HSV is an outdated format from the 1970s and is not recommended to be used.
20
+ ///
21
+ /// Source: @ref https://www.laurivan.com/rgb-to-hsv-to-rgb-for-shaders/
22
+ ///
23
+ /// @param c RGB color values
24
+ /// @return HSV color values with hue, saturation, and value in range [0,1].
25
+ ///
26
+ float3 rgb2hsv(float3 c) {
27
+ float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
28
+ float4 p = c.g < c.b ? float4(c.bg, K.wz) : float4(c.gb, K.xy);
29
+ float4 q = c.r < p.x ? float4(p.xyw, c.r) : float4(c.r, p.yzx);
30
+ float d = q.x - min(q.w, q.y);
31
+ float e = 1.0e-10;
32
+ return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
33
+ }
34
+
35
+ /// @brief Convert an HSV color to an RGB color.
36
+ ///
37
+ /// HSV is a cylindrical color space.
38
+ /// HSV stands for Hue, saturation, value.
39
+ ///
40
+ /// Hue goes from red primary at 0°, passing through the green
41
+ /// primary at 120°, the blue primary at 180°, and then wrapping
42
+ /// back to red at 360°.
43
+ /// Saturation goes from unsaturated at 0% to full saturated at 100%.
44
+ /// Value goes from black at 0% to white at 100%.
45
+ /// See: @ref https://en.wikipedia.org/wiki/HSL_and_HSV
46
+ ///
47
+ /// Note: HSV is an outdated format from the 1970s and is not recommended to be used.
48
+ ///
49
+ /// Source: @ref https://www.laurivan.com/rgb-to-hsv-to-rgb-for-shaders/
50
+ ///
51
+ /// @param c HSV color values with hue, saturation, and value in range [0,1].
52
+ /// @return RGB color values
53
+ ///
54
+ float3 hsv2rgb(float3 c) {
55
+ float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
56
+ float3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
57
+ return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
58
+ }
59
+
60
+ /// @brief Convert an RGB color to an HSP color.
61
+ ///
62
+ /// HSP stands for hue, saturation, and perceived brightness.
63
+ ///
64
+ /// Hue goes from red primary at 0°, passing through the green
65
+ /// primary at 120°, the blue primary at 180°, and then wrapping
66
+ /// back to red at 360°.
67
+ ///
68
+ /// Based on a public domain function by Darel Rex Finley, 2006
69
+ /// See: @ref http://alienryderflex.com/hsp.html
70
+ ///
71
+ /// @param c RGB color values in range [0,1].
72
+ /// @return HSP color values with hue, saturation, and perceived-brightness in range [0,1].
73
+ ///
74
+ float3 rgb2hsp(float3 c) {
75
+ c = clamp(c, 0.0, 1.0);
76
+ float r = c.r;
77
+ float g = c.g;
78
+ float b = c.b;
79
+ // Hue, saturation, and perceived brightness output
80
+ float h = 0.0;
81
+ float s = 0.0;
82
+ float p = sqrt(dot(GRAYSCALE_WEIGHTS_W3C, c * c));
83
+
84
+ // Calculate the hue and saturation. (This part works
85
+ // the same way as in the HSV/B and HSL systems.)
86
+ if (r == g && r == b) {
87
+ // Grey value
88
+ // Nothing to do as p is already set and h and s are 0.
89
+ return float3(h, s, p);
90
+ } else if (r >= g && r >= b) {
91
+ // r is largest
92
+ if (b >= g) {
93
+ h = 6.0 / 6.0 - 1.0 / 6.0 * (b - g) / (r - g);
94
+ s = 1.0 - g / r;
95
+ } else {
96
+ h = 0.0 / 6.0 + 1.0 / 6.0 * (g - b) / (r - b);
97
+ s = 1.0 - b / r;
98
+ }
99
+ } else if (g >= r && g >= b) {
100
+ // g is largest
101
+ if (r >= b) {
102
+ h = 2.0 / 6.0 - 1.0 / 6.0 * (r - b) / (g - b);
103
+ s = 1.0 - b / g;
104
+ } else {
105
+ h = 2.0 / 6.0 + 1.0 / 6.0 * (b - r) / (g - r);
106
+ s = 1.0 - r / g;
107
+ }
108
+ } else {
109
+ // b is largest
110
+ if (g >= r) {
111
+ h = 4.0 / 6.0 - 1.0 / 6.0 * (g - r) / (b - r);
112
+ s = 1.0 - r / b;
113
+ } else {
114
+ h = 4.0 / 6.0 + 1.0 / 6.0 * (r - g) / (b - g);
115
+ s = 1.0 - g / b;
116
+ }
117
+ }
118
+
119
+ return clamp(float3(h, s, p), 0.0, 1.0);
120
+ }
121
+
122
+ /// @brief Convert an HSP color to an RGB color.
123
+ ///
124
+ /// HSP stands for hue, saturation and perceived brightness.
125
+ ///
126
+ /// Hue goes from red primary at 0°, passing through the green
127
+ /// primary at 120°, the blue primary at 180°, and then wrapping
128
+ /// back to red at 360°.
129
+ ///
130
+ /// Based on a public domain function by Darel Rex Finley, 2006
131
+ /// See: @ref http://alienryderflex.com/hsp.html
132
+ ///
133
+ /// Note that some combinations of HSP, even if in the scale
134
+ /// 0-1, may return RGB values that exceed a value of 1. For
135
+ /// example, if you pass in the HSP color (0, 1, 1), the result
136
+ /// would be the RGB color (2.037, 0, 0).
137
+ /// An automatic rescale of the values to 0-1 will be used that
138
+ /// keeps relative ratios.
139
+ ///
140
+ /// @param c HSP color values in range [0,1].
141
+ /// @return RGB in range [0,1].
142
+ ///
143
+ float3 hsp2rgb(float3 c) {
144
+ float h = c.x;
145
+ float s = c.y;
146
+ float p = c.z;
147
+
148
+ // RGB output
149
+ float r = 0.0;
150
+ float g = 0.0;
151
+ float b = 0.0;
152
+
153
+ float minOverMax = 1.0 - s;
154
+ float part;
155
+
156
+ const float PR = GRAYSCALE_WEIGHTS_W3C.r;
157
+ const float PG = GRAYSCALE_WEIGHTS_W3C.g;
158
+ const float PB = GRAYSCALE_WEIGHTS_W3C.b;
159
+
160
+ if (minOverMax > 0.0) {
161
+ if (h < 1.0 / 6.0) {
162
+ // r>g>b
163
+ h = 6.0 * (h - 0.0 / 6.0);
164
+ part = 1.0 + h * (1.0 / minOverMax - 1.0);
165
+ b = p / sqrt(PR / minOverMax / minOverMax + PG * part * part + PB);
166
+ r = b / minOverMax;
167
+ g = b + h * (r - b);
168
+ } else if (h < 2.0 / 6.0) {
169
+ // g>r>b
170
+ h = 6.0 * (-h + 2.0 / 6.0);
171
+ part = 1.0 + h * (1.0 / minOverMax - 1.0);
172
+ b = p / sqrt(PG / minOverMax / minOverMax + PR * part * part + PB);
173
+ g = b / minOverMax;
174
+ r = b + h * (g - b);
175
+ } else if ((h < 3.0 / 6.0)) {
176
+ // g>b>r
177
+ h = 6.0 * (h - 2.0 / 6.0);
178
+ part = 1.0 + h * (1.0 / minOverMax - 1.0);
179
+ r = p / sqrt(PG / minOverMax / minOverMax + PB * part * part + PR);
180
+ g = r / minOverMax;
181
+ b = r + h * (g - r);
182
+ } else if ((h < 4.0 / 6.0)) {
183
+ // b>g>r
184
+ h = 6.0 * (-h + 4.0 / 6.00);
185
+ part = 1.0 + h * (1.0 / minOverMax - 1.0);
186
+ r = p / sqrt(PB / minOverMax / minOverMax + PG * part * part + PR);
187
+ b = r / minOverMax;
188
+ g = r + h * (b - r);
189
+ } else if ((h < 5.0 / 6.0)) {
190
+ // b>r>g
191
+ h = 6.0 * (h - 4.0 / 6.0);
192
+ part = 1.0 + h * (1.0 / minOverMax - 1.0);
193
+ g = p / sqrt(PB / minOverMax / minOverMax + PR * part * part + PG);
194
+ b = g / minOverMax;
195
+ r = g + h * (b - g);
196
+ } else {
197
+ // r>b>g
198
+ h = 6.0 * (-h + 6.0 / 6.0);
199
+ part = 1.0 + h * (1.0 / minOverMax - 1.0);
200
+ g = p / sqrt(PR / minOverMax / minOverMax + PB * part * part + PG);
201
+ r = g / minOverMax;
202
+ b = g + h * (r - g);
203
+ }
204
+ } else {
205
+ if (h < 1.0 / 6.0) {
206
+ // r>g>b
207
+ h = 6.0 * (h - 0.0 / 6.0);
208
+ r = sqrt(p * p / (PR + PG * h * h));
209
+ g = r * h;
210
+ b = 0.0;
211
+ } else if (h < 2.0 / 6.0) {
212
+ // g>r>b
213
+ h = 6.0 * (-h + 2.0 / 6.0);
214
+ g = sqrt(p * p / (PG + PR * h * h));
215
+ r = g * h;
216
+ b = 0.0;
217
+ } else if (h < 3.0 / 6.0) {
218
+ // g>b>r
219
+ h = 6.0 * (h - 2.0 / 6.0);
220
+ g = sqrt(p * p / (PG + PB * h * h));
221
+ b = g * h;
222
+ r = 0.0;
223
+ } else if (h < 4.0 / 6.0) {
224
+ // b>g>r
225
+ h = 6.0 * (-h + 4.0 / 6.0);
226
+ b = sqrt(p * p / (PB + PG * h * h));
227
+ g = b * h;
228
+ r = 0.0;
229
+ } else if (h < 5.0 / 6.0) {
230
+ // b>r>g
231
+ h = 6.0 * (h - 4.0 / 6.0);
232
+ b = sqrt(p * p / (PB + PR * h * h));
233
+ r = b * h;
234
+ g = 0.0;
235
+ } else {
236
+ // r>g>b
237
+ h = 6.0 * (-h + 6.0 / 6.0);
238
+ r = sqrt(p * p / (PR + PB * h * h));
239
+ b = r * h;
240
+ g = 0.0;
241
+ }
242
+ }
243
+
244
+ float3 outColor = float3(r, g, b);
245
+
246
+ // Handle out of range values
247
+ if (r > 1.0 || g > 1.0 || b > 1.0) {
248
+ // Rescale all values by maximum to prevent color changes.
249
+ float maxc = max(r, g);
250
+ maxc = max(maxc, b);
251
+ outColor /= maxc;
252
+ }
253
+
254
+ return outColor;
255
+ }
256
+
257
+ /// @brief Convert an RGB color to an HSL color.
258
+ ///
259
+ /// HSL stands for hue, saturation, and lightness.
260
+ /// See: @ref https://en.wikipedia.org/wiki/HSL_and_HSV
261
+ ///
262
+ /// Based on colorsys implementation: colorsys.rgb_to_hls(r, g, b)
263
+ ///
264
+ /// @param c RGB color values in range [0,1].
265
+ /// @return HSP color values with hue, saturation, and perceived-brightness in range [0,1].
266
+ ///
267
+ float3 rgb2hsl(float3 c) {
268
+ float r = c.r;
269
+ float g = c.g;
270
+ float b = c.b;
271
+
272
+ float maxc = max(r, g);
273
+ maxc = max(maxc, b);
274
+ float minc = min(r, g);
275
+ minc = min(minc, b);
276
+
277
+ float h = 0.0;
278
+ float s = 0.0;
279
+ float l = (minc + maxc) / 2.0;
280
+
281
+ float rc, gc, bc;
282
+
283
+ if (minc == maxc) {
284
+ // Grey
285
+ h = 0.0;
286
+ s = 0.0;
287
+ return float3(h, s, l);
288
+ }
289
+
290
+ if (l <= 0.5) {
291
+ s = (maxc - minc) / (maxc + minc);
292
+ } else {
293
+ if ((2.0 - maxc - minc) > 0.0) {
294
+ s = (maxc - minc) / (2.0 - maxc - minc);
295
+ } else {
296
+ s = 1.0;
297
+ }
298
+ }
299
+
300
+ rc = (maxc - r) / (maxc - minc);
301
+ gc = (maxc - g) / (maxc - minc);
302
+ bc = (maxc - b) / (maxc - minc);
303
+ if (r == maxc) {
304
+ h = bc - gc;
305
+ } else if (g == maxc) {
306
+ h = 2.0 + rc - bc;
307
+ } else {
308
+ h = 4.0 + gc - rc;
309
+ }
310
+ h = mod((h / 6.0), 1.0);
311
+
312
+ return float3(h, s, l);
313
+ }
314
+
315
+ /// @brief HSL helper function
316
+ float _hslV(float m1, float m2, float hue) {
317
+ hue = mod(hue, 1.0);
318
+ if (hue < 1.0 / 6.0) {
319
+ return m1 + (m2 - m1) * hue * 6.0;
320
+ }
321
+ if (hue < 0.5) {
322
+ return m2;
323
+ }
324
+ if (hue < 2.0 / 3.0) {
325
+ return m1 + (m2 - m1) * (2.0 / 3.0 - hue) * 6.0;
326
+ }
327
+ return m1;
328
+ }
329
+
330
+ /// @brief Convert an HSL color to an RGB color.
331
+ ///
332
+ /// HSL stands for hue, saturation, and lightness.
333
+ /// See: @ref https://en.wikipedia.org/wiki/HSL_and_HSV
334
+ ///
335
+ /// @param c HSL color values in range [0,1].
336
+ /// @return RGB in range [0,1].
337
+ ///
338
+ float3 hsl2rgb(float3 c) {
339
+ float h = c.x;
340
+ float s = c.y;
341
+ float l = c.z;
342
+ float m1, m2;
343
+
344
+ if (s == 0.0) {
345
+ return float3(l, l, l);
346
+ }
347
+ if (l <= 0.5) {
348
+ m2 = l * (1.0 + s);
349
+ } else {
350
+ m2 = l + s - (l * s);
351
+ }
352
+ m1 = 2.0 * l - m2;
353
+ return float3(_hslV(m1, m2, h + 1.0 / 3.0), _hslV(m1, m2, h), _hslV(m1, m2, h - 1.0 / 3.0));
354
+ }
@@ -0,0 +1,13 @@
1
+ // Pi related constants
2
+ const float PI = 3.14159265358979323846;
3
+ const float TWO_PI = 2.0 * PI;
4
+ const float PI_BY_2 = 0.5 * PI;
5
+ const float PI_BY_4 = 0.25 * PI;
6
+ const float PI_BY_8 = 0.125 * PI;
7
+
8
+ // Default value for avoiding /0 divisions
9
+ const float EPSILON = 0.0000001;
10
+
11
+ // Weights used for RGB -> Grayscale conversion
12
+ const float3 GRAYSCALE_WEIGHTS = float3(0.2126, 0.7152, 0.0722); // W3C_YIQ standard
13
+ const float3 GRAYSCALE_WEIGHTS_W3C = float3(0.299, 0.587, 0.114); // W3C standard
@@ -0,0 +1,86 @@
1
+
2
+ /// @brief Constants for the HSV, HSL, and HSP color models
3
+
4
+ // Angles of the colors for HSV, HSL, and HSP color models
5
+ // This defines where the hues are located on the color wheel.
6
+ // Values are mapped from [0, 360] to [0,1]
7
+ // H 0.0:
8
+ const float HUE_RED = 0.0;
9
+ // H ~0.0833:
10
+ const float HUE_ORANGE = 30.0 / 360.0;
11
+ // H ~0.1667:
12
+ const float HUE_YELLOW = 60.0 / 360.0;
13
+ // H ~0.2500:
14
+ const float HUE_GREEN_YELLOW = 90.0 / 360.0;
15
+ // H ~0.3333:
16
+ const float HUE_GREEN = 120.0 / 360.0;
17
+ // H ~0.4167:
18
+ const float HUE_AQUA_GREEN = 150.0 / 360.0;
19
+ // H ~0.5000:
20
+ const float HUE_AQUA = 180.0 / 360.0;
21
+ // H ~0.5833:
22
+ const float HUE_BLUE_AQUA = 210.0 / 360.0;
23
+ // H ~0.6667:
24
+ const float HUE_BLUE = 240.0 / 360.0;
25
+ // H ~0.7500:
26
+ const float HUE_PURPLE = 270.0 / 360.0;
27
+ // H ~0.8333:
28
+ const float HUE_MAGENTA = 300.0 / 360.0;
29
+ // H ~0.9167:
30
+ const float HUE_RED_MAGENTA = 330.0 / 360.0;
31
+ // H 1.0:
32
+ const float HUE_RED_2 = 1.0;
33
+
34
+ // Array indices for accessing the color operations by name
35
+ const int RED = 0;
36
+ const int ORANGE = 1;
37
+ const int YELLOW = 2;
38
+ const int GREEN = 3;
39
+ const int AQUA = 4;
40
+ const int BLUE = 5;
41
+ const int PURPLE = 6;
42
+ const int MAGENTA = 7;
43
+ // Without the RED_2 special case
44
+ const int NUM_COLOR_RANGES = 8;
45
+ // Special case as red wraps around at 360°
46
+ const int RED_2 = 8;
47
+ // With the RED_2 special case
48
+ const int NUM_COLOR_RANGES_2 = 9;
49
+
50
+ // Max index value for curve points, used in for-loops
51
+ const int MAX_RANGE_INDEX = 3;
52
+ const int NUM_RANGE_INDICES = 4;
53
+ const int MAX_HUE_INDEX = 3;
54
+ const int NUM_HUE_INDICES = 4;
55
+
56
+ // Point offsets for x- and y-points for constructing hue adjustment curves
57
+ // This influences the width of the color gradient on the left side of
58
+ // the adjusted colors. Right side is already smooth...
59
+ const float HUE_INC_X0_OFFSET = -29.9 / 360.0;
60
+ // This is for a smoother transition in between. Cuts off part of the ear.
61
+ const float HUE_INC_X2_OFFSET = 5.0 / 360.0;
62
+ // Keep first point on diagonal line
63
+ const float HUE_INC_Y0_OFFSET = -29.9 / 360.0;
64
+ // This is for a smoother transition in between. Cuts off part of the ear.
65
+ // Should be set in relation to Y2.
66
+ const float HUE_INC_Y1_OFFSET = -7.0 / 360.0;
67
+ // This influences how much of target color is shown early. It influences a wide
68
+ // range of the interval.
69
+ const float HUE_INC_Y2_OFFSET = -2.0 / 360.0;
70
+ // This is for a smoother transition in between. Cuts off part of the ear.
71
+ const float HUE_DEC_X1_OFFSET = -5.0 / 360.0;
72
+ // This influences the width of the color gradient on the right side of
73
+ // the adjusted colors. Left side is already smooth...
74
+ const float HUE_DEC_X3_OFFSET = 29.9 / 360.0;
75
+ // This influences how much of target color is shown early. It influences a wide
76
+ // range of the interval.
77
+ const float HUE_DEC_Y1_OFFSET = 6.0 / 360.0;
78
+ // This is for a smoother transition in between. Cuts off part of the ear.
79
+ // Should be set in relation to Y1.
80
+ const float HUE_DEC_Y2_OFFSET = 11.0 / 360.0;
81
+ // Keep last point on diagonal line
82
+ const float HUE_DEC_Y3_OFFSET = 29.9 / 360.0;
83
+
84
+ // Max curve point value used for normlizing the values
85
+ const float HUE_INCREASE_NORMALIZE_VALUE = HUE_YELLOW + 1.0;
86
+ const float HUE_DECREASE_NORMALIZE_VALUE = HUE_YELLOW + 1.0 + HUE_DEC_X3_OFFSET;
@@ -0,0 +1,82 @@
1
+ // Description : Array and textureless GLSL 2D simplex noise function.
2
+ // Author : Ian McEwan, Ashima Arts.
3
+ // Maintainer : stegu
4
+ // Lastmod : 20110822 (ijm)
5
+ // License : Copyright (C) 2011 Ashima Arts. All rights reserved.
6
+ // Distributed under the MIT License. See LICENSE file.
7
+ // https://github.com/ashima/webgl-noise
8
+ // https://github.com/stegu/webgl-noise
9
+ //
10
+
11
+ float3 mod289(float3 x) {
12
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
13
+ }
14
+
15
+ float2 mod289(float2 x) {
16
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
17
+ }
18
+
19
+ float3 permute(float3 x) {
20
+ return mod289(((x * 34.0) + 1.0) * x);
21
+ }
22
+
23
+ float noise2d(float2 v) {
24
+ const float4 C = float4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
25
+ 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
26
+ -0.577350269189626, // -1.0 + 2.0 * C.x
27
+ 0.024390243902439); // 1.0 / 41.0
28
+ // First corner
29
+ float2 i = floor(v + dot(v, C.yy));
30
+ float2 x0 = v - i + dot(i, C.xx);
31
+
32
+ // Other corners
33
+ float2 i1;
34
+
35
+ i1 = (x0.x > x0.y) ? float2(1.0, 0.0) : float2(0.0, 1.0);
36
+
37
+ float4 x12 = x0.xyxy + C.xxzz;
38
+ x12.xy -= i1;
39
+
40
+ // Permutations
41
+ i = mod289(i); // Avoid truncation effects in permutation
42
+ float3 p = permute(permute(i.y + float3(0.0, i1.y, 1.0)) + i.x + float3(0.0, i1.x, 1.0));
43
+
44
+ float3 m = max(0.5 - float3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);
45
+ m = m * m;
46
+ m = m * m;
47
+
48
+ // Gradients: 41 points uniformly over a line, mapped onto a diamond.
49
+ // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
50
+
51
+ float3 x = 2.0 * fract(p * C.www) - 1.0;
52
+ float3 h = abs(x) - 0.5;
53
+ float3 ox = floor(x + 0.5);
54
+ float3 a0 = x - ox;
55
+
56
+ // Normalise gradients implicitly by scaling m
57
+ // Approximation of: m *= inversesqrt( a0*a0 + h*h );
58
+ m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);
59
+
60
+ // Compute final noise value at P
61
+ float3 g;
62
+ g.x = a0.x * x0.x + h.x * x0.y;
63
+ g.yz = a0.yz * x12.xz + h.yz * x12.yw;
64
+ return 130.0 * dot(m, g);
65
+ }
66
+
67
+ float getNoise(float2 uv, float t, float scale, float speed) {
68
+ // generate multi-octave noise based on uv position and time
69
+ // move noise over time
70
+ // scale noise position relative to center
71
+ uv -= 0.5;
72
+ // octave 1
73
+ float scl = 4.0 * scale;
74
+ float noise = noise2d(float2(uv.x * scl, uv.y * scl - t * speed));
75
+ // octave 2
76
+ scl = 16.0 * scale;
77
+ noise += noise2d(float2(uv.x * scl + t * speed, uv.y * scl)) * 0.2;
78
+ // octave 3
79
+ scl = 26.0 * scale;
80
+ noise += noise2d(float2(uv.x * scl + t * speed, uv.y * scl)) * 0.2;
81
+ return noise;
82
+ }
@@ -0,0 +1,38 @@
1
+ // #include //ly.img.cesdk/shader/common/ubq_constants
2
+ // #include //ly.img.cesdk/shader/common/ubq_noise
3
+ uniform shader image;
4
+ uniform float2 imageSize;
5
+ uniform float slices;
6
+ uniform float offset;
7
+ uniform float speedV;
8
+ uniform float time;
9
+
10
+ float steppedVal(float v, float steps) {
11
+ return floor(v * steps) / steps;
12
+ }
13
+
14
+ // returns 0 - 1
15
+ float random1d(float n) {
16
+ const float scale = 0.2;
17
+ const float speed = 1.0;
18
+ return getNoise(float2(n, n), n, scale, speed);
19
+ }
20
+
21
+ // returns 0 - 1
22
+ float noise1d(float p) {
23
+ float fl = floor(p);
24
+ float fc = fract(p);
25
+ return mix(random1d(fl), random1d(fl + 1.0), fc);
26
+ }
27
+
28
+ half4 main(float2 coord) {
29
+ float2 uv = coord / imageSize;
30
+ // variable width strips
31
+ float n = noise1d((1 - uv.y) * slices + time * speedV * 3.0);
32
+ float ns = steppedVal(fract(n), slices) + 2.0;
33
+
34
+ float nsr = random1d(ns);
35
+ uv.x += nsr * sin(time * TWO_PI + nsr * 20.0) * offset;
36
+ uv *= imageSize;
37
+ return image.eval(uv);
38
+ }
@@ -0,0 +1,29 @@
1
+ // #include //ly.img.cesdk/shader/common/ubq_constants
2
+
3
+ // Inputs
4
+ uniform shader image;
5
+ uniform float2 imageSize;
6
+ uniform float dots;
7
+ uniform float size;
8
+ uniform float blur;
9
+
10
+ half4 main(float2 coord) {
11
+ float2 uv = coord / imageSize;
12
+ float dotSize = 1.0 / dots;
13
+ float2 samplePos = uv - mod(uv, dotSize) + 0.5 * dotSize;
14
+ float distanceFromSamplePoint = distance(samplePos, uv);
15
+ float4 imageColor = image.eval(samplePos * imageSize);
16
+
17
+ float4 backgroundColor = float4(0.0);
18
+
19
+ // Adjust blur value to avoid sharp transitions between image color and background color.
20
+ // Reasoning: when both lower and upper edge values are the same, smoothstep no longer provides
21
+ // a gradual transition between them (either immediatelly returs 0 or 1).
22
+ // This causes mix() to output imageColor or backgroundColor instead of doing a linear interpolation between them.
23
+ float adjustedBlur = max(blur, EPSILON);
24
+
25
+ float4 color =
26
+ mix(imageColor, backgroundColor,
27
+ smoothstep(dotSize * size, dotSize * (size + adjustedBlur), distanceFromSamplePoint));
28
+ return color;
29
+ }
@@ -0,0 +1,26 @@
1
+ // #include //ly.img.cesdk/shader/common/ubq_constants
2
+ uniform shader image;
3
+ uniform float4 lightColor;
4
+ uniform float4 darkColor;
5
+ uniform float intensity;
6
+
7
+ half4 main(float2 coord) {
8
+ float4 sampledCol = image.eval(coord);
9
+ float4 color = clamp(sampledCol, 0.0, 1.0); // necessary to get rid of all extended sRGB issues with OpenGL ES
10
+
11
+ // Apply intensity as "symmetric gamma"
12
+ if (intensity > 0.0) {
13
+ color.rgb = 1.0 - pow(1.0 - color.rgb, float3(max(intensity + 1.0, EPSILON)));
14
+ } else {
15
+ color.rgb = pow(color.rgb, float3(max(-intensity + 1.0, EPSILON)));
16
+ }
17
+
18
+ // Colorimetric (perceptual luminance-preserving) RGB to grayscale conversion
19
+ // https://en.wikipedia.org/wiki/Grayscale#Colorimetric_(perceptual_luminance-preserving)_conversion_to_grayscale
20
+ float luminance = dot(GRAYSCALE_WEIGHTS, color.rgb);
21
+
22
+ // Apply DuoTone
23
+ float4 duotone = mix(darkColor, lightColor, clamp(luminance, 0.0, 1.0));
24
+ duotone *= color.a;
25
+ return duotone;
26
+ }