@bbki.ng/site 5.4.34 → 5.4.35

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 5.4.35
4
+
5
+ ### Patch Changes
6
+
7
+ - 3d9b106: add paper texture
8
+ - Updated dependencies [3d9b106]
9
+ - @bbki.ng/ui@0.1.9
10
+
3
11
  ## 5.4.34
4
12
 
5
13
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "5.4.34",
3
+ "version": "5.4.35",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "react-dom": "^18.0.0",
15
15
  "react-router-dom": "6",
16
16
  "swr": "^2.2.5",
17
- "@bbki.ng/ui": "0.1.8"
17
+ "@bbki.ng/ui": "0.1.9"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@eslint/compat": "^1.0.0",
@@ -1,36 +1,15 @@
1
- float rand(vec2 co){
2
- return fract(
3
- sin(
4
- dot(
5
- co.xy,
6
- vec2(12.9898, 78.233) * 2.
7
- ) * uProgress
8
- ) * 43758.5453
9
- );
10
- }
11
-
12
- vec4 grain(vec4 fragColor, vec2 uv){
13
- vec4 color = fragColor;
14
- float diff = (rand(uv) - 0.0) * 0.09;
15
- color.r += diff;
16
- color.g += diff;
17
- color.b += diff;
18
- return color;
1
+ // Integer-based hash, stable on mediump float and immune to precision loss
2
+ float rand(vec2 co) {
3
+ vec2 seed = co * uResolution + fract(uProgress * vec2(12.453, 78.379));
4
+ vec3 p = fract(vec3(seed.xyx) * vec3(443.897, 441.423, 437.195));
5
+ p += dot(p, p.yzx + 19.19);
6
+ return fract((p.x + p.y) * p.z);
19
7
  }
20
8
 
21
9
  vec4 randGrain(vec2 uv) {
22
- vec4 color = vec4(
23
- rand(uv) * 0.1,
24
- rand(uv) * 0.1,
25
- rand(uv) * 0.1,
26
- 0.1
27
- );
28
-
29
- vec4 result = grain(color, uv) * 0.4;
30
-
31
- result.a *= 0.8;
32
-
33
- return result;
10
+ float n = rand(uv);
11
+ float intensity = (n - 0.5) * 0.05;
12
+ return vec4(vec3(0.0), abs(intensity) + 0.02);
34
13
  }
35
14
 
36
15
  void drawGrainOnNav(vec2 uv) {
@@ -0,0 +1,52 @@
1
+ // Fine book paper texture — static, white-only, subtle fiber pattern
2
+
3
+ float paperHash(vec2 p) {
4
+ vec3 p3 = fract(vec3(p.xyx) * vec3(443.897, 441.423, 437.195));
5
+ p3 += dot(p3, p3.yzx + 19.19);
6
+ return fract((p3.x + p3.y) * p3.z);
7
+ }
8
+
9
+ float paperNoise(vec2 uv) {
10
+ vec2 i = floor(uv);
11
+ vec2 f = fract(uv);
12
+ // smooth interpolation
13
+ vec2 u = f * f * (3.0 - 2.0 * f);
14
+
15
+ float a = paperHash(i);
16
+ float b = paperHash(i + vec2(1.0, 0.0));
17
+ float c = paperHash(i + vec2(0.0, 1.0));
18
+ float d = paperHash(i + vec2(1.0, 1.0));
19
+
20
+ return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
21
+ }
22
+
23
+ // fBm with 3 octaves for fine fiber detail
24
+ float paperFBM(vec2 uv) {
25
+ float value = 0.0;
26
+ float amplitude = 0.5;
27
+ for (int i = 0; i < 3; i++) {
28
+ value += amplitude * paperNoise(uv);
29
+ uv *= 2.2;
30
+ amplitude *= 0.45;
31
+ }
32
+ return value;
33
+ }
34
+
35
+ void drawPaperTexture(vec2 uv) {
36
+ // Scale to physical pixels so texture density stays consistent across screens
37
+ vec2 texCoord = uv * uResolution / uDevicePixelRatio;
38
+
39
+ // Fine-scale fiber pattern (~1px detail at 1x)
40
+ float fiber = paperFBM(texCoord * 0.8);
41
+
42
+ // Normalize to center around 0 and keep very subtle
43
+ float tex = (fiber - 0.5) * 0.06;
44
+
45
+ // White-only: positive values add slight white highlights (paper fiber ridges)
46
+ // Negative values stay transparent
47
+ float alpha = max(tex, 0.0);
48
+
49
+ // Blend paper texture under the grain effect
50
+ vec4 paper = vec4(1.0, 1.0, 1.0, alpha);
51
+ gl_FragColor = paper + gl_FragColor * (1.0 - paper.a * 0.3);
52
+ }
@@ -7,6 +7,7 @@ uniform float uDevicePixelRatio;
7
7
  #define DefaultColor vec4(0.0, 0.0, 0.0, 0.0)
8
8
 
9
9
  #include "effects/grain.frag"
10
+ #include "effects/paper.frag"
10
11
  #include "effects/spiral.frag"
11
12
  //#include "shapes/circle.frag"
12
13
 
@@ -17,8 +18,8 @@ void main() {
17
18
  // set default color
18
19
  gl_FragColor = DefaultColor;
19
20
 
20
- // draw circle on mouse
21
- // drawCircleUnderMouse(uv, 0.05);
21
+ // draw paper texture (base layer)
22
+ drawPaperTexture(uv);
22
23
 
23
24
  // draw grain on nav
24
25
  drawGrainOnNav(uv);