react-native-shine 0.3.5 → 0.4.1

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 (48) hide show
  1. package/README.md +7 -6
  2. package/lib/module/components/Content.js +46 -36
  3. package/lib/module/components/Content.js.map +1 -1
  4. package/lib/module/components/ShineGroup.js +0 -2
  5. package/lib/module/components/ShineGroup.js.map +1 -1
  6. package/lib/module/shaders/bindGroupLayouts.js +20 -0
  7. package/lib/module/shaders/bindGroupLayouts.js.map +1 -1
  8. package/lib/module/shaders/bindGroupUtils.js +5 -1
  9. package/lib/module/shaders/bindGroupUtils.js.map +1 -1
  10. package/lib/module/shaders/fragmentShaders/colorMaskFragment.js +2 -2
  11. package/lib/module/shaders/fragmentShaders/colorMaskFragment.js.map +1 -1
  12. package/lib/module/shaders/fragmentShaders/holoFragment.js +2 -2
  13. package/lib/module/shaders/fragmentShaders/holoFragment.js.map +1 -1
  14. package/lib/module/shaders/fragmentShaders/reverseHoloFragment.js +28 -6
  15. package/lib/module/shaders/fragmentShaders/reverseHoloFragment.js.map +1 -1
  16. package/lib/module/shaders/tgpuUtils.js +41 -0
  17. package/lib/module/shaders/tgpuUtils.js.map +1 -1
  18. package/lib/module/shaders/utils.js +1 -1
  19. package/lib/module/types/typeUtils.js +33 -0
  20. package/lib/module/types/typeUtils.js.map +1 -1
  21. package/lib/module/utils/size.js +2 -2
  22. package/lib/module/utils/vector.js +19 -19
  23. package/lib/typescript/src/components/Content.d.ts +4 -3
  24. package/lib/typescript/src/components/Content.d.ts.map +1 -1
  25. package/lib/typescript/src/components/ShineGroup.d.ts +1 -1
  26. package/lib/typescript/src/components/ShineGroup.d.ts.map +1 -1
  27. package/lib/typescript/src/shaders/bindGroupLayouts.d.ts +42 -0
  28. package/lib/typescript/src/shaders/bindGroupLayouts.d.ts.map +1 -1
  29. package/lib/typescript/src/shaders/bindGroupUtils.d.ts +23 -1
  30. package/lib/typescript/src/shaders/bindGroupUtils.d.ts.map +1 -1
  31. package/lib/typescript/src/shaders/fragmentShaders/reverseHoloFragment.d.ts.map +1 -1
  32. package/lib/typescript/src/shaders/tgpuUtils.d.ts +2 -0
  33. package/lib/typescript/src/shaders/tgpuUtils.d.ts.map +1 -1
  34. package/lib/typescript/src/types/typeUtils.d.ts +9 -1
  35. package/lib/typescript/src/types/typeUtils.d.ts.map +1 -1
  36. package/lib/typescript/src/types/types.d.ts +8 -0
  37. package/lib/typescript/src/types/types.d.ts.map +1 -1
  38. package/package.json +6 -6
  39. package/src/components/Content.tsx +60 -27
  40. package/src/components/ShineGroup.tsx +0 -2
  41. package/src/shaders/bindGroupLayouts.ts +22 -0
  42. package/src/shaders/bindGroupUtils.ts +13 -0
  43. package/src/shaders/fragmentShaders/colorMaskFragment.ts +1 -1
  44. package/src/shaders/fragmentShaders/holoFragment.ts +1 -1
  45. package/src/shaders/fragmentShaders/reverseHoloFragment.ts +33 -4
  46. package/src/shaders/tgpuUtils.ts +40 -0
  47. package/src/types/typeUtils.ts +33 -0
  48. package/src/types/types.ts +9 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ShineGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/ShineGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAW5E,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEjD,KAAK,eAAe,GAAG,iBAAiB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;AAE9D,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,eAAuB,EACvB,cAAsB,EACtB,OAAe,EACf,cAAsB,GACvB,EAAE,eAAe,2CAkEjB"}
1
+ {"version":3,"file":"ShineGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/ShineGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAW5E,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEjD,KAAK,eAAe,GAAG,iBAAiB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;AAE9D,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,eAAuB,EACvB,OAAe,EACf,cAAsB,GACvB,EAAE,eAAe,2CAiEjB"}
@@ -64,6 +64,37 @@ export declare const colorMaskBindGroupLayout: import("typegpu").TgpuBindGroupLa
64
64
  }>;
65
65
  };
66
66
  }>;
67
+ export declare const reverseHoloDetectionChannelFlagsSchema: d.WgslStruct<{
68
+ redChannel: d.Decorated<d.F32, [d.Align<16>]>;
69
+ greenChannel: d.F32;
70
+ blueChannel: d.F32;
71
+ hue: d.F32;
72
+ saturation: d.F32;
73
+ value: d.F32;
74
+ }>;
75
+ export type ReverseHoloDetectionChannelFlagsSchema = typeof reverseHoloDetectionChannelFlagsSchema;
76
+ export declare const reverseHoloDetectionChannelFlagsBindGroupLayout: import("typegpu").TgpuBindGroupLayout<{
77
+ channelFlags: {
78
+ uniform: d.WgslStruct<{
79
+ redChannel: d.Decorated<d.F32, [d.Align<16>]>;
80
+ greenChannel: d.F32;
81
+ blueChannel: d.F32;
82
+ hue: d.F32;
83
+ saturation: d.F32;
84
+ value: d.F32;
85
+ }>;
86
+ };
87
+ glareOptions: {
88
+ uniform: d.WgslStruct<{
89
+ glowPower: d.F32;
90
+ hueShiftAngleMax: d.F32;
91
+ hueShiftAngleMin: d.F32;
92
+ hueBlendPower: d.F32;
93
+ lightIntensity: d.F32;
94
+ glareIntensity: d.F32;
95
+ }>;
96
+ };
97
+ }>;
67
98
  export declare const bufferData: {
68
99
  readonly rotation: {
69
100
  readonly schema: d.Vec3f;
@@ -90,6 +121,17 @@ export declare const bufferData: {
90
121
  }>;
91
122
  readonly usage: "uniform";
92
123
  };
124
+ readonly reverseHoloDetectionChannelFlags: {
125
+ readonly schema: d.WgslStruct<{
126
+ redChannel: d.Decorated<d.F32, [d.Align<16>]>;
127
+ greenChannel: d.F32;
128
+ blueChannel: d.F32;
129
+ hue: d.F32;
130
+ saturation: d.F32;
131
+ value: d.F32;
132
+ }>;
133
+ readonly usage: "uniform";
134
+ };
93
135
  };
94
136
  export type BufferData = typeof bufferData;
95
137
  //# sourceMappingURL=bindGroupLayouts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindGroupLayouts.d.ts","sourceRoot":"","sources":["../../../../src/shaders/bindGroupLayouts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,eAAO,MAAM,sBAAsB;;;;;;;;;EAIjC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;EAIrC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;EAElC,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;EAOtB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC;AAE7C,eAAO,MAAM,oBAAoB;;;;;;;;;;;EAE/B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;EAM1B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC;AAErD,eAAO,MAAM,wBAAwB;;;;;;;;;;EAEnC,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC"}
1
+ {"version":3,"file":"bindGroupLayouts.d.ts","sourceRoot":"","sources":["../../../../src/shaders/bindGroupLayouts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,eAAO,MAAM,sBAAsB;;;;;;;;;EAIjC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;EAIrC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;EAElC,CAAC;AAEH,eAAO,MAAM,WAAW;;;;;;;EAOtB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC;AAE7C,eAAO,MAAM,oBAAoB;;;;;;;;;;;EAE/B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;EAM1B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC;AAErD,eAAO,MAAM,wBAAwB;;;;;;;;;;EAEnC,CAAC;AAEH,eAAO,MAAM,sCAAsC;;;;;;;EAOjD,CAAC;AAEH,MAAM,MAAM,sCAAsC,GAChD,OAAO,sCAAsC,CAAC;AAEhD,eAAO,MAAM,+CAA+C;;;;;;;;;;;;;;;;;;;;;EAIxD,CAAC;AAEL,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { type TgpuBuffer, type TgpuRoot, type UniformFlag } from 'typegpu';
2
2
  import * as d from 'typegpu/data';
3
- import { type ColorMaskSchema, type GlareSchema } from './bindGroupLayouts';
3
+ import { type ColorMaskSchema, type GlareSchema, type ReverseHoloDetectionChannelFlagsSchema } from './bindGroupLayouts';
4
4
  import type { GlareOptions, ColorMask, PartiallyOptional } from '../types/types';
5
5
  export declare const createRotationBuffer: (root: TgpuRoot, initValues?: {
6
6
  x: number;
@@ -50,4 +50,26 @@ export declare const createColorMaskBindGroup: (root: TgpuRoot, buffer: TgpuBuff
50
50
  }>;
51
51
  };
52
52
  }>;
53
+ export declare const createReverseHoloDetectionChannelFlagsBindGroup: (root: TgpuRoot, detectionChannelBuffer: TgpuBuffer<ReverseHoloDetectionChannelFlagsSchema> & UniformFlag, glareOptionsBuffer: TgpuBuffer<GlareSchema> & UniformFlag) => import("typegpu").TgpuBindGroup<{
54
+ channelFlags: {
55
+ uniform: d.WgslStruct<{
56
+ redChannel: d.Decorated<d.F32, [d.Align<16>]>;
57
+ greenChannel: d.F32;
58
+ blueChannel: d.F32;
59
+ hue: d.F32;
60
+ saturation: d.F32;
61
+ value: d.F32;
62
+ }>;
63
+ };
64
+ glareOptions: {
65
+ uniform: d.WgslStruct<{
66
+ glowPower: d.F32;
67
+ hueShiftAngleMax: d.F32;
68
+ hueShiftAngleMin: d.F32;
69
+ hueBlendPower: d.F32;
70
+ lightIntensity: d.F32;
71
+ glareIntensity: d.F32;
72
+ }>;
73
+ };
74
+ }>;
53
75
  //# sourceMappingURL=bindGroupUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindGroupUtils.d.ts","sourceRoot":"","sources":["../../../../src/shaders/bindGroupUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAIL,KAAK,eAAe,EAEpB,KAAK,WAAW,EAEjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AASxB,eAAO,MAAM,oBAAoB,GAAI,MAAM,QAAQ,EAAE;;;;CAAoB,sCAGnD,CAAC;AAEvB,eAAO,MAAM,6BAA6B,GACxC,MAAM,QAAQ,EACd,QAAQ,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC;;;;EAIzB,CAAC;AAEL,eAAO,MAAM,wBAAwB,GACnC,MAAM,QAAQ,EACd,aAAa,OAAO,CAAC,YAAY,CAAC;;;;;;;iBAId,CAAC;AAEvB,eAAO,MAAM,oBAAoB,GAC/B,MAAM,QAAQ,EACd,QAAQ,UAAU,CAAC,WAAW,CAAC,GAAG,WAAW;;;;;;;;;;;EAI3C,CAAC;AAEL,eAAO,MAAM,qBAAqB,GAChC,MAAM,QAAQ,EAC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,CAAC;AAEL,eAAO,MAAM,+CAA+C,GAC1D,MAAM,QAAQ,EACd,wBAAwB,UAAU,CAAC,sCAAsC,CAAC,GACxE,WAAW,EACb,oBAAoB,UAAU,CAAC,WAAW,CAAC,GAAG,WAAW;;;;;;;;;;;;;;;;;;;;;EAKvD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"reverseHoloFragment.d.ts","sourceRoot":"","sources":["../../../../../src/shaders/fragmentShaders/reverseHoloFragment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAUlC,eAAO,MAAM,mBAAmB;;WA2D9B,CAAC"}
1
+ {"version":3,"file":"reverseHoloFragment.d.ts","sourceRoot":"","sources":["../../../../../src/shaders/fragmentShaders/reverseHoloFragment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAUlC,eAAO,MAAM,mBAAmB;;WAwF9B,CAAC"}
@@ -1,5 +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
+ export declare const rgbToHSV: import("typegpu").TgpuFn<(rgb: d.Vec3f) => d.Vec3f>;
4
+ export declare const fmod: import("typegpu").TgpuFn<(number: d.F32, md: d.F32) => d.F32>;
3
5
  export declare const glareColorShift: import("typegpu").TgpuFn<(color: d.Vec3f, power: d.F32) => d.Vec3f>;
4
6
  export declare const overlayChannel: import("typegpu").TgpuFn<(base: d.F32, blend: d.F32) => d.F32>;
5
7
  export declare const overlayChannels: import("typegpu").TgpuFn<(base: d.Vec3f, blend: d.Vec3f) => d.Vec3f>;
@@ -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,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"}
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,qDA2BnB,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"}
@@ -1,5 +1,5 @@
1
1
  import { f32 } from 'typegpu/data';
2
- import type { GlareOptions, ColorMask, DeepPartiallyOptional, HoloOptions } from './types';
2
+ import type { GlareOptions, ColorMask, DeepPartiallyOptional, HoloOptions, ReverseHoloDetectionChannelFlags } from './types';
3
3
  export declare const createGlareOptions: (options: Partial<GlareOptions>) => GlareOptions;
4
4
  export declare const mapToF32: <T extends Record<string, number>>(obj: T) => { [K in keyof T]: ReturnType<typeof f32>; };
5
5
  export declare const createColorMask: (colorMask: DeepPartiallyOptional<ColorMask, "baseColor">) => ColorMask;
@@ -11,5 +11,13 @@ export declare const colorMaskToTyped: (colorMask: ColorMask) => {
11
11
  };
12
12
  };
13
13
  export declare const createHoloOptions: (options: Partial<HoloOptions>) => HoloOptions;
14
+ export declare const createReverseHoloDetectionChannelFlags: (options?: Partial<ReverseHoloDetectionChannelFlags>) => {
15
+ redChannel: number;
16
+ greenChannel: number;
17
+ blueChannel: number;
18
+ hue: number;
19
+ saturation: number;
20
+ value: number;
21
+ };
14
22
  export declare const numberArrToTyped: (vec: number[]) => any;
15
23
  //# sourceMappingURL=typeUtils.d.ts.map
@@ -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;AACxD,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,qBAAqB,EAErB,WAAW,EACZ,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,SAcF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,WAAW,SAAS;;;;;;CASpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,OAAO,CAAC,WAAW,CAAC,KAC5B,WAQF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,QAkB7C,CAAC"}
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,SAcF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,WAAW,SAAS;;;;;;CASpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,OAAO,CAAC,WAAW,CAAC,KAC5B,WAQF,CAAC;AAEF,eAAO,MAAM,sCAAsC,GACjD,UAAU,OAAO,CAAC,gCAAgC,CAAC;;;;;;;CA4BpD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,QAkB7C,CAAC"}
@@ -19,6 +19,14 @@ export type ColorMask = {
19
19
  lower: vec3;
20
20
  };
21
21
  };
22
+ export type ReverseHoloDetectionChannelFlags = {
23
+ redChannel: number;
24
+ greenChannel: number;
25
+ blueChannel: number;
26
+ hue: number;
27
+ saturation: number;
28
+ value: number;
29
+ };
22
30
  export type HoloOptions = {
23
31
  intensity: number;
24
32
  waveCallback: WaveCallbackFn;
@@ -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,EAAE,MAAM,CAAC,CAAC;AACpC,MAAM,MAAM,I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B,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-shine",
3
- "version": "0.3.5",
3
+ "version": "0.4.1",
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",
@@ -82,11 +82,11 @@
82
82
  "prettier": "^3.0.3",
83
83
  "react": "19.0.0",
84
84
  "react-dom": "19.0.0",
85
- "react-native": "0.79.5",
85
+ "react-native": "0.81.0",
86
86
  "react-native-builder-bob": "^0.40.13",
87
87
  "react-native-reanimated": "^4.1.3",
88
- "react-native-wgpu": "^0.2.8",
89
- "react-native-worklets": "^0.5.1",
88
+ "react-native-wgpu": "^0.3.1",
89
+ "react-native-worklets": "^0.5.2",
90
90
  "release-it": "^17.10.0",
91
91
  "typegpu": "0.7.1",
92
92
  "typescript": "^5.8.3",
@@ -96,8 +96,8 @@
96
96
  "react": "*",
97
97
  "react-native": "*",
98
98
  "react-native-reanimated": "^4.1.3",
99
- "react-native-wgpu": "^0.2.8",
100
- "react-native-worklets": "^0.5.1",
99
+ "react-native-wgpu": "^0.3.1",
100
+ "react-native-worklets": "^0.5.2",
101
101
  "typegpu": "0.7.1"
102
102
  },
103
103
  "workspaces": [
@@ -1,5 +1,5 @@
1
- import { useEffect, useMemo, useRef } from 'react';
2
- import { PixelRatio, Platform, View } from 'react-native';
1
+ import { useEffect, useMemo, useRef, useState } from 'react';
2
+ import { PixelRatio, View } from 'react-native';
3
3
  import Animated, {
4
4
  SensorType,
5
5
  type SharedValue,
@@ -8,7 +8,11 @@ import Animated, {
8
8
  useDerivedValue,
9
9
  useSharedValue,
10
10
  } from 'react-native-reanimated';
11
- import { Canvas, useGPUContext } from 'react-native-wgpu';
11
+ import {
12
+ Canvas,
13
+ type CanvasRef,
14
+ type RNCanvasContext,
15
+ } from 'react-native-wgpu';
12
16
  import * as d from 'typegpu/data';
13
17
  import type {
14
18
  TextureProps,
@@ -26,6 +30,7 @@ import { TypedBufferMap } from '../shaders/resourceManagement/bufferManager';
26
30
  import {
27
31
  createColorMaskBindGroup,
28
32
  createGlareBindGroup,
33
+ createReverseHoloDetectionChannelFlagsBindGroup,
29
34
  createRotationValuesBindGroup,
30
35
  } from '../shaders/bindGroupUtils';
31
36
  import colorMaskFragment from '../shaders/fragmentShaders/colorMaskFragment';
@@ -46,11 +51,13 @@ import type {
46
51
  DeepPartiallyOptional,
47
52
  GlareOptions,
48
53
  PipelineAttachmentPair,
54
+ ReverseHoloDetectionChannelFlags,
49
55
  } from '../types/types';
50
56
  import {
51
57
  colorMaskToTyped,
52
58
  createColorMask,
53
59
  createGlareOptions,
60
+ createReverseHoloDetectionChannelFlags,
54
61
  } from '../types/typeUtils';
55
62
  import type { V2d, V3d } from '../types/vector';
56
63
  import {
@@ -75,9 +82,10 @@ export interface SharedProps {
75
82
  colorMaskOptions?: DeepPartiallyOptional<ColorMask, 'baseColor'>;
76
83
  useTouchControl?: boolean;
77
84
  touchPosition?: SharedValue<V2d>;
78
- addTextureMask?: boolean;
79
85
  addReverseHolo?: boolean;
86
+ reverseHoloDetectionChannelOptions?: Partial<ReverseHoloDetectionChannelFlags>;
80
87
  addHolo?: boolean;
88
+ translateViewIn3d?: boolean;
81
89
  }
82
90
 
83
91
  interface ContentProps extends SharedProps {
@@ -97,7 +105,7 @@ interface PipelineMap {
97
105
  export default function Content({
98
106
  addHolo,
99
107
  addReverseHolo,
100
- addTextureMask,
108
+ reverseHoloDetectionChannelOptions,
101
109
  colorMaskOptions,
102
110
  glareOptions,
103
111
  height,
@@ -107,9 +115,18 @@ export default function Content({
107
115
  touchPosition,
108
116
  useTouchControl,
109
117
  width,
118
+ translateViewIn3d = false,
110
119
  }: ContentProps) {
111
120
  const { device } = root;
112
- const { ref, context } = useGPUContext();
121
+ // const { ref, context } = useGPUContext();
122
+ const ref = useRef<CanvasRef>(null);
123
+ const [context, setContext] = useState<RNCanvasContext | null>(null);
124
+ // const context = ref.current!.getContext('webgpu')!;
125
+
126
+ useEffect(() => {
127
+ if (ref) setContext(ref.current?.getContext('webgpu')!);
128
+ }, [ref]);
129
+
113
130
  const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
114
131
  const renderRef = useRef<() => void>(null);
115
132
 
@@ -146,7 +163,6 @@ export default function Content({
146
163
  { perspective: 300 },
147
164
  { rotateX: `${-rotY}deg` },
148
165
  { rotateY: `${rotX}deg` },
149
- // { rotateZ: `${rotX * 5}deg` },
150
166
  ],
151
167
  };
152
168
  });
@@ -275,6 +291,18 @@ export default function Content({
275
291
  );
276
292
  const colorMaskBindGroup = createColorMaskBindGroup(root, colorMaskBuffer);
277
293
 
294
+ const reverseHoloDetectionChannelFlagsBuffer = bufferMap.addBuffer(
295
+ root,
296
+ 'reverseHoloDetectionChannelFlags',
297
+ createReverseHoloDetectionChannelFlags(reverseHoloDetectionChannelOptions)
298
+ );
299
+ const reverseHoloDetectionChannelFlagsBindGroup =
300
+ createReverseHoloDetectionChannelFlagsBindGroup(
301
+ root,
302
+ reverseHoloDetectionChannelFlagsBuffer,
303
+ glareBuffer
304
+ );
305
+
278
306
  const pipelineMap: PipelineMap = {
279
307
  glare: attachBindGroups(
280
308
  root['~unstable']
@@ -308,7 +336,11 @@ export default function Content({
308
336
  reverseHolo: createReverseHoloPipeline(
309
337
  root,
310
338
  maskTexture,
311
- [imageTextureBindGroup, rotationBindGroup, glareBindGroup],
339
+ [
340
+ imageTextureBindGroup,
341
+ rotationBindGroup,
342
+ reverseHoloDetectionChannelFlagsBindGroup,
343
+ ],
312
344
  sampler,
313
345
  presentationFormat
314
346
  ),
@@ -344,7 +376,7 @@ export default function Content({
344
376
 
345
377
  const pairs: PipelineAttachmentPair[] = [[glare, initialAttachment]];
346
378
 
347
- if (addTextureMask && mask) pairs.push([mask, loadingAttachment]);
379
+ if (mask) pairs.push([mask, loadingAttachment]);
348
380
  if (addReverseHolo && reverseHolo)
349
381
  pairs.push([reverseHolo, loadingAttachment]);
350
382
  if (addHolo && holo) pairs.push([holo, loadingAttachment]);
@@ -362,6 +394,9 @@ export default function Content({
362
394
  renderPipelines();
363
395
  presentContext();
364
396
  };
397
+
398
+ // const res = tgpu.resolve({ externals: { reverseHoloFragment } });
399
+ // console.log('reverseHoloFragment resolve:', res);
365
400
  }, [
366
401
  device,
367
402
  context,
@@ -375,29 +410,27 @@ export default function Content({
375
410
  colorMaskOptions,
376
411
  addHolo,
377
412
  addReverseHolo,
378
- addTextureMask,
413
+ reverseHoloDetectionChannelOptions,
379
414
  pixelSize,
380
415
  ]);
381
416
 
382
417
  useAnimationFrame(() => renderRef.current?.());
383
418
 
384
419
  return (
385
- <Animated.View style={[animatedStyle]}>
386
- <View
387
- style={
388
- [
389
- // styles.container,
390
- // { width, height },
391
- ]
392
- }
393
- >
394
- <Canvas
395
- ref={ref}
396
- style={[{ width, height }]}
397
- transparent={Platform.OS === 'ios'}
398
- // transparent={true}
399
- />
400
- </View>
401
- </Animated.View>
420
+ <View
421
+ style={{
422
+ transform: [
423
+ {
424
+ matrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 50, 1],
425
+ },
426
+ ],
427
+ }}
428
+ >
429
+ <Animated.View style={[translateViewIn3d && animatedStyle]}>
430
+ <View>
431
+ <Canvas ref={ref} style={[{ width, height }]} transparent={true} />
432
+ </View>
433
+ </Animated.View>
434
+ </View>
402
435
  );
403
436
  }
@@ -20,7 +20,6 @@ export function ShineGroup({
20
20
  maskURI,
21
21
  touchPosition,
22
22
  useTouchControl = false,
23
- addTextureMask = false,
24
23
  addHolo = false,
25
24
  addReverseHolo = false,
26
25
  }: ShineGroupProps) {
@@ -82,7 +81,6 @@ export function ShineGroup({
82
81
  maskURI={maskURI}
83
82
  touchPosition={touchPosition}
84
83
  useTouchControl={useTouchControl}
85
- addTextureMask={addTextureMask}
86
84
  addReverseHolo={addReverseHolo}
87
85
  addHolo={addHolo}
88
86
  />
@@ -47,6 +47,24 @@ export const colorMaskBindGroupLayout = tgpu.bindGroupLayout({
47
47
  mask: { uniform: colorMaskSchema },
48
48
  });
49
49
 
50
+ export const reverseHoloDetectionChannelFlagsSchema = d.struct({
51
+ redChannel: d.align(16, d.f32),
52
+ greenChannel: d.f32,
53
+ blueChannel: d.f32,
54
+ hue: d.f32,
55
+ saturation: d.f32,
56
+ value: d.f32,
57
+ });
58
+
59
+ export type ReverseHoloDetectionChannelFlagsSchema =
60
+ typeof reverseHoloDetectionChannelFlagsSchema;
61
+
62
+ export const reverseHoloDetectionChannelFlagsBindGroupLayout =
63
+ tgpu.bindGroupLayout({
64
+ channelFlags: { uniform: reverseHoloDetectionChannelFlagsSchema },
65
+ glareOptions: { uniform: glareSchema },
66
+ });
67
+
50
68
  export const bufferData = {
51
69
  rotation: {
52
70
  schema: d.vec3f,
@@ -60,6 +78,10 @@ export const bufferData = {
60
78
  schema: colorMaskSchema,
61
79
  usage: 'uniform',
62
80
  },
81
+ reverseHoloDetectionChannelFlags: {
82
+ schema: reverseHoloDetectionChannelFlagsSchema,
83
+ usage: 'uniform',
84
+ },
63
85
  } as const satisfies Record<
64
86
  string,
65
87
  { schema: ValidateBufferSchema<any>; usage: BufferUsageType }
@@ -8,6 +8,8 @@ import {
8
8
  rotationBindGroupLayout,
9
9
  type GlareSchema,
10
10
  colorMaskSchema,
11
+ type ReverseHoloDetectionChannelFlagsSchema,
12
+ reverseHoloDetectionChannelFlagsBindGroupLayout,
11
13
  } from './bindGroupLayouts';
12
14
  import type {
13
15
  GlareOptions,
@@ -70,6 +72,17 @@ export const createColorMaskBindGroup = (
70
72
  mask: buffer,
71
73
  });
72
74
 
75
+ export const createReverseHoloDetectionChannelFlagsBindGroup = (
76
+ root: TgpuRoot,
77
+ detectionChannelBuffer: TgpuBuffer<ReverseHoloDetectionChannelFlagsSchema> &
78
+ UniformFlag,
79
+ glareOptionsBuffer: TgpuBuffer<GlareSchema> & UniformFlag
80
+ ) =>
81
+ root.createBindGroup(reverseHoloDetectionChannelFlagsBindGroupLayout, {
82
+ channelFlags: detectionChannelBuffer,
83
+ glareOptions: glareOptionsBuffer,
84
+ });
85
+
73
86
  // export const crateHoloBuffer = (
74
87
  // root: TgpuRoot,
75
88
  // initValues: Partial<HoloOptions>
@@ -29,7 +29,7 @@ const colorMaskFragment = tgpu['~unstable'].fragmentFn({
29
29
  if (upperCheck && lowerCheck) {
30
30
  return d.vec4f(color.xyz, 0.0);
31
31
  }
32
- return d.vec4f(1.0);
32
+ return d.vec4f(color.xyz, color.w);
33
33
  });
34
34
 
35
35
  export default colorMaskFragment;
@@ -31,5 +31,5 @@ export const holoFragment = tgpu['~unstable'].fragmentFn({
31
31
  const rainbowColor = hueShift(d.vec3f(1.0, 1.0, 1.0), hueAngle);
32
32
  const finalColor = std.mul(rainbowColor, 1.0);
33
33
 
34
- return d.vec4f(finalColor, 0.7 * textureColor.w);
34
+ return d.vec4f(finalColor, 0.9 * textureColor.w);
35
35
  });
@@ -5,9 +5,9 @@ import {
5
5
  textureBindGroupLayout,
6
6
  maskTextureBindGroupLayout,
7
7
  rotationBindGroupLayout,
8
- glareBindGroupLayout,
8
+ reverseHoloDetectionChannelFlagsBindGroupLayout,
9
9
  } from '../bindGroupLayouts';
10
- import { hueShift } from '../tgpuUtils';
10
+ import { hueShift, rgbToHSV } from '../tgpuUtils';
11
11
 
12
12
  export const reverseHoloFragment = tgpu['~unstable'].fragmentFn({
13
13
  in: { uv: d.vec2f },
@@ -20,13 +20,26 @@ export const reverseHoloFragment = tgpu['~unstable'].fragmentFn({
20
20
  const rot = rotationBindGroupLayout.$.vec;
21
21
  const center = std.add(d.vec2f(0.0), d.vec2f(rot.x, rot.y)); // center from device orientation/touch
22
22
 
23
- const opts = glareBindGroupLayout.$.glareOptions;
23
+ // glare options---------------------------------
24
+ const opts = reverseHoloDetectionChannelFlagsBindGroupLayout.$.glareOptions;
24
25
  const glareIntensity = opts.glareIntensity;
25
26
  const glowPower = opts.glowPower;
26
27
  const hueBlendPower = opts.hueBlendPower;
27
28
  const hueShiftAngleMin = opts.hueShiftAngleMin;
28
29
  const hueShiftAngleMax = opts.hueShiftAngleMax;
29
30
  const lightIntensity = opts.lightIntensity;
31
+ //-----------------------------------------------
32
+
33
+ // detection channel flags-----------------------
34
+ const detectionChannelFlags =
35
+ reverseHoloDetectionChannelFlagsBindGroupLayout.$.channelFlags;
36
+ const redChannelFlag = detectionChannelFlags.redChannel;
37
+ const greenChannelFlag = detectionChannelFlags.greenChannel;
38
+ const blueChannelFlag = detectionChannelFlags.blueChannel;
39
+ const hueFlag = detectionChannelFlags.hue;
40
+ const saturationFlag = detectionChannelFlags.saturation;
41
+ const valueFlag = detectionChannelFlags.value;
42
+ //------------------------------------------------
30
43
 
31
44
  const cardColor = std.textureSample(
32
45
  textureBindGroupLayout.$.texture,
@@ -49,9 +62,25 @@ export const reverseHoloFragment = tgpu['~unstable'].fragmentFn({
49
62
  const influence = std.smoothstep(0.0, 1.0, scaledRadial);
50
63
  const curvePower = std.clamp(glowPower, 0.05, 64.0);
51
64
  const glowMask = std.pow(influence, std.div(1.0, curvePower));
65
+ const holoMaskColorHSV = rgbToHSV(holoMaskColor.xyz);
66
+
67
+ const rgbSelection = d.vec3f(
68
+ redChannelFlag,
69
+ greenChannelFlag,
70
+ blueChannelFlag
71
+ );
72
+ const channelFactor = std.dot(holoMaskColor.xyz, rgbSelection);
73
+
74
+ const hsvSelection = d.vec3f(hueFlag, saturationFlag, valueFlag);
75
+ const channelFactorHSV = std.dot(holoMaskColorHSV.xyz, hsvSelection);
76
+ //TODO: delete this combination to have separate RGB and HSV controls,
77
+ // maybe add weights later or choice of combination method
78
+ const channelFactorCombined = std.mix(channelFactor, channelFactorHSV, 0.0);
52
79
 
53
80
  const holoFactor =
54
- (1.0 - holoMaskColor.x) * holoMaskColor.w * std.pow(scaledRadial, 1.5);
81
+ (1.0 - channelFactorCombined) *
82
+ holoMaskColor.w *
83
+ std.pow(scaledRadial, 1.5);
55
84
 
56
85
  const maskedGlow = std.mul(glowMask, holoFactor); // only affect masked areas
57
86
 
@@ -33,6 +33,46 @@ export const hueShift = tgpu.fn(
33
33
  return d.vec3f(r, g, b);
34
34
  });
35
35
 
36
+ export const rgbToHSV = tgpu.fn(
37
+ [d.vec3f],
38
+ d.vec3f
39
+ )((rgb) => {
40
+ const cMax = std.max(std.max(rgb.x, rgb.y), rgb.z);
41
+ const cMin = std.min(std.min(rgb.x, rgb.y), rgb.z);
42
+ const delta = std.sub(cMax, cMin);
43
+
44
+ const hueDeltaZero = d.f32(0.0);
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)
53
+ );
54
+ hue = std.select(hue, hueGmax, cMax === rgb.y && delta !== d.f32(0.0));
55
+ hue = std.select(hue, hueBmax, cMax === rgb.z && delta !== d.f32(0.0));
56
+ hue = std.select(hue, d.f32(0.0), delta === d.f32(0.0));
57
+
58
+ hue = std.mod(hue, d.f32(360.0));
59
+ const saturation = std.select(delta / cMax, d.f32(0.0), cMax === d.f32(0.0));
60
+ const value = cMax;
61
+
62
+ return d.vec3f(hue, saturation, value);
63
+ });
64
+
65
+ export const fmod = tgpu.fn(
66
+ [d.f32, d.f32],
67
+ d.f32
68
+ )((number, md) => {
69
+ const dv = std.div(number, md);
70
+ const val = std.mul(md, std.floor(dv));
71
+ const c = std.sub(number, val);
72
+
73
+ return c;
74
+ });
75
+
36
76
  export const glareColorShift = tgpu.fn(
37
77
  [d.vec3f, d.f32],
38
78
  d.vec3f