@luma.gl/shadertools 8.5.13 → 8.5.16
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/dist/dist.min.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/index.js +10 -10
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/assemble-shaders.js +6 -2
- package/dist/es5/lib/assemble-shaders.js.map +1 -1
- package/dist/es5/lib/constants.js +1 -1
- package/dist/es5/lib/constants.js.map +1 -1
- package/dist/es5/lib/filters/prop-types.js.map +1 -1
- package/dist/es5/lib/inject-shader.js +2 -2
- package/dist/es5/lib/inject-shader.js.map +1 -1
- package/dist/es5/lib/platform-defines.js.map +1 -1
- package/dist/es5/lib/resolve-modules.js +2 -2
- package/dist/es5/lib/resolve-modules.js.map +1 -1
- package/dist/es5/lib/shader-module.js +1 -1
- package/dist/es5/lib/shader-module.js.map +1 -1
- package/dist/es5/lib/transpile-shader.js +1 -1
- package/dist/es5/lib/transpile-shader.js.map +1 -1
- package/dist/es5/modules/dirlight/dirlight.js.map +1 -1
- package/dist/es5/modules/fp32/fp32.js.map +1 -1
- package/dist/es5/modules/fp64/fp64-arithmetic.glsl.js.map +1 -1
- package/dist/es5/modules/fp64/fp64-functions.glsl.js.map +1 -1
- package/dist/es5/modules/fp64/fp64-utils.js +1 -1
- package/dist/es5/modules/fp64/fp64-utils.js.map +1 -1
- package/dist/es5/modules/fp64/fp64.js +6 -5
- package/dist/es5/modules/fp64/fp64.js.map +1 -1
- package/dist/es5/modules/fxaa/fxaa.js.map +1 -1
- package/dist/es5/modules/geometry/geometry.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/denoise.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/noise.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/sepia.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/vignette.js.map +1 -1
- package/dist/es5/modules/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/es5/modules/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/es5/modules/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/dotscreen.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/edgework.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/ink.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/magnify.js.map +1 -1
- package/dist/es5/modules/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/es5/modules/image-warp-filters/swirl.js.map +1 -1
- package/dist/es5/modules/image-warp-filters/warp.js.map +1 -1
- package/dist/es5/modules/index.js +62 -62
- package/dist/es5/modules/index.js.map +1 -1
- package/dist/es5/modules/lights/lights.glsl.js.map +1 -1
- package/dist/es5/modules/lights/lights.js +1 -1
- package/dist/es5/modules/lights/lights.js.map +1 -1
- package/dist/es5/modules/module-injectors.js +1 -1
- package/dist/es5/modules/module-injectors.js.map +1 -1
- package/dist/es5/modules/pbr/pbr-fragment.glsl.js.map +1 -1
- package/dist/es5/modules/pbr/pbr-vertex.glsl.js.map +1 -1
- package/dist/es5/modules/pbr/pbr.js.map +1 -1
- package/dist/es5/modules/phong-lighting/phong-lighting.glsl.js.map +1 -1
- package/dist/es5/modules/phong-lighting/phong-lighting.js.map +1 -1
- package/dist/es5/modules/picking/picking.js.map +1 -1
- package/dist/es5/modules/project/project.js.map +1 -1
- package/dist/es5/modules/transform/transform.js.map +1 -1
- package/dist/es5/modules/utils/random.js.map +1 -1
- package/dist/es5/utils/assert.js.map +1 -1
- package/dist/es5/utils/index.js.map +1 -1
- package/dist/es5/utils/is-old-ie.js.map +1 -1
- package/dist/es5/utils/shader-utils.js +3 -3
- package/dist/es5/utils/shader-utils.js.map +1 -1
- package/dist/es5/utils/webgl-info.js +2 -2
- package/dist/es5/utils/webgl-info.js.map +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/assemble-shaders.js +38 -51
- package/dist/esm/lib/assemble-shaders.js.map +1 -1
- package/dist/esm/lib/constants.js.map +1 -1
- package/dist/esm/lib/filters/prop-types.js.map +1 -1
- package/dist/esm/lib/inject-shader.js +4 -3
- package/dist/esm/lib/inject-shader.js.map +1 -1
- package/dist/esm/lib/platform-defines.js +9 -80
- package/dist/esm/lib/platform-defines.js.map +1 -1
- package/dist/esm/lib/resolve-modules.js +9 -7
- package/dist/esm/lib/resolve-modules.js.map +1 -1
- package/dist/esm/lib/shader-module.js +20 -23
- package/dist/esm/lib/shader-module.js.map +1 -1
- package/dist/esm/lib/transpile-shader.js +5 -5
- package/dist/esm/lib/transpile-shader.js.map +1 -1
- package/dist/esm/modules/dirlight/dirlight.js +3 -9
- package/dist/esm/modules/dirlight/dirlight.js.map +1 -1
- package/dist/esm/modules/fp32/fp32.js +1 -148
- package/dist/esm/modules/fp32/fp32.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-arithmetic.glsl.js +1 -143
- package/dist/esm/modules/fp64/fp64-arithmetic.glsl.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-functions.glsl.js +1 -630
- package/dist/esm/modules/fp64/fp64-functions.glsl.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-utils.js +3 -1
- package/dist/esm/modules/fp64/fp64-utils.js.map +1 -1
- package/dist/esm/modules/fp64/fp64.js.map +1 -1
- package/dist/esm/modules/fxaa/fxaa.js +1 -535
- package/dist/esm/modules/fxaa/fxaa.js.map +1 -1
- package/dist/esm/modules/geometry/geometry.js +2 -28
- package/dist/esm/modules/geometry/geometry.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/brightnesscontrast.js +1 -18
- package/dist/esm/modules/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/denoise.js +1 -22
- package/dist/esm/modules/image-adjust-filters/denoise.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/huesaturation.js +1 -28
- package/dist/esm/modules/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/noise.js +1 -19
- package/dist/esm/modules/image-adjust-filters/noise.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/sepia.js +1 -20
- package/dist/esm/modules/image-adjust-filters/sepia.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/vibrance.js +1 -15
- package/dist/esm/modules/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/vignette.js +1 -14
- package/dist/esm/modules/image-adjust-filters/vignette.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/tiltshift.js +1 -37
- package/dist/esm/modules/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/triangleblur.js +1 -27
- package/dist/esm/modules/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/zoomblur.js +1 -26
- package/dist/esm/modules/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/colorhalftone.js +1 -34
- package/dist/esm/modules/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/dotscreen.js +1 -22
- package/dist/esm/modules/image-fun-filters/dotscreen.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/edgework.js +1 -50
- package/dist/esm/modules/image-fun-filters/edgework.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/hexagonalpixelate.js +1 -42
- package/dist/esm/modules/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/ink.js +1 -27
- package/dist/esm/modules/image-fun-filters/ink.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/magnify.js +1 -20
- package/dist/esm/modules/image-fun-filters/magnify.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/bulgepinch.js +1 -27
- package/dist/esm/modules/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/swirl.js +1 -29
- package/dist/esm/modules/image-warp-filters/swirl.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/warp.js +1 -11
- package/dist/esm/modules/image-warp-filters/warp.js.map +1 -1
- package/dist/esm/modules/index.js.map +1 -1
- package/dist/esm/modules/lights/lights.glsl.js +1 -34
- package/dist/esm/modules/lights/lights.glsl.js.map +1 -1
- package/dist/esm/modules/lights/lights.js +19 -15
- package/dist/esm/modules/lights/lights.js.map +1 -1
- package/dist/esm/modules/module-injectors.js +2 -27
- package/dist/esm/modules/module-injectors.js.map +1 -1
- package/dist/esm/modules/pbr/pbr-fragment.glsl.js +1 -351
- package/dist/esm/modules/pbr/pbr-fragment.glsl.js.map +1 -1
- package/dist/esm/modules/pbr/pbr-vertex.glsl.js +1 -39
- package/dist/esm/modules/pbr/pbr-vertex.glsl.js.map +1 -1
- package/dist/esm/modules/pbr/pbr.js.map +1 -1
- package/dist/esm/modules/phong-lighting/phong-lighting.glsl.js +1 -75
- package/dist/esm/modules/phong-lighting/phong-lighting.glsl.js.map +1 -1
- package/dist/esm/modules/phong-lighting/phong-lighting.js +3 -1
- package/dist/esm/modules/phong-lighting/phong-lighting.js.map +1 -1
- package/dist/esm/modules/picking/picking.js +4 -87
- package/dist/esm/modules/picking/picking.js.map +1 -1
- package/dist/esm/modules/project/project.js +6 -69
- package/dist/esm/modules/project/project.js.map +1 -1
- package/dist/esm/modules/transform/transform.js +1 -28
- package/dist/esm/modules/transform/transform.js.map +1 -1
- package/dist/esm/modules/utils/random.js +1 -5
- package/dist/esm/modules/utils/random.js.map +1 -1
- package/dist/esm/utils/assert.js.map +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/is-old-ie.js +2 -1
- package/dist/esm/utils/is-old-ie.js.map +1 -1
- package/dist/esm/utils/shader-utils.js +11 -24
- package/dist/esm/utils/shader-utils.js.map +1 -1
- package/dist/esm/utils/webgl-info.js +3 -2
- package/dist/esm/utils/webgl-info.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"zoomblur.js","names":["random","fs","uniforms","center","strength","value","min","softMax","zoomBlur","name","dependencies","passes","sampler"],"sources":["../../../../src/modules/image-blur-filters/zoomblur.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\nimport {random} from '../utils/random';\n\nconst fs = `\nuniform vec2 center;\nuniform float strength;\n\nvec4 zoomBlur_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n vec2 toCenter = center * texSize - texCoord * texSize;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = 0.0; t <= 40.0; t++) {\n float percent = (t + offset) / 40.0;\n float weight = 4.0 * (percent - percent * percent);\n vec4 sample = texture2D(texture, texCoord + toCenter * percent * strength / texSize);\n\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n }\n\n color = color / total;\n\n /* switch back from pre-multiplied alpha */\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n`;\n\nconst uniforms = {\n center: [0.5, 0.5],\n strength: {value: 0.3, min: 0, softMax: 1}\n};\n\n/** @type {ShaderPass} */\nexport const zoomBlur = {\n name: 'zoomBlur',\n uniforms,\n fs,\n dependencies: [random],\n passes: [{sampler: true}]\n};\n"],"mappings":"AACA,SAAQA,MAAR,QAAqB,iBAArB;AAEA,MAAMC,EAAE,usBAAR;AAiCA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE,CAAC,GAAD,EAAM,GAAN,CADO;EAEfC,QAAQ,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,OAAO,EAAE;EAA9B;AAFK,CAAjB;AAMA,OAAO,MAAMC,QAAQ,GAAG;EACtBC,IAAI,EAAE,UADgB;EAEtBP,QAFsB;EAGtBD,EAHsB;EAItBS,YAAY,EAAE,CAACV,MAAD,CAJQ;EAKtBW,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AALc,CAAjB"}
|
|
@@ -1,37 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform vec2 center;
|
|
3
|
-
uniform float angle;
|
|
4
|
-
uniform float size;
|
|
5
|
-
|
|
6
|
-
float scale = 3.1514 / size;
|
|
7
|
-
|
|
8
|
-
float pattern(float angle, vec2 texSize, vec2 texCoord) {
|
|
9
|
-
float s = sin(angle), c = cos(angle);
|
|
10
|
-
vec2 tex = texCoord * texSize - center * texSize;
|
|
11
|
-
vec2 point = vec2(
|
|
12
|
-
c * tex.x - s * tex.y,
|
|
13
|
-
s * tex.x + c * tex.y
|
|
14
|
-
) * scale;
|
|
15
|
-
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
19
|
-
vec3 cmy = 1.0 - color.rgb;
|
|
20
|
-
float k = min(cmy.x, min(cmy.y, cmy.z));
|
|
21
|
-
cmy = (cmy - k) / (1.0 - k);
|
|
22
|
-
cmy = clamp(
|
|
23
|
-
cmy * 10.0 - 3.0 + vec3(
|
|
24
|
-
pattern(angle + 0.26179, texSize, texCoord),
|
|
25
|
-
pattern(angle + 1.30899, texSize, texCoord),
|
|
26
|
-
pattern(angle, texSize, texCoord)
|
|
27
|
-
),
|
|
28
|
-
0.0,
|
|
29
|
-
1.0
|
|
30
|
-
);
|
|
31
|
-
k = clamp(k * 10.0 - 5.0 + pattern(angle + 0.78539, texSize, texCoord), 0.0, 1.0);
|
|
32
|
-
return vec4(1.0 - cmy - k, color.a);
|
|
33
|
-
}
|
|
34
|
-
`;
|
|
1
|
+
const fs = "uniform vec2 center;\nuniform float angle;\nuniform float size;\n\nfloat scale = 3.1514 / size;\n\nfloat pattern(float angle, vec2 texSize, vec2 texCoord) {\n float s = sin(angle), c = cos(angle);\n vec2 tex = texCoord * texSize - center * texSize;\n vec2 point = vec2(\n\tc * tex.x - s * tex.y,\n\ts * tex.x + c * tex.y\n ) * scale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n}\n\nvec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n vec3 cmy = 1.0 - color.rgb;\n float k = min(cmy.x, min(cmy.y, cmy.z));\n cmy = (cmy - k) / (1.0 - k);\n cmy = clamp(\n\tcmy * 10.0 - 3.0 + vec3(\n pattern(angle + 0.26179, texSize, texCoord),\n\t pattern(angle + 1.30899, texSize, texCoord),\n pattern(angle, texSize, texCoord)\n ),\n\t0.0,\n\t1.0\n );\n k = clamp(k * 10.0 - 5.0 + pattern(angle + 0.78539, texSize, texCoord), 0.0, 1.0);\n return vec4(1.0 - cmy - k, color.a);\n}\n";
|
|
35
2
|
const uniforms = {
|
|
36
3
|
center: [0.5, 0.5],
|
|
37
4
|
angle: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"colorhalftone.js","names":["fs","uniforms","center","angle","value","softMin","softMax","Math","PI","size","min","colorHalftone","name","passes","filter"],"sources":["../../../../src/modules/image-fun-filters/colorhalftone.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\n// TODO pass texCoord to angle\nconst fs = `\\\nuniform vec2 center;\nuniform float angle;\nuniform float size;\n\nfloat scale = 3.1514 / size;\n\nfloat pattern(float angle, vec2 texSize, vec2 texCoord) {\n float s = sin(angle), c = cos(angle);\n vec2 tex = texCoord * texSize - center * texSize;\n vec2 point = vec2(\n\tc * tex.x - s * tex.y,\n\ts * tex.x + c * tex.y\n ) * scale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n}\n\nvec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n vec3 cmy = 1.0 - color.rgb;\n float k = min(cmy.x, min(cmy.y, cmy.z));\n cmy = (cmy - k) / (1.0 - k);\n cmy = clamp(\n\tcmy * 10.0 - 3.0 + vec3(\n pattern(angle + 0.26179, texSize, texCoord),\n\t pattern(angle + 1.30899, texSize, texCoord),\n pattern(angle, texSize, texCoord)\n ),\n\t0.0,\n\t1.0\n );\n k = clamp(k * 10.0 - 5.0 + pattern(angle + 0.78539, texSize, texCoord), 0.0, 1.0);\n return vec4(1.0 - cmy - k, color.a);\n}\n`;\n\nconst uniforms = {\n center: [0.5, 0.5],\n angle: {value: 1.1, softMin: 0, softMax: Math.PI / 2},\n size: {value: 4, min: 1, softMin: 3, softMax: 20}\n};\n\n/** @type {ShaderPass} */\nexport const colorHalftone = {\n name: 'colorHalftone',\n uniforms,\n fs,\n passes: [{filter: true}]\n};\n"],"mappings":"AAGA,MAAMA,EAAE,q5BAAR;AAmCA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE,CAAC,GAAD,EAAM,GAAN,CADO;EAEfC,KAAK,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,OAAO,EAAE,CAAtB;IAAyBC,OAAO,EAAEC,IAAI,CAACC,EAAL,GAAU;EAA5C,CAFQ;EAGfC,IAAI,EAAE;IAACL,KAAK,EAAE,CAAR;IAAWM,GAAG,EAAE,CAAhB;IAAmBL,OAAO,EAAE,CAA5B;IAA+BC,OAAO,EAAE;EAAxC;AAHS,CAAjB;AAOA,OAAO,MAAMK,aAAa,GAAG;EAC3BC,IAAI,EAAE,eADqB;EAE3BX,QAF2B;EAG3BD,EAH2B;EAI3Ba,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJmB,CAAtB"}
|
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform vec2 center;
|
|
3
|
-
uniform float angle;
|
|
4
|
-
uniform float size;
|
|
5
|
-
|
|
6
|
-
float pattern(vec2 texSize, vec2 texCoord) {
|
|
7
|
-
float scale = 3.1415 / size;
|
|
8
|
-
|
|
9
|
-
float s = sin(angle), c = cos(angle);
|
|
10
|
-
vec2 tex = texCoord * texSize - center * texSize;
|
|
11
|
-
vec2 point = vec2(
|
|
12
|
-
c * tex.x - s * tex.y,
|
|
13
|
-
s * tex.x + c * tex.y
|
|
14
|
-
) * scale;
|
|
15
|
-
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
19
|
-
float average = (color.r + color.g + color.b) / 3.0;
|
|
20
|
-
return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
1
|
+
const fs = "uniform vec2 center;\nuniform float angle;\nuniform float size;\n\nfloat pattern(vec2 texSize, vec2 texCoord) {\n float scale = 3.1415 / size;\n\n float s = sin(angle), c = cos(angle);\n vec2 tex = texCoord * texSize - center * texSize;\n vec2 point = vec2(\n c * tex.x - s * tex.y,\n s * tex.x + c * tex.y\n ) * scale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n}\n\nvec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n float average = (color.r + color.g + color.b) / 3.0;\n return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);\n}\n";
|
|
23
2
|
const uniforms = {
|
|
24
3
|
center: [0.5, 0.5],
|
|
25
4
|
angle: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"dotscreen.js","names":["fs","uniforms","center","angle","value","softMin","softMax","Math","PI","size","min","dotScreen","name","passes","filter"],"sources":["../../../../src/modules/image-fun-filters/dotscreen.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nconst fs = `\\\nuniform vec2 center;\nuniform float angle;\nuniform float size;\n\nfloat pattern(vec2 texSize, vec2 texCoord) {\n float scale = 3.1415 / size;\n\n float s = sin(angle), c = cos(angle);\n vec2 tex = texCoord * texSize - center * texSize;\n vec2 point = vec2(\n c * tex.x - s * tex.y,\n s * tex.x + c * tex.y\n ) * scale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n}\n\nvec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n float average = (color.r + color.g + color.b) / 3.0;\n return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);\n}\n`;\n\nconst uniforms = {\n center: [0.5, 0.5],\n angle: {value: 1.1, softMin: 0, softMax: Math.PI / 2},\n size: {value: 3, min: 1, softMin: 3, softMax: 20}\n};\n\n/** @type {ShaderPass} */\nexport const dotScreen = {\n name: 'dotScreen',\n uniforms,\n fs,\n passes: [{filter: true}]\n};\n"],"mappings":"AAEA,MAAMA,EAAE,ylBAAR;AAuBA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE,CAAC,GAAD,EAAM,GAAN,CADO;EAEfC,KAAK,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,OAAO,EAAE,CAAtB;IAAyBC,OAAO,EAAEC,IAAI,CAACC,EAAL,GAAU;EAA5C,CAFQ;EAGfC,IAAI,EAAE;IAACL,KAAK,EAAE,CAAR;IAAWM,GAAG,EAAE,CAAhB;IAAmBL,OAAO,EAAE,CAA5B;IAA+BC,OAAO,EAAE;EAAxC;AAHS,CAAjB;AAOA,OAAO,MAAMK,SAAS,GAAG;EACvBC,IAAI,EAAE,WADiB;EAEvBX,QAFuB;EAGvBD,EAHuB;EAIvBa,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJe,CAAlB"}
|
|
@@ -1,54 +1,5 @@
|
|
|
1
1
|
import { random } from '../utils/random';
|
|
2
|
-
const fs =
|
|
3
|
-
uniform float radius;
|
|
4
|
-
uniform vec2 delta;
|
|
5
|
-
|
|
6
|
-
vec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
7
|
-
vec2 relativeDelta = radius * delta / texSize;
|
|
8
|
-
|
|
9
|
-
vec2 color = vec2(0.0);
|
|
10
|
-
vec2 total = vec2(0.0);
|
|
11
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
12
|
-
|
|
13
|
-
for (float t = -30.0; t <= 30.0; t++) {
|
|
14
|
-
float percent = (t + offset - 0.5) / 30.0;
|
|
15
|
-
float weight = 1.0 - abs(percent);
|
|
16
|
-
vec3 sampleColor = texture2D(source, texCoord + relativeDelta * percent).rgb;
|
|
17
|
-
float average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;
|
|
18
|
-
color.x += average * weight;
|
|
19
|
-
total.x += weight;
|
|
20
|
-
if (abs(t) < 15.0) {
|
|
21
|
-
weight = weight * 2.0 - 1.0;
|
|
22
|
-
color.y += average * weight;
|
|
23
|
-
total.y += weight;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return vec4(color / total, 0.0, 1.0);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
30
|
-
vec2 relativeDelta = radius * delta / texSize;
|
|
31
|
-
|
|
32
|
-
vec2 color = vec2(0.0);
|
|
33
|
-
vec2 total = vec2(0.0);
|
|
34
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
35
|
-
|
|
36
|
-
for (float t = -30.0; t <= 30.0; t++) {
|
|
37
|
-
float percent = (t + offset - 0.5) / 30.0;
|
|
38
|
-
float weight = 1.0 - abs(percent);
|
|
39
|
-
vec2 sampleColor = texture2D(source, texCoord + relativeDelta * percent).xy;
|
|
40
|
-
color.x += sampleColor.x * weight;
|
|
41
|
-
total.x += weight;
|
|
42
|
-
if (abs(t) < 15.0) {
|
|
43
|
-
weight = weight * 2.0 - 1.0;
|
|
44
|
-
color.y += sampleColor.y * weight;
|
|
45
|
-
total.y += weight;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
|
|
49
|
-
return vec4(c, c, c, 1.0);
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
2
|
+
const fs = "uniform float radius;\nuniform vec2 delta;\n\nvec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 relativeDelta = radius * delta / texSize;\n\n vec2 color = vec2(0.0);\n vec2 total = vec2(0.0);\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec3 sampleColor = texture2D(source, texCoord + relativeDelta * percent).rgb;\n float average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;\n color.x += average * weight;\n total.x += weight;\n if (abs(t) < 15.0) {\n weight = weight * 2.0 - 1.0;\n color.y += average * weight;\n total.y += weight;\n }\n }\n return vec4(color / total, 0.0, 1.0);\n}\n\nvec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 relativeDelta = radius * delta / texSize;\n\n vec2 color = vec2(0.0);\n vec2 total = vec2(0.0);\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec2 sampleColor = texture2D(source, texCoord + relativeDelta * percent).xy;\n color.x += sampleColor.x * weight;\n total.x += weight;\n if (abs(t) < 15.0) {\n weight = weight * 2.0 - 1.0;\n color.y += sampleColor.y * weight;\n total.y += weight;\n }\n }\n float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);\n return vec4(c, c, c, 1.0);\n}\n";
|
|
52
3
|
const uniforms = {
|
|
53
4
|
radius: {
|
|
54
5
|
value: 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"edgework.js","names":["random","fs","uniforms","radius","value","min","softMax","delta","private","edgeWork","name","dependencies","passes","sampler"],"sources":["../../../../src/modules/image-fun-filters/edgework.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nimport {random} from '../utils/random';\n\nconst fs = `\\\nuniform float radius;\nuniform vec2 delta;\n\nvec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 relativeDelta = radius * delta / texSize;\n\n vec2 color = vec2(0.0);\n vec2 total = vec2(0.0);\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec3 sampleColor = texture2D(source, texCoord + relativeDelta * percent).rgb;\n float average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;\n color.x += average * weight;\n total.x += weight;\n if (abs(t) < 15.0) {\n weight = weight * 2.0 - 1.0;\n color.y += average * weight;\n total.y += weight;\n }\n }\n return vec4(color / total, 0.0, 1.0);\n}\n\nvec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 relativeDelta = radius * delta / texSize;\n\n vec2 color = vec2(0.0);\n vec2 total = vec2(0.0);\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec2 sampleColor = texture2D(source, texCoord + relativeDelta * percent).xy;\n color.x += sampleColor.x * weight;\n total.x += weight;\n if (abs(t) < 15.0) {\n weight = weight * 2.0 - 1.0;\n color.y += sampleColor.y * weight;\n total.y += weight;\n }\n }\n float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);\n return vec4(c, c, c, 1.0);\n}\n`;\n\nconst uniforms = {\n radius: {value: 2, min: 1, softMax: 50},\n delta: {value: [1, 0], private: true}\n};\n\n/** @type {ShaderPass} */\nexport const edgeWork = {\n name: 'edgeWork',\n uniforms,\n fs,\n dependencies: [random],\n passes: [\n {\n sampler: 'edgeWork_sampleColor1',\n uniforms: {delta: [1, 0]}\n },\n {\n sampler: 'edgeWork_sampleColor2',\n uniforms: {delta: [0, 1]}\n }\n ]\n};\n"],"mappings":"AAEA,SAAQA,MAAR,QAAqB,iBAArB;AAEA,MAAMC,EAAE,klDAAR;AAuDA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE;IAACC,KAAK,EAAE,CAAR;IAAWC,GAAG,EAAE,CAAhB;IAAmBC,OAAO,EAAE;EAA5B,CADO;EAEfC,KAAK,EAAE;IAACH,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ,CAAR;IAAgBI,OAAO,EAAE;EAAzB;AAFQ,CAAjB;AAMA,OAAO,MAAMC,QAAQ,GAAG;EACtBC,IAAI,EAAE,UADgB;EAEtBR,QAFsB;EAGtBD,EAHsB;EAItBU,YAAY,EAAE,CAACX,MAAD,CAJQ;EAKtBY,MAAM,EAAE,CACN;IACEC,OAAO,EAAE,uBADX;IAEEX,QAAQ,EAAE;MAACK,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;IAAR;EAFZ,CADM,EAKN;IACEM,OAAO,EAAE,uBADX;IAEEX,QAAQ,EAAE;MAACK,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;IAAR;EAFZ,CALM;AALc,CAAjB"}
|
|
@@ -1,45 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform vec2 center;
|
|
3
|
-
uniform float scale;
|
|
4
|
-
|
|
5
|
-
vec4 hexagonalPixelate_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
|
|
6
|
-
vec2 tex = (texCoord * texSize - center * texSize) / scale;
|
|
7
|
-
tex.y /= 0.866025404;
|
|
8
|
-
tex.x -= tex.y * 0.5;
|
|
9
|
-
|
|
10
|
-
vec2 a;
|
|
11
|
-
if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {
|
|
12
|
-
a = vec2(floor(tex.x), floor(tex.y));
|
|
13
|
-
}
|
|
14
|
-
else a = vec2(ceil(tex.x), ceil(tex.y));
|
|
15
|
-
vec2 b = vec2(ceil(tex.x), floor(tex.y));
|
|
16
|
-
vec2 c = vec2(floor(tex.x), ceil(tex.y));
|
|
17
|
-
|
|
18
|
-
vec3 TEX = vec3(tex.x, tex.y, 1.0 - tex.x - tex.y);
|
|
19
|
-
vec3 A = vec3(a.x, a.y, 1.0 - a.x - a.y);
|
|
20
|
-
vec3 B = vec3(b.x, b.y, 1.0 - b.x - b.y);
|
|
21
|
-
vec3 C = vec3(c.x, c.y, 1.0 - c.x - c.y);
|
|
22
|
-
|
|
23
|
-
float alen = length(TEX - A);
|
|
24
|
-
float blen = length(TEX - B);
|
|
25
|
-
float clen = length(TEX - C);
|
|
26
|
-
|
|
27
|
-
vec2 choice;
|
|
28
|
-
if (alen < blen) {
|
|
29
|
-
if (alen < clen) choice = a;
|
|
30
|
-
else choice = c;
|
|
31
|
-
} else {
|
|
32
|
-
if (blen < clen) choice = b;
|
|
33
|
-
else choice = c;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
choice.x += choice.y * 0.5;
|
|
37
|
-
choice.y *= 0.866025404;
|
|
38
|
-
choice *= scale / texSize;
|
|
39
|
-
|
|
40
|
-
return texture2D(texture, choice + center);
|
|
41
|
-
}
|
|
42
|
-
`;
|
|
1
|
+
const fs = "uniform vec2 center;\nuniform float scale;\n\nvec4 hexagonalPixelate_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 tex = (texCoord * texSize - center * texSize) / scale;\n tex.y /= 0.866025404;\n tex.x -= tex.y * 0.5;\n\n vec2 a;\n if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {\n a = vec2(floor(tex.x), floor(tex.y));\n }\n else a = vec2(ceil(tex.x), ceil(tex.y));\n vec2 b = vec2(ceil(tex.x), floor(tex.y));\n vec2 c = vec2(floor(tex.x), ceil(tex.y));\n\n vec3 TEX = vec3(tex.x, tex.y, 1.0 - tex.x - tex.y);\n vec3 A = vec3(a.x, a.y, 1.0 - a.x - a.y);\n vec3 B = vec3(b.x, b.y, 1.0 - b.x - b.y);\n vec3 C = vec3(c.x, c.y, 1.0 - c.x - c.y);\n\n float alen = length(TEX - A);\n float blen = length(TEX - B);\n float clen = length(TEX - C);\n\n vec2 choice;\n if (alen < blen) {\n if (alen < clen) choice = a;\n else choice = c;\n } else {\n if (blen < clen) choice = b;\n else choice = c;\n }\n\n choice.x += choice.y * 0.5;\n choice.y *= 0.866025404;\n choice *= scale / texSize;\n\n return texture2D(texture, choice + center);\n}\n";
|
|
43
2
|
const uniforms = {
|
|
44
3
|
center: {
|
|
45
4
|
value: [0.5, 0.5],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"hexagonalpixelate.js","names":["fs","uniforms","center","value","hint","scale","min","softMin","softMax","hexagonalPixelate","name","passes","sampler"],"sources":["../../../../src/modules/image-fun-filters/hexagonalpixelate.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nconst fs = `\\\nuniform vec2 center;\nuniform float scale;\n\nvec4 hexagonalPixelate_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 tex = (texCoord * texSize - center * texSize) / scale;\n tex.y /= 0.866025404;\n tex.x -= tex.y * 0.5;\n\n vec2 a;\n if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {\n a = vec2(floor(tex.x), floor(tex.y));\n }\n else a = vec2(ceil(tex.x), ceil(tex.y));\n vec2 b = vec2(ceil(tex.x), floor(tex.y));\n vec2 c = vec2(floor(tex.x), ceil(tex.y));\n\n vec3 TEX = vec3(tex.x, tex.y, 1.0 - tex.x - tex.y);\n vec3 A = vec3(a.x, a.y, 1.0 - a.x - a.y);\n vec3 B = vec3(b.x, b.y, 1.0 - b.x - b.y);\n vec3 C = vec3(c.x, c.y, 1.0 - c.x - c.y);\n\n float alen = length(TEX - A);\n float blen = length(TEX - B);\n float clen = length(TEX - C);\n\n vec2 choice;\n if (alen < blen) {\n if (alen < clen) choice = a;\n else choice = c;\n } else {\n if (blen < clen) choice = b;\n else choice = c;\n }\n\n choice.x += choice.y * 0.5;\n choice.y *= 0.866025404;\n choice *= scale / texSize;\n\n return texture2D(texture, choice + center);\n}\n`;\n\nconst uniforms = {\n center: {value: [0.5, 0.5], hint: 'screenspace'},\n scale: {value: 10, min: 1, softMin: 5, softMax: 50}\n};\n\n/** @type {ShaderPass} */\nexport const hexagonalPixelate = {\n name: 'hexagonalPixelate',\n uniforms,\n fs,\n passes: [{sampler: true}]\n};\n"],"mappings":"AAEA,MAAMA,EAAE,slCAAR;AA2CA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE;IAACC,KAAK,EAAE,CAAC,GAAD,EAAM,GAAN,CAAR;IAAoBC,IAAI,EAAE;EAA1B,CADO;EAEfC,KAAK,EAAE;IAACF,KAAK,EAAE,EAAR;IAAYG,GAAG,EAAE,CAAjB;IAAoBC,OAAO,EAAE,CAA7B;IAAgCC,OAAO,EAAE;EAAzC;AAFQ,CAAjB;AAMA,OAAO,MAAMC,iBAAiB,GAAG;EAC/BC,IAAI,EAAE,mBADyB;EAE/BT,QAF+B;EAG/BD,EAH+B;EAI/BW,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AAJuB,CAA1B"}
|
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform float strength;
|
|
3
|
-
|
|
4
|
-
vec4 ink_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
|
|
5
|
-
vec2 dx = vec2(1.0 / texSize.x, 0.0);
|
|
6
|
-
vec2 dy = vec2(0.0, 1.0 / texSize.y);
|
|
7
|
-
vec4 color = texture2D(texture, texCoord);
|
|
8
|
-
float bigTotal = 0.0;
|
|
9
|
-
float smallTotal = 0.0;
|
|
10
|
-
vec3 bigAverage = vec3(0.0);
|
|
11
|
-
vec3 smallAverage = vec3(0.0);
|
|
12
|
-
for (float x = -2.0; x <= 2.0; x += 1.0) {
|
|
13
|
-
for (float y = -2.0; y <= 2.0; y += 1.0) {
|
|
14
|
-
vec3 sample = texture2D(texture, texCoord + dx * x + dy * y).rgb;
|
|
15
|
-
bigAverage += sample;
|
|
16
|
-
bigTotal += 1.0;
|
|
17
|
-
if (abs(x) + abs(y) < 2.0) {
|
|
18
|
-
smallAverage += sample;
|
|
19
|
-
smallTotal += 1.0;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
|
|
24
|
-
float power = strength * strength * strength * strength * strength;
|
|
25
|
-
return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
1
|
+
const fs = "uniform float strength;\n\nvec4 ink_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 dx = vec2(1.0 / texSize.x, 0.0);\n vec2 dy = vec2(0.0, 1.0 / texSize.y);\n vec4 color = texture2D(texture, texCoord);\n float bigTotal = 0.0;\n float smallTotal = 0.0;\n vec3 bigAverage = vec3(0.0);\n vec3 smallAverage = vec3(0.0);\n for (float x = -2.0; x <= 2.0; x += 1.0) {\n for (float y = -2.0; y <= 2.0; y += 1.0) {\n vec3 sample = texture2D(texture, texCoord + dx * x + dy * y).rgb;\n bigAverage += sample;\n bigTotal += 1.0;\n if (abs(x) + abs(y) < 2.0) {\n smallAverage += sample;\n smallTotal += 1.0;\n }\n }\n }\n vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);\n float power = strength * strength * strength * strength * strength;\n return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);\n}\n";
|
|
28
2
|
const uniforms = {
|
|
29
3
|
strength: {
|
|
30
4
|
value: 0.25,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ink.js","names":["fs","uniforms","strength","value","min","softMax","ink","name","passes","sampler"],"sources":["../../../../src/modules/image-fun-filters/ink.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nconst fs = `\\\nuniform float strength;\n\nvec4 ink_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 dx = vec2(1.0 / texSize.x, 0.0);\n vec2 dy = vec2(0.0, 1.0 / texSize.y);\n vec4 color = texture2D(texture, texCoord);\n float bigTotal = 0.0;\n float smallTotal = 0.0;\n vec3 bigAverage = vec3(0.0);\n vec3 smallAverage = vec3(0.0);\n for (float x = -2.0; x <= 2.0; x += 1.0) {\n for (float y = -2.0; y <= 2.0; y += 1.0) {\n vec3 sample = texture2D(texture, texCoord + dx * x + dy * y).rgb;\n bigAverage += sample;\n bigTotal += 1.0;\n if (abs(x) + abs(y) < 2.0) {\n smallAverage += sample;\n smallTotal += 1.0;\n }\n }\n }\n vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);\n float power = strength * strength * strength * strength * strength;\n return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);\n}\n`;\n\nconst uniforms = {\n strength: {value: 0.25, min: 0, softMax: 1}\n};\n\n/** @type {ShaderPass} */\nexport const ink = {\n name: 'ink',\n uniforms,\n fs,\n passes: [{sampler: true}]\n};\n"],"mappings":"AAEA,MAAMA,EAAE,q5BAAR;AA4BA,MAAMC,QAAQ,GAAG;EACfC,QAAQ,EAAE;IAACC,KAAK,EAAE,IAAR;IAAcC,GAAG,EAAE,CAAnB;IAAsBC,OAAO,EAAE;EAA/B;AADK,CAAjB;AAKA,OAAO,MAAMC,GAAG,GAAG;EACjBC,IAAI,EAAE,KADW;EAEjBN,QAFiB;EAGjBD,EAHiB;EAIjBQ,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AAJS,CAAZ"}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform vec2 screenXY;
|
|
3
|
-
uniform float radiusPixels;
|
|
4
|
-
uniform float zoom;
|
|
5
|
-
uniform float borderWidthPixels;
|
|
6
|
-
uniform vec4 borderColor;
|
|
7
|
-
|
|
8
|
-
vec4 magnify_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
|
|
9
|
-
vec2 pos = vec2(screenXY.x, 1.0 - screenXY.y);
|
|
10
|
-
float dist = distance(texCoord * texSize, pos * texSize);
|
|
11
|
-
if (dist < radiusPixels) {
|
|
12
|
-
return texture2D(texture, (texCoord - pos) / zoom + pos);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (dist <= radiusPixels + borderWidthPixels) {
|
|
16
|
-
return borderColor;
|
|
17
|
-
}
|
|
18
|
-
return texture2D(texture, texCoord);
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
1
|
+
const fs = "uniform vec2 screenXY;\nuniform float radiusPixels;\nuniform float zoom;\nuniform float borderWidthPixels;\nuniform vec4 borderColor;\n\nvec4 magnify_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 pos = vec2(screenXY.x, 1.0 - screenXY.y);\n float dist = distance(texCoord * texSize, pos * texSize);\n if (dist < radiusPixels) {\n return texture2D(texture, (texCoord - pos) / zoom + pos);\n }\n\n if (dist <= radiusPixels + borderWidthPixels) {\n return borderColor;\n }\n return texture2D(texture, texCoord);\n}\n";
|
|
21
2
|
const uniforms = {
|
|
22
3
|
screenXY: [0, 0],
|
|
23
4
|
radiusPixels: 200,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"magnify.js","names":["fs","uniforms","screenXY","radiusPixels","zoom","borderWidthPixels","borderColor","magnify","name","passes","sampler"],"sources":["../../../../src/modules/image-fun-filters/magnify.js"],"sourcesContent":["const fs = `\\\nuniform vec2 screenXY;\nuniform float radiusPixels;\nuniform float zoom;\nuniform float borderWidthPixels;\nuniform vec4 borderColor;\n\nvec4 magnify_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 pos = vec2(screenXY.x, 1.0 - screenXY.y);\n float dist = distance(texCoord * texSize, pos * texSize);\n if (dist < radiusPixels) {\n return texture2D(texture, (texCoord - pos) / zoom + pos);\n }\n\n if (dist <= radiusPixels + borderWidthPixels) {\n return borderColor;\n }\n return texture2D(texture, texCoord);\n}\n`;\n\nconst uniforms = {\n // range 0 to 1\n screenXY: [0, 0],\n radiusPixels: 200,\n zoom: 2.0,\n borderWidthPixels: 0.0,\n borderColor: [255, 255, 255, 255]\n};\n\nexport const magnify = {\n name: 'magnify',\n uniforms,\n fs,\n passes: [{sampler: true}]\n};\n"],"mappings":"AAAA,MAAMA,EAAE,yiBAAR;AAqBA,MAAMC,QAAQ,GAAG;EAEfC,QAAQ,EAAE,CAAC,CAAD,EAAI,CAAJ,CAFK;EAGfC,YAAY,EAAE,GAHC;EAIfC,IAAI,EAAE,GAJS;EAKfC,iBAAiB,EAAE,GALJ;EAMfC,WAAW,EAAE,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB;AANE,CAAjB;AASA,OAAO,MAAMC,OAAO,GAAG;EACrBC,IAAI,EAAE,SADe;EAErBP,QAFqB;EAGrBD,EAHqB;EAIrBS,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AAJa,CAAhB"}
|
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
import { warp } from './warp';
|
|
2
|
-
const fs =
|
|
3
|
-
uniform float radius;
|
|
4
|
-
uniform float strength;
|
|
5
|
-
uniform vec2 center;
|
|
6
|
-
|
|
7
|
-
vec2 bulgePinch_warp(vec2 coord, vec2 texCenter) {
|
|
8
|
-
coord -= texCenter;
|
|
9
|
-
float distance = length(coord);
|
|
10
|
-
if (distance < radius) {
|
|
11
|
-
float percent = distance / radius;
|
|
12
|
-
if (strength > 0.0) {
|
|
13
|
-
coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75);
|
|
14
|
-
} else {
|
|
15
|
-
coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
coord += texCenter;
|
|
19
|
-
return coord;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
vec4 bulgePinch_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
|
|
23
|
-
vec2 coord = texCoord * texSize;
|
|
24
|
-
coord = bulgePinch_warp(coord, center * texSize);
|
|
25
|
-
|
|
26
|
-
return warp_sampleColor(texture, texSize, coord);
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
2
|
+
const fs = "uniform float radius;\nuniform float strength;\nuniform vec2 center;\n\nvec2 bulgePinch_warp(vec2 coord, vec2 texCenter) {\n coord -= texCenter;\n float distance = length(coord);\n if (distance < radius) {\n float percent = distance / radius;\n if (strength > 0.0) {\n coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75);\n } else {\n coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent);\n }\n }\n coord += texCenter;\n return coord;\n}\n\nvec4 bulgePinch_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 coord = texCoord * texSize;\n coord = bulgePinch_warp(coord, center * texSize);\n\n return warp_sampleColor(texture, texSize, coord);\n}\n";
|
|
29
3
|
const uniforms = {
|
|
30
4
|
center: [0.5, 0.5],
|
|
31
5
|
radius: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"bulgepinch.js","names":["warp","fs","uniforms","center","radius","value","min","softMax","strength","max","bulgePinch","name","dependencies","passes","sampler"],"sources":["../../../../src/modules/image-warp-filters/bulgepinch.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nimport {warp} from './warp';\n\nconst fs = `\\\nuniform float radius;\nuniform float strength;\nuniform vec2 center;\n\nvec2 bulgePinch_warp(vec2 coord, vec2 texCenter) {\n coord -= texCenter;\n float distance = length(coord);\n if (distance < radius) {\n float percent = distance / radius;\n if (strength > 0.0) {\n coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75);\n } else {\n coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent);\n }\n }\n coord += texCenter;\n return coord;\n}\n\nvec4 bulgePinch_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 coord = texCoord * texSize;\n coord = bulgePinch_warp(coord, center * texSize);\n\n return warp_sampleColor(texture, texSize, coord);\n}\n`;\n\nconst uniforms = {\n center: [0.5, 0.5],\n radius: {value: 200, min: 1, softMax: 600},\n strength: {value: 0.5, min: -1, max: 1}\n};\n\n/** @type {ShaderPass} */\nexport const bulgePinch = {\n name: 'bulgePinch',\n fs,\n uniforms,\n dependencies: [warp],\n passes: [{sampler: true}]\n};\n"],"mappings":"AAEA,SAAQA,IAAR,QAAmB,QAAnB;AAEA,MAAMC,EAAE,6vBAAR;AA4BA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE,CAAC,GAAD,EAAM,GAAN,CADO;EAEfC,MAAM,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,OAAO,EAAE;EAA9B,CAFO;EAGfC,QAAQ,EAAE;IAACH,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAC,CAAnB;IAAsBG,GAAG,EAAE;EAA3B;AAHK,CAAjB;AAOA,OAAO,MAAMC,UAAU,GAAG;EACxBC,IAAI,EAAE,YADkB;EAExBV,EAFwB;EAGxBC,QAHwB;EAIxBU,YAAY,EAAE,CAACZ,IAAD,CAJU;EAKxBa,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AALgB,CAAnB"}
|
|
@@ -1,33 +1,5 @@
|
|
|
1
1
|
import { warp } from './warp';
|
|
2
|
-
const fs =
|
|
3
|
-
uniform float radius;
|
|
4
|
-
uniform float angle;
|
|
5
|
-
uniform vec2 center;
|
|
6
|
-
|
|
7
|
-
vec2 swirl_warp(vec2 coord, vec2 texCenter) {
|
|
8
|
-
coord -= texCenter;
|
|
9
|
-
float distance = length(coord);
|
|
10
|
-
if (distance < radius) {
|
|
11
|
-
float percent = (radius - distance) / radius;
|
|
12
|
-
float theta = percent * percent * angle;
|
|
13
|
-
float s = sin(theta);
|
|
14
|
-
float c = cos(theta);
|
|
15
|
-
coord = vec2(
|
|
16
|
-
coord.x * c - coord.y * s,
|
|
17
|
-
coord.x * s + coord.y * c
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
coord += texCenter;
|
|
21
|
-
return coord;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
vec4 swirl_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
|
|
25
|
-
vec2 coord = texCoord * texSize;
|
|
26
|
-
coord = swirl_warp(coord, center * texSize);
|
|
27
|
-
|
|
28
|
-
return warp_sampleColor(texture, texSize, coord);
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
2
|
+
const fs = "uniform float radius;\nuniform float angle;\nuniform vec2 center;\n\nvec2 swirl_warp(vec2 coord, vec2 texCenter) {\n coord -= texCenter;\n float distance = length(coord);\n if (distance < radius) {\n float percent = (radius - distance) / radius;\n float theta = percent * percent * angle;\n float s = sin(theta);\n float c = cos(theta);\n coord = vec2(\n coord.x * c - coord.y * s,\n coord.x * s + coord.y * c\n );\n }\n coord += texCenter;\n return coord;\n}\n\nvec4 swirl_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 coord = texCoord * texSize;\n coord = swirl_warp(coord, center * texSize);\n\n return warp_sampleColor(texture, texSize, coord);\n}\n";
|
|
31
3
|
const uniforms = {
|
|
32
4
|
center: [0.5, 0.5],
|
|
33
5
|
radius: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"swirl.js","names":["warp","fs","uniforms","center","radius","value","min","softMax","angle","softMin","swirl","name","dependencies","passes","sampler"],"sources":["../../../../src/modules/image-warp-filters/swirl.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\nimport {warp} from './warp';\n\nconst fs = `\\\nuniform float radius;\nuniform float angle;\nuniform vec2 center;\n\nvec2 swirl_warp(vec2 coord, vec2 texCenter) {\n coord -= texCenter;\n float distance = length(coord);\n if (distance < radius) {\n float percent = (radius - distance) / radius;\n float theta = percent * percent * angle;\n float s = sin(theta);\n float c = cos(theta);\n coord = vec2(\n coord.x * c - coord.y * s,\n coord.x * s + coord.y * c\n );\n }\n coord += texCenter;\n return coord;\n}\n\nvec4 swirl_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 coord = texCoord * texSize;\n coord = swirl_warp(coord, center * texSize);\n\n return warp_sampleColor(texture, texSize, coord);\n}\n`;\n\nconst uniforms = {\n center: [0.5, 0.5],\n radius: {value: 200, min: 1, softMax: 600},\n angle: {value: 3, softMin: -25, softMax: 25}\n};\n\n/** @type {ShaderPass} */\nexport const swirl = {\n name: 'swirl',\n fs,\n uniforms,\n dependencies: [warp],\n passes: [{sampler: true}]\n};\n"],"mappings":"AACA,SAAQA,IAAR,QAAmB,QAAnB;AAEA,MAAMC,EAAE,8sBAAR;AA8BA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE,CAAC,GAAD,EAAM,GAAN,CADO;EAEfC,MAAM,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,OAAO,EAAE;EAA9B,CAFO;EAGfC,KAAK,EAAE;IAACH,KAAK,EAAE,CAAR;IAAWI,OAAO,EAAE,CAAC,EAArB;IAAyBF,OAAO,EAAE;EAAlC;AAHQ,CAAjB;AAOA,OAAO,MAAMG,KAAK,GAAG;EACnBC,IAAI,EAAE,OADa;EAEnBV,EAFmB;EAGnBC,QAHmB;EAInBU,YAAY,EAAE,CAACZ,IAAD,CAJK;EAKnBa,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AALW,CAAd"}
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
vec4 warp_sampleColor(sampler2D texture, vec2 texSize, vec2 coord) {
|
|
3
|
-
vec4 color = texture2D(texture, coord / texSize);
|
|
4
|
-
vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
|
|
5
|
-
if (coord != clampedCoord) {
|
|
6
|
-
color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return color;
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
1
|
+
const fs = "vec4 warp_sampleColor(sampler2D texture, vec2 texSize, vec2 coord) {\n vec4 color = texture2D(texture, coord / texSize);\n vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);\n if (coord != clampedCoord) {\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n return color;\n}\n";
|
|
12
2
|
export const warp = {
|
|
13
3
|
name: 'warp',
|
|
14
4
|
fs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"warp.js","names":["fs","warp","name"],"sources":["../../../../src/modules/image-warp-filters/warp.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nconst fs = `\\\nvec4 warp_sampleColor(sampler2D texture, vec2 texSize, vec2 coord) {\n vec4 color = texture2D(texture, coord / texSize);\n vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);\n if (coord != clampedCoord) {\n /* fade to transparent if we are outside the image */\n color.a *= max(0.0, 1.0 - length(coord - clampedCoord));\n }\n\n return color;\n}\n`;\n\n/** @type {ShaderModule} */\nexport const warp = {\n name: 'warp',\n fs\n};\n"],"mappings":"AAEA,MAAMA,EAAE,kTAAR;AAcA,OAAO,MAAMC,IAAI,GAAG;EAClBC,IAAI,EAAE,MADY;EAElBF;AAFkB,CAAb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["random","fp32","fp64","fp64arithmetic","project","lights","dirlight","picking","gouraudLighting","phongLighting","pbr","tiltShift","triangleBlur","zoomBlur","brightnessContrast","denoise","hueSaturation","noise","sepia","vibrance","vignette","colorHalftone","dotScreen","edgeWork","hexagonalPixelate","ink","magnify","bulgePinch","swirl","warp","_warp","fxaa","transform","_transform"],"sources":["../../../src/modules/index.js"],"sourcesContent":["// utils\nexport {random} from './utils/random';\n\n// math libraries\nexport {fp32} from './fp32/fp32';\nexport {fp64, fp64arithmetic} from './fp64/fp64';\n\n// projection and lighting\nexport {project} from './project/project';\nexport {lights} from './lights/lights';\nexport {dirlight} from './dirlight/dirlight';\nexport {picking} from './picking/picking';\nexport {gouraudLighting, phongLighting} from './phong-lighting/phong-lighting';\nexport {pbr} from './pbr/pbr';\n\n// glfx BLUR shader modules\nexport {tiltShift} from './image-blur-filters/tiltshift';\nexport {triangleBlur} from './image-blur-filters/triangleblur';\nexport {zoomBlur} from './image-blur-filters/zoomblur';\n\n// glfx image adjustment shader modules\nexport {brightnessContrast} from './image-adjust-filters/brightnesscontrast';\nexport {denoise} from './image-adjust-filters/denoise';\nexport {hueSaturation} from './image-adjust-filters/huesaturation';\nexport {noise} from './image-adjust-filters/noise';\nexport {sepia} from './image-adjust-filters/sepia';\nexport {vibrance} from './image-adjust-filters/vibrance';\nexport {vignette} from './image-adjust-filters/vignette';\n\n// glfx FUN shader modules\nexport {colorHalftone} from './image-fun-filters/colorhalftone';\nexport {dotScreen} from './image-fun-filters/dotscreen';\nexport {edgeWork} from './image-fun-filters/edgework';\nexport {hexagonalPixelate} from './image-fun-filters/hexagonalpixelate';\nexport {ink} from './image-fun-filters/ink';\nexport {magnify} from './image-fun-filters/magnify';\n\n// glfx WARP shader modules\nexport {bulgePinch} from './image-warp-filters/bulgepinch';\nexport {swirl} from './image-warp-filters/swirl';\nexport {warp as _warp} from './image-warp-filters/warp';\n\n// Postprocessing\nexport {fxaa} from './fxaa/fxaa';\n\n// experimental\nexport {transform as _transform} from './transform/transform';\n"],"mappings":"AACA,SAAQA,MAAR,QAAqB,gBAArB;AAGA,SAAQC,IAAR,QAAmB,aAAnB;AACA,SAAQC,IAAR,EAAcC,cAAd,QAAmC,aAAnC;AAGA,SAAQC,OAAR,QAAsB,mBAAtB;AACA,SAAQC,MAAR,QAAqB,iBAArB;AACA,SAAQC,QAAR,QAAuB,qBAAvB;AACA,SAAQC,OAAR,QAAsB,mBAAtB;AACA,SAAQC,eAAR,EAAyBC,aAAzB,QAA6C,iCAA7C;AACA,SAAQC,GAAR,QAAkB,WAAlB;AAGA,SAAQC,SAAR,QAAwB,gCAAxB;AACA,SAAQC,YAAR,QAA2B,mCAA3B;AACA,SAAQC,QAAR,QAAuB,+BAAvB;AAGA,SAAQC,kBAAR,QAAiC,2CAAjC;AACA,SAAQC,OAAR,QAAsB,gCAAtB;AACA,SAAQC,aAAR,QAA4B,sCAA5B;AACA,SAAQC,KAAR,QAAoB,8BAApB;AACA,SAAQC,KAAR,QAAoB,8BAApB;AACA,SAAQC,QAAR,QAAuB,iCAAvB;AACA,SAAQC,QAAR,QAAuB,iCAAvB;AAGA,SAAQC,aAAR,QAA4B,mCAA5B;AACA,SAAQC,SAAR,QAAwB,+BAAxB;AACA,SAAQC,QAAR,QAAuB,8BAAvB;AACA,SAAQC,iBAAR,QAAgC,uCAAhC;AACA,SAAQC,GAAR,QAAkB,yBAAlB;AACA,SAAQC,OAAR,QAAsB,6BAAtB;AAGA,SAAQC,UAAR,QAAyB,iCAAzB;AACA,SAAQC,KAAR,QAAoB,4BAApB;AACA,SAAQC,IAAI,IAAIC,KAAhB,QAA4B,2BAA5B;AAGA,SAAQC,IAAR,QAAmB,aAAnB;AAGA,SAAQC,SAAS,IAAIC,UAArB,QAAsC,uBAAtC"}
|
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
export default
|
|
2
|
-
#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
3
|
-
|
|
4
|
-
struct AmbientLight {
|
|
5
|
-
vec3 color;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
struct PointLight {
|
|
9
|
-
vec3 color;
|
|
10
|
-
vec3 position;
|
|
11
|
-
vec3 attenuation;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
struct DirectionalLight {
|
|
15
|
-
vec3 color;
|
|
16
|
-
vec3 direction;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
uniform AmbientLight lighting_uAmbientLight;
|
|
20
|
-
uniform PointLight lighting_uPointLight[MAX_LIGHTS];
|
|
21
|
-
uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];
|
|
22
|
-
uniform int lighting_uPointLightCount;
|
|
23
|
-
uniform int lighting_uDirectionalLightCount;
|
|
24
|
-
|
|
25
|
-
uniform bool lighting_uEnabled;
|
|
26
|
-
|
|
27
|
-
float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
28
|
-
return pointLight.attenuation.x
|
|
29
|
-
+ pointLight.attenuation.y * distance
|
|
30
|
-
+ pointLight.attenuation.z * distance * distance;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
#endif
|
|
34
|
-
`;
|
|
1
|
+
export default "#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\n\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\n\nuniform bool lighting_uEnabled;\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n#endif\n";
|
|
35
2
|
//# sourceMappingURL=lights.glsl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"lights.glsl.js","names":[],"sources":["../../../../src/modules/lights/lights.glsl.js"],"sourcesContent":["export default `\\\n#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\n\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n\n // Constant-Linear-Exponential\n vec3 attenuation;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\n\nuniform bool lighting_uEnabled;\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n#endif\n`;\n"],"mappings":"AAAA"}
|
|
@@ -3,18 +3,20 @@ const INITIAL_MODULE_OPTIONS = {
|
|
|
3
3
|
lightSources: {}
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
-
function convertColor({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
function convertColor() {
|
|
7
|
+
let {
|
|
8
|
+
color = [0, 0, 0],
|
|
9
|
+
intensity = 1.0
|
|
10
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
10
11
|
return color.map(component => component * intensity / 255.0);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
function getLightSourceUniforms({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
function getLightSourceUniforms(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
ambientLight,
|
|
17
|
+
pointLights = [],
|
|
18
|
+
directionalLights = []
|
|
19
|
+
} = _ref;
|
|
18
20
|
const lightSourceUniforms = {};
|
|
19
21
|
|
|
20
22
|
if (ambientLight) {
|
|
@@ -24,20 +26,22 @@ function getLightSourceUniforms({
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
pointLights.forEach((pointLight, index) => {
|
|
27
|
-
lightSourceUniforms[
|
|
28
|
-
lightSourceUniforms[
|
|
29
|
-
lightSourceUniforms[
|
|
29
|
+
lightSourceUniforms["lighting_uPointLight[".concat(index, "].color")] = convertColor(pointLight);
|
|
30
|
+
lightSourceUniforms["lighting_uPointLight[".concat(index, "].position")] = pointLight.position;
|
|
31
|
+
lightSourceUniforms["lighting_uPointLight[".concat(index, "].attenuation")] = pointLight.attenuation || [1, 0, 0];
|
|
30
32
|
});
|
|
31
33
|
lightSourceUniforms.lighting_uPointLightCount = pointLights.length;
|
|
32
34
|
directionalLights.forEach((directionalLight, index) => {
|
|
33
|
-
lightSourceUniforms[
|
|
34
|
-
lightSourceUniforms[
|
|
35
|
+
lightSourceUniforms["lighting_uDirectionalLight[".concat(index, "].color")] = convertColor(directionalLight);
|
|
36
|
+
lightSourceUniforms["lighting_uDirectionalLight[".concat(index, "].direction")] = directionalLight.direction;
|
|
35
37
|
});
|
|
36
38
|
lightSourceUniforms.lighting_uDirectionalLightCount = directionalLights.length;
|
|
37
39
|
return lightSourceUniforms;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
function getUniforms(
|
|
42
|
+
function getUniforms() {
|
|
43
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_MODULE_OPTIONS;
|
|
44
|
+
|
|
41
45
|
if ('lightSources' in opts) {
|
|
42
46
|
const {
|
|
43
47
|
ambientLight,
|