@paper-design/shaders 0.0.0-canary.390a3d9

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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/dist/get-empty-pixel.d.ts +1 -0
  4. package/dist/get-empty-pixel.js +19 -0
  5. package/dist/get-empty-pixel.js.map +7 -0
  6. package/dist/get-shader-color-from-string.d.ts +3 -0
  7. package/dist/get-shader-color-from-string.js +93 -0
  8. package/dist/get-shader-color-from-string.js.map +7 -0
  9. package/dist/get-shader-noise-texture.d.ts +1 -0
  10. package/dist/get-shader-noise-texture.js +19 -0
  11. package/dist/get-shader-noise-texture.js.map +7 -0
  12. package/dist/index.d.ts +53 -0
  13. package/dist/index.js +168 -0
  14. package/dist/index.js.map +7 -0
  15. package/dist/shader-color-spaces.d.ts +6 -0
  16. package/dist/shader-color-spaces.js +96 -0
  17. package/dist/shader-color-spaces.js.map +7 -0
  18. package/dist/shader-mount.d.ts +130 -0
  19. package/dist/shader-mount.js +483 -0
  20. package/dist/shader-mount.js.map +7 -0
  21. package/dist/shader-sizing.d.ts +35 -0
  22. package/dist/shader-sizing.js +230 -0
  23. package/dist/shader-sizing.js.map +7 -0
  24. package/dist/shader-utils.d.ts +10 -0
  25. package/dist/shader-utils.js +131 -0
  26. package/dist/shader-utils.js.map +7 -0
  27. package/dist/shaders/color-panels.d.ts +50 -0
  28. package/dist/shaders/color-panels.js +224 -0
  29. package/dist/shaders/color-panels.js.map +7 -0
  30. package/dist/shaders/dithering.d.ts +56 -0
  31. package/dist/shaders/dithering.js +223 -0
  32. package/dist/shaders/dithering.js.map +7 -0
  33. package/dist/shaders/dot-grid.d.ts +51 -0
  34. package/dist/shaders/dot-grid.js +110 -0
  35. package/dist/shaders/dot-grid.js.map +7 -0
  36. package/dist/shaders/dot-orbit.d.ts +39 -0
  37. package/dist/shaders/dot-orbit.js +124 -0
  38. package/dist/shaders/dot-orbit.js.map +7 -0
  39. package/dist/shaders/fluted-glass.d.ts +73 -0
  40. package/dist/shaders/fluted-glass.js +187 -0
  41. package/dist/shaders/fluted-glass.js.map +7 -0
  42. package/dist/shaders/god-rays.d.ts +45 -0
  43. package/dist/shaders/god-rays.js +133 -0
  44. package/dist/shaders/god-rays.js.map +7 -0
  45. package/dist/shaders/grain-gradient.d.ts +58 -0
  46. package/dist/shaders/grain-gradient.js +289 -0
  47. package/dist/shaders/grain-gradient.js.map +7 -0
  48. package/dist/shaders/heatmap.d.ts +31 -0
  49. package/dist/shaders/heatmap.js +303 -0
  50. package/dist/shaders/heatmap.js.map +7 -0
  51. package/dist/shaders/image-dithering.d.ts +49 -0
  52. package/dist/shaders/image-dithering.js +163 -0
  53. package/dist/shaders/image-dithering.js.map +7 -0
  54. package/dist/shaders/image-halftone-dots.d.ts +46 -0
  55. package/dist/shaders/image-halftone-dots.js +337 -0
  56. package/dist/shaders/image-halftone-dots.js.map +7 -0
  57. package/dist/shaders/liquid-metal.d.ts +66 -0
  58. package/dist/shaders/liquid-metal.js +627 -0
  59. package/dist/shaders/liquid-metal.js.map +7 -0
  60. package/dist/shaders/mesh-gradient.d.ts +33 -0
  61. package/dist/shaders/mesh-gradient.js +136 -0
  62. package/dist/shaders/mesh-gradient.js.map +7 -0
  63. package/dist/shaders/metaballs.d.ts +35 -0
  64. package/dist/shaders/metaballs.js +112 -0
  65. package/dist/shaders/metaballs.js.map +7 -0
  66. package/dist/shaders/neuro-noise.d.ts +27 -0
  67. package/dist/shaders/neuro-noise.js +80 -0
  68. package/dist/shaders/neuro-noise.js.map +7 -0
  69. package/dist/shaders/paper-texture.d.ts +53 -0
  70. package/dist/shaders/paper-texture.js +248 -0
  71. package/dist/shaders/paper-texture.js.map +7 -0
  72. package/dist/shaders/perlin-noise.d.ts +33 -0
  73. package/dist/shaders/perlin-noise.js +195 -0
  74. package/dist/shaders/perlin-noise.js.map +7 -0
  75. package/dist/shaders/pulsing-border.d.ts +72 -0
  76. package/dist/shaders/pulsing-border.js +237 -0
  77. package/dist/shaders/pulsing-border.js.map +7 -0
  78. package/dist/shaders/simplex-noise.d.ts +27 -0
  79. package/dist/shaders/simplex-noise.js +100 -0
  80. package/dist/shaders/simplex-noise.js.map +7 -0
  81. package/dist/shaders/smoke-ring.d.ts +39 -0
  82. package/dist/shaders/smoke-ring.js +130 -0
  83. package/dist/shaders/smoke-ring.js.map +7 -0
  84. package/dist/shaders/spiral.d.ts +41 -0
  85. package/dist/shaders/spiral.js +81 -0
  86. package/dist/shaders/spiral.js.map +7 -0
  87. package/dist/shaders/static-mesh-gradient.d.ts +42 -0
  88. package/dist/shaders/static-mesh-gradient.js +139 -0
  89. package/dist/shaders/static-mesh-gradient.js.map +7 -0
  90. package/dist/shaders/static-radial-gradient.d.ts +50 -0
  91. package/dist/shaders/static-radial-gradient.js +195 -0
  92. package/dist/shaders/static-radial-gradient.js.map +7 -0
  93. package/dist/shaders/swirl.d.ts +42 -0
  94. package/dist/shaders/swirl.js +102 -0
  95. package/dist/shaders/swirl.js.map +7 -0
  96. package/dist/shaders/voronoi.d.ts +44 -0
  97. package/dist/shaders/voronoi.js +139 -0
  98. package/dist/shaders/voronoi.js.map +7 -0
  99. package/dist/shaders/warp.d.ts +54 -0
  100. package/dist/shaders/warp.js +132 -0
  101. package/dist/shaders/warp.js.map +7 -0
  102. package/dist/shaders/water.d.ts +39 -0
  103. package/dist/shaders/water.js +120 -0
  104. package/dist/shaders/water.js.map +7 -0
  105. package/dist/shaders/waves.d.ts +38 -0
  106. package/dist/shaders/waves.js +66 -0
  107. package/dist/shaders/waves.js.map +7 -0
  108. package/dist/types.d.ts +3 -0
  109. package/dist/types.js +6 -0
  110. package/dist/types.js.map +7 -0
  111. package/dist/vertex-shader.d.ts +2 -0
  112. package/dist/vertex-shader.js +211 -0
  113. package/dist/vertex-shader.js.map +7 -0
  114. package/package.json +27 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/shaders/water.ts"],
4
+ "sourcesContent": ["import type { ShaderMotionParams } from '../shader-mount.js';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';\nimport { declarePI, rotation2, simplexNoise } from '../shader-utils.js';\n\n/**\n * Mimicking water surface distortion with a combination of noises;\n * Can be applied over the texture or just be used as an animated pattern\n *\n * Uniforms:\n * - u_colorBack, u_colorHighlight (RGBA)\n * - u_size: pattern scale relative to the image\n * - u_caustic: power of caustic distortion\n * - u_layering: the power of 2nd layer of caustic distortion\n * - u_edges: caustic distortion power on the image edges\n * - u_waves: additional distortion based in Simplex noise, independent from caustic\n * - u_highlights: a coloring added over the image/background, following the caustic shape\n *\n */\n\n// language=GLSL\nexport const waterFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform float u_time;\n\nuniform vec4 u_colorBack;\nuniform vec4 u_colorHighlight;\n\nuniform sampler2D u_image;\nuniform float u_imageAspectRatio;\n\nuniform float u_size;\nuniform float u_highlights;\nuniform float u_layering;\nuniform float u_edges;\nuniform float u_caustic;\nuniform float u_waves;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n${rotation2}\n${simplexNoise}\n\nfloat getUvFrame(vec2 uv) {\n float aax = 2. * fwidth(uv.x);\n float aay = 2. * fwidth(uv.y);\n\n float left = smoothstep(0., aax, uv.x);\n float right = 1.0 - smoothstep(1. - aax, 1., uv.x);\n float bottom = smoothstep(0., aay, uv.y);\n float top = 1.0 - smoothstep(1. - aay, 1., uv.y);\n\n return left * right * bottom * top;\n}\n\nmat2 rotate2D(float r) {\n return mat2(cos(r), sin(r), -sin(r), cos(r));\n}\n\nfloat getCausticNoise(vec2 uv, float t, float scale) {\n vec2 n = vec2(.1);\n vec2 N = vec2(.1);\n mat2 m = rotate2D(.5);\n for (int j = 0; j < 6; j++) {\n uv *= m;\n n *= m;\n vec2 q = uv * scale + float(j) + n + (.5 + .5 * float(j)) * (mod(float(j), 2.) - 1.) * t;\n n += sin(q);\n N += cos(q) / scale;\n scale *= 1.1;\n }\n return (N.x + N.y + 1.);\n}\n\nvoid main() {\n vec2 imageUV = v_imageUV;\n vec2 patternUV = v_imageUV - .5;\n patternUV = (patternUV * vec2(u_imageAspectRatio, 1.));\n patternUV /= (.01 + .09 * u_size);\n\n float t = u_time;\n\n float wavesNoise = snoise((.3 + .1 * sin(t)) * .1 * patternUV + vec2(0., .4 * t));\n\n float causticNoise = getCausticNoise(patternUV + u_waves * vec2(1., -1.) * wavesNoise, 2. * t, 1.5);\n\n causticNoise += u_layering * getCausticNoise(patternUV + 2. * u_waves * vec2(1., -1.) * wavesNoise, 1.5 * t, 2.);\n causticNoise = causticNoise * causticNoise;\n\n float edgesDistortion = smoothstep(0., .1, imageUV.x);\n edgesDistortion *= smoothstep(0., .1, imageUV.y);\n edgesDistortion *= (smoothstep(1., 1.1, imageUV.x) + (1.0 - smoothstep(.8, .95, imageUV.x)));\n edgesDistortion *= (1.0 - smoothstep(.9, 1., imageUV.y));\n edgesDistortion = mix(edgesDistortion, 1., u_edges);\n\n float causticNoiseDistortion = .02 * causticNoise * edgesDistortion;\n\n float wavesDistortion = .1 * u_waves * wavesNoise;\n\n imageUV += vec2(wavesDistortion, -wavesDistortion);\n imageUV += (u_caustic * causticNoiseDistortion);\n\n float frame = getUvFrame(imageUV);\n\n vec4 image = texture(u_image, imageUV);\n vec4 backColor = u_colorBack;\n backColor.rgb *= backColor.a;\n\n vec3 color = mix(backColor.rgb, image.rgb, image.a * frame);\n float opacity = backColor.a + image.a * frame;\n\n causticNoise = max(-.2, causticNoise);\n\n float hightlight = .025 * u_highlights * causticNoise;\n hightlight *= u_colorHighlight.a;\n color = mix(color, u_colorHighlight.rgb, .05 * u_highlights * causticNoise);\n opacity += hightlight;\n\n color += hightlight * (.5 + .5 * wavesNoise);\n opacity += hightlight * (.5 + .5 * wavesNoise);\n\n opacity = clamp(opacity, 0., 1.);\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface WaterUniforms extends ShaderSizingUniforms {\n u_image: HTMLImageElement | string | undefined;\n u_colorBack: [number, number, number, number];\n u_colorHighlight: [number, number, number, number];\n u_highlights: number;\n u_layering: number;\n u_edges: number;\n u_caustic: number;\n u_waves: number;\n u_size: number;\n}\n\nexport interface WaterParams extends ShaderSizingParams, ShaderMotionParams {\n image?: HTMLImageElement | string;\n colorBack?: string;\n colorHighlight?: string;\n highlights?: number;\n layering?: number;\n edges?: number;\n caustic?: number;\n waves?: number;\n size?: number;\n}\n"],
5
+ "mappings": ";;;;;AACA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,WAAW,oBAAoB;AAkB5C,MAAM,sBAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBzC,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,38 @@
1
+ import { type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';
2
+ /**
3
+ * Waveform pattern
4
+ *
5
+ * Uniforms:
6
+ * - u_colorBack, u_colorFront (RGBA)
7
+ * - u_shape (float, fractional numbers allowed):
8
+ * ---- 0: zigzag
9
+ * ---- 1: sine wave
10
+ * ---- 2: irregular wave
11
+ * ---- 3: irregular wave
12
+ * - u_amplitude, u_frequency, u_spacing: wave settings
13
+ * - u_proportion: (0..1) blend point between 2 colors (0.5 = equal distribution)
14
+ * - u_softness: color transition sharpness (0 = hard edge, 1 = smooth fade)
15
+ *
16
+ * */
17
+ export declare const wavesFragmentShader: string;
18
+ export interface WavesUniforms extends ShaderSizingUniforms {
19
+ u_colorFront: [number, number, number, number];
20
+ u_colorBack: [number, number, number, number];
21
+ u_shape: number;
22
+ u_frequency: number;
23
+ u_amplitude: number;
24
+ u_spacing: number;
25
+ u_proportion: number;
26
+ u_softness: number;
27
+ }
28
+ export interface WavesParams extends ShaderSizingParams {
29
+ colorFront?: string;
30
+ colorBack?: string;
31
+ rotation?: number;
32
+ shape?: number;
33
+ frequency?: number;
34
+ amplitude?: number;
35
+ spacing?: number;
36
+ proportion?: number;
37
+ softness?: number;
38
+ }
@@ -0,0 +1,66 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ import { sizingVariablesDeclaration } from "../shader-sizing.js";
7
+ import { declarePI } from "../shader-utils.js";
8
+ const wavesFragmentShader = `#version 300 es
9
+ precision mediump float;
10
+
11
+ uniform vec4 u_colorFront;
12
+ uniform vec4 u_colorBack;
13
+ uniform float u_shape;
14
+ uniform float u_frequency;
15
+ uniform float u_amplitude;
16
+ uniform float u_spacing;
17
+ uniform float u_proportion;
18
+ uniform float u_softness;
19
+
20
+ ${sizingVariablesDeclaration}
21
+
22
+ out vec4 fragColor;
23
+
24
+ ${declarePI}
25
+
26
+ void main() {
27
+ vec2 shape_uv = v_patternUV;
28
+ shape_uv *= 4.;
29
+
30
+ float wave = .5 * cos(shape_uv.x * u_frequency * TWO_PI);
31
+ float zigzag = 2. * abs(fract(shape_uv.x * u_frequency) - .5);
32
+ float irregular = sin(shape_uv.x * .25 * u_frequency * TWO_PI) * cos(shape_uv.x * u_frequency * TWO_PI);
33
+ float irregular2 = .75 * (sin(shape_uv.x * u_frequency * TWO_PI) + .5 * cos(shape_uv.x * .5 * u_frequency * TWO_PI));
34
+
35
+ float offset = mix(zigzag, wave, smoothstep(0., 1., u_shape));
36
+ offset = mix(offset, irregular, smoothstep(1., 2., u_shape));
37
+ offset = mix(offset, irregular2, smoothstep(2., 3., u_shape));
38
+ offset *= 2. * u_amplitude;
39
+
40
+ float spacing = (.001 + u_spacing);
41
+ float shape = .5 + .5 * sin((shape_uv.y + offset) * PI / spacing);
42
+
43
+ float aa = .0001 + fwidth(shape);
44
+ float dc = 1. - clamp(u_proportion, 0., 1.);
45
+ float e0 = dc - u_softness - aa;
46
+ float e1 = dc + u_softness + aa;
47
+ float res = smoothstep(min(e0, e1), max(e0, e1), shape);
48
+
49
+ vec3 fgColor = u_colorFront.rgb * u_colorFront.a;
50
+ float fgOpacity = u_colorFront.a;
51
+ vec3 bgColor = u_colorBack.rgb * u_colorBack.a;
52
+ float bgOpacity = u_colorBack.a;
53
+
54
+ vec3 color = fgColor * res;
55
+ float opacity = fgOpacity * res;
56
+
57
+ color += bgColor * (1. - opacity);
58
+ opacity += bgOpacity * (1. - opacity);
59
+
60
+ fragColor = vec4(color, opacity);
61
+ }
62
+ `;
63
+ export {
64
+ wavesFragmentShader
65
+ };
66
+ //# sourceMappingURL=waves.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/shaders/waves.ts"],
4
+ "sourcesContent": ["import { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing.js';\nimport { declarePI } from '../shader-utils.js';\n\n/**\n * Waveform pattern\n *\n * Uniforms:\n * - u_colorBack, u_colorFront (RGBA)\n * - u_shape (float, fractional numbers allowed):\n * ---- 0: zigzag\n * ---- 1: sine wave\n * ---- 2: irregular wave\n * ---- 3: irregular wave\n * - u_amplitude, u_frequency, u_spacing: wave settings\n * - u_proportion: (0..1) blend point between 2 colors (0.5 = equal distribution)\n * - u_softness: color transition sharpness (0 = hard edge, 1 = smooth fade)\n *\n * */\n\n// language=GLSL\nexport const wavesFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform vec4 u_colorFront;\nuniform vec4 u_colorBack;\nuniform float u_shape;\nuniform float u_frequency;\nuniform float u_amplitude;\nuniform float u_spacing;\nuniform float u_proportion;\nuniform float u_softness;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n\nvoid main() {\n vec2 shape_uv = v_patternUV;\n shape_uv *= 4.;\n\n float wave = .5 * cos(shape_uv.x * u_frequency * TWO_PI);\n float zigzag = 2. * abs(fract(shape_uv.x * u_frequency) - .5);\n float irregular = sin(shape_uv.x * .25 * u_frequency * TWO_PI) * cos(shape_uv.x * u_frequency * TWO_PI);\n float irregular2 = .75 * (sin(shape_uv.x * u_frequency * TWO_PI) + .5 * cos(shape_uv.x * .5 * u_frequency * TWO_PI));\n\n float offset = mix(zigzag, wave, smoothstep(0., 1., u_shape));\n offset = mix(offset, irregular, smoothstep(1., 2., u_shape));\n offset = mix(offset, irregular2, smoothstep(2., 3., u_shape));\n offset *= 2. * u_amplitude;\n\n float spacing = (.001 + u_spacing);\n float shape = .5 + .5 * sin((shape_uv.y + offset) * PI / spacing);\n\n float aa = .0001 + fwidth(shape);\n float dc = 1. - clamp(u_proportion, 0., 1.);\n float e0 = dc - u_softness - aa;\n float e1 = dc + u_softness + aa;\n float res = smoothstep(min(e0, e1), max(e0, e1), shape);\n \n vec3 fgColor = u_colorFront.rgb * u_colorFront.a;\n float fgOpacity = u_colorFront.a;\n vec3 bgColor = u_colorBack.rgb * u_colorBack.a;\n float bgOpacity = u_colorBack.a;\n\n vec3 color = fgColor * res;\n float opacity = fgOpacity * res;\n\n color += bgColor * (1. - opacity);\n opacity += bgOpacity * (1. - opacity);\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface WavesUniforms extends ShaderSizingUniforms {\n u_colorFront: [number, number, number, number];\n u_colorBack: [number, number, number, number];\n u_shape: number;\n u_frequency: number;\n u_amplitude: number;\n u_spacing: number;\n u_proportion: number;\n u_softness: number;\n}\n\nexport interface WavesParams extends ShaderSizingParams {\n colorFront?: string;\n colorBack?: string;\n rotation?: number;\n shape?: number;\n frequency?: number;\n amplitude?: number;\n spacing?: number;\n proportion?: number;\n softness?: number;\n}\n"],
5
+ "mappings": ";;;;;AAAA,SAAS,kCAAsF;AAC/F,SAAS,iBAAiB;AAmBnB,MAAM,sBAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYzC,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ export type vec4 = [number, number, number, number];
2
+ export type vec3 = [number, number, number];
3
+ export type vec2 = [number, number];
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** Vertex shader for the shader mount */
2
+ export declare const vertexShaderSource = "#version 300 es\nprecision mediump float;\n\nlayout(location = 0) in vec4 a_position;\n\nuniform vec2 u_resolution;\nuniform float u_pixelRatio;\nuniform float u_imageAspectRatio;\n\nuniform float u_originX;\nuniform float u_originY;\nuniform float u_worldWidth;\nuniform float u_worldHeight;\nuniform float u_fit;\n\nuniform float u_scale;\nuniform float u_rotation;\nuniform float u_offsetX;\nuniform float u_offsetY;\n\nuniform float u_pxSize;\n\nout vec2 v_objectUV;\nout vec2 v_objectBoxSize;\nout vec2 v_objectHelperBox;\n\nout vec2 v_responsiveUV;\nout vec2 v_responsiveBoxSize;\nout vec2 v_responsiveHelperBox;\nout vec2 v_responsiveBoxGivenSize;\n\nout vec2 v_patternUV;\nout vec2 v_patternBoxSize;\nout vec2 v_patternHelperBox;\n\nout vec2 v_imageUV;\n\n// #define ADD_HELPERS\n\nvec3 getBoxSize(float boxRatio, vec2 givenBoxSize) {\n vec2 box = vec2(0.);\n // fit = none\n box.x = boxRatio * min(givenBoxSize.x / boxRatio, givenBoxSize.y);\n float noFitBoxWidth = box.x;\n if (u_fit == 1.) { // fit = contain\n box.x = boxRatio * min(u_resolution.x / boxRatio, u_resolution.y);\n } else if (u_fit == 2.) { // fit = cover\n box.x = boxRatio * max(u_resolution.x / boxRatio, u_resolution.y);\n }\n box.y = box.x / boxRatio;\n return vec3(box, noFitBoxWidth);\n}\n\nvoid main() {\n gl_Position = a_position;\n\n vec2 uv = gl_Position.xy * .5;\n vec2 boxOrigin = vec2(.5 - u_originX, u_originY - .5);\n vec2 givenBoxSize = vec2(u_worldWidth, u_worldHeight);\n givenBoxSize = max(givenBoxSize, vec2(1.)) * u_pixelRatio;\n float r = u_rotation * 3.14159265358979323846 / 180.;\n mat2 graphicRotation = mat2(cos(r), sin(r), -sin(r), cos(r));\n vec2 graphicOffset = vec2(-u_offsetX, u_offsetY);\n\n\n // ===================================================\n // Sizing api for graphic objects with fixed ratio\n // (currently supports only ratio = 1)\n\n float fixedRatio = 1.;\n vec2 fixedRatioBoxGivenSize = vec2(\n (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,\n (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y\n );\n\n v_objectBoxSize = getBoxSize(fixedRatio, fixedRatioBoxGivenSize).xy;\n vec2 objectWorldScale = u_resolution.xy / v_objectBoxSize;\n\n #ifdef ADD_HELPERS\n v_objectHelperBox = uv;\n v_objectHelperBox *= objectWorldScale;\n v_objectHelperBox += boxOrigin * (objectWorldScale - 1.);\n #endif\n\n v_objectUV = uv;\n v_objectUV *= objectWorldScale;\n v_objectUV += boxOrigin * (objectWorldScale - 1.);\n v_objectUV += graphicOffset;\n v_objectUV /= u_scale;\n v_objectUV = graphicRotation * v_objectUV;\n\n\n // ===================================================\n\n\n // ===================================================\n // Sizing api for graphic objects with either givenBoxSize ratio or canvas ratio.\n // Full-screen mode available with u_worldWidth = u_worldHeight = 0\n\n v_responsiveBoxGivenSize = vec2(\n (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,\n (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y\n );\n float responsiveRatio = v_responsiveBoxGivenSize.x / v_responsiveBoxGivenSize.y;\n v_responsiveBoxSize = getBoxSize(responsiveRatio, v_responsiveBoxGivenSize).xy;\n vec2 responsiveBoxScale = u_resolution.xy / v_responsiveBoxSize;\n\n #ifdef ADD_HELPERS\n v_responsiveHelperBox = uv;\n v_responsiveHelperBox *= responsiveBoxScale;\n v_responsiveHelperBox += boxOrigin * (responsiveBoxScale - 1.);\n #endif\n\n v_responsiveUV = uv;\n v_responsiveUV *= responsiveBoxScale;\n v_responsiveUV += boxOrigin * (responsiveBoxScale - 1.);\n v_responsiveUV += graphicOffset;\n v_responsiveUV /= u_scale;\n v_responsiveUV.x *= responsiveRatio;\n v_responsiveUV = graphicRotation * v_responsiveUV;\n v_responsiveUV.x /= responsiveRatio;\n\n // ===================================================\n\n\n // ===================================================\n // Sizing api for patterns\n // (treating graphics as a image u_worldWidth x u_worldHeight size)\n\n float patternBoxRatio = givenBoxSize.x / givenBoxSize.y;\n vec2 patternBoxGivenSize = vec2(\n (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,\n (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y\n );\n patternBoxRatio = patternBoxGivenSize.x / patternBoxGivenSize.y;\n\n vec3 boxSizeData = getBoxSize(patternBoxRatio, patternBoxGivenSize);\n v_patternBoxSize = boxSizeData.xy;\n float patternBoxNoFitBoxWidth = boxSizeData.z;\n vec2 patternBoxScale = u_resolution.xy / v_patternBoxSize;\n\n #ifdef ADD_HELPERS\n v_patternHelperBox = uv;\n v_patternHelperBox *= patternBoxScale;\n v_patternHelperBox += boxOrigin * (patternBoxScale - 1.);\n #endif\n\n v_patternUV = uv;\n v_patternUV += graphicOffset / patternBoxScale;\n v_patternUV += boxOrigin;\n v_patternUV -= boxOrigin / patternBoxScale;\n v_patternUV *= u_resolution.xy;\n v_patternUV /= u_pixelRatio;\n if (u_fit > 0.) {\n v_patternUV *= (patternBoxNoFitBoxWidth / v_patternBoxSize.x);\n }\n v_patternUV /= u_scale;\n v_patternUV = graphicRotation * v_patternUV;\n v_patternUV += boxOrigin / patternBoxScale;\n v_patternUV -= boxOrigin;\n // x100 is a default multiplier between vertex and fragmant shaders\n // we use it to avoid UV presision issues\n v_patternUV *= .01;\n\n // ===================================================\n\n\n // ===================================================\n // Sizing api for images\n\n vec2 imageBoxSize;\n if (u_fit == 1.) { // contain\n imageBoxSize.x = min(u_resolution.x / u_imageAspectRatio, u_resolution.y) * u_imageAspectRatio;\n } else if (u_fit == 2.) { // cover\n imageBoxSize.x = max(u_resolution.x / u_imageAspectRatio, u_resolution.y) * u_imageAspectRatio;\n } else {\n imageBoxSize.x = min(10.0, 10.0 / u_imageAspectRatio * u_imageAspectRatio);\n }\n imageBoxSize.y = imageBoxSize.x / u_imageAspectRatio;\n vec2 imageBoxScale = u_resolution.xy / imageBoxSize;\n\n #ifdef ADD_HELPERS\n vec2 imageHelperBox = uv;\n imageHelperBox *= imageBoxScale;\n imageHelperBox += boxOrigin * (imageBoxScale - 1.);\n #endif\n\n v_imageUV = uv;\n v_imageUV *= imageBoxScale;\n v_imageUV += boxOrigin * (imageBoxScale - 1.);\n v_imageUV += graphicOffset;\n v_imageUV /= u_scale;\n v_imageUV.x *= u_imageAspectRatio;\n v_imageUV = graphicRotation * v_imageUV;\n v_imageUV.x /= u_imageAspectRatio;\n\n v_imageUV += .5;\n v_imageUV.y = 1. - v_imageUV.y;\n\n // ===================================================\n\n}";
@@ -0,0 +1,211 @@
1
+ /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
+ * Paper Shaders *
3
+ * https://github.com/paper-design/shaders *
4
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5
+
6
+ const vertexShaderSource = `#version 300 es
7
+ precision mediump float;
8
+
9
+ layout(location = 0) in vec4 a_position;
10
+
11
+ uniform vec2 u_resolution;
12
+ uniform float u_pixelRatio;
13
+ uniform float u_imageAspectRatio;
14
+
15
+ uniform float u_originX;
16
+ uniform float u_originY;
17
+ uniform float u_worldWidth;
18
+ uniform float u_worldHeight;
19
+ uniform float u_fit;
20
+
21
+ uniform float u_scale;
22
+ uniform float u_rotation;
23
+ uniform float u_offsetX;
24
+ uniform float u_offsetY;
25
+
26
+ uniform float u_pxSize;
27
+
28
+ out vec2 v_objectUV;
29
+ out vec2 v_objectBoxSize;
30
+ out vec2 v_objectHelperBox;
31
+
32
+ out vec2 v_responsiveUV;
33
+ out vec2 v_responsiveBoxSize;
34
+ out vec2 v_responsiveHelperBox;
35
+ out vec2 v_responsiveBoxGivenSize;
36
+
37
+ out vec2 v_patternUV;
38
+ out vec2 v_patternBoxSize;
39
+ out vec2 v_patternHelperBox;
40
+
41
+ out vec2 v_imageUV;
42
+
43
+ // #define ADD_HELPERS
44
+
45
+ vec3 getBoxSize(float boxRatio, vec2 givenBoxSize) {
46
+ vec2 box = vec2(0.);
47
+ // fit = none
48
+ box.x = boxRatio * min(givenBoxSize.x / boxRatio, givenBoxSize.y);
49
+ float noFitBoxWidth = box.x;
50
+ if (u_fit == 1.) { // fit = contain
51
+ box.x = boxRatio * min(u_resolution.x / boxRatio, u_resolution.y);
52
+ } else if (u_fit == 2.) { // fit = cover
53
+ box.x = boxRatio * max(u_resolution.x / boxRatio, u_resolution.y);
54
+ }
55
+ box.y = box.x / boxRatio;
56
+ return vec3(box, noFitBoxWidth);
57
+ }
58
+
59
+ void main() {
60
+ gl_Position = a_position;
61
+
62
+ vec2 uv = gl_Position.xy * .5;
63
+ vec2 boxOrigin = vec2(.5 - u_originX, u_originY - .5);
64
+ vec2 givenBoxSize = vec2(u_worldWidth, u_worldHeight);
65
+ givenBoxSize = max(givenBoxSize, vec2(1.)) * u_pixelRatio;
66
+ float r = u_rotation * 3.14159265358979323846 / 180.;
67
+ mat2 graphicRotation = mat2(cos(r), sin(r), -sin(r), cos(r));
68
+ vec2 graphicOffset = vec2(-u_offsetX, u_offsetY);
69
+
70
+
71
+ // ===================================================
72
+ // Sizing api for graphic objects with fixed ratio
73
+ // (currently supports only ratio = 1)
74
+
75
+ float fixedRatio = 1.;
76
+ vec2 fixedRatioBoxGivenSize = vec2(
77
+ (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,
78
+ (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y
79
+ );
80
+
81
+ v_objectBoxSize = getBoxSize(fixedRatio, fixedRatioBoxGivenSize).xy;
82
+ vec2 objectWorldScale = u_resolution.xy / v_objectBoxSize;
83
+
84
+ #ifdef ADD_HELPERS
85
+ v_objectHelperBox = uv;
86
+ v_objectHelperBox *= objectWorldScale;
87
+ v_objectHelperBox += boxOrigin * (objectWorldScale - 1.);
88
+ #endif
89
+
90
+ v_objectUV = uv;
91
+ v_objectUV *= objectWorldScale;
92
+ v_objectUV += boxOrigin * (objectWorldScale - 1.);
93
+ v_objectUV += graphicOffset;
94
+ v_objectUV /= u_scale;
95
+ v_objectUV = graphicRotation * v_objectUV;
96
+
97
+
98
+ // ===================================================
99
+
100
+
101
+ // ===================================================
102
+ // Sizing api for graphic objects with either givenBoxSize ratio or canvas ratio.
103
+ // Full-screen mode available with u_worldWidth = u_worldHeight = 0
104
+
105
+ v_responsiveBoxGivenSize = vec2(
106
+ (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,
107
+ (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y
108
+ );
109
+ float responsiveRatio = v_responsiveBoxGivenSize.x / v_responsiveBoxGivenSize.y;
110
+ v_responsiveBoxSize = getBoxSize(responsiveRatio, v_responsiveBoxGivenSize).xy;
111
+ vec2 responsiveBoxScale = u_resolution.xy / v_responsiveBoxSize;
112
+
113
+ #ifdef ADD_HELPERS
114
+ v_responsiveHelperBox = uv;
115
+ v_responsiveHelperBox *= responsiveBoxScale;
116
+ v_responsiveHelperBox += boxOrigin * (responsiveBoxScale - 1.);
117
+ #endif
118
+
119
+ v_responsiveUV = uv;
120
+ v_responsiveUV *= responsiveBoxScale;
121
+ v_responsiveUV += boxOrigin * (responsiveBoxScale - 1.);
122
+ v_responsiveUV += graphicOffset;
123
+ v_responsiveUV /= u_scale;
124
+ v_responsiveUV.x *= responsiveRatio;
125
+ v_responsiveUV = graphicRotation * v_responsiveUV;
126
+ v_responsiveUV.x /= responsiveRatio;
127
+
128
+ // ===================================================
129
+
130
+
131
+ // ===================================================
132
+ // Sizing api for patterns
133
+ // (treating graphics as a image u_worldWidth x u_worldHeight size)
134
+
135
+ float patternBoxRatio = givenBoxSize.x / givenBoxSize.y;
136
+ vec2 patternBoxGivenSize = vec2(
137
+ (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,
138
+ (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y
139
+ );
140
+ patternBoxRatio = patternBoxGivenSize.x / patternBoxGivenSize.y;
141
+
142
+ vec3 boxSizeData = getBoxSize(patternBoxRatio, patternBoxGivenSize);
143
+ v_patternBoxSize = boxSizeData.xy;
144
+ float patternBoxNoFitBoxWidth = boxSizeData.z;
145
+ vec2 patternBoxScale = u_resolution.xy / v_patternBoxSize;
146
+
147
+ #ifdef ADD_HELPERS
148
+ v_patternHelperBox = uv;
149
+ v_patternHelperBox *= patternBoxScale;
150
+ v_patternHelperBox += boxOrigin * (patternBoxScale - 1.);
151
+ #endif
152
+
153
+ v_patternUV = uv;
154
+ v_patternUV += graphicOffset / patternBoxScale;
155
+ v_patternUV += boxOrigin;
156
+ v_patternUV -= boxOrigin / patternBoxScale;
157
+ v_patternUV *= u_resolution.xy;
158
+ v_patternUV /= u_pixelRatio;
159
+ if (u_fit > 0.) {
160
+ v_patternUV *= (patternBoxNoFitBoxWidth / v_patternBoxSize.x);
161
+ }
162
+ v_patternUV /= u_scale;
163
+ v_patternUV = graphicRotation * v_patternUV;
164
+ v_patternUV += boxOrigin / patternBoxScale;
165
+ v_patternUV -= boxOrigin;
166
+ // x100 is a default multiplier between vertex and fragmant shaders
167
+ // we use it to avoid UV presision issues
168
+ v_patternUV *= .01;
169
+
170
+ // ===================================================
171
+
172
+
173
+ // ===================================================
174
+ // Sizing api for images
175
+
176
+ vec2 imageBoxSize;
177
+ if (u_fit == 1.) { // contain
178
+ imageBoxSize.x = min(u_resolution.x / u_imageAspectRatio, u_resolution.y) * u_imageAspectRatio;
179
+ } else if (u_fit == 2.) { // cover
180
+ imageBoxSize.x = max(u_resolution.x / u_imageAspectRatio, u_resolution.y) * u_imageAspectRatio;
181
+ } else {
182
+ imageBoxSize.x = min(10.0, 10.0 / u_imageAspectRatio * u_imageAspectRatio);
183
+ }
184
+ imageBoxSize.y = imageBoxSize.x / u_imageAspectRatio;
185
+ vec2 imageBoxScale = u_resolution.xy / imageBoxSize;
186
+
187
+ #ifdef ADD_HELPERS
188
+ vec2 imageHelperBox = uv;
189
+ imageHelperBox *= imageBoxScale;
190
+ imageHelperBox += boxOrigin * (imageBoxScale - 1.);
191
+ #endif
192
+
193
+ v_imageUV = uv;
194
+ v_imageUV *= imageBoxScale;
195
+ v_imageUV += boxOrigin * (imageBoxScale - 1.);
196
+ v_imageUV += graphicOffset;
197
+ v_imageUV /= u_scale;
198
+ v_imageUV.x *= u_imageAspectRatio;
199
+ v_imageUV = graphicRotation * v_imageUV;
200
+ v_imageUV.x /= u_imageAspectRatio;
201
+
202
+ v_imageUV += .5;
203
+ v_imageUV.y = 1. - v_imageUV.y;
204
+
205
+ // ===================================================
206
+
207
+ }`;
208
+ export {
209
+ vertexShaderSource
210
+ };
211
+ //# sourceMappingURL=vertex-shader.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/vertex-shader.ts"],
4
+ "sourcesContent": ["/** Vertex shader for the shader mount */\n// language=GLSL\nexport const vertexShaderSource = `#version 300 es\nprecision mediump float;\n\nlayout(location = 0) in vec4 a_position;\n\nuniform vec2 u_resolution;\nuniform float u_pixelRatio;\nuniform float u_imageAspectRatio;\n\nuniform float u_originX;\nuniform float u_originY;\nuniform float u_worldWidth;\nuniform float u_worldHeight;\nuniform float u_fit;\n\nuniform float u_scale;\nuniform float u_rotation;\nuniform float u_offsetX;\nuniform float u_offsetY;\n\nuniform float u_pxSize;\n\nout vec2 v_objectUV;\nout vec2 v_objectBoxSize;\nout vec2 v_objectHelperBox;\n\nout vec2 v_responsiveUV;\nout vec2 v_responsiveBoxSize;\nout vec2 v_responsiveHelperBox;\nout vec2 v_responsiveBoxGivenSize;\n\nout vec2 v_patternUV;\nout vec2 v_patternBoxSize;\nout vec2 v_patternHelperBox;\n\nout vec2 v_imageUV;\n\n// #define ADD_HELPERS\n\nvec3 getBoxSize(float boxRatio, vec2 givenBoxSize) {\n vec2 box = vec2(0.);\n // fit = none\n box.x = boxRatio * min(givenBoxSize.x / boxRatio, givenBoxSize.y);\n float noFitBoxWidth = box.x;\n if (u_fit == 1.) { // fit = contain\n box.x = boxRatio * min(u_resolution.x / boxRatio, u_resolution.y);\n } else if (u_fit == 2.) { // fit = cover\n box.x = boxRatio * max(u_resolution.x / boxRatio, u_resolution.y);\n }\n box.y = box.x / boxRatio;\n return vec3(box, noFitBoxWidth);\n}\n\nvoid main() {\n gl_Position = a_position;\n\n vec2 uv = gl_Position.xy * .5;\n vec2 boxOrigin = vec2(.5 - u_originX, u_originY - .5);\n vec2 givenBoxSize = vec2(u_worldWidth, u_worldHeight);\n givenBoxSize = max(givenBoxSize, vec2(1.)) * u_pixelRatio;\n float r = u_rotation * 3.14159265358979323846 / 180.;\n mat2 graphicRotation = mat2(cos(r), sin(r), -sin(r), cos(r));\n vec2 graphicOffset = vec2(-u_offsetX, u_offsetY);\n\n\n // ===================================================\n // Sizing api for graphic objects with fixed ratio\n // (currently supports only ratio = 1)\n\n float fixedRatio = 1.;\n vec2 fixedRatioBoxGivenSize = vec2(\n (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,\n (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y\n );\n\n v_objectBoxSize = getBoxSize(fixedRatio, fixedRatioBoxGivenSize).xy;\n vec2 objectWorldScale = u_resolution.xy / v_objectBoxSize;\n\n #ifdef ADD_HELPERS\n v_objectHelperBox = uv;\n v_objectHelperBox *= objectWorldScale;\n v_objectHelperBox += boxOrigin * (objectWorldScale - 1.);\n #endif\n\n v_objectUV = uv;\n v_objectUV *= objectWorldScale;\n v_objectUV += boxOrigin * (objectWorldScale - 1.);\n v_objectUV += graphicOffset;\n v_objectUV /= u_scale;\n v_objectUV = graphicRotation * v_objectUV;\n\n\n // ===================================================\n\n\n // ===================================================\n // Sizing api for graphic objects with either givenBoxSize ratio or canvas ratio.\n // Full-screen mode available with u_worldWidth = u_worldHeight = 0\n\n v_responsiveBoxGivenSize = vec2(\n (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,\n (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y\n );\n float responsiveRatio = v_responsiveBoxGivenSize.x / v_responsiveBoxGivenSize.y;\n v_responsiveBoxSize = getBoxSize(responsiveRatio, v_responsiveBoxGivenSize).xy;\n vec2 responsiveBoxScale = u_resolution.xy / v_responsiveBoxSize;\n\n #ifdef ADD_HELPERS\n v_responsiveHelperBox = uv;\n v_responsiveHelperBox *= responsiveBoxScale;\n v_responsiveHelperBox += boxOrigin * (responsiveBoxScale - 1.);\n #endif\n\n v_responsiveUV = uv;\n v_responsiveUV *= responsiveBoxScale;\n v_responsiveUV += boxOrigin * (responsiveBoxScale - 1.);\n v_responsiveUV += graphicOffset;\n v_responsiveUV /= u_scale;\n v_responsiveUV.x *= responsiveRatio;\n v_responsiveUV = graphicRotation * v_responsiveUV;\n v_responsiveUV.x /= responsiveRatio;\n\n // ===================================================\n\n\n // ===================================================\n // Sizing api for patterns\n // (treating graphics as a image u_worldWidth x u_worldHeight size)\n\n float patternBoxRatio = givenBoxSize.x / givenBoxSize.y;\n vec2 patternBoxGivenSize = vec2(\n (u_worldWidth == 0.) ? u_resolution.x : givenBoxSize.x,\n (u_worldHeight == 0.) ? u_resolution.y : givenBoxSize.y\n );\n patternBoxRatio = patternBoxGivenSize.x / patternBoxGivenSize.y;\n\n vec3 boxSizeData = getBoxSize(patternBoxRatio, patternBoxGivenSize);\n v_patternBoxSize = boxSizeData.xy;\n float patternBoxNoFitBoxWidth = boxSizeData.z;\n vec2 patternBoxScale = u_resolution.xy / v_patternBoxSize;\n\n #ifdef ADD_HELPERS\n v_patternHelperBox = uv;\n v_patternHelperBox *= patternBoxScale;\n v_patternHelperBox += boxOrigin * (patternBoxScale - 1.);\n #endif\n\n v_patternUV = uv;\n v_patternUV += graphicOffset / patternBoxScale;\n v_patternUV += boxOrigin;\n v_patternUV -= boxOrigin / patternBoxScale;\n v_patternUV *= u_resolution.xy;\n v_patternUV /= u_pixelRatio;\n if (u_fit > 0.) {\n v_patternUV *= (patternBoxNoFitBoxWidth / v_patternBoxSize.x);\n }\n v_patternUV /= u_scale;\n v_patternUV = graphicRotation * v_patternUV;\n v_patternUV += boxOrigin / patternBoxScale;\n v_patternUV -= boxOrigin;\n // x100 is a default multiplier between vertex and fragmant shaders\n // we use it to avoid UV presision issues\n v_patternUV *= .01;\n\n // ===================================================\n\n\n // ===================================================\n // Sizing api for images\n\n vec2 imageBoxSize;\n if (u_fit == 1.) { // contain\n imageBoxSize.x = min(u_resolution.x / u_imageAspectRatio, u_resolution.y) * u_imageAspectRatio;\n } else if (u_fit == 2.) { // cover\n imageBoxSize.x = max(u_resolution.x / u_imageAspectRatio, u_resolution.y) * u_imageAspectRatio;\n } else {\n imageBoxSize.x = min(10.0, 10.0 / u_imageAspectRatio * u_imageAspectRatio);\n }\n imageBoxSize.y = imageBoxSize.x / u_imageAspectRatio;\n vec2 imageBoxScale = u_resolution.xy / imageBoxSize;\n\n #ifdef ADD_HELPERS\n vec2 imageHelperBox = uv;\n imageHelperBox *= imageBoxScale;\n imageHelperBox += boxOrigin * (imageBoxScale - 1.);\n #endif\n\n v_imageUV = uv;\n v_imageUV *= imageBoxScale;\n v_imageUV += boxOrigin * (imageBoxScale - 1.);\n v_imageUV += graphicOffset;\n v_imageUV /= u_scale;\n v_imageUV.x *= u_imageAspectRatio;\n v_imageUV = graphicRotation * v_imageUV;\n v_imageUV.x /= u_imageAspectRatio;\n\n v_imageUV += .5;\n v_imageUV.y = 1. - v_imageUV.y;\n\n // ===================================================\n\n}`;\n"],
5
+ "mappings": ";;;;;AAEO,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@paper-design/shaders",
3
+ "version": "0.0.0-canary.390a3d9",
4
+ "license": "SEE LICENSE IN https://github.com/paper-design/shaders/blob/main/LICENSE",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "module": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "type-check": "tsc --project tsconfig.json"
25
+ },
26
+ "dependencies": {}
27
+ }