react-native-shine 0.7.1 → 0.8.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 +112 -145
- package/lib/module/components/Content.js.map +1 -1
- package/lib/module/components/Shine.js +14 -5
- package/lib/module/components/Shine.js.map +1 -1
- package/lib/module/components/ShineGroup.js +0 -4
- package/lib/module/components/ShineGroup.js.map +1 -1
- package/lib/module/enums/colorPresets.js +192 -0
- package/lib/module/enums/colorPresets.js.map +1 -1
- package/lib/module/enums/effectDefaults.js +59 -0
- package/lib/module/enums/effectDefaults.js.map +1 -0
- package/lib/module/enums/effectPresets.js +67 -10
- package/lib/module/enums/effectPresets.js.map +1 -1
- package/lib/module/shaders/bindGroupLayouts.js +47 -29
- package/lib/module/shaders/bindGroupLayouts.js.map +1 -1
- package/lib/module/shaders/bindGroupUtils.js +30 -44
- package/lib/module/shaders/bindGroupUtils.js.map +1 -1
- package/lib/module/shaders/colorConversions.js +78 -0
- package/lib/module/shaders/colorConversions.js.map +1 -0
- package/lib/module/shaders/computeShaders/precomputeColorMask.js +5 -5
- package/lib/module/shaders/computeShaders/precomputeColorMask.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/baseTextureFragment.js +4 -9
- package/lib/module/shaders/fragmentShaders/baseTextureFragment.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/colorMaskFragment.js +28 -41
- package/lib/module/shaders/fragmentShaders/colorMaskFragment.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/glareFlareFragment.js +84 -0
- package/lib/module/shaders/fragmentShaders/glareFlareFragment.js.map +1 -0
- package/lib/module/shaders/fragmentShaders/glareFragment.js +8 -88
- package/lib/module/shaders/fragmentShaders/glareFragment.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/holoFragment.js +120 -11
- package/lib/module/shaders/fragmentShaders/holoFragment.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/maskFragment.js +5 -4
- package/lib/module/shaders/fragmentShaders/maskFragment.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/reverseHoloFragment.js +7 -7
- package/lib/module/shaders/fragmentShaders/reverseHoloFragment.js.map +1 -1
- package/lib/module/shaders/pipelineSetups.js +2 -61
- package/lib/module/shaders/pipelineSetups.js.map +1 -1
- package/lib/module/shaders/resourceManagement/buffersMap.js +41 -0
- package/lib/module/shaders/resourceManagement/buffersMap.js.map +1 -0
- package/lib/module/shaders/resourceManagement/pipelineMap.js +115 -0
- package/lib/module/shaders/resourceManagement/pipelineMap.js.map +1 -0
- package/lib/module/shaders/resourceManagement/textures.js +2 -2
- package/lib/module/shaders/resourceManagement/textures.js.map +1 -1
- package/lib/module/shaders/tgpuUtils.js +41 -0
- package/lib/module/shaders/tgpuUtils.js.map +1 -1
- package/lib/module/shaders/utils.js +21 -2
- package/lib/module/shaders/utils.js.map +1 -1
- package/lib/module/shaders/vertexShaders/mainRotationEffectVertex.js +4 -4
- package/lib/module/shaders/vertexShaders/mainRotationEffectVertex.js.map +1 -1
- package/lib/module/types/typeUtils.js +26 -155
- package/lib/module/types/typeUtils.js.map +1 -1
- package/lib/module/types/types.js +8 -1
- package/lib/module/types/types.js.map +1 -1
- package/lib/module/utils/size.js +4 -4
- package/lib/module/utils/vector.js +38 -38
- package/lib/typescript/src/components/Content.d.ts +6 -6
- package/lib/typescript/src/components/Content.d.ts.map +1 -1
- package/lib/typescript/src/components/Shine.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/enums/colorPresets.d.ts +152 -0
- package/lib/typescript/src/enums/colorPresets.d.ts.map +1 -1
- package/lib/typescript/src/enums/effectDefaults.d.ts +39 -0
- package/lib/typescript/src/enums/effectDefaults.d.ts.map +1 -0
- package/lib/typescript/src/enums/effectPresets.d.ts +284 -5
- package/lib/typescript/src/enums/effectPresets.d.ts.map +1 -1
- package/lib/typescript/src/shaders/bindGroupLayouts.d.ts +77 -41
- package/lib/typescript/src/shaders/bindGroupLayouts.d.ts.map +1 -1
- package/lib/typescript/src/shaders/bindGroupUtils.d.ts +86 -70
- package/lib/typescript/src/shaders/bindGroupUtils.d.ts.map +1 -1
- package/lib/typescript/src/shaders/colorConversions.d.ts +4 -0
- package/lib/typescript/src/shaders/colorConversions.d.ts.map +1 -0
- package/lib/typescript/src/shaders/fragmentShaders/baseTextureFragment.d.ts.map +1 -1
- package/lib/typescript/src/shaders/fragmentShaders/colorMaskFragment.d.ts.map +1 -1
- package/lib/typescript/src/shaders/fragmentShaders/glareFlareFragment.d.ts +5 -0
- package/lib/typescript/src/shaders/fragmentShaders/glareFlareFragment.d.ts.map +1 -0
- package/lib/typescript/src/shaders/fragmentShaders/glareFragment.d.ts +0 -3
- package/lib/typescript/src/shaders/fragmentShaders/glareFragment.d.ts.map +1 -1
- package/lib/typescript/src/shaders/fragmentShaders/holoFragment.d.ts +7 -0
- package/lib/typescript/src/shaders/fragmentShaders/holoFragment.d.ts.map +1 -1
- package/lib/typescript/src/shaders/fragmentShaders/maskFragment.d.ts.map +1 -1
- package/lib/typescript/src/shaders/fragmentShaders/reverseHoloFragment.d.ts.map +1 -1
- package/lib/typescript/src/shaders/pipelineSetups.d.ts +0 -6
- package/lib/typescript/src/shaders/pipelineSetups.d.ts.map +1 -1
- package/lib/typescript/src/shaders/resourceManagement/buffersMap.d.ts +10 -0
- package/lib/typescript/src/shaders/resourceManagement/buffersMap.d.ts.map +1 -0
- package/lib/typescript/src/shaders/resourceManagement/pipelineMap.d.ts +24 -0
- package/lib/typescript/src/shaders/resourceManagement/pipelineMap.d.ts.map +1 -0
- package/lib/typescript/src/shaders/resourceManagement/textures.d.ts +0 -1
- package/lib/typescript/src/shaders/resourceManagement/textures.d.ts.map +1 -1
- package/lib/typescript/src/shaders/tgpuUtils.d.ts +3 -0
- package/lib/typescript/src/shaders/tgpuUtils.d.ts.map +1 -1
- package/lib/typescript/src/shaders/utils.d.ts +1 -0
- package/lib/typescript/src/shaders/utils.d.ts.map +1 -1
- package/lib/typescript/src/types/typeUtils.d.ts +8 -47
- package/lib/typescript/src/types/typeUtils.d.ts.map +1 -1
- package/lib/typescript/src/types/types.d.ts +59 -54
- package/lib/typescript/src/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Content.tsx +126 -296
- package/src/components/Shine.tsx +22 -5
- package/src/components/ShineGroup.tsx +0 -4
- package/src/enums/colorPresets.ts +59 -1
- package/src/enums/effectDefaults.ts +57 -0
- package/src/enums/effectPresets.ts +142 -9
- package/src/shaders/bindGroupLayouts.ts +57 -28
- package/src/shaders/bindGroupUtils.ts +66 -69
- package/src/shaders/colorConversions.ts +88 -0
- package/src/shaders/computeShaders/precomputeColorMask.ts +4 -4
- package/src/shaders/fragmentShaders/baseTextureFragment.ts +2 -10
- package/src/shaders/fragmentShaders/colorMaskFragment.ts +34 -55
- package/src/shaders/fragmentShaders/glareFlareFragment.ts +79 -0
- package/src/shaders/fragmentShaders/glareFragment.ts +9 -84
- package/src/shaders/fragmentShaders/holoFragment.ts +139 -11
- package/src/shaders/fragmentShaders/maskFragment.ts +3 -9
- package/src/shaders/fragmentShaders/reverseHoloFragment.ts +4 -9
- package/src/shaders/pipelineSetups.ts +2 -120
- package/src/shaders/resourceManagement/buffersMap.ts +80 -0
- package/src/shaders/resourceManagement/pipelineMap.ts +169 -0
- package/src/shaders/resourceManagement/textures.ts +2 -2
- package/src/shaders/tgpuUtils.ts +29 -0
- package/src/shaders/utils.ts +29 -0
- package/src/shaders/vertexShaders/mainRotationEffectVertex.ts +2 -2
- package/src/types/typeUtils.ts +39 -159
- package/src/types/types.ts +111 -60
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":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"name": "react-native-shine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { PixelRatio, View, type ViewStyle } from 'react-native';
|
|
3
3
|
import Animated, {
|
|
4
4
|
SensorType,
|
|
@@ -15,52 +15,22 @@ import {
|
|
|
15
15
|
} from 'react-native-wgpu';
|
|
16
16
|
import * as d from 'typegpu/data';
|
|
17
17
|
import type {
|
|
18
|
+
SampledFlag,
|
|
19
|
+
StorageFlag,
|
|
18
20
|
TextureProps,
|
|
19
|
-
// TgpuComputePipeline,
|
|
20
|
-
TgpuRenderPipeline,
|
|
21
21
|
TgpuRoot,
|
|
22
22
|
TgpuTexture,
|
|
23
23
|
} from 'typegpu';
|
|
24
|
+
import { scheduleOnUI } from 'react-native-worklets';
|
|
24
25
|
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
colorMaskArraySchema,
|
|
27
|
+
precomputeColorMaskBindGroupLayout,
|
|
28
|
+
precomputeColorMaskOutputBindGroupLayout,
|
|
29
|
+
rotationSchema,
|
|
29
30
|
} from '../shaders/bindGroupLayouts';
|
|
30
31
|
import useAnimationFrame from '../hooks/useAnimationFrame';
|
|
31
|
-
import { TypedBufferMap } from '../shaders/resourceManagement/bufferManager';
|
|
32
|
-
import {
|
|
33
|
-
createColorMaskBindGroup,
|
|
34
|
-
createGlareBindGroup,
|
|
35
|
-
createReverseHoloDetectionChannelFlagsBindGroup,
|
|
36
|
-
createRotationValuesBindGroup,
|
|
37
|
-
} from '../shaders/bindGroupUtils';
|
|
38
|
-
import colorMaskFragment from '../shaders/fragmentShaders/colorMaskFragment';
|
|
39
|
-
import { newGlareFragment } from '../shaders/fragmentShaders/glareFragment';
|
|
40
|
-
import {
|
|
41
|
-
attachBindGroups,
|
|
42
|
-
blend,
|
|
43
|
-
createMaskPipeline,
|
|
44
|
-
createRainbowHoloPipeline as createHoloPipeline,
|
|
45
|
-
createReverseHoloPipeline,
|
|
46
|
-
getDefaultTarget,
|
|
47
|
-
} from '../shaders/pipelineSetups';
|
|
48
|
-
import mainVertex from '../shaders/vertexShaders/mainVertex';
|
|
49
32
|
import { subscribeToOrientationChange } from '../shaders/utils';
|
|
50
|
-
import type {
|
|
51
|
-
ColorAttachment,
|
|
52
|
-
ColorMask,
|
|
53
|
-
DeepPartiallyOptional,
|
|
54
|
-
Effect,
|
|
55
|
-
GlareOptions,
|
|
56
|
-
PipelineAttachmentPair,
|
|
57
|
-
} from '../types/types';
|
|
58
|
-
import {
|
|
59
|
-
colorMasksToTyped,
|
|
60
|
-
createColorMasks,
|
|
61
|
-
createGlareOptions,
|
|
62
|
-
createReverseHoloDetectionChannelFlags,
|
|
63
|
-
} from '../types/typeUtils';
|
|
33
|
+
import type { ColorMask } from '../types/types';
|
|
64
34
|
import type { V2d, V3d } from '../types/vector';
|
|
65
35
|
import {
|
|
66
36
|
addV3d,
|
|
@@ -77,19 +47,19 @@ import {
|
|
|
77
47
|
zeroV3d,
|
|
78
48
|
} from '../utils/vector';
|
|
79
49
|
import { baseTextureFragment } from '../shaders/fragmentShaders/baseTextureFragment';
|
|
80
|
-
|
|
50
|
+
import { PipelineManager } from '../shaders/resourceManagement/pipelineMap';
|
|
51
|
+
import { blend, type Effect } from '../enums/effectPresets';
|
|
52
|
+
import { createColorMasks } from '../types/typeUtils';
|
|
53
|
+
import { createColorMaskBindGroup } from '../shaders/bindGroupUtils';
|
|
54
|
+
import colorMaskFragment from '../shaders/fragmentShaders/colorMaskFragment';
|
|
55
|
+
import { precomputeColorMask } from '../shaders/computeShaders/precomputeColorMask';
|
|
81
56
|
|
|
82
57
|
export interface SharedProps {
|
|
83
58
|
width: number;
|
|
84
59
|
height: number;
|
|
85
|
-
|
|
86
|
-
enableGlare?: boolean;
|
|
87
|
-
highlightColors?: DeepPartiallyOptional<ColorMask, 'baseColor'>[];
|
|
60
|
+
highlightColors?: ColorMask[];
|
|
88
61
|
isHighlightInclusive?: boolean;
|
|
89
62
|
lightPosition?: SharedValue<V2d>;
|
|
90
|
-
// addReverseHolo?: boolean;
|
|
91
|
-
// reverseHoloDetectionChannelOptions?: Partial<ReverseHoloDetectionChannelFlags>;
|
|
92
|
-
// addHolo?: boolean;
|
|
93
63
|
translateViewIn3d?:
|
|
94
64
|
| boolean
|
|
95
65
|
| {
|
|
@@ -105,27 +75,13 @@ interface ContentProps extends SharedProps {
|
|
|
105
75
|
root: TgpuRoot;
|
|
106
76
|
imageTexture: TgpuTexture<TextureProps>;
|
|
107
77
|
maskTexture?: TgpuTexture<TextureProps>;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
interface PipelineMap {
|
|
111
|
-
baseTexture: TgpuRenderPipeline;
|
|
112
|
-
glare: TgpuRenderPipeline | void;
|
|
113
|
-
colorMask: TgpuRenderPipeline | void;
|
|
114
|
-
mask: TgpuRenderPipeline | void;
|
|
115
|
-
reverseHolo: TgpuRenderPipeline | void;
|
|
116
|
-
holo: TgpuRenderPipeline | void;
|
|
117
|
-
// precomputeColorMaskPipeline: TgpuComputePipeline | void;
|
|
78
|
+
colorMaskStorageTexture?: TgpuTexture<any> & StorageFlag;
|
|
118
79
|
}
|
|
119
80
|
|
|
120
81
|
export default function Content({
|
|
121
|
-
|
|
122
|
-
// addReverseHolo,
|
|
123
|
-
// reverseHoloDetectionChannelOptions,
|
|
124
|
-
effects,
|
|
82
|
+
effects = [{ name: 'glare' }],
|
|
125
83
|
highlightColors,
|
|
126
84
|
isHighlightInclusive = true,
|
|
127
|
-
glareOptions,
|
|
128
|
-
enableGlare = true,
|
|
129
85
|
height,
|
|
130
86
|
imageTexture,
|
|
131
87
|
maskTexture,
|
|
@@ -135,26 +91,19 @@ export default function Content({
|
|
|
135
91
|
translateViewIn3d = false,
|
|
136
92
|
style,
|
|
137
93
|
containerStyle,
|
|
94
|
+
colorMaskStorageTexture,
|
|
138
95
|
}: ContentProps) {
|
|
139
96
|
const { device } = root;
|
|
140
97
|
// const { ref, context } = useGPUContext();
|
|
141
98
|
const ref = useRef<CanvasRef>(null);
|
|
142
99
|
const [context, setContext] = useState<RNCanvasContext | null>(null);
|
|
143
|
-
// const context = ref.current!.getContext('webgpu')!;
|
|
144
100
|
|
|
145
101
|
useEffect(() => {
|
|
146
102
|
if (ref) setContext(ref.current?.getContext('webgpu')!);
|
|
147
103
|
}, [ref]);
|
|
148
104
|
|
|
149
105
|
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
//changing canvas size to prevent blur
|
|
153
|
-
const pixelRatio = PixelRatio.get();
|
|
154
|
-
const size = { x: width, y: height };
|
|
155
|
-
const pixelSize = transformV2d(scaleV2d(size, pixelRatio), (v) =>
|
|
156
|
-
Math.max(1, Math.round(v))
|
|
157
|
-
);
|
|
106
|
+
const isCanvasReady = useSharedValue(true);
|
|
158
107
|
|
|
159
108
|
const landscape = useSharedValue<boolean>(false);
|
|
160
109
|
const rotation = useSharedValue<V3d>(zeroV3d); // final GPU offsets
|
|
@@ -166,9 +115,10 @@ export default function Content({
|
|
|
166
115
|
const calibrated = useSharedValue<boolean>(false);
|
|
167
116
|
const gravitySensor = useAnimatedSensor(SensorType.GRAVITY, { interval: 20 });
|
|
168
117
|
|
|
169
|
-
const
|
|
170
|
-
() =>
|
|
171
|
-
|
|
118
|
+
const pipelineCache = useMemo(
|
|
119
|
+
() =>
|
|
120
|
+
new PipelineManager(root, presentationFormat, imageTexture, maskTexture),
|
|
121
|
+
[imageTexture, maskTexture, presentationFormat, root]
|
|
172
122
|
);
|
|
173
123
|
|
|
174
124
|
const animatedStyle = useAnimatedStyle(() => {
|
|
@@ -255,11 +205,88 @@ export default function Content({
|
|
|
255
205
|
);
|
|
256
206
|
});
|
|
257
207
|
|
|
258
|
-
//
|
|
208
|
+
//TODO: is this needed here?
|
|
209
|
+
const effectsCache =
|
|
210
|
+
JSON.stringify(effects) + JSON.stringify(highlightColors);
|
|
211
|
+
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
const initPipelines = async () => {
|
|
214
|
+
pipelineCache.pipelinesMap.clear();
|
|
215
|
+
|
|
216
|
+
pipelineCache.addPipeline(baseTextureFragment);
|
|
217
|
+
|
|
218
|
+
effects.forEach(({ name, options }) => {
|
|
219
|
+
pipelineCache.addPipelineWithBuffer(name, options);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
//TODO: move to effect definition
|
|
223
|
+
if (highlightColors) {
|
|
224
|
+
const colorMaskBuffer = pipelineCache.buffersMap.syncUniformBuffer(
|
|
225
|
+
colorMaskArraySchema,
|
|
226
|
+
createColorMasks(highlightColors, isHighlightInclusive)
|
|
227
|
+
);
|
|
228
|
+
const colorMaskBindGroup = createColorMaskBindGroup(
|
|
229
|
+
root,
|
|
230
|
+
colorMaskBuffer
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
if (colorMaskStorageTexture) {
|
|
234
|
+
const precomputeColorMaskBindGroup = root.createBindGroup(
|
|
235
|
+
precomputeColorMaskBindGroupLayout,
|
|
236
|
+
{
|
|
237
|
+
colorMaskStorage: colorMaskStorageTexture as TgpuTexture<{
|
|
238
|
+
size: readonly number[];
|
|
239
|
+
format: 'rgba8unorm';
|
|
240
|
+
}> &
|
|
241
|
+
StorageFlag,
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
const precomputeColorMaskOutputBindGroup = root.createBindGroup(
|
|
245
|
+
precomputeColorMaskOutputBindGroupLayout,
|
|
246
|
+
{
|
|
247
|
+
colorMaskOutput: colorMaskStorageTexture as TgpuTexture<{
|
|
248
|
+
size: readonly number[];
|
|
249
|
+
format: 'rgba8unorm';
|
|
250
|
+
}> &
|
|
251
|
+
SampledFlag,
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
pipelineCache.addComputePipeline(precomputeColorMask, [
|
|
255
|
+
colorMaskBindGroup,
|
|
256
|
+
precomputeColorMaskBindGroup,
|
|
257
|
+
]);
|
|
258
|
+
await pipelineCache.runComputePipeline(precomputeColorMask);
|
|
259
|
+
// colorMaskOutputTexture.write(colorMaskStorageTexture);
|
|
260
|
+
|
|
261
|
+
pipelineCache.addPipeline(
|
|
262
|
+
colorMaskFragment,
|
|
263
|
+
[colorMaskBindGroup, precomputeColorMaskOutputBindGroup],
|
|
264
|
+
blend
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
initPipelines();
|
|
270
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
271
|
+
}, [
|
|
272
|
+
effectsCache,
|
|
273
|
+
isHighlightInclusive,
|
|
274
|
+
pipelineCache,
|
|
275
|
+
root,
|
|
276
|
+
colorMaskStorageTexture,
|
|
277
|
+
]);
|
|
278
|
+
|
|
259
279
|
useEffect(() => {
|
|
260
|
-
if (!context)
|
|
280
|
+
if (!context) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
// changing canvas size to prevent blur
|
|
284
|
+
const pixelRatio = PixelRatio.get();
|
|
285
|
+
const size = { x: width, y: height };
|
|
286
|
+
const pixelSize = transformV2d(scaleV2d(size, pixelRatio), (v) =>
|
|
287
|
+
Math.max(1, Math.round(v))
|
|
288
|
+
);
|
|
261
289
|
|
|
262
|
-
//this sets the underlying resolution of the canvas to prevent blurriness
|
|
263
290
|
const canvasElement = context.canvas;
|
|
264
291
|
|
|
265
292
|
if (
|
|
@@ -269,230 +296,33 @@ export default function Content({
|
|
|
269
296
|
canvasElement.width = pixelSize.x;
|
|
270
297
|
canvasElement.height = pixelSize.y;
|
|
271
298
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
299
|
+
//this is a workaround to prevent error logs but it should be handled by webgpu
|
|
300
|
+
scheduleOnUI(() => {
|
|
301
|
+
'worklet';
|
|
302
|
+
context.configure({
|
|
303
|
+
device,
|
|
304
|
+
format: presentationFormat,
|
|
305
|
+
alphaMode: 'premultiplied',
|
|
306
|
+
});
|
|
307
|
+
isCanvasReady.value = true;
|
|
277
308
|
});
|
|
309
|
+
}, [context, device, height, presentationFormat, width, isCanvasReady]);
|
|
278
310
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
// });
|
|
284
|
-
|
|
285
|
-
const sampler = root['~unstable'].createSampler({
|
|
286
|
-
magFilter: 'linear',
|
|
287
|
-
minFilter: 'linear',
|
|
288
|
-
mipmapFilter: 'linear',
|
|
289
|
-
}) as any as GPUSampler; //TODO: delete this cast when TgpuFixedSampler gets exposed
|
|
290
|
-
|
|
291
|
-
const imageTextureBindGroup = root.createBindGroup(textureBindGroupLayout, {
|
|
292
|
-
texture: root.unwrap(imageTexture).createView(),
|
|
293
|
-
sampler,
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
const rotationBuffer = bufferMap.addBuffer(root, 'rotation', d.vec3f(0.0));
|
|
297
|
-
|
|
298
|
-
const rotationBindGroup = createRotationValuesBindGroup(
|
|
299
|
-
root,
|
|
300
|
-
rotationBuffer
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
const glareBuffer = bufferMap.addBuffer(
|
|
304
|
-
root,
|
|
305
|
-
'glare',
|
|
306
|
-
createGlareOptions(glareOptions ?? {})
|
|
307
|
-
);
|
|
308
|
-
const glareBindGroup = createGlareBindGroup(root, glareBuffer);
|
|
309
|
-
|
|
310
|
-
const colorMaskBuffer = bufferMap.addBuffer(
|
|
311
|
-
root,
|
|
312
|
-
'colorMask',
|
|
313
|
-
colorMasksToTyped(
|
|
314
|
-
createColorMasks(
|
|
315
|
-
highlightColors ?? [{ baseColor: [-20, -20, -20], useHSV: false }]
|
|
316
|
-
),
|
|
317
|
-
highlightColors && highlightColors.length
|
|
318
|
-
? isHighlightInclusive
|
|
319
|
-
: !isHighlightInclusive
|
|
320
|
-
)
|
|
321
|
-
);
|
|
322
|
-
const colorMaskBindGroup = createColorMaskBindGroup(root, colorMaskBuffer);
|
|
323
|
-
|
|
324
|
-
const reverseHoloEffect = effects
|
|
325
|
-
? effects.find((e) => e.name === 'reverseHolo')
|
|
326
|
-
: undefined;
|
|
327
|
-
const reverseHoloDetectionChannelFlagsBuffer = bufferMap.addBuffer(
|
|
328
|
-
root,
|
|
329
|
-
'reverseHoloDetectionChannelFlags',
|
|
330
|
-
createReverseHoloDetectionChannelFlags(reverseHoloEffect?.options)
|
|
331
|
-
);
|
|
332
|
-
const reverseHoloDetectionChannelFlagsBindGroup =
|
|
333
|
-
createReverseHoloDetectionChannelFlagsBindGroup(
|
|
334
|
-
root,
|
|
335
|
-
reverseHoloDetectionChannelFlagsBuffer,
|
|
336
|
-
glareBuffer
|
|
337
|
-
);
|
|
338
|
-
|
|
339
|
-
const holoEffect = effects
|
|
340
|
-
? effects.find((e) => e.name === 'holo')
|
|
341
|
-
: undefined;
|
|
342
|
-
|
|
343
|
-
// const precomputeColorMaskBindGroup = root.createBindGroup(
|
|
344
|
-
// precomputeColorMaskBindGroupLayout,
|
|
345
|
-
// {
|
|
346
|
-
// colorMaskTextureDst: colorMaskStorageTexture,
|
|
347
|
-
// }
|
|
348
|
-
// );
|
|
349
|
-
|
|
350
|
-
const pipelineMap: PipelineMap = {
|
|
351
|
-
baseTexture: attachBindGroups(
|
|
352
|
-
root['~unstable']
|
|
353
|
-
.withVertex(mainVertex, {})
|
|
354
|
-
.withFragment(
|
|
355
|
-
baseTextureFragment,
|
|
356
|
-
getDefaultTarget(presentationFormat)
|
|
357
|
-
)
|
|
358
|
-
.createPipeline(),
|
|
359
|
-
[imageTextureBindGroup, rotationBindGroup]
|
|
360
|
-
),
|
|
361
|
-
glare: attachBindGroups(
|
|
362
|
-
root['~unstable']
|
|
363
|
-
.withVertex(mainVertex, {})
|
|
364
|
-
.withFragment(newGlareFragment, getDefaultTarget(presentationFormat))
|
|
365
|
-
.createPipeline(),
|
|
366
|
-
[
|
|
367
|
-
imageTextureBindGroup,
|
|
368
|
-
rotationBindGroup,
|
|
369
|
-
glareBindGroup,
|
|
370
|
-
colorMaskBindGroup,
|
|
371
|
-
]
|
|
372
|
-
),
|
|
373
|
-
colorMask: attachBindGroups(
|
|
374
|
-
root['~unstable']
|
|
375
|
-
.withVertex(mainVertex, {})
|
|
376
|
-
.withFragment(
|
|
377
|
-
colorMaskFragment,
|
|
378
|
-
getDefaultTarget(presentationFormat, blend)
|
|
379
|
-
)
|
|
380
|
-
.createPipeline(),
|
|
381
|
-
[imageTextureBindGroup, colorMaskBindGroup, rotationBindGroup]
|
|
382
|
-
),
|
|
383
|
-
mask: createMaskPipeline(
|
|
384
|
-
root,
|
|
385
|
-
maskTexture,
|
|
386
|
-
[imageTextureBindGroup, rotationBindGroup],
|
|
387
|
-
sampler,
|
|
388
|
-
presentationFormat
|
|
389
|
-
),
|
|
390
|
-
reverseHolo: createReverseHoloPipeline(
|
|
391
|
-
root,
|
|
392
|
-
maskTexture,
|
|
393
|
-
[
|
|
394
|
-
imageTextureBindGroup,
|
|
395
|
-
rotationBindGroup,
|
|
396
|
-
reverseHoloDetectionChannelFlagsBindGroup,
|
|
397
|
-
],
|
|
398
|
-
sampler,
|
|
399
|
-
presentationFormat
|
|
400
|
-
),
|
|
401
|
-
holo: createHoloPipeline(
|
|
402
|
-
root,
|
|
403
|
-
imageTexture,
|
|
404
|
-
[rotationBindGroup],
|
|
405
|
-
sampler,
|
|
406
|
-
presentationFormat
|
|
407
|
-
),
|
|
408
|
-
// precomputeColorMaskPipeline: attachBindGroups(
|
|
409
|
-
// root['~unstable'].withCompute(precomputeColorMask).createPipeline(),
|
|
410
|
-
// [
|
|
411
|
-
// imageTextureBindGroup,
|
|
412
|
-
// colorMaskBindGroup,
|
|
413
|
-
// precomputeColorMaskBindGroup,
|
|
414
|
-
// ]
|
|
415
|
-
// ),
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
const modifyBuffers = () => {
|
|
419
|
-
rotationBuffer.write(d.vec3f(...componentsFromV3d(rotation.value)));
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
const renderPipelines = () => {
|
|
423
|
-
const view = context.getCurrentTexture().createView();
|
|
424
|
-
const initialAttachment: ColorAttachment = {
|
|
425
|
-
view,
|
|
426
|
-
clearValue: [0, 0, 0, 0],
|
|
427
|
-
loadOp: 'clear',
|
|
428
|
-
storeOp: 'store',
|
|
429
|
-
};
|
|
430
|
-
const loadingAttachment: ColorAttachment = {
|
|
431
|
-
view,
|
|
432
|
-
clearValue: [0, 0, 0, 0],
|
|
433
|
-
loadOp: 'load',
|
|
434
|
-
storeOp: 'store',
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
const {
|
|
438
|
-
baseTexture,
|
|
439
|
-
glare,
|
|
440
|
-
mask,
|
|
441
|
-
colorMask,
|
|
442
|
-
holo,
|
|
443
|
-
reverseHolo,
|
|
444
|
-
// precomputeColorMaskPipeline,
|
|
445
|
-
} = pipelineMap;
|
|
446
|
-
|
|
447
|
-
//TODO: delete this from here after testing
|
|
448
|
-
// precomputeColorMaskPipeline!.dispatchWorkgroups(8, 8);
|
|
449
|
-
|
|
450
|
-
const pairs: PipelineAttachmentPair[] = [
|
|
451
|
-
[baseTexture, initialAttachment],
|
|
452
|
-
];
|
|
453
|
-
|
|
454
|
-
if ((glareOptions || enableGlare) && glare) {
|
|
455
|
-
pairs.push([glare, loadingAttachment]);
|
|
456
|
-
}
|
|
457
|
-
if (mask) pairs.push([mask, loadingAttachment]);
|
|
458
|
-
if (reverseHoloEffect && reverseHolo)
|
|
459
|
-
pairs.push([reverseHolo, loadingAttachment]);
|
|
460
|
-
if (holoEffect && holo) pairs.push([holo, loadingAttachment]);
|
|
461
|
-
if (colorMask) pairs.push([colorMask, loadingAttachment]);
|
|
462
|
-
|
|
463
|
-
pairs.forEach(([pipeline, attachment]) =>
|
|
464
|
-
pipeline.withColorAttachment(attachment).draw(6)
|
|
465
|
-
);
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
const presentContext = () => context.present();
|
|
311
|
+
const frameCallback = useCallback(() => {
|
|
312
|
+
if (!context || !isCanvasReady.value) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
469
315
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
presentContext();
|
|
474
|
-
};
|
|
316
|
+
pipelineCache.buffersMap
|
|
317
|
+
.get(rotationSchema)
|
|
318
|
+
?.write(d.vec3f(...componentsFromV3d(rotation.value)));
|
|
475
319
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
context,
|
|
481
|
-
root,
|
|
482
|
-
presentationFormat,
|
|
483
|
-
imageTexture,
|
|
484
|
-
maskTexture,
|
|
485
|
-
rotation,
|
|
486
|
-
bufferMap,
|
|
487
|
-
glareOptions,
|
|
488
|
-
enableGlare,
|
|
489
|
-
highlightColors,
|
|
490
|
-
pixelSize,
|
|
491
|
-
effects,
|
|
492
|
-
isHighlightInclusive,
|
|
493
|
-
]);
|
|
320
|
+
const view = context.getCurrentTexture().createView();
|
|
321
|
+
pipelineCache.renderPipelines(view);
|
|
322
|
+
context.present();
|
|
323
|
+
}, [context, pipelineCache, rotation, isCanvasReady]);
|
|
494
324
|
|
|
495
|
-
useAnimationFrame(
|
|
325
|
+
useAnimationFrame(frameCallback);
|
|
496
326
|
|
|
497
327
|
return (
|
|
498
328
|
<View
|
package/src/components/Shine.tsx
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { useDevice } from 'react-native-wgpu';
|
|
3
|
-
import type { TgpuTexture } from 'typegpu';
|
|
3
|
+
import type { StorageFlag, TgpuTexture } from 'typegpu';
|
|
4
4
|
import { getOrInitRoot } from '../roots';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createTexture,
|
|
7
|
+
loadBitmap,
|
|
8
|
+
} from '../shaders/resourceManagement/textures';
|
|
6
9
|
import Content, { type SharedProps } from './Content';
|
|
10
|
+
import getBitmapFromURI from '../shaders/resourceManagement/bitmaps';
|
|
7
11
|
|
|
8
12
|
export interface ShineProps extends SharedProps {
|
|
9
13
|
imageURI: string;
|
|
@@ -15,12 +19,24 @@ export function Shine({ imageURI, maskURI, ...props }: ShineProps) {
|
|
|
15
19
|
const root = device && getOrInitRoot(device);
|
|
16
20
|
const [imageTexture, setImageTexture] = useState<TgpuTexture>();
|
|
17
21
|
const [maskTexture, setMaskTexture] = useState<TgpuTexture>();
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
const [colorMaskStorageTexture, setColorMaskStorageTexture] = useState<
|
|
23
|
+
TgpuTexture<any> & StorageFlag
|
|
24
|
+
>();
|
|
20
25
|
//TODO: complete the work with the compute shader, try out the shader
|
|
21
26
|
|
|
22
27
|
useEffect(() => {
|
|
23
|
-
if (root)
|
|
28
|
+
if (root) {
|
|
29
|
+
loadBitmap(root, imageURI, setImageTexture);
|
|
30
|
+
const makeStorage = async () => {
|
|
31
|
+
const bitmap = await getBitmapFromURI(imageURI);
|
|
32
|
+
const texture = (await createTexture(root, bitmap)).$usage(
|
|
33
|
+
'storage',
|
|
34
|
+
'sampled'
|
|
35
|
+
);
|
|
36
|
+
setColorMaskStorageTexture(texture);
|
|
37
|
+
};
|
|
38
|
+
makeStorage();
|
|
39
|
+
}
|
|
24
40
|
}, [root, imageURI]);
|
|
25
41
|
|
|
26
42
|
useEffect(() => {
|
|
@@ -40,6 +56,7 @@ export function Shine({ imageURI, maskURI, ...props }: ShineProps) {
|
|
|
40
56
|
root={root}
|
|
41
57
|
imageTexture={imageTexture}
|
|
42
58
|
maskTexture={maskTexture}
|
|
59
|
+
colorMaskStorageTexture={colorMaskStorageTexture}
|
|
43
60
|
/>
|
|
44
61
|
)
|
|
45
62
|
);
|
|
@@ -15,12 +15,10 @@ type ShineGroupProps = PropsWithChildren<Partial<ShineProps>>;
|
|
|
15
15
|
|
|
16
16
|
export function ShineGroup({
|
|
17
17
|
children,
|
|
18
|
-
glareOptions,
|
|
19
18
|
highlightColors,
|
|
20
19
|
maskURI,
|
|
21
20
|
lightPosition: touchPosition,
|
|
22
21
|
effects,
|
|
23
|
-
enableGlare = true,
|
|
24
22
|
isHighlightInclusive = true,
|
|
25
23
|
translateViewIn3d = false,
|
|
26
24
|
containerStyle,
|
|
@@ -79,13 +77,11 @@ export function ShineGroup({
|
|
|
79
77
|
<Shine
|
|
80
78
|
{...sizeFromV2d(size)}
|
|
81
79
|
imageURI={capturedURI}
|
|
82
|
-
glareOptions={glareOptions}
|
|
83
80
|
highlightColors={highlightColors}
|
|
84
81
|
maskURI={maskURI}
|
|
85
82
|
lightPosition={touchPosition}
|
|
86
83
|
effects={effects}
|
|
87
84
|
translateViewIn3d={translateViewIn3d}
|
|
88
|
-
enableGlare={enableGlare}
|
|
89
85
|
containerStyle={containerStyle}
|
|
90
86
|
isHighlightInclusive={isHighlightInclusive}
|
|
91
87
|
style={style}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { vec3 } from '../types/types';
|
|
1
|
+
import type { ColorMask, vec3 } from '../types/types';
|
|
2
2
|
|
|
3
3
|
export const ColorPresets = {
|
|
4
4
|
// --- Primary & Secondary ---
|
|
@@ -39,3 +39,61 @@ export const ColorPresets = {
|
|
|
39
39
|
BEIGE: [245, 245, 220], // #F5F5DC
|
|
40
40
|
POTATO: [222, 184, 135], // #DEB887
|
|
41
41
|
} as const satisfies Record<string, vec3>;
|
|
42
|
+
|
|
43
|
+
export const HSVColorsPreset = {
|
|
44
|
+
RED: { hueMin: 330, hueMax: 15 }, // #FF0022
|
|
45
|
+
ORANGE: { hueMin: 15, hueMax: 45 }, // #FF8000
|
|
46
|
+
YELLOW: { hueMin: 45, hueMax: 75 }, // #FFFF00
|
|
47
|
+
GREEN: { hueMin: 75, hueMax: 165 }, // #00FF00
|
|
48
|
+
BLUE: { hueMin: 165, hueMax: 255 }, // #0080FF
|
|
49
|
+
VIOLET: { hueMin: 255, hueMax: 285 }, // #8000FF
|
|
50
|
+
MAGENTA: { hueMin: 285, hueMax: 330 }, // #FF00D5
|
|
51
|
+
|
|
52
|
+
TRUE_RED: { hueMin: 345, hueMax: 15 }, // #FF0000
|
|
53
|
+
CRIMSON: { hueMin: 330, hueMax: 350 }, // #FF0055
|
|
54
|
+
ROSE: { hueMin: 315, hueMax: 335 }, // #FF0095
|
|
55
|
+
PINK: { hueMin: 300, hueMax: 330 }, // #FF00BF
|
|
56
|
+
|
|
57
|
+
CORAL: { hueMin: 10, hueMax: 30 }, // #FF5500
|
|
58
|
+
TRUE_ORANGE: { hueMin: 20, hueMax: 45 }, // #FF8C00
|
|
59
|
+
AMBER: { hueMin: 35, hueMax: 50 }, // #FFB300
|
|
60
|
+
TRUE_YELLOW: { hueMin: 45, hueMax: 65 }, // #FFD500
|
|
61
|
+
GOLD: { hueMin: 40, hueMax: 55 }, // #FFCC00
|
|
62
|
+
|
|
63
|
+
LIME: { hueMin: 65, hueMax: 90 }, // #BFFF00
|
|
64
|
+
CHARTREUSE: { hueMin: 70, hueMax: 100 }, // #95FF00
|
|
65
|
+
TRUE_GREEN: { hueMin: 90, hueMax: 140 }, // #15FF00
|
|
66
|
+
EMERALD: { hueMin: 130, hueMax: 160 }, // #00FF6A
|
|
67
|
+
MINT: { hueMin: 140, hueMax: 170 }, // #00FF95
|
|
68
|
+
|
|
69
|
+
TEAL: { hueMin: 160, hueMax: 180 }, // #00FFD5
|
|
70
|
+
CYAN: { hueMin: 170, hueMax: 195 }, // #00F2FF
|
|
71
|
+
TURQUOISE: { hueMin: 165, hueMax: 190 }, // #00FFF2
|
|
72
|
+
AZURE: { hueMin: 190, hueMax: 215 }, // #009FFF
|
|
73
|
+
TRUE_BLUE: { hueMin: 210, hueMax: 240 }, // #0040FF
|
|
74
|
+
ROYAL_BLUE: { hueMin: 225, hueMax: 250 }, // #0011FF
|
|
75
|
+
INDIGO: { hueMin: 240, hueMax: 260 }, // #2B00FF
|
|
76
|
+
|
|
77
|
+
TRUE_VIOLET: { hueMin: 250, hueMax: 280 }, // #6A00FF
|
|
78
|
+
PURPLE: { hueMin: 260, hueMax: 290 }, // #9500FF
|
|
79
|
+
TRUE_MAGENTA: { hueMin: 285, hueMax: 315 }, // #FF00FF
|
|
80
|
+
FUCHSIA: { hueMin: 295, hueMax: 325 }, // #ff00d5ff
|
|
81
|
+
|
|
82
|
+
GRAY: { hueMin: 0, hueMax: 360, saturationMax: 0.2, saturationMin: 0 }, // #738c8cff
|
|
83
|
+
WHITE: {
|
|
84
|
+
hueMin: 0,
|
|
85
|
+
hueMax: 360,
|
|
86
|
+
saturationMax: 1,
|
|
87
|
+
saturationMin: 0,
|
|
88
|
+
lightnessMax: 1,
|
|
89
|
+
lightnessMin: 0.9,
|
|
90
|
+
}, // #d9f2f2ff
|
|
91
|
+
BLACK: {
|
|
92
|
+
hueMin: 0,
|
|
93
|
+
hueMax: 360,
|
|
94
|
+
saturationMax: 1,
|
|
95
|
+
saturationMin: 0,
|
|
96
|
+
lightnessMax: 0.2,
|
|
97
|
+
lightnessMin: 0,
|
|
98
|
+
}, // #0d2626ff
|
|
99
|
+
} as const satisfies Record<string, ColorMask>;
|