react-native-shine 0.4.1 → 0.5.0
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/lib/module/components/Content.js +22 -23
- package/lib/module/components/Content.js.map +1 -1
- package/lib/module/components/ShineGroup.js +0 -2
- package/lib/module/components/ShineGroup.js.map +1 -1
- package/lib/module/config/debugMode.js +4 -0
- package/lib/module/config/debugMode.js.map +1 -0
- package/lib/module/enums/colorPresets.js +71 -0
- package/lib/module/enums/colorPresets.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/shaders/bindGroupLayouts.js +10 -1
- package/lib/module/shaders/bindGroupLayouts.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/colorMaskFragment.js +37 -6
- package/lib/module/shaders/fragmentShaders/colorMaskFragment.js.map +1 -1
- package/lib/module/shaders/resourceManagement/bitmaps.js +4 -3
- package/lib/module/shaders/resourceManagement/bitmaps.js.map +1 -1
- package/lib/module/shaders/resourceManagement/bufferManager.js +6 -1
- package/lib/module/shaders/resourceManagement/bufferManager.js.map +1 -1
- package/lib/module/shaders/tgpuUtils.js +27 -19
- package/lib/module/shaders/tgpuUtils.js.map +1 -1
- package/lib/module/types/typeUtils.js +36 -4
- package/lib/module/types/typeUtils.js.map +1 -1
- package/lib/module/utils/vector.js +7 -0
- package/lib/module/utils/vector.js.map +1 -1
- package/lib/typescript/src/components/Content.d.ts +4 -2
- package/lib/typescript/src/components/Content.d.ts.map +1 -1
- package/lib/typescript/src/components/ShineGroup.d.ts +1 -1
- package/lib/typescript/src/components/ShineGroup.d.ts.map +1 -1
- package/lib/typescript/src/config/debugMode.d.ts +2 -0
- package/lib/typescript/src/config/debugMode.d.ts.map +1 -0
- package/lib/typescript/src/enums/colorPresets.d.ts +33 -0
- package/lib/typescript/src/enums/colorPresets.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/shaders/bindGroupLayouts.d.ts +27 -0
- package/lib/typescript/src/shaders/bindGroupLayouts.d.ts.map +1 -1
- package/lib/typescript/src/shaders/bindGroupUtils.d.ts +18 -0
- package/lib/typescript/src/shaders/bindGroupUtils.d.ts.map +1 -1
- package/lib/typescript/src/shaders/fragmentShaders/colorMaskFragment.d.ts.map +1 -1
- package/lib/typescript/src/shaders/resourceManagement/bitmaps.d.ts.map +1 -1
- package/lib/typescript/src/shaders/resourceManagement/bufferManager.d.ts.map +1 -1
- package/lib/typescript/src/shaders/tgpuUtils.d.ts +1 -0
- package/lib/typescript/src/shaders/tgpuUtils.d.ts.map +1 -1
- package/lib/typescript/src/types/typeUtils.d.ts +9 -0
- package/lib/typescript/src/types/typeUtils.d.ts.map +1 -1
- package/lib/typescript/src/types/types.d.ts +9 -0
- package/lib/typescript/src/types/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/vector.d.ts +1 -0
- package/lib/typescript/src/utils/vector.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Content.tsx +17 -8
- package/src/components/ShineGroup.tsx +0 -2
- package/src/config/debugMode.ts +1 -0
- package/src/enums/colorPresets.ts +41 -0
- package/src/index.tsx +1 -0
- package/src/shaders/bindGroupLayouts.ts +9 -0
- package/src/shaders/fragmentShaders/colorMaskFragment.ts +46 -4
- package/src/shaders/resourceManagement/bitmaps.ts +4 -3
- package/src/shaders/resourceManagement/bufferManager.ts +10 -1
- package/src/shaders/tgpuUtils.ts +38 -21
- package/src/types/typeUtils.ts +33 -2
- package/src/types/types.ts +6 -0
- package/src/utils/vector.ts +4 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as d from 'typegpu/data';
|
|
2
2
|
export declare const hueShift: import("typegpu").TgpuFn<(rgb: d.Vec3f, angle: d.F32) => d.Vec3f>;
|
|
3
3
|
export declare const rgbToHSV: import("typegpu").TgpuFn<(rgb: d.Vec3f) => d.Vec3f>;
|
|
4
|
+
export declare const hsvToRGB: import("typegpu").TgpuFn<(hsv: d.Vec3f) => d.Vec3f>;
|
|
4
5
|
export declare const fmod: import("typegpu").TgpuFn<(number: d.F32, md: d.F32) => d.F32>;
|
|
5
6
|
export declare const glareColorShift: import("typegpu").TgpuFn<(color: d.Vec3f, power: d.F32) => d.Vec3f>;
|
|
6
7
|
export declare const overlayChannel: import("typegpu").TgpuFn<(base: d.F32, blend: d.F32) => d.F32>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tgpuUtils.d.ts","sourceRoot":"","sources":["../../../../src/shaders/tgpuUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,eAAO,MAAM,QAAQ,mEA6BnB,CAAC;AAEH,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"tgpuUtils.d.ts","sourceRoot":"","sources":["../../../../src/shaders/tgpuUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,eAAO,MAAM,QAAQ,mEA6BnB,CAAC;AAEH,eAAO,MAAM,QAAQ,qDA6BnB,CAAC;AAEH,eAAO,MAAM,QAAQ,qDAanB,CAAC;AAEH,eAAO,MAAM,IAAI,+DASf,CAAC;AAEH,eAAO,MAAM,eAAe,qEAc1B,CAAC;AAEH,eAAO,MAAM,cAAc,gEAYzB,CAAC;AAEH,eAAO,MAAM,eAAe,sEAS1B,CAAC;AAEH,mBAAmB;AACnB,eAAO,MAAM,OAAO,mDAQlB,CAAC;AAEH,eAAO,MAAM,0BAA0B,+DAcrC,CAAC;AAEH,eAAO,MAAM,UAAU,yEAMrB,CAAC"}
|
|
@@ -9,6 +9,15 @@ export declare const colorMaskToTyped: (colorMask: ColorMask) => {
|
|
|
9
9
|
upper: any;
|
|
10
10
|
lower: any;
|
|
11
11
|
};
|
|
12
|
+
useHSV: number;
|
|
13
|
+
hueToleranceRange: {
|
|
14
|
+
lower: number;
|
|
15
|
+
upper: number;
|
|
16
|
+
};
|
|
17
|
+
brightnessTolerance: number;
|
|
18
|
+
saturationTolerance: number;
|
|
19
|
+
lowSaturationThreshold: number;
|
|
20
|
+
lowBrightnessThreshold: number;
|
|
12
21
|
};
|
|
13
22
|
export declare const createHoloOptions: (options: Partial<HoloOptions>) => HoloOptions;
|
|
14
23
|
export declare const createReverseHoloDetectionChannelFlags: (options?: Partial<ReverseHoloDetectionChannelFlags>) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeUtils.d.ts","sourceRoot":"","sources":["../../../../src/types/typeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAuB,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,qBAAqB,EAErB,WAAW,EACX,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,kBAAkB,GAC7B,SAAS,OAAO,CAAC,YAAY,CAAC,KAC7B,YAoBF,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACvD,KAAK,CAAC,KACL,GACA,CAAC,IAAI,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,GAQvC,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,WAAW,qBAAqB,CAAC,SAAS,EAAE,WAAW,CAAC,KACvD,
|
|
1
|
+
{"version":3,"file":"typeUtils.d.ts","sourceRoot":"","sources":["../../../../src/types/typeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAuB,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,qBAAqB,EAErB,WAAW,EACX,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,kBAAkB,GAC7B,SAAS,OAAO,CAAC,YAAY,CAAC,KAC7B,YAoBF,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACvD,KAAK,CAAC,KACL,GACA,CAAC,IAAI,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,GAQvC,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,WAAW,qBAAqB,CAAC,SAAS,EAAE,WAAW,CAAC,KACvD,SAqCF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,WAAW,SAAS;;;;;;;;;;;;;;;CAkBpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,OAAO,CAAC,WAAW,CAAC,KAC5B,WAQF,CAAC;AAEF,eAAO,MAAM,sCAAsC,GACjD,UAAU,OAAO,CAAC,gCAAgC,CAAC;;;;;;;CA2BpD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,QAkB7C,CAAC"}
|
|
@@ -14,6 +14,15 @@ export type GlareOptions = {
|
|
|
14
14
|
};
|
|
15
15
|
export type ColorMask = {
|
|
16
16
|
baseColor: vec3;
|
|
17
|
+
useHSV?: boolean;
|
|
18
|
+
hueToleranceRange: {
|
|
19
|
+
upper: number;
|
|
20
|
+
lower: number;
|
|
21
|
+
};
|
|
22
|
+
brightnessTolerance?: number;
|
|
23
|
+
lowBrightnessThreshold?: number;
|
|
24
|
+
saturationTolerance?: number;
|
|
25
|
+
lowSaturationThreshold?: number;
|
|
17
26
|
rgbToleranceRange: {
|
|
18
27
|
upper: vec3;
|
|
19
28
|
lower: vec3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EA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AAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,IAAI,GACJ,SAAS,CAAC;AAId,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3E,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAC5E,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE1B,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,KAAK,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,CACtC,kBAAkB,CAAC,qBAAqB,CAAC,CAC1C,CAAC,CAAC,CAAC,CAAC;AAEL,MAAM,MAAM,sBAAsB,GAAG,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC"}
|
|
@@ -25,6 +25,7 @@ export declare function transformV3d(v3d: V3d, transformer: Transformer): V3d;
|
|
|
25
25
|
export declare function clamp(v: number, min?: number, max?: number): number;
|
|
26
26
|
export declare function clampV3d(v3d: V3d, min: number, max: number): V3d;
|
|
27
27
|
export declare function degToRad(deg: number): number;
|
|
28
|
+
export declare function createV3d(x: number, y: number, z: number): V3d;
|
|
28
29
|
export declare const zeroV3d: {
|
|
29
30
|
x: number;
|
|
30
31
|
y: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../../src/utils/vector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WA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,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAG5E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,GAAG,GAAG,CAMpE;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,SAAK,EAAE,GAAG,SAAI,GAAG,MAAM,CAG1D;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG,CAGhE;AAID,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG,CAE9D;AAED,eAAO,MAAM,OAAO;;;;CAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-shine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Fast and efficient way of adding interactive effects that are run entirely on shaders using typeGPU.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { PixelRatio, View } from 'react-native';
|
|
2
|
+
import { PixelRatio, View, type ViewStyle } from 'react-native';
|
|
3
3
|
import Animated, {
|
|
4
4
|
SensorType,
|
|
5
5
|
type SharedValue,
|
|
@@ -80,12 +80,13 @@ export interface SharedProps {
|
|
|
80
80
|
height: number;
|
|
81
81
|
glareOptions?: Partial<GlareOptions>;
|
|
82
82
|
colorMaskOptions?: DeepPartiallyOptional<ColorMask, 'baseColor'>;
|
|
83
|
-
useTouchControl?: boolean;
|
|
84
83
|
touchPosition?: SharedValue<V2d>;
|
|
85
84
|
addReverseHolo?: boolean;
|
|
86
85
|
reverseHoloDetectionChannelOptions?: Partial<ReverseHoloDetectionChannelFlags>;
|
|
87
86
|
addHolo?: boolean;
|
|
88
87
|
translateViewIn3d?: boolean;
|
|
88
|
+
style?: ViewStyle;
|
|
89
|
+
containerStyle?: ViewStyle;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
interface ContentProps extends SharedProps {
|
|
@@ -113,9 +114,10 @@ export default function Content({
|
|
|
113
114
|
maskTexture,
|
|
114
115
|
root,
|
|
115
116
|
touchPosition,
|
|
116
|
-
useTouchControl,
|
|
117
117
|
width,
|
|
118
118
|
translateViewIn3d = false,
|
|
119
|
+
style,
|
|
120
|
+
containerStyle,
|
|
119
121
|
}: ContentProps) {
|
|
120
122
|
const { device } = root;
|
|
121
123
|
// const { ref, context } = useGPUContext();
|
|
@@ -152,8 +154,6 @@ export default function Content({
|
|
|
152
154
|
[]
|
|
153
155
|
);
|
|
154
156
|
|
|
155
|
-
//TODO: add once again, when the wgpu issues are fixed :3
|
|
156
|
-
|
|
157
157
|
const animatedStyle = useAnimatedStyle(() => {
|
|
158
158
|
const rotX = rotation.value.x * 10;
|
|
159
159
|
const rotY = rotation.value.y * 10;
|
|
@@ -166,6 +166,7 @@ export default function Content({
|
|
|
166
166
|
],
|
|
167
167
|
};
|
|
168
168
|
});
|
|
169
|
+
|
|
169
170
|
// Subscribe to orientation changes and reset calibration on change
|
|
170
171
|
useEffect(
|
|
171
172
|
() =>
|
|
@@ -179,7 +180,7 @@ export default function Content({
|
|
|
179
180
|
useDerivedValue(() => {
|
|
180
181
|
'worklet';
|
|
181
182
|
|
|
182
|
-
if (
|
|
183
|
+
if (touchPosition) {
|
|
183
184
|
rotation.value = touchPosition
|
|
184
185
|
? { x: touchPosition.value.x, y: touchPosition.value.y, z: 0 }
|
|
185
186
|
: zeroV3d;
|
|
@@ -229,6 +230,7 @@ export default function Content({
|
|
|
229
230
|
1
|
|
230
231
|
);
|
|
231
232
|
});
|
|
233
|
+
|
|
232
234
|
// Render loop
|
|
233
235
|
useEffect(() => {
|
|
234
236
|
if (!context) return;
|
|
@@ -286,7 +288,9 @@ export default function Content({
|
|
|
286
288
|
root,
|
|
287
289
|
'colorMask',
|
|
288
290
|
colorMaskToTyped(
|
|
289
|
-
createColorMask(
|
|
291
|
+
createColorMask(
|
|
292
|
+
colorMaskOptions ?? { baseColor: [-20, -20, -20], useHSV: false }
|
|
293
|
+
)
|
|
290
294
|
)
|
|
291
295
|
);
|
|
292
296
|
const colorMaskBindGroup = createColorMaskBindGroup(root, colorMaskBuffer);
|
|
@@ -424,11 +428,16 @@ export default function Content({
|
|
|
424
428
|
matrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 50, 1],
|
|
425
429
|
},
|
|
426
430
|
],
|
|
431
|
+
...containerStyle,
|
|
427
432
|
}}
|
|
428
433
|
>
|
|
429
434
|
<Animated.View style={[translateViewIn3d && animatedStyle]}>
|
|
430
435
|
<View>
|
|
431
|
-
<Canvas
|
|
436
|
+
<Canvas
|
|
437
|
+
ref={ref}
|
|
438
|
+
style={[{ width, height }, style]}
|
|
439
|
+
transparent={true}
|
|
440
|
+
/>
|
|
432
441
|
</View>
|
|
433
442
|
</Animated.View>
|
|
434
443
|
</View>
|
|
@@ -19,7 +19,6 @@ export function ShineGroup({
|
|
|
19
19
|
colorMaskOptions,
|
|
20
20
|
maskURI,
|
|
21
21
|
touchPosition,
|
|
22
|
-
useTouchControl = false,
|
|
23
22
|
addHolo = false,
|
|
24
23
|
addReverseHolo = false,
|
|
25
24
|
}: ShineGroupProps) {
|
|
@@ -80,7 +79,6 @@ export function ShineGroup({
|
|
|
80
79
|
colorMaskOptions={colorMaskOptions}
|
|
81
80
|
maskURI={maskURI}
|
|
82
81
|
touchPosition={touchPosition}
|
|
83
|
-
useTouchControl={useTouchControl}
|
|
84
82
|
addReverseHolo={addReverseHolo}
|
|
85
83
|
addHolo={addHolo}
|
|
86
84
|
/>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const debug = false;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { vec3 } from '../types/types';
|
|
2
|
+
|
|
3
|
+
export const ColorPresets = {
|
|
4
|
+
// --- Primary & Secondary ---
|
|
5
|
+
RED: [255, 0, 0], // #FF0000
|
|
6
|
+
GREEN: [0, 255, 0], // #00FF00
|
|
7
|
+
BLUE: [0, 0, 255], // #0000FF
|
|
8
|
+
YELLOW: [255, 255, 0], // #FFFF00
|
|
9
|
+
CYAN: [0, 255, 255], // #00FFFF
|
|
10
|
+
MAGENTA: [255, 0, 255], // #FF00FF
|
|
11
|
+
|
|
12
|
+
// --- Grayscale ---
|
|
13
|
+
WHITE: [255, 255, 255], // #FFFFFF
|
|
14
|
+
BLACK: [0, 0, 0], // #000000
|
|
15
|
+
GRAY: [128, 128, 128], // #808080
|
|
16
|
+
LIGHT_GRAY: [211, 211, 211], // #D3D3D3
|
|
17
|
+
DARK_GRAY: [105, 105, 105], // #696969
|
|
18
|
+
|
|
19
|
+
// --- Common Colors ---
|
|
20
|
+
ORANGE: [255, 165, 0], // #FFA500
|
|
21
|
+
PURPLE: [128, 0, 128], // #800080
|
|
22
|
+
BROWN: [165, 42, 42], // #A52A2A
|
|
23
|
+
PINK: [255, 192, 203], // #FFC0CB
|
|
24
|
+
LIME_GREEN: [50, 205, 50], // #32CD32
|
|
25
|
+
FOREST_GREEN: [34, 139, 34], // #228B22
|
|
26
|
+
OLIVE: [128, 128, 0], // #808000
|
|
27
|
+
TEAL: [0, 128, 128], // #008080
|
|
28
|
+
NAVY: [0, 0, 128], // #000080
|
|
29
|
+
ROYAL_BLUE: [65, 105, 225], // #4169E1
|
|
30
|
+
SKY_BLUE: [135, 206, 235], // #87CEEB
|
|
31
|
+
INDIGO: [75, 0, 130], // #4B0082
|
|
32
|
+
VIOLET: [238, 130, 238], // #EE82EE
|
|
33
|
+
MAROON: [128, 0, 0], // #800000
|
|
34
|
+
|
|
35
|
+
// --- Hues & Tints ---
|
|
36
|
+
GOLD: [255, 215, 0], // #FFD700
|
|
37
|
+
TOMATO: [255, 99, 71], // #FF6347
|
|
38
|
+
SALMON: [250, 128, 114], // #FA8072
|
|
39
|
+
BEIGE: [245, 245, 220], // #F5F5DC
|
|
40
|
+
POTATO: [222, 184, 135], // #DEB887
|
|
41
|
+
} as const satisfies Record<string, vec3>;
|
package/src/index.tsx
CHANGED
|
@@ -39,6 +39,15 @@ export const colorMaskSchema = d.struct({
|
|
|
39
39
|
upper: d.vec3f,
|
|
40
40
|
lower: d.vec3f,
|
|
41
41
|
}),
|
|
42
|
+
hueToleranceRange: d.struct({
|
|
43
|
+
upper: d.f32,
|
|
44
|
+
lower: d.f32,
|
|
45
|
+
}),
|
|
46
|
+
useHSV: d.align(16, d.u32),
|
|
47
|
+
brightnessTolerance: d.f32,
|
|
48
|
+
saturationTolerance: d.f32,
|
|
49
|
+
lowSaturationThreshold: d.f32,
|
|
50
|
+
lowBrightnessThreshold: d.f32,
|
|
42
51
|
});
|
|
43
52
|
|
|
44
53
|
export type ColorMaskSchema = typeof colorMaskSchema;
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
textureBindGroupLayout,
|
|
6
6
|
colorMaskBindGroupLayout,
|
|
7
7
|
} from '../bindGroupLayouts';
|
|
8
|
+
import { rgbToHSV } from '../tgpuUtils';
|
|
8
9
|
|
|
9
10
|
const colorMaskFragment = tgpu['~unstable'].fragmentFn({
|
|
10
11
|
in: { uv: d.vec2f },
|
|
@@ -15,6 +16,16 @@ const colorMaskFragment = tgpu['~unstable'].fragmentFn({
|
|
|
15
16
|
const mask = colorMaskBindGroupLayout.$.mask;
|
|
16
17
|
const maskedColor = mask.baseColor;
|
|
17
18
|
const rgbToleranceRange = mask.rgbToleranceRange;
|
|
19
|
+
const useHSV = mask.useHSV;
|
|
20
|
+
|
|
21
|
+
const hueToleranceRange = mask.hueToleranceRange;
|
|
22
|
+
const hueUpper = hueToleranceRange.upper;
|
|
23
|
+
const hueLower = hueToleranceRange.lower;
|
|
24
|
+
|
|
25
|
+
const brightnessTolerance = mask.brightnessTolerance;
|
|
26
|
+
const saturationTolerance = mask.saturationTolerance;
|
|
27
|
+
const lowSaturationThreshold = mask.lowSaturationThreshold;
|
|
28
|
+
const lowBrightnessThreshold = mask.lowBrightnessThreshold;
|
|
18
29
|
|
|
19
30
|
let color = std.textureSample(
|
|
20
31
|
textureBindGroupLayout.$.texture,
|
|
@@ -26,10 +37,41 @@ const colorMaskFragment = tgpu['~unstable'].fragmentFn({
|
|
|
26
37
|
const maskedColorUpper = std.add(maskedColor, rgbToleranceRange.upper);
|
|
27
38
|
const upperCheck = std.all(std.le(color.xyz, maskedColorUpper));
|
|
28
39
|
const lowerCheck = std.all(std.ge(color.xyz, maskedColorLower));
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
const rgbCheck = upperCheck && lowerCheck;
|
|
41
|
+
|
|
42
|
+
const maskedHSV = rgbToHSV(maskedColor);
|
|
43
|
+
const colorHSV = rgbToHSV(color.xyz);
|
|
44
|
+
|
|
45
|
+
let hueDiff = std.sub(colorHSV.x, maskedHSV.x);
|
|
46
|
+
hueDiff = std.select(hueDiff, std.sub(hueDiff, 1.0), hueDiff > d.f32(0.5));
|
|
47
|
+
hueDiff = std.select(hueDiff, std.add(hueDiff, 1.0), hueDiff < d.f32(-0.5));
|
|
48
|
+
const lowerHueCheck = hueDiff >= -hueLower;
|
|
49
|
+
const upperHueCheck = hueDiff <= hueUpper;
|
|
50
|
+
let hueCheck = lowerHueCheck && upperHueCheck;
|
|
51
|
+
|
|
52
|
+
const saturationDiff = std.abs(std.sub(colorHSV.y, maskedHSV.y));
|
|
53
|
+
const saturationCheck = saturationDiff <= saturationTolerance;
|
|
54
|
+
|
|
55
|
+
const brightnessDiff = std.abs(std.sub(colorHSV.z, maskedHSV.z));
|
|
56
|
+
const brightnessCheck = brightnessDiff <= brightnessTolerance;
|
|
57
|
+
|
|
58
|
+
const pixelIsGray = colorHSV.y < lowSaturationThreshold;
|
|
59
|
+
const targetIsGray = maskedHSV.y < lowSaturationThreshold;
|
|
60
|
+
|
|
61
|
+
const pixelIsBlack = colorHSV.z < lowBrightnessThreshold;
|
|
62
|
+
const targetIsBlack = maskedHSV.z < lowBrightnessThreshold;
|
|
63
|
+
|
|
64
|
+
//hue is unstable when either color is gray or black (low saturation or low brightness)
|
|
65
|
+
const hueIsUnstable =
|
|
66
|
+
pixelIsGray || targetIsGray || pixelIsBlack || targetIsBlack;
|
|
67
|
+
|
|
68
|
+
hueCheck = std.select(hueCheck, d.bool(true), hueIsUnstable);
|
|
69
|
+
|
|
70
|
+
const hsvCheck = hueCheck && saturationCheck && brightnessCheck;
|
|
71
|
+
const maskCheck = std.select(rgbCheck, hsvCheck, useHSV === d.u32(1));
|
|
72
|
+
|
|
73
|
+
color = std.select(color, d.vec4f(color.xyz, 0.0), maskCheck);
|
|
74
|
+
return color;
|
|
33
75
|
});
|
|
34
76
|
|
|
35
77
|
export default colorMaskFragment;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Asset } from 'expo-asset';
|
|
2
|
+
import { debug } from '../../config/debugMode';
|
|
2
3
|
|
|
3
4
|
const getBitmapFromURI = async (uri: string): Promise<ImageBitmap> => {
|
|
4
5
|
if (uriToBitmapMap.has(uri)) return uriToBitmapMap.get(uri)!;
|
|
5
|
-
console.log('bitmap not found in cache, fetching from URI');
|
|
6
|
+
if (debug) console.log('bitmap not found in cache, fetching from URI');
|
|
6
7
|
|
|
7
8
|
const ast = Asset.fromURI(uri);
|
|
8
9
|
await ast.downloadAsync();
|
|
9
10
|
const fileURI = ast.localUri || ast.uri;
|
|
10
11
|
|
|
11
|
-
console.log('fetch completed, creating ImageBitmap');
|
|
12
|
+
if (debug) console.log('fetch completed, creating ImageBitmap');
|
|
12
13
|
const response = await fetch(fileURI);
|
|
13
14
|
const blob = await response.blob();
|
|
14
15
|
const imageBitmap = await createImageBitmap(blob);
|
|
15
16
|
|
|
16
|
-
console.log('bitmap size: ', imageBitmap);
|
|
17
|
+
if (debug) console.log('bitmap size: ', imageBitmap);
|
|
17
18
|
uriToBitmapMap.set(uri, imageBitmap);
|
|
18
19
|
return imageBitmap;
|
|
19
20
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TgpuRoot, TgpuBuffer, ValidateBufferSchema } from 'typegpu';
|
|
2
|
+
import { debug } from '../../config/debugMode';
|
|
2
3
|
|
|
3
4
|
export type BufferUsageType = 'uniform' | 'storage' | 'vertex';
|
|
4
5
|
|
|
@@ -49,7 +50,15 @@ export class TypedBufferMap<
|
|
|
49
50
|
|
|
50
51
|
const { schema, usage } = entry;
|
|
51
52
|
if (this.buffers[key]) {
|
|
52
|
-
console.warn(`Buffer "${String(key)}" already exists
|
|
53
|
+
if (debug) console.warn(`Buffer "${String(key)}" already exists.`);
|
|
54
|
+
|
|
55
|
+
if (initValues) {
|
|
56
|
+
(this.buffers[key] as TgpuBuffer<any>).write(initValues);
|
|
57
|
+
if (debug)
|
|
58
|
+
console.log(
|
|
59
|
+
`Buffer "${String(key)}" updated with new initial values.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
53
62
|
return this.buffers[key]!;
|
|
54
63
|
}
|
|
55
64
|
|
package/src/shaders/tgpuUtils.ts
CHANGED
|
@@ -33,33 +33,50 @@ export const hueShift = tgpu.fn(
|
|
|
33
33
|
return d.vec3f(r, g, b);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
export const rgbToHSV = tgpu.fn(
|
|
36
|
+
export const rgbToHSV = tgpu['~unstable'].fn(
|
|
37
37
|
[d.vec3f],
|
|
38
38
|
d.vec3f
|
|
39
39
|
)((rgb) => {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const hueRmax = d.f32(60.0) * fmod((rgb.y - rgb.z) / delta, d.f32(6.0));
|
|
46
|
-
const hueGmax = d.f32(60.0) * ((rgb.z - rgb.x) / delta + d.f32(2.0));
|
|
47
|
-
const hueBmax = d.f32(60.0) * ((rgb.x - rgb.y) / delta + d.f32(4.0));
|
|
48
|
-
|
|
49
|
-
let hue = std.select(
|
|
50
|
-
hueDeltaZero,
|
|
51
|
-
hueRmax,
|
|
52
|
-
cMax === rgb.x && delta !== d.f32(0.0)
|
|
40
|
+
const K = d.vec4f(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
|
41
|
+
const p = std.mix(
|
|
42
|
+
d.vec4f(rgb.y, rgb.z, K.w, K.z),
|
|
43
|
+
d.vec4f(rgb.z, rgb.y, K.x, K.y),
|
|
44
|
+
std.step(rgb.z, rgb.y)
|
|
53
45
|
);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
const q = std.mix(
|
|
47
|
+
d.vec4f(p.x, p.y, p.w, rgb.x),
|
|
48
|
+
d.vec4f(rgb.x, p.y, p.z, p.x),
|
|
49
|
+
std.step(p.x, rgb.x)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const d_val = std.sub(q.x, std.min(q.w, q.y));
|
|
53
|
+
const epsilon = d.f32(1.0e-10);
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
const h = std.abs(
|
|
56
|
+
std.add(
|
|
57
|
+
q.z,
|
|
58
|
+
std.div(std.sub(q.w, q.y), std.add(std.mul(6.0, d_val), epsilon))
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
const s = std.div(d_val, std.add(q.x, epsilon));
|
|
62
|
+
const v = q.x;
|
|
63
|
+
|
|
64
|
+
return d.vec3f(h, s, v);
|
|
65
|
+
});
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
export const hsvToRGB = tgpu['~unstable'].fn(
|
|
68
|
+
[d.vec3f],
|
|
69
|
+
d.vec3f
|
|
70
|
+
)((hsv) => {
|
|
71
|
+
const K = d.vec4f(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
72
|
+
const p = std.abs(
|
|
73
|
+
std.sub(std.mul(std.fract(std.add(hsv.xxx, K.xxx)), 6.0), K.zzz)
|
|
74
|
+
);
|
|
75
|
+
const rgb = std.mul(
|
|
76
|
+
hsv.z,
|
|
77
|
+
std.mix(K.xxx, std.saturate(std.sub(p, K.xxx)), hsv.y)
|
|
78
|
+
);
|
|
79
|
+
return rgb;
|
|
63
80
|
});
|
|
64
81
|
|
|
65
82
|
export const fmod = tgpu.fn(
|
package/src/types/typeUtils.ts
CHANGED
|
@@ -51,16 +51,39 @@ export const mapToF32 = <T extends Record<string, number>>(
|
|
|
51
51
|
export const createColorMask = (
|
|
52
52
|
colorMask: DeepPartiallyOptional<ColorMask, 'baseColor'>
|
|
53
53
|
): ColorMask => {
|
|
54
|
-
const {
|
|
54
|
+
const {
|
|
55
|
+
baseColor,
|
|
56
|
+
rgbToleranceRange,
|
|
57
|
+
useHSV,
|
|
58
|
+
hueToleranceRange,
|
|
59
|
+
brightnessTolerance,
|
|
60
|
+
saturationTolerance,
|
|
61
|
+
lowBrightnessThreshold,
|
|
62
|
+
lowSaturationThreshold,
|
|
63
|
+
} = colorMask;
|
|
55
64
|
const baseTolerance = {
|
|
56
65
|
upper: [20, 20, 20] as vec3,
|
|
57
66
|
lower: [20, 20, 20] as vec3,
|
|
58
67
|
};
|
|
68
|
+
const baseHueTolerance = {
|
|
69
|
+
upper: 20,
|
|
70
|
+
lower: 20,
|
|
71
|
+
};
|
|
59
72
|
const tolerance = { ...baseTolerance, ...rgbToleranceRange };
|
|
73
|
+
const hueTolerance = { ...baseHueTolerance, ...hueToleranceRange };
|
|
60
74
|
|
|
75
|
+
// TODO: add radian and degree angle handling
|
|
76
|
+
// '123deg' <- interpret as a numeric angle value
|
|
77
|
+
// 2 <- interpret as a radian value
|
|
61
78
|
const mask: ColorMask = {
|
|
62
79
|
baseColor: baseColor,
|
|
63
80
|
rgbToleranceRange: tolerance,
|
|
81
|
+
useHSV: useHSV!!,
|
|
82
|
+
hueToleranceRange: hueTolerance,
|
|
83
|
+
brightnessTolerance: brightnessTolerance ?? 1.0,
|
|
84
|
+
saturationTolerance: saturationTolerance ?? 1.0,
|
|
85
|
+
lowBrightnessThreshold: lowBrightnessThreshold ?? 0.0,
|
|
86
|
+
lowSaturationThreshold: lowSaturationThreshold ?? 0.0,
|
|
64
87
|
};
|
|
65
88
|
|
|
66
89
|
return mask;
|
|
@@ -73,6 +96,15 @@ export const colorMaskToTyped = (colorMask: ColorMask) => {
|
|
|
73
96
|
upper: div(numberArrToTyped(colorMask.rgbToleranceRange.upper), 255),
|
|
74
97
|
lower: div(numberArrToTyped(colorMask.rgbToleranceRange.lower), 255),
|
|
75
98
|
},
|
|
99
|
+
useHSV: d.u32(colorMask.useHSV ? 1 : 0),
|
|
100
|
+
hueToleranceRange: {
|
|
101
|
+
lower: div(f32(colorMask.hueToleranceRange.lower), 360),
|
|
102
|
+
upper: div(f32(colorMask.hueToleranceRange.upper), 360),
|
|
103
|
+
},
|
|
104
|
+
brightnessTolerance: f32(colorMask.brightnessTolerance),
|
|
105
|
+
saturationTolerance: f32(colorMask.saturationTolerance),
|
|
106
|
+
lowSaturationThreshold: f32(colorMask.lowSaturationThreshold),
|
|
107
|
+
lowBrightnessThreshold: f32(colorMask.lowBrightnessThreshold),
|
|
76
108
|
};
|
|
77
109
|
return result;
|
|
78
110
|
};
|
|
@@ -116,7 +148,6 @@ export const createReverseHoloDetectionChannelFlags = (
|
|
|
116
148
|
};
|
|
117
149
|
}
|
|
118
150
|
|
|
119
|
-
console.log('createReverseHoloDetectionChannelFlags:', channelFlags);
|
|
120
151
|
return channelFlags;
|
|
121
152
|
};
|
|
122
153
|
|
package/src/types/types.ts
CHANGED
|
@@ -21,6 +21,12 @@ export type GlareOptions = {
|
|
|
21
21
|
|
|
22
22
|
export type ColorMask = {
|
|
23
23
|
baseColor: vec3;
|
|
24
|
+
useHSV?: boolean;
|
|
25
|
+
hueToleranceRange: { upper: number; lower: number };
|
|
26
|
+
brightnessTolerance?: number;
|
|
27
|
+
lowBrightnessThreshold?: number;
|
|
28
|
+
saturationTolerance?: number;
|
|
29
|
+
lowSaturationThreshold?: number;
|
|
24
30
|
rgbToleranceRange: {
|
|
25
31
|
upper: vec3;
|
|
26
32
|
lower: vec3;
|
package/src/utils/vector.ts
CHANGED