react-native-shine 0.6.0 → 0.7.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 +41 -27
- package/lib/module/components/Content.js.map +1 -1
- package/lib/module/components/ShineGroup.js +16 -8
- package/lib/module/components/ShineGroup.js.map +1 -1
- package/lib/module/enums/colorHighlightPresets.js +24 -0
- package/lib/module/enums/colorHighlightPresets.js.map +1 -0
- package/lib/module/enums/effectPresets.js +16 -0
- package/lib/module/enums/effectPresets.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/shaders/bindGroupLayouts.js +19 -15
- package/lib/module/shaders/bindGroupLayouts.js.map +1 -1
- package/lib/module/shaders/bindGroupUtils.js +16 -7
- package/lib/module/shaders/bindGroupUtils.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/colorMaskFragment.js +53 -41
- package/lib/module/shaders/fragmentShaders/colorMaskFragment.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/glareFragment.js +11 -8
- package/lib/module/shaders/fragmentShaders/glareFragment.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/holoFragment.js +6 -5
- package/lib/module/shaders/fragmentShaders/holoFragment.js.map +1 -1
- package/lib/module/shaders/fragmentShaders/reverseHoloFragment.js +12 -8
- package/lib/module/shaders/fragmentShaders/reverseHoloFragment.js.map +1 -1
- package/lib/module/types/size.js +2 -0
- package/lib/module/types/typeUtils.js +97 -51
- package/lib/module/types/typeUtils.js.map +1 -1
- package/lib/module/types/vector.js +2 -0
- package/lib/module/utils/vector.js +6 -6
- package/lib/typescript/src/components/Content.d.ts +11 -8
- 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/enums/colorHighlightPresets.d.ts +12 -0
- package/lib/typescript/src/enums/colorHighlightPresets.d.ts.map +1 -0
- package/lib/typescript/src/enums/effectPresets.d.ts +14 -0
- package/lib/typescript/src/enums/effectPresets.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/shaders/bindGroupLayouts.d.ts +93 -49
- package/lib/typescript/src/shaders/bindGroupLayouts.d.ts.map +1 -1
- package/lib/typescript/src/shaders/bindGroupUtils.d.ts +41 -48
- 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/fragmentShaders/glareFragment.d.ts.map +1 -1
- package/lib/typescript/src/shaders/fragmentShaders/reverseHoloFragment.d.ts.map +1 -1
- package/lib/typescript/src/types/typeUtils.d.ts +32 -3
- package/lib/typescript/src/types/typeUtils.d.ts.map +1 -1
- package/lib/typescript/src/types/types.d.ts +31 -4
- package/lib/typescript/src/types/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/components/Content.tsx +62 -34
- package/src/components/ShineGroup.tsx +16 -8
- package/src/enums/colorHighlightPresets.ts +33 -0
- package/src/enums/effectPresets.ts +11 -0
- package/src/index.tsx +2 -0
- package/src/shaders/bindGroupLayouts.ts +26 -10
- package/src/shaders/bindGroupUtils.ts +19 -26
- package/src/shaders/fragmentShaders/colorMaskFragment.ts +64 -45
- package/src/shaders/fragmentShaders/glareFragment.ts +10 -6
- package/src/shaders/fragmentShaders/holoFragment.ts +5 -5
- package/src/shaders/fragmentShaders/reverseHoloFragment.ts +12 -7
- package/src/types/typeUtils.ts +100 -57
- package/src/types/types.ts +36 -4
|
@@ -24,10 +24,12 @@ export const reverseHoloFragment = tgpu['~unstable'].fragmentFn({
|
|
|
24
24
|
const opts = reverseHoloDetectionChannelFlagsBindGroupLayout.$.glareOptions;
|
|
25
25
|
const glareIntensity = opts.glareIntensity;
|
|
26
26
|
const glowPower = opts.glowPower;
|
|
27
|
-
const hueBlendPower = opts.hueBlendPower;
|
|
28
|
-
const hueShiftAngleMin = opts.hueShiftAngleMin;
|
|
29
|
-
const hueShiftAngleMax = opts.hueShiftAngleMax;
|
|
30
27
|
const lightIntensity = opts.lightIntensity;
|
|
28
|
+
|
|
29
|
+
const glareColor = opts.glareColor;
|
|
30
|
+
const hueBlendPower = glareColor.hueBlendPower;
|
|
31
|
+
const hueShiftAngleMin = glareColor.hueShiftAngleMin;
|
|
32
|
+
const hueShiftAngleMax = glareColor.hueShiftAngleMax;
|
|
31
33
|
//-----------------------------------------------
|
|
32
34
|
|
|
33
35
|
// detection channel flags-----------------------
|
|
@@ -82,7 +84,8 @@ export const reverseHoloFragment = tgpu['~unstable'].fragmentFn({
|
|
|
82
84
|
holoMaskColor.w *
|
|
83
85
|
std.pow(scaledRadial, 1.5);
|
|
84
86
|
|
|
85
|
-
const
|
|
87
|
+
// const decayedGlowMask = std.exp(1.0 - glowMask);
|
|
88
|
+
const maskedGlow = std.pow(std.mul(glowMask, holoFactor), 2.0); // only affect masked areas
|
|
86
89
|
|
|
87
90
|
const hueAmount = std.mix(
|
|
88
91
|
hueShiftAngleMin,
|
|
@@ -90,11 +93,13 @@ export const reverseHoloFragment = tgpu['~unstable'].fragmentFn({
|
|
|
90
93
|
std.clamp(maskedGlow, 0.0, 1.0)
|
|
91
94
|
);
|
|
92
95
|
const sparkleHue = hueShift(cardColor.xyz, hueAmount);
|
|
96
|
+
const shineStrength = std.clamp(lightIntensity, 1.0, 100.0);
|
|
97
|
+
const shineIntensity = 1.5 * shineStrength * maskedGlow;
|
|
98
|
+
|
|
93
99
|
const hueMixAmt = std.clamp((hueBlendPower / 5.0) * maskedGlow, 0.0, 1.0);
|
|
94
100
|
const chromaMix = std.mix(cardColor.xyz, sparkleHue, hueMixAmt);
|
|
95
101
|
|
|
96
|
-
const
|
|
97
|
-
const shineLayer = std.mul(chromaMix, 1.5 * shineStrength * maskedGlow);
|
|
102
|
+
const shineLayer = std.mul(chromaMix, shineIntensity);
|
|
98
103
|
|
|
99
|
-
return d.vec4f(shineLayer, 1 - maskedGlow);
|
|
104
|
+
return d.vec4f(d.vec3f(shineLayer), 1.0 - maskedGlow);
|
|
100
105
|
});
|
package/src/types/typeUtils.ts
CHANGED
|
@@ -11,84 +11,126 @@ import type {
|
|
|
11
11
|
import { div } from 'typegpu/std';
|
|
12
12
|
import { WAVE_CALLBACKS } from '../enums/waveCallback';
|
|
13
13
|
import { colorMaskDebug } from '../config/debugMode';
|
|
14
|
+
import { COLOR_MASK_MAX_COUNT } from '../shaders/bindGroupLayouts';
|
|
14
15
|
|
|
15
16
|
export const createGlareOptions = (
|
|
16
17
|
options: Partial<GlareOptions>
|
|
17
18
|
): GlareOptions => {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
hueShiftAngleMin,
|
|
22
|
-
hueBlendPower,
|
|
23
|
-
lightIntensity,
|
|
24
|
-
glareIntensity,
|
|
25
|
-
} = options;
|
|
19
|
+
const { glowPower, glareColor, lightIntensity, glareIntensity } = options;
|
|
20
|
+
const { hueBlendPower, hueShiftAngleMax, hueShiftAngleMin } =
|
|
21
|
+
glareColor || {};
|
|
26
22
|
|
|
27
23
|
const glareOp = {
|
|
28
24
|
glowPower: glowPower ?? 1.0,
|
|
29
|
-
hueShiftAngleMax: hueShiftAngleMax ?? 1.0,
|
|
30
|
-
hueShiftAngleMin: hueShiftAngleMin ?? 0.0,
|
|
31
|
-
hueBlendPower: hueBlendPower ?? 1.0,
|
|
32
25
|
lightIntensity: lightIntensity ?? 1.0,
|
|
33
26
|
glareIntensity: glareIntensity ?? 1.0,
|
|
27
|
+
glareColor: {
|
|
28
|
+
hueShiftAngleMax: hueShiftAngleMax ?? 1.0,
|
|
29
|
+
hueShiftAngleMin: hueShiftAngleMin ?? 0.0,
|
|
30
|
+
hueBlendPower: hueBlendPower ?? 1.0,
|
|
31
|
+
},
|
|
34
32
|
};
|
|
35
33
|
|
|
36
34
|
return glareOp;
|
|
37
35
|
};
|
|
38
36
|
|
|
39
|
-
export const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
export const glareOptionsToTyped = (glareOptions: GlareOptions) => {
|
|
38
|
+
return {
|
|
39
|
+
glowPower: f32(glareOptions.glowPower),
|
|
40
|
+
lightIntensity: f32(glareOptions.lightIntensity),
|
|
41
|
+
glareIntensity: f32(glareOptions.glareIntensity),
|
|
42
|
+
glareColor: {
|
|
43
|
+
hueShiftAngleMax: f32(glareOptions.glareColor.hueShiftAngleMax),
|
|
44
|
+
hueShiftAngleMin: f32(glareOptions.glareColor.hueShiftAngleMin),
|
|
45
|
+
hueBlendPower: f32(glareOptions.glareColor.hueBlendPower),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
50
48
|
};
|
|
51
49
|
|
|
52
|
-
export const
|
|
53
|
-
|
|
54
|
-
): ColorMask => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
50
|
+
export const createColorMasks = (
|
|
51
|
+
colorMasks: DeepPartiallyOptional<ColorMask, 'baseColor'>[]
|
|
52
|
+
): ColorMask[] => {
|
|
53
|
+
const newColorMasks: ColorMask[] = [];
|
|
54
|
+
for (const i in colorMasks) {
|
|
55
|
+
const {
|
|
56
|
+
baseColor,
|
|
57
|
+
rgbToleranceRange,
|
|
58
|
+
useHSV,
|
|
59
|
+
hueToleranceRange,
|
|
60
|
+
brightnessTolerance,
|
|
61
|
+
saturationTolerance,
|
|
62
|
+
lowBrightnessThreshold,
|
|
63
|
+
lowSaturationThreshold,
|
|
64
|
+
} = colorMasks[i]!;
|
|
65
|
+
const baseTolerance = {
|
|
66
|
+
upper: [20, 20, 20] as vec3,
|
|
67
|
+
lower: [20, 20, 20] as vec3,
|
|
68
|
+
};
|
|
69
|
+
const baseHueTolerance = {
|
|
70
|
+
upper: 20,
|
|
71
|
+
lower: 20,
|
|
72
|
+
};
|
|
73
|
+
const tolerance = { ...baseTolerance, ...rgbToleranceRange };
|
|
74
|
+
const hueTolerance = { ...baseHueTolerance, ...hueToleranceRange };
|
|
75
|
+
const newColorMask: ColorMask = {
|
|
76
|
+
baseColor: baseColor,
|
|
77
|
+
rgbToleranceRange: tolerance,
|
|
78
|
+
useHSV: useHSV!!,
|
|
79
|
+
hueToleranceRange: hueTolerance,
|
|
80
|
+
brightnessTolerance: brightnessTolerance ?? 1.0,
|
|
81
|
+
saturationTolerance: saturationTolerance ?? 1.0,
|
|
82
|
+
lowBrightnessThreshold: lowBrightnessThreshold ?? 0.0,
|
|
83
|
+
lowSaturationThreshold: lowSaturationThreshold ?? 0.0,
|
|
84
|
+
debugMode: colorMaskDebug,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
newColorMasks[i] = newColorMask;
|
|
88
|
+
}
|
|
75
89
|
|
|
76
90
|
// TODO: add radian and degree angle handling
|
|
77
91
|
// '123deg' <- interpret as a numeric angle value
|
|
78
92
|
// 2 <- interpret as a radian value
|
|
79
|
-
const mask: ColorMask = {
|
|
80
|
-
baseColor: baseColor,
|
|
81
|
-
rgbToleranceRange: tolerance,
|
|
82
|
-
useHSV: useHSV!!,
|
|
83
|
-
hueToleranceRange: hueTolerance,
|
|
84
|
-
brightnessTolerance: brightnessTolerance ?? 1.0,
|
|
85
|
-
saturationTolerance: saturationTolerance ?? 1.0,
|
|
86
|
-
lowBrightnessThreshold: lowBrightnessThreshold ?? 0.0,
|
|
87
|
-
lowSaturationThreshold: lowSaturationThreshold ?? 0.0,
|
|
88
|
-
debugMode: colorMaskDebug,
|
|
89
|
-
};
|
|
90
93
|
|
|
91
|
-
return
|
|
94
|
+
return newColorMasks;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const fillColorMaskBufferWithDummies = (
|
|
98
|
+
colorMasks: ColorMask[]
|
|
99
|
+
): ColorMask[] => {
|
|
100
|
+
const dummyFilledColorMasks = new Array(COLOR_MASK_MAX_COUNT);
|
|
101
|
+
for (let i = 0; i < dummyFilledColorMasks.length; i++) {
|
|
102
|
+
if (i < colorMasks.length) {
|
|
103
|
+
dummyFilledColorMasks[i] = colorMasks[i];
|
|
104
|
+
} else {
|
|
105
|
+
dummyFilledColorMasks[i] = {
|
|
106
|
+
baseColor: [0, 0, 0],
|
|
107
|
+
useHSV: false,
|
|
108
|
+
rgbToleranceRange: {
|
|
109
|
+
upper: [0, 0, 0],
|
|
110
|
+
lower: [0, 0, 0],
|
|
111
|
+
},
|
|
112
|
+
hueToleranceRange: {
|
|
113
|
+
upper: 0,
|
|
114
|
+
lower: 0,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return dummyFilledColorMasks;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const colorMasksToTyped = (
|
|
123
|
+
colorMasks: ColorMask[],
|
|
124
|
+
reverseHighlight: boolean
|
|
125
|
+
) => {
|
|
126
|
+
const typedColorMasks = fillColorMaskBufferWithDummies(colorMasks).map(
|
|
127
|
+
(mask) => colorMaskToTyped(mask)
|
|
128
|
+
);
|
|
129
|
+
return {
|
|
130
|
+
masks: typedColorMasks,
|
|
131
|
+
usedMaskCount: colorMasks.length,
|
|
132
|
+
reverseHighlight: reverseHighlight ? 1 : 0,
|
|
133
|
+
};
|
|
92
134
|
};
|
|
93
135
|
|
|
94
136
|
export const colorMaskToTyped = (colorMask: ColorMask) => {
|
|
@@ -109,6 +151,7 @@ export const colorMaskToTyped = (colorMask: ColorMask) => {
|
|
|
109
151
|
lowBrightnessThreshold: f32(colorMask.lowBrightnessThreshold),
|
|
110
152
|
debugMode: d.u32(colorMask.debugMode ? d.u32(1) : d.u32(0)),
|
|
111
153
|
};
|
|
154
|
+
|
|
112
155
|
return result;
|
|
113
156
|
};
|
|
114
157
|
|
package/src/types/types.ts
CHANGED
|
@@ -12,11 +12,13 @@ export type quaternion = vec4;
|
|
|
12
12
|
|
|
13
13
|
export type GlareOptions = {
|
|
14
14
|
glowPower: number;
|
|
15
|
-
hueShiftAngleMax: number;
|
|
16
|
-
hueShiftAngleMin: number;
|
|
17
|
-
hueBlendPower: number;
|
|
18
15
|
lightIntensity: number;
|
|
19
16
|
glareIntensity: number;
|
|
17
|
+
glareColor: {
|
|
18
|
+
hueBlendPower: number;
|
|
19
|
+
hueShiftAngleMax: number;
|
|
20
|
+
hueShiftAngleMin: number;
|
|
21
|
+
};
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
export type ColorMask = {
|
|
@@ -24,8 +26,8 @@ export type ColorMask = {
|
|
|
24
26
|
useHSV?: boolean;
|
|
25
27
|
hueToleranceRange: { upper: number; lower: number };
|
|
26
28
|
brightnessTolerance?: number;
|
|
27
|
-
lowBrightnessThreshold?: number;
|
|
28
29
|
saturationTolerance?: number;
|
|
30
|
+
lowBrightnessThreshold?: number;
|
|
29
31
|
lowSaturationThreshold?: number;
|
|
30
32
|
rgbToleranceRange: {
|
|
31
33
|
upper: vec3;
|
|
@@ -34,6 +36,36 @@ export type ColorMask = {
|
|
|
34
36
|
debugMode?: boolean;
|
|
35
37
|
};
|
|
36
38
|
|
|
39
|
+
//TODO: figure out how to tell compiler that im sure that it's long enough ;-;
|
|
40
|
+
export type ColorMaskArrayShaderAssert = [
|
|
41
|
+
any,
|
|
42
|
+
any,
|
|
43
|
+
any,
|
|
44
|
+
any,
|
|
45
|
+
any,
|
|
46
|
+
any,
|
|
47
|
+
any,
|
|
48
|
+
any,
|
|
49
|
+
any,
|
|
50
|
+
any,
|
|
51
|
+
any,
|
|
52
|
+
any,
|
|
53
|
+
any,
|
|
54
|
+
any,
|
|
55
|
+
any,
|
|
56
|
+
any,
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
export type Effect =
|
|
60
|
+
| {
|
|
61
|
+
name: 'reverseHolo';
|
|
62
|
+
options: Partial<ReverseHoloDetectionChannelFlags>;
|
|
63
|
+
}
|
|
64
|
+
| {
|
|
65
|
+
name: 'holo';
|
|
66
|
+
options?: HoloOptions;
|
|
67
|
+
};
|
|
68
|
+
|
|
37
69
|
export type ReverseHoloDetectionChannelFlags = {
|
|
38
70
|
redChannel: number;
|
|
39
71
|
greenChannel: number;
|