vireglass 0.1.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/LICENSE +202 -0
- package/NOTICE +10 -0
- package/README.md +216 -0
- package/android/build.gradle +15 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/expo/modules/glasslens/GlassBackdropView.kt +335 -0
- package/android/src/main/java/expo/modules/glasslens/GlassLensModule.kt +49 -0
- package/android/src/main/java/expo/modules/glasslens/GlassLensView.kt +463 -0
- package/android/src/main/java/expo/modules/glasslens/GlassProbeView.kt +76 -0
- package/dist/adaptation-BSbbdExK.d.cts +78 -0
- package/dist/adaptation-BSbbdExK.d.ts +78 -0
- package/dist/adapters-BPB0D5nr.d.cts +357 -0
- package/dist/adapters-BgSc-smX.d.ts +357 -0
- package/dist/chunk-HF2AWZEZ.js +1741 -0
- package/dist/chunk-HF2AWZEZ.js.map +1 -0
- package/dist/chunk-JNRZNMJJ.js +20 -0
- package/dist/chunk-JNRZNMJJ.js.map +1 -0
- package/dist/index.cjs +2159 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +294 -0
- package/dist/index.d.ts +294 -0
- package/dist/index.js +286 -0
- package/dist/index.js.map +1 -0
- package/dist/material-CkUHUBoy.d.cts +408 -0
- package/dist/material-CkUHUBoy.d.ts +408 -0
- package/dist/react.cjs +73 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +25 -0
- package/dist/react.d.ts +25 -0
- package/dist/react.js +59 -0
- package/dist/react.js.map +1 -0
- package/dist/web/index.cjs +1990 -0
- package/dist/web/index.cjs.map +1 -0
- package/dist/web/index.d.cts +148 -0
- package/dist/web/index.d.ts +148 -0
- package/dist/web/index.js +657 -0
- package/dist/web/index.js.map +1 -0
- package/expo-module.config.json +6 -0
- package/package.json +127 -0
- package/src/accessibility.ts +51 -0
- package/src/adaptation.ts +85 -0
- package/src/adapters.ts +362 -0
- package/src/concentric.ts +25 -0
- package/src/geometry.ts +151 -0
- package/src/glass-scale.ts +37 -0
- package/src/group-model.ts +224 -0
- package/src/index.ts +17 -0
- package/src/lens-shader.ts +547 -0
- package/src/material.ts +553 -0
- package/src/native/environment.ts +70 -0
- package/src/native/glass-group.tsx +107 -0
- package/src/native/glass-ink.tsx +44 -0
- package/src/native/glass-surface.tsx +477 -0
- package/src/native/index.ts +18 -0
- package/src/native/lens.ts +106 -0
- package/src/native/provider.tsx +58 -0
- package/src/native/surface-registry.ts +51 -0
- package/src/native/system-accessibility.ts +90 -0
- package/src/optics.ts +177 -0
- package/src/react.ts +102 -0
- package/src/reference-scene.ts +222 -0
- package/src/scroll-edge.ts +30 -0
- package/src/sdf.ts +149 -0
- package/src/surface-shader.ts +287 -0
- package/src/targets/agsl.ts +8 -0
- package/src/targets/glsl.ts +140 -0
- package/src/touch-response.ts +195 -0
- package/src/web/gl.ts +119 -0
- package/src/web/index.ts +3 -0
- package/src/web/probe.ts +312 -0
- package/src/web/reference-draw.ts +142 -0
- package/src/web/renderer.ts +524 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
VireGlass
|
|
2
|
+
Copyright 2026 Danil Kotlaev
|
|
3
|
+
|
|
4
|
+
This product includes software developed as part of the vireSpace platform
|
|
5
|
+
(https://github.com/pruffit/vire).
|
|
6
|
+
|
|
7
|
+
The material model was calibrated against publicly available reference material
|
|
8
|
+
from Apple's WWDC 2025 sessions 219 and 356 and related design talks. No Apple
|
|
9
|
+
code, assets, or footage is included in or distributed with this software; the
|
|
10
|
+
references in the documentation are citations, not redistribution.
|
package/README.md
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# VireGlass
|
|
2
|
+
|
|
3
|
+
A liquid glass material for interfaces, derived from optics rather than assembled from effects.
|
|
4
|
+
|
|
5
|
+
One material model, one shader source, two render targets: **WebGL2** in the browser and
|
|
6
|
+
**AGSL** on Android. Apache-2.0.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install vireglass
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## The idea
|
|
15
|
+
|
|
16
|
+
Most glass effects are a stack of knobs: blur radius, rim brightness, rainbow strength, a
|
|
17
|
+
highlight slider. Every knob is independent, so most of the combinations you can dial in
|
|
18
|
+
describe glass that does not exist — a razor-thin bevel with a dense white rim, a rim whose
|
|
19
|
+
optics scale with the element's size.
|
|
20
|
+
|
|
21
|
+
VireGlass exposes **causes** and derives the rest:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { resolveOptics } from 'vireglass';
|
|
25
|
+
|
|
26
|
+
const optics = resolveOptics({
|
|
27
|
+
ior: 1.5, // index of refraction — water 1.33, glass 1.5, sapphire 1.77
|
|
28
|
+
thickness: 20, // dp
|
|
29
|
+
bevel: 10, // dp, absolute: a real rim doesn't scale with the piece
|
|
30
|
+
roughness: 0.12,
|
|
31
|
+
film: 0, // thin-film thickness, nm — iridescence
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Those turn into the values the shaders need — refraction strength, magnification, Fresnel,
|
|
36
|
+
specular, dispersion, diffraction, interference, medium tint, body density, ambient colour
|
|
37
|
+
pickup. There is no "rainbow strength" knob because dispersion, diffraction and interference
|
|
38
|
+
are one cause (wavelength dependence) and one hue multiplier, normalised to its own mean: they
|
|
39
|
+
tint the reflection without brightening it.
|
|
40
|
+
|
|
41
|
+
Dispersion follows Cauchy, absorption follows Beer–Lambert, reflectance follows Schlick. Where
|
|
42
|
+
the model departs from physics, the comment says so and says why.
|
|
43
|
+
|
|
44
|
+
## Presets
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { MATERIAL_PRESETS, resolveOptics } from 'vireglass';
|
|
48
|
+
|
|
49
|
+
resolveOptics(MATERIAL_PRESETS.crystal);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`water` · `glass` · `crystal` · `frosted` · `thick` · `thin` · `iridescent` — points in the
|
|
53
|
+
space of causes, not bundles of finished effects.
|
|
54
|
+
|
|
55
|
+
## Web
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { createVireGlassRenderer } from 'vireglass/web';
|
|
59
|
+
import { resolveOptics, roundedRectGeometry, MATERIAL_PRESETS } from 'vireglass';
|
|
60
|
+
|
|
61
|
+
const renderer = createVireGlassRenderer(canvas);
|
|
62
|
+
renderer.resize(canvas.width, canvas.height);
|
|
63
|
+
|
|
64
|
+
renderer.render({
|
|
65
|
+
density: devicePixelRatio,
|
|
66
|
+
debug: 'normal',
|
|
67
|
+
scene: (ctx, width, height) => {
|
|
68
|
+
ctx.fillStyle = '#12141a';
|
|
69
|
+
ctx.fillRect(0, 0, width, height);
|
|
70
|
+
// ...draw whatever the glass should refract
|
|
71
|
+
},
|
|
72
|
+
pieces: [
|
|
73
|
+
{
|
|
74
|
+
optics: resolveOptics(MATERIAL_PRESETS.glass),
|
|
75
|
+
geometry: roundedRectGeometry(220, 120, 32),
|
|
76
|
+
centerX: canvas.width / 2,
|
|
77
|
+
centerY: canvas.height / 2,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`render` also returns one backdrop probe per element — mean lightness, 10th/90th percentiles
|
|
84
|
+
and variegation of what lies under it. That is what the adaptation layer reads.
|
|
85
|
+
|
|
86
|
+
> **WebGL does not see the DOM.** The lens refracts only what the renderer drew itself, which is
|
|
87
|
+
> why you hand it a `scene` callback that rasterises your backdrop into a 2D canvas. Glass over
|
|
88
|
+
> live HTML is not supported in this release. If that is what you came for, this package does
|
|
89
|
+
> not do it yet.
|
|
90
|
+
|
|
91
|
+
## Android / React Native
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { VireGlassProvider, VireGlassSurface } from 'vireglass/native';
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The Android target is an Expo module: `expo-module.config.json` ships in the package, so
|
|
98
|
+
autolinking picks up the Kotlin in an Expo app and stays silent everywhere else. Run
|
|
99
|
+
`expo prebuild` after installing. `vireglass/native` ships as **source** on purpose — the
|
|
100
|
+
surface uses a Reanimated worklet, and worklets are compiled by the consumer's Babel plugin.
|
|
101
|
+
|
|
102
|
+
`VireGlassProvider` is optional. Mount it to give the host app an escape hatch:
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<VireGlassProvider glassEnabled={settings.glass} reduceMotion={settings.reduceMotion}>
|
|
106
|
+
<App />
|
|
107
|
+
</VireGlassProvider>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Without it, everything works on sensible defaults.
|
|
111
|
+
|
|
112
|
+
## How the glass decides what to be
|
|
113
|
+
|
|
114
|
+
Three loops, all automatic, all in the core and shared by both platforms.
|
|
115
|
+
|
|
116
|
+
**The body adapts to the backdrop by a gradient, not a number.** The probe returns a plane of
|
|
117
|
+
lightness — a slope along each axis — so the glass separates itself from the ink at *every*
|
|
118
|
+
point of the element: it darkens harder over the bright half and barely touches the dark one. A
|
|
119
|
+
plane is the crudest model that can express "one half is brighter than the other", and the only
|
|
120
|
+
one that is smooth by construction. A point estimate at a density break produced ghost copies
|
|
121
|
+
of the text underneath.
|
|
122
|
+
|
|
123
|
+
**Density adapts to variegation.** Fine texture — a checkerboard, a line of type — cannot be
|
|
124
|
+
described by a plane, so density rises as a whole, driven by the lightness range. This is what
|
|
125
|
+
real glass does with roughness: it stops being a window.
|
|
126
|
+
|
|
127
|
+
**Presence.** Over a uniform backdrop there is nothing to refract, and the glass honestly
|
|
128
|
+
disappears. Correct for a piece of background, wrong for a control. `presence` sets a minimum
|
|
129
|
+
lightness separation from the backdrop, and the sign is taken from the *backdrop*: lighter over
|
|
130
|
+
dark, darker over light.
|
|
131
|
+
|
|
132
|
+
Ink polarity is decided by the **cost of holding it**, not by contrast: how much body density
|
|
133
|
+
it would take to keep light ink legible. Above the threshold the element would stop being glass
|
|
134
|
+
and become a painted plate, and the decision passes to the app. Contrast is the wrong measure —
|
|
135
|
+
it also collapses on saturated yellow, and light icons kept flipping to dark over coloured
|
|
136
|
+
blocks.
|
|
137
|
+
|
|
138
|
+
## React
|
|
139
|
+
|
|
140
|
+
The core is dependency-free on purpose, so the one piece that needs hooks lives behind its own
|
|
141
|
+
entry point:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { useGlassAdaptation } from 'vireglass/react';
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
It carries the confirmation policy and the recolor fade. The decision itself —
|
|
148
|
+
`shouldInkBeLight` — is a pure function in the core, shared by every platform.
|
|
149
|
+
|
|
150
|
+
## Accessibility
|
|
151
|
+
|
|
152
|
+
`applyAccessibility` maps the three system settings — reduced transparency, increased contrast,
|
|
153
|
+
reduced motion — onto the material. They set floors and they win over the user's clarity
|
|
154
|
+
preference; `applyGlassScale` gives that preference its own axis, ultra clear to fully tinted.
|
|
155
|
+
|
|
156
|
+
## Quality gates
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npm run typecheck
|
|
160
|
+
npm test # 122 tests
|
|
161
|
+
npm run check:glsl # both shaders compile and link as GLSL ES 3.0
|
|
162
|
+
npm run check:optics
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`check:optics` is the interesting one. It renders the material over a sweep of backdrops and
|
|
166
|
+
asserts that the glass stays **both a window and an object**: enough of the backdrop's lightness
|
|
167
|
+
range survives inside the element, and the element stays visible against it — across the whole
|
|
168
|
+
range, not at a convenient value. It also checks that ink under a finger defocuses, that a
|
|
169
|
+
raised element separates from its backdrop, that ink and content both survive over a busy
|
|
170
|
+
canvas, and that the rim gathers what is behind it.
|
|
171
|
+
|
|
172
|
+
## Limits — read these before adopting
|
|
173
|
+
|
|
174
|
+
- **No glass over live DOM on the web.** See above.
|
|
175
|
+
- **Refraction needs Android 13+** (`RenderEffect`). Below that it degrades to an affine
|
|
176
|
+
magnifier: a loupe, not a lens.
|
|
177
|
+
- **No iOS.** There is no public API for reading what is behind a view.
|
|
178
|
+
- **Real glass only works outside a capture target.** You cannot put glass inside the node it is
|
|
179
|
+
capturing — the RenderNode tree closes on itself and the runtime crashes. In practice that
|
|
180
|
+
means chrome (tab bars, mini players), not content. See `docs/adr-001-rendering.md` §2.
|
|
181
|
+
- **Budget: about 0.8 ms of GPU per surface**, growing linearly — 4 ms at one surface, 7 at
|
|
182
|
+
three, 8 at six, against an 8.33 ms frame budget at 120 Hz on the reference device. Three is
|
|
183
|
+
the confirmed product maximum. Six is where the budget runs out, not a measured cliff: the
|
|
184
|
+
saturation point was never found. Cost also depends on the scene, not just the count. Do not
|
|
185
|
+
judge frame cost on an emulator — it inflates GPU cost roughly 20× (it does reproduce the
|
|
186
|
+
phone closely for *correctness*, within 2.4 units across the reference canvases).
|
|
187
|
+
- **The probe cannot see texture finer than a 22 px cell.** Below that it averages, and the
|
|
188
|
+
glass treats the backdrop as uniform.
|
|
189
|
+
- **Interference (`film`) derives a value but produces no visible iridescence yet.** Known,
|
|
190
|
+
unexplained.
|
|
191
|
+
- Editing a shader needs an app restart on Android, not just Fast Refresh: the source travels as
|
|
192
|
+
a prop out of a memoised adapter.
|
|
193
|
+
|
|
194
|
+
## Documentation
|
|
195
|
+
|
|
196
|
+
| | |
|
|
197
|
+
|---|---|
|
|
198
|
+
| `docs/reference.md` | what the material was calibrated against, and what each number must satisfy |
|
|
199
|
+
| `docs/architecture.md` | layers, parameters, limits |
|
|
200
|
+
| `docs/adr-001-rendering.md` | the rendering architecture decision and its evidence |
|
|
201
|
+
| `docs/platform-parity.md` | how web and Android are kept numerically in agreement |
|
|
202
|
+
| `docs/benchmarks.md` | measurement protocol, device, numbers |
|
|
203
|
+
| `docs/material-lab.md` | selected entries from the experiment journal |
|
|
204
|
+
|
|
205
|
+
## Calibration
|
|
206
|
+
|
|
207
|
+
The material was measured against publicly available reference material — Apple's WWDC 2025
|
|
208
|
+
sessions 219 and 356 and related design talks — and the documentation cites them by session and
|
|
209
|
+
timestamp so the claims can be checked. No Apple code, assets or footage is included in or
|
|
210
|
+
distributed with this package.
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
215
|
+
|
|
216
|
+
The patent grant is deliberate: this is an optical algorithm, not glue code.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
plugins {
|
|
2
|
+
id 'com.android.library'
|
|
3
|
+
id 'expo-module-gradle-plugin'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
group = 'expo.modules.glasslens'
|
|
7
|
+
version = '0.1.0'
|
|
8
|
+
|
|
9
|
+
android {
|
|
10
|
+
namespace "expo.modules.glasslens"
|
|
11
|
+
defaultConfig {
|
|
12
|
+
versionCode 1
|
|
13
|
+
versionName "0.1.0"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
|