@luma.gl/shadertools 8.5.19 → 8.5.21
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/es5/bundle.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/assemble-shaders.js.map +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.map +1 -1
- package/dist/es5/lib/platform-defines.js.map +1 -1
- package/dist/es5/lib/resolve-modules.js.map +1 -1
- package/dist/es5/lib/shader-module.js.map +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.map +1 -1
- 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.map +1 -1
- package/dist/es5/modules/lights/lights.glsl.js.map +1 -1
- package/dist/es5/modules/lights/lights.js.map +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.map +1 -1
- 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.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.map +1 -1
- package/dist/esm/lib/platform-defines.js.map +1 -1
- package/dist/esm/lib/resolve-modules.js.map +1 -1
- package/dist/esm/lib/shader-module.js.map +1 -1
- package/dist/esm/lib/transpile-shader.js.map +1 -1
- package/dist/esm/modules/dirlight/dirlight.js.map +1 -1
- package/dist/esm/modules/fp32/fp32.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-arithmetic.glsl.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-functions.glsl.js.map +1 -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.map +1 -1
- package/dist/esm/modules/geometry/geometry.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/denoise.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/noise.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/sepia.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/vignette.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/dotscreen.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/edgework.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/ink.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/magnify.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/swirl.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/modules/lights/lights.js.map +1 -1
- package/dist/esm/modules/module-injectors.js.map +1 -1
- package/dist/esm/modules/pbr/pbr-fragment.glsl.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/modules/phong-lighting/phong-lighting.js.map +1 -1
- package/dist/esm/modules/picking/picking.js.map +1 -1
- package/dist/esm/modules/project/project.js.map +1 -1
- package/dist/esm/modules/transform/transform.js.map +1 -1
- 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.map +1 -1
- package/dist/esm/utils/shader-utils.js.map +1 -1
- package/dist/esm/utils/webgl-info.js.map +1 -1
- package/package.json +2 -2
- package/src/.DS_Store +0 -0
- package/src/lib/.DS_Store +0 -0
- package/src/modules/.DS_Store +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/fxaa/fxaa.js"],"names":["fs","fxaa","name","uniforms","passes","sampler"],"mappings":";;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiEA,IAAMA,EAAE,2mpBAAR;AAukBO,IAAMC,IAAI,GAAG;AAClBC,EAAAA,IAAI,EAAE,MADY;AAElBC,EAAAA,QAAQ,EAAE,EAFQ;AAGlBH,EAAAA,EAAE,EAAFA,EAHkB;AAIlBI,EAAAA,MAAM,EAAE,CAAC;AAACC,IAAAA,OAAO,EAAE;AAAV,GAAD;AAJU,CAAb","sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\n/**\n * ORIGINAL LICENCE\n * @license\n * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * * Neither the name of NVIDIA CORPORATION nor the names of its\n * contributors may be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n// LUMA.GL\n// WebGL version from cesium.js, used under Apached 2.0 License\n// https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n// with the following modifications:\n// - fxaa_sampleColor to integrate with luma.gl\n// - Return color value with alpha to avoid another tap\n// - Calculate luminance in FxaaLuma\n\n// COMMENTS FROM CESIUM VERSION\n// NVIDIA GameWorks Graphics Samples GitHub link: https://github.com/NVIDIAGameWorks/GraphicsSamples\n// Original FXAA 3.11 shader link: https://github.com/NVIDIAGameWorks/GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h\n//\n// Steps used to integrate into Cesium:\n// * The following defines are set:\n// #define FXAA_PC 1\n// #define FXAA_WEBGL_1 1\n// #define FXAA_GREEN_AS_LUMA 1\n// #define FXAA_EARLY_EXIT 1\n// #define FXAA_GLSL_120 1\n// * All other preprocessor directives besides the FXAA_QUALITY__P* directives were removed.\n// * Double underscores are invalid for preprocessor directives so replace them with a single underscore. Replace\n// /FXAA_QUALITY__P(.*)/g with /FXAA_QUALITY__P$1/.\n// * There are no implicit conversions from ivec* to vec* so replace:\n// #define FxaaInt2 ivec2\n// with\n// #define FxaaInt2 vec2\n// * The texture2DLod function is only available in vertex shaders so replace:\n// #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)\n// #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)\n// with\n// #define FxaaTexTop(t, p) texture2D(t, p)\n// #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r))\n// * FXAA_QUALITY_PRESET is prepended in the javascript code. We may want to expose that setting in the future.\n// * The following parameters to FxaaPixelShader_ are unused and can be removed:\n// fxaaConsolePosPos\n// fxaaConsoleRcpFrameOpt\n// fxaaConsoleRcpFrameOpt2\n// fxaaConsole360RcpFrameOpt2\n// fxaaConsoleEdgeSharpness\n// fxaaConsoleEdgeThreshold\n// fxaaConsoleEdgeThresholdMi\n// fxaaConsole360ConstDir\n//\n// Choose the quality preset.\n// This needs to be compiled into the shader as it effects code.\n// Best option to include multiple presets is to\n// in each shader define the preset, then include this file.\n//\n// OPTIONS\n// -----------------------------------------------------------------------\n// 10 to 15 - default medium dither (10=fastest, 15=highest quality)\n// 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)\n// 39 - no dither, very expensive\n//\n// NOTES\n// -----------------------------------------------------------------------\n// 12 = slightly faster then FXAA 3.9 and higher edge quality (default)\n// 13 = about same speed as FXAA 3.9 and better than 12\n// 23 = closest to FXAA 3.9 visually and performance wise\n// _ = the lowest digit is directly related to performance\n// _ = the highest digit is directly related to style\n//\n\nconst fs = `\n#define FXAA_QUALITY_PRESET 29\n\n#if (FXAA_QUALITY_PRESET == 10)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 3.0\n #define FXAA_QUALITY_P2 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 11)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 3.0\n #define FXAA_QUALITY_P3 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 12)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 4.0\n #define FXAA_QUALITY_P4 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 13)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 4.0\n #define FXAA_QUALITY_P5 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 14)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 4.0\n #define FXAA_QUALITY_P6 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 15)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 20)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 2.0\n #define FXAA_QUALITY_P2 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 21)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 22)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 23)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 24)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 3.0\n #define FXAA_QUALITY_P6 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 25)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 26)\n #define FXAA_QUALITY_PS 9\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 4.0\n #define FXAA_QUALITY_P8 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 27)\n #define FXAA_QUALITY_PS 10\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 4.0\n #define FXAA_QUALITY_P9 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 28)\n #define FXAA_QUALITY_PS 11\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 4.0\n #define FXAA_QUALITY_P10 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 29)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 39)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.0\n #define FXAA_QUALITY_P2 1.0\n #define FXAA_QUALITY_P3 1.0\n #define FXAA_QUALITY_P4 1.0\n #define FXAA_QUALITY_P5 1.5\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n\n#define FxaaBool bool\n#define FxaaFloat float\n#define FxaaFloat2 vec2\n#define FxaaFloat3 vec3\n#define FxaaFloat4 vec4\n#define FxaaHalf float\n#define FxaaHalf2 vec2\n#define FxaaHalf3 vec3\n#define FxaaHalf4 vec4\n#define FxaaInt2 vec2\n#define FxaaTex sampler2D\n\n#define FxaaSat(x) clamp(x, 0.0, 1.0)\n#define FxaaTexTop(t, p) texture2D(t, p)\n#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r))\n\nFxaaFloat FxaaLuma_(FxaaFloat4 rgba) { return dot(rgba.rgb, vec3(0.2126, 0.7152, 0.0722)); }\n\nFxaaFloat4 FxaaPixelShader_(\n //\n // Use noperspective interpolation here (turn off perspective interpolation).\n // {xy} = center of pixel\n FxaaFloat2 pos,\n //\n // Input color texture.\n // {rgb_} = color in linear or perceptual color space\n // if (FXAA_GREEN_AS_LUMA == 0)\n // {___a} = luma in perceptual color space (not linear)\n FxaaTex tex,\n //\n // Only used on FXAA Quality.\n // This must be from a constant/uniform.\n // {x_} = 1.0/screenWidthInPixels\n // {_y} = 1.0/screenHeightInPixels\n FxaaFloat2 fxaaQualityRcpFrame,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_SUBPIX define.\n // It is here now to allow easier tuning.\n // Choose the amount of sub-pixel aliasing removal.\n // This can effect sharpness.\n // 1.00 - upper limit (softer)\n // 0.75 - default amount of filtering\n // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)\n // 0.25 - almost off\n // 0.00 - completely off\n FxaaFloat fxaaQualitySubpix,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.\n // It is here now to allow easier tuning.\n // The minimum amount of local contrast required to apply algorithm.\n // 0.333 - too little (faster)\n // 0.250 - low quality\n // 0.166 - default\n // 0.125 - high quality\n // 0.063 - overkill (slower)\n FxaaFloat fxaaQualityEdgeThreshold,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.\n // It is here now to allow easier tuning.\n // Trims the algorithm from processing darks.\n // 0.0833 - upper limit (default, the start of visible unfiltered edges)\n // 0.0625 - high quality (faster)\n // 0.0312 - visible limit (slower)\n // Special notes when using FXAA_GREEN_AS_LUMA,\n // Likely want to set this to zero.\n // As colors that are mostly not-green\n // will appear very dark in the green channel!\n // Tune by looking at mostly non-green content,\n // then start at zero and increase until aliasing is a problem.\n FxaaFloat fxaaQualityEdgeThresholdMin\n) {\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posM;\n posM.x = pos.x;\n posM.y = pos.y;\n FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n #define lumaM rgbyM.y\n FxaaFloat lumaS = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaN = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n/*--------------------------------------------------------------------------*/\n FxaaFloat maxSM = max(lumaS, lumaM);\n FxaaFloat minSM = min(lumaS, lumaM);\n FxaaFloat maxESM = max(lumaE, maxSM);\n FxaaFloat minESM = min(lumaE, minSM);\n FxaaFloat maxWN = max(lumaN, lumaW);\n FxaaFloat minWN = min(lumaN, lumaW);\n FxaaFloat rangeMax = max(maxWN, maxESM);\n FxaaFloat rangeMin = min(minWN, minESM);\n FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n FxaaFloat range = rangeMax - rangeMin;\n FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n FxaaBool earlyExit = range < rangeMaxClamped;\n/*--------------------------------------------------------------------------*/\n if(earlyExit)\n return rgbyM;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaNE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNS = lumaN + lumaS;\n FxaaFloat lumaWE = lumaW + lumaE;\n FxaaFloat subpixRcpRange = 1.0/range;\n FxaaFloat subpixNSWE = lumaNS + lumaWE;\n FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\n FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNESE = lumaNE + lumaSE;\n FxaaFloat lumaNWNE = lumaNW + lumaNE;\n FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNWSW = lumaNW + lumaSW;\n FxaaFloat lumaSWSE = lumaSW + lumaSE;\n FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\n FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\n/*--------------------------------------------------------------------------*/\n FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\n FxaaFloat lengthSign = fxaaQualityRcpFrame.x;\n FxaaBool horzSpan = edgeHorz >= edgeVert;\n FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n/*--------------------------------------------------------------------------*/\n if(!horzSpan) lumaN = lumaW;\n if(!horzSpan) lumaS = lumaE;\n if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\n/*--------------------------------------------------------------------------*/\n FxaaFloat gradientN = lumaN - lumaM;\n FxaaFloat gradientS = lumaS - lumaM;\n FxaaFloat lumaNN = lumaN + lumaM;\n FxaaFloat lumaSS = lumaS + lumaM;\n FxaaBool pairN = abs(gradientN) >= abs(gradientS);\n FxaaFloat gradient = max(abs(gradientN), abs(gradientS));\n if(pairN) lengthSign = -lengthSign;\n FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posB;\n posB.x = posM.x;\n posB.y = posM.y;\n FxaaFloat2 offNP;\n offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n if(!horzSpan) posB.x += lengthSign * 0.5;\n if( horzSpan) posB.y += lengthSign * 0.5;\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posN;\n posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\n posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\n FxaaFloat2 posP;\n posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\n posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\n FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\n FxaaFloat lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN));\n FxaaFloat subpixE = subpixC * subpixC;\n FxaaFloat lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP));\n/*--------------------------------------------------------------------------*/\n if(!pairN) lumaNN = lumaSS;\n FxaaFloat gradientScaled = gradient * 1.0/4.0;\n FxaaFloat lumaMM = lumaM - lumaNN * 0.5;\n FxaaFloat subpixF = subpixD * subpixE;\n FxaaBool lumaMLTZero = lumaMM < 0.0;\n/*--------------------------------------------------------------------------*/\n lumaEndN -= lumaNN * 0.5;\n lumaEndP -= lumaNN * 0.5;\n FxaaBool doneN = abs(lumaEndN) >= gradientScaled;\n FxaaBool doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\n FxaaBool doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\n/*--------------------------------------------------------------------------*/\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 3)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 4)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 5)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 6)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 7)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 8)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 9)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 10)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 11)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 12)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n/*--------------------------------------------------------------------------*/\n FxaaFloat dstN = posM.x - posN.x;\n FxaaFloat dstP = posP.x - posM.x;\n if(!horzSpan) dstN = posM.y - posN.y;\n if(!horzSpan) dstP = posP.y - posM.y;\n/*--------------------------------------------------------------------------*/\n FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n FxaaFloat spanLength = (dstP + dstN);\n FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n FxaaFloat spanLengthRcp = 1.0/spanLength;\n/*--------------------------------------------------------------------------*/\n FxaaBool directionN = dstN < dstP;\n FxaaFloat dst = min(dstN, dstP);\n FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\n FxaaFloat subpixG = subpixF * subpixF;\n FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n FxaaFloat subpixH = subpixG * fxaaQualitySubpix;\n/*--------------------------------------------------------------------------*/\n FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n return FxaaTexTop(tex, posM);\n}\n\nvec4 fxaa_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n const float fxaa_QualitySubpix = 0.5;\n const float fxaa_QualityEdgeThreshold = 0.125;\n const float fxaa_QualityEdgeThresholdMin = 0.0833;\n\n return FxaaPixelShader_(\n texCoord,\n texture,\n vec2(1.0) / texSize,\n fxaa_QualitySubpix,\n fxaa_QualityEdgeThreshold,\n fxaa_QualityEdgeThresholdMin\n );\n}\n`;\n\n/** @type {ShaderPass} */\nexport const fxaa = {\n name: 'fxaa',\n uniforms: {},\n fs,\n passes: [{sampler: true}]\n};\n"],"file":"fxaa.js"}
|
|
1
|
+
{"version":3,"file":"fxaa.js","names":["fs","fxaa","name","uniforms","passes","sampler"],"sources":["../../../../src/modules/fxaa/fxaa.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\n/**\n * ORIGINAL LICENCE\n * @license\n * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * * Neither the name of NVIDIA CORPORATION nor the names of its\n * contributors may be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n// LUMA.GL\n// WebGL version from cesium.js, used under Apached 2.0 License\n// https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n// with the following modifications:\n// - fxaa_sampleColor to integrate with luma.gl\n// - Return color value with alpha to avoid another tap\n// - Calculate luminance in FxaaLuma\n\n// COMMENTS FROM CESIUM VERSION\n// NVIDIA GameWorks Graphics Samples GitHub link: https://github.com/NVIDIAGameWorks/GraphicsSamples\n// Original FXAA 3.11 shader link: https://github.com/NVIDIAGameWorks/GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h\n//\n// Steps used to integrate into Cesium:\n// * The following defines are set:\n// #define FXAA_PC 1\n// #define FXAA_WEBGL_1 1\n// #define FXAA_GREEN_AS_LUMA 1\n// #define FXAA_EARLY_EXIT 1\n// #define FXAA_GLSL_120 1\n// * All other preprocessor directives besides the FXAA_QUALITY__P* directives were removed.\n// * Double underscores are invalid for preprocessor directives so replace them with a single underscore. Replace\n// /FXAA_QUALITY__P(.*)/g with /FXAA_QUALITY__P$1/.\n// * There are no implicit conversions from ivec* to vec* so replace:\n// #define FxaaInt2 ivec2\n// with\n// #define FxaaInt2 vec2\n// * The texture2DLod function is only available in vertex shaders so replace:\n// #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)\n// #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)\n// with\n// #define FxaaTexTop(t, p) texture2D(t, p)\n// #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r))\n// * FXAA_QUALITY_PRESET is prepended in the javascript code. We may want to expose that setting in the future.\n// * The following parameters to FxaaPixelShader_ are unused and can be removed:\n// fxaaConsolePosPos\n// fxaaConsoleRcpFrameOpt\n// fxaaConsoleRcpFrameOpt2\n// fxaaConsole360RcpFrameOpt2\n// fxaaConsoleEdgeSharpness\n// fxaaConsoleEdgeThreshold\n// fxaaConsoleEdgeThresholdMi\n// fxaaConsole360ConstDir\n//\n// Choose the quality preset.\n// This needs to be compiled into the shader as it effects code.\n// Best option to include multiple presets is to\n// in each shader define the preset, then include this file.\n//\n// OPTIONS\n// -----------------------------------------------------------------------\n// 10 to 15 - default medium dither (10=fastest, 15=highest quality)\n// 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)\n// 39 - no dither, very expensive\n//\n// NOTES\n// -----------------------------------------------------------------------\n// 12 = slightly faster then FXAA 3.9 and higher edge quality (default)\n// 13 = about same speed as FXAA 3.9 and better than 12\n// 23 = closest to FXAA 3.9 visually and performance wise\n// _ = the lowest digit is directly related to performance\n// _ = the highest digit is directly related to style\n//\n\nconst fs = `\n#define FXAA_QUALITY_PRESET 29\n\n#if (FXAA_QUALITY_PRESET == 10)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 3.0\n #define FXAA_QUALITY_P2 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 11)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 3.0\n #define FXAA_QUALITY_P3 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 12)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 4.0\n #define FXAA_QUALITY_P4 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 13)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 4.0\n #define FXAA_QUALITY_P5 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 14)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 4.0\n #define FXAA_QUALITY_P6 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 15)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 20)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 2.0\n #define FXAA_QUALITY_P2 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 21)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 22)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 23)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 24)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 3.0\n #define FXAA_QUALITY_P6 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 25)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 26)\n #define FXAA_QUALITY_PS 9\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 4.0\n #define FXAA_QUALITY_P8 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 27)\n #define FXAA_QUALITY_PS 10\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 4.0\n #define FXAA_QUALITY_P9 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 28)\n #define FXAA_QUALITY_PS 11\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 4.0\n #define FXAA_QUALITY_P10 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 29)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 39)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.0\n #define FXAA_QUALITY_P2 1.0\n #define FXAA_QUALITY_P3 1.0\n #define FXAA_QUALITY_P4 1.0\n #define FXAA_QUALITY_P5 1.5\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n\n#define FxaaBool bool\n#define FxaaFloat float\n#define FxaaFloat2 vec2\n#define FxaaFloat3 vec3\n#define FxaaFloat4 vec4\n#define FxaaHalf float\n#define FxaaHalf2 vec2\n#define FxaaHalf3 vec3\n#define FxaaHalf4 vec4\n#define FxaaInt2 vec2\n#define FxaaTex sampler2D\n\n#define FxaaSat(x) clamp(x, 0.0, 1.0)\n#define FxaaTexTop(t, p) texture2D(t, p)\n#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r))\n\nFxaaFloat FxaaLuma_(FxaaFloat4 rgba) { return dot(rgba.rgb, vec3(0.2126, 0.7152, 0.0722)); }\n\nFxaaFloat4 FxaaPixelShader_(\n //\n // Use noperspective interpolation here (turn off perspective interpolation).\n // {xy} = center of pixel\n FxaaFloat2 pos,\n //\n // Input color texture.\n // {rgb_} = color in linear or perceptual color space\n // if (FXAA_GREEN_AS_LUMA == 0)\n // {___a} = luma in perceptual color space (not linear)\n FxaaTex tex,\n //\n // Only used on FXAA Quality.\n // This must be from a constant/uniform.\n // {x_} = 1.0/screenWidthInPixels\n // {_y} = 1.0/screenHeightInPixels\n FxaaFloat2 fxaaQualityRcpFrame,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_SUBPIX define.\n // It is here now to allow easier tuning.\n // Choose the amount of sub-pixel aliasing removal.\n // This can effect sharpness.\n // 1.00 - upper limit (softer)\n // 0.75 - default amount of filtering\n // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)\n // 0.25 - almost off\n // 0.00 - completely off\n FxaaFloat fxaaQualitySubpix,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.\n // It is here now to allow easier tuning.\n // The minimum amount of local contrast required to apply algorithm.\n // 0.333 - too little (faster)\n // 0.250 - low quality\n // 0.166 - default\n // 0.125 - high quality\n // 0.063 - overkill (slower)\n FxaaFloat fxaaQualityEdgeThreshold,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.\n // It is here now to allow easier tuning.\n // Trims the algorithm from processing darks.\n // 0.0833 - upper limit (default, the start of visible unfiltered edges)\n // 0.0625 - high quality (faster)\n // 0.0312 - visible limit (slower)\n // Special notes when using FXAA_GREEN_AS_LUMA,\n // Likely want to set this to zero.\n // As colors that are mostly not-green\n // will appear very dark in the green channel!\n // Tune by looking at mostly non-green content,\n // then start at zero and increase until aliasing is a problem.\n FxaaFloat fxaaQualityEdgeThresholdMin\n) {\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posM;\n posM.x = pos.x;\n posM.y = pos.y;\n FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n #define lumaM rgbyM.y\n FxaaFloat lumaS = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaN = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n/*--------------------------------------------------------------------------*/\n FxaaFloat maxSM = max(lumaS, lumaM);\n FxaaFloat minSM = min(lumaS, lumaM);\n FxaaFloat maxESM = max(lumaE, maxSM);\n FxaaFloat minESM = min(lumaE, minSM);\n FxaaFloat maxWN = max(lumaN, lumaW);\n FxaaFloat minWN = min(lumaN, lumaW);\n FxaaFloat rangeMax = max(maxWN, maxESM);\n FxaaFloat rangeMin = min(minWN, minESM);\n FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n FxaaFloat range = rangeMax - rangeMin;\n FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n FxaaBool earlyExit = range < rangeMaxClamped;\n/*--------------------------------------------------------------------------*/\n if(earlyExit)\n return rgbyM;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaNE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNS = lumaN + lumaS;\n FxaaFloat lumaWE = lumaW + lumaE;\n FxaaFloat subpixRcpRange = 1.0/range;\n FxaaFloat subpixNSWE = lumaNS + lumaWE;\n FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\n FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNESE = lumaNE + lumaSE;\n FxaaFloat lumaNWNE = lumaNW + lumaNE;\n FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNWSW = lumaNW + lumaSW;\n FxaaFloat lumaSWSE = lumaSW + lumaSE;\n FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\n FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\n/*--------------------------------------------------------------------------*/\n FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\n FxaaFloat lengthSign = fxaaQualityRcpFrame.x;\n FxaaBool horzSpan = edgeHorz >= edgeVert;\n FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n/*--------------------------------------------------------------------------*/\n if(!horzSpan) lumaN = lumaW;\n if(!horzSpan) lumaS = lumaE;\n if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\n/*--------------------------------------------------------------------------*/\n FxaaFloat gradientN = lumaN - lumaM;\n FxaaFloat gradientS = lumaS - lumaM;\n FxaaFloat lumaNN = lumaN + lumaM;\n FxaaFloat lumaSS = lumaS + lumaM;\n FxaaBool pairN = abs(gradientN) >= abs(gradientS);\n FxaaFloat gradient = max(abs(gradientN), abs(gradientS));\n if(pairN) lengthSign = -lengthSign;\n FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posB;\n posB.x = posM.x;\n posB.y = posM.y;\n FxaaFloat2 offNP;\n offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n if(!horzSpan) posB.x += lengthSign * 0.5;\n if( horzSpan) posB.y += lengthSign * 0.5;\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posN;\n posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\n posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\n FxaaFloat2 posP;\n posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\n posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\n FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\n FxaaFloat lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN));\n FxaaFloat subpixE = subpixC * subpixC;\n FxaaFloat lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP));\n/*--------------------------------------------------------------------------*/\n if(!pairN) lumaNN = lumaSS;\n FxaaFloat gradientScaled = gradient * 1.0/4.0;\n FxaaFloat lumaMM = lumaM - lumaNN * 0.5;\n FxaaFloat subpixF = subpixD * subpixE;\n FxaaBool lumaMLTZero = lumaMM < 0.0;\n/*--------------------------------------------------------------------------*/\n lumaEndN -= lumaNN * 0.5;\n lumaEndP -= lumaNN * 0.5;\n FxaaBool doneN = abs(lumaEndN) >= gradientScaled;\n FxaaBool doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\n FxaaBool doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\n/*--------------------------------------------------------------------------*/\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 3)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 4)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 5)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 6)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 7)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 8)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 9)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 10)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 11)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 12)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n/*--------------------------------------------------------------------------*/\n FxaaFloat dstN = posM.x - posN.x;\n FxaaFloat dstP = posP.x - posM.x;\n if(!horzSpan) dstN = posM.y - posN.y;\n if(!horzSpan) dstP = posP.y - posM.y;\n/*--------------------------------------------------------------------------*/\n FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n FxaaFloat spanLength = (dstP + dstN);\n FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n FxaaFloat spanLengthRcp = 1.0/spanLength;\n/*--------------------------------------------------------------------------*/\n FxaaBool directionN = dstN < dstP;\n FxaaFloat dst = min(dstN, dstP);\n FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\n FxaaFloat subpixG = subpixF * subpixF;\n FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n FxaaFloat subpixH = subpixG * fxaaQualitySubpix;\n/*--------------------------------------------------------------------------*/\n FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n return FxaaTexTop(tex, posM);\n}\n\nvec4 fxaa_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n const float fxaa_QualitySubpix = 0.5;\n const float fxaa_QualityEdgeThreshold = 0.125;\n const float fxaa_QualityEdgeThresholdMin = 0.0833;\n\n return FxaaPixelShader_(\n texCoord,\n texture,\n vec2(1.0) / texSize,\n fxaa_QualitySubpix,\n fxaa_QualityEdgeThreshold,\n fxaa_QualityEdgeThresholdMin\n );\n}\n`;\n\n/** @type {ShaderPass} */\nexport const fxaa = {\n name: 'fxaa',\n uniforms: {},\n fs,\n passes: [{sampler: true}]\n};\n"],"mappings":";;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiEA,IAAMA,EAAE,2mpBAAR;AAukBO,IAAMC,IAAI,GAAG;EAClBC,IAAI,EAAE,MADY;EAElBC,QAAQ,EAAE,EAFQ;EAGlBH,EAAE,EAAFA,EAHkB;EAIlBI,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AAJU,CAAb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"geometry.js","names":["vs","fs","geometry","name"],"sources":["../../../../src/modules/geometry/geometry.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\n// TODO - reuse normal from geometry module\nconst vs = `\\\nvarying vec4 geometry_vPosition;\nvarying vec3 geometry_vNormal;\n\nvoid geometry_setNormal(vec3 normal) {\n geometry_vNormal = normal;\n}\n\nvoid geometry_setPosition(vec4 position) {\n geometry_vPosition = position;\n}\n\nvoid geometry_setPosition(vec3 position) {\n geometry_vPosition = vec4(position, 1.);\n}\n`;\n\nconst fs = `\\\nvarying vec4 geometry_vPosition;\nvarying vec3 geometry_vNormal;\n\nvec4 geometry_getPosition() {\n return geometry_vPosition;\n}\n\nvec3 geometry_getNormal() {\n return geometry_vNormal;\n}\n`;\n\n/** @type {ShaderModule} */\nexport const geometry = {\n name: 'geometry',\n vs,\n fs\n};\n"],"mappings":";;;;;;AAGA,IAAMA,EAAE,kUAAR;AAiBA,IAAMC,EAAE,uMAAR;AAcO,IAAMC,QAAQ,GAAG;EACtBC,IAAI,EAAE,UADgB;EAEtBH,EAAE,EAAFA,EAFsB;EAGtBC,EAAE,EAAFA;AAHsB,CAAjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"brightnesscontrast.js","names":["fs","uniforms","brightness","value","min","max","contrast","brightnessContrast","name","passes","filter"],"sources":["../../../../src/modules/image-adjust-filters/brightnesscontrast.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nconst fs = `\\\nuniform float brightness;\nuniform float contrast;\n\nvec4 brightnessContrast_filterColor(vec4 color) {\n color.rgb += brightness;\n if (contrast > 0.0) {\n color.rgb = (color.rgb - 0.5) / (1.0 - contrast) + 0.5;\n } else {\n color.rgb = (color.rgb - 0.5) * (1.0 + contrast) + 0.5;\n }\n return color;\n}\n\nvec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {\n return brightnessContrast_filterColor(color);\n}\n`;\n\nconst uniforms = {\n brightness: {value: 0, min: -1, max: 1},\n contrast: {value: 0, min: -1, max: 1}\n};\n\n/** @type {ShaderPass} */\nexport const brightnessContrast = {\n name: 'brightnessContrast',\n uniforms,\n fs,\n passes: [{filter: true}]\n};\n"],"mappings":";;;;;;AAEA,IAAMA,EAAE,ycAAR;AAmBA,IAAMC,QAAQ,GAAG;EACfC,UAAU,EAAE;IAACC,KAAK,EAAE,CAAR;IAAWC,GAAG,EAAE,CAAC,CAAjB;IAAoBC,GAAG,EAAE;EAAzB,CADG;EAEfC,QAAQ,EAAE;IAACH,KAAK,EAAE,CAAR;IAAWC,GAAG,EAAE,CAAC,CAAjB;IAAoBC,GAAG,EAAE;EAAzB;AAFK,CAAjB;AAMO,IAAME,kBAAkB,GAAG;EAChCC,IAAI,EAAE,oBAD0B;EAEhCP,QAAQ,EAARA,QAFgC;EAGhCD,EAAE,EAAFA,EAHgC;EAIhCS,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJwB,CAA3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"denoise.js","names":["fs","uniforms","strength","value","min","max","adjust","Math","pow","denoise","name","passes","sampler"],"sources":["../../../../src/modules/image-adjust-filters/denoise.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\n// Do a 9x9 bilateral box filter\nconst fs = `\\\nuniform float strength;\n\nvec4 denoise_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n float adjustedExponent = 3. + 200. * pow(1. - strength, 4.);\n\n vec4 center = texture2D(texture, texCoord);\n vec4 color = vec4(0.0);\n float total = 0.0;\n for (float x = -4.0; x <= 4.0; x += 1.0) {\n for (float y = -4.0; y <= 4.0; y += 1.0) {\n vec4 sample = texture2D(texture, texCoord + vec2(x, y) / texSize);\n float weight = 1.0 - abs(dot(sample.rgb - center.rgb, vec3(0.25)));\n weight = pow(weight, adjustedExponent);\n color += sample * weight;\n total += weight;\n }\n }\n\n return color / total;\n}\n`;\n\nconst uniforms = {\n strength: {\n value: 0.5,\n min: 0,\n max: 0.1,\n adjust: strength => 0.53 + 200 * Math.pow(1 - strength, 4) // TODO - JS preprocessing\n }\n};\n\n/** @type {ShaderPass} */\nexport const denoise = {\n name: 'denoise',\n uniforms,\n fs,\n passes: [{sampler: true}, {sampler: true}]\n};\n"],"mappings":";;;;;;AAGA,IAAMA,EAAE,mpBAAR;AAuBA,IAAMC,QAAQ,GAAG;EACfC,QAAQ,EAAE;IACRC,KAAK,EAAE,GADC;IAERC,GAAG,EAAE,CAFG;IAGRC,GAAG,EAAE,GAHG;IAIRC,MAAM,EAAE,gBAAAJ,QAAQ;MAAA,OAAI,OAAO,MAAMK,IAAI,CAACC,GAAL,CAAS,IAAIN,QAAb,EAAuB,CAAvB,CAAjB;IAAA;EAJR;AADK,CAAjB;AAUO,IAAMO,OAAO,GAAG;EACrBC,IAAI,EAAE,SADe;EAErBT,QAAQ,EAARA,QAFqB;EAGrBD,EAAE,EAAFA,EAHqB;EAIrBW,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD,EAAkB;IAACA,OAAO,EAAE;EAAV,CAAlB;AAJa,CAAhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"huesaturation.js","names":["fs","uniforms","hue","value","min","max","saturation","hueSaturation","name","passes","filter"],"sources":["../../../../src/modules/image-adjust-filters/huesaturation.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nconst fs = `\\\nuniform float hue;\nuniform float saturation;\n\nvec4 hueSaturation_filterColor(vec4 color) {\n // hue adjustment, wolfram alpha: RotationTransform[angle, {1, 1, 1}][{x, y, z}]\n float angle = hue * 3.14159265;\n float s = sin(angle), c = cos(angle);\n vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;\n float len = length(color.rgb);\n color.rgb = vec3(\n dot(color.rgb, weights.xyz),\n dot(color.rgb, weights.zxy),\n dot(color.rgb, weights.yzx)\n );\n\n // saturation adjustment\n float average = (color.r + color.g + color.b) / 3.0;\n if (saturation > 0.0) {\n color.rgb += (average - color.rgb) * (1.0 - 1.0 / (1.001 - saturation));\n } else {\n color.rgb += (average - color.rgb) * (-saturation);\n }\n\n return color;\n}\n\nvec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n return hueSaturation_filterColor(color);\n}\n`;\n\nconst uniforms = {\n hue: {value: 0, min: -1, max: 1},\n saturation: {value: 0, min: -1, max: 1}\n};\n\n/** @type {ShaderPass} */\nexport const hueSaturation = {\n name: 'hueSaturation',\n uniforms,\n fs,\n passes: [{filter: true}]\n};\n"],"mappings":";;;;;;AAEA,IAAMA,EAAE,qyBAAR;AAgCA,IAAMC,QAAQ,GAAG;EACfC,GAAG,EAAE;IAACC,KAAK,EAAE,CAAR;IAAWC,GAAG,EAAE,CAAC,CAAjB;IAAoBC,GAAG,EAAE;EAAzB,CADU;EAEfC,UAAU,EAAE;IAACH,KAAK,EAAE,CAAR;IAAWC,GAAG,EAAE,CAAC,CAAjB;IAAoBC,GAAG,EAAE;EAAzB;AAFG,CAAjB;AAMO,IAAME,aAAa,GAAG;EAC3BC,IAAI,EAAE,eADqB;EAE3BP,QAAQ,EAARA,QAF2B;EAG3BD,EAAE,EAAFA,EAH2B;EAI3BS,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJmB,CAAtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"noise.js","names":["fs","uniforms","amount","value","min","max","noise","name","passes","filter"],"sources":["../../../../src/modules/image-adjust-filters/noise.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nconst fs = `\\\nuniform float amount;\n\nfloat rand(vec2 co) {\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\nvec4 noise_filterColor(vec4 color, vec2 texCoord) {\n float diff = (rand(texCoord) - 0.5) * amount;\n color.r += diff;\n color.g += diff;\n color.b += diff;\n return color;\n}\n\nvec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n return noise_filterColor(color, texCoord);\n}\n`;\n\nconst uniforms = {\n amount: {value: 0.5, min: 0, max: 1}\n};\n\n/** @type {ShaderPass} */\nexport const noise = {\n name: 'noise',\n uniforms,\n fs,\n passes: [{filter: true}]\n};\n"],"mappings":";;;;;;AAEA,IAAMA,EAAE,2aAAR;AAoBA,IAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,GAAG,EAAE;EAA1B;AADO,CAAjB;AAKO,IAAMC,KAAK,GAAG;EACnBC,IAAI,EAAE,OADa;EAEnBN,QAAQ,EAARA,QAFmB;EAGnBD,EAAE,EAAFA,EAHmB;EAInBQ,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJW,CAAd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sepia.js","names":["fs","uniforms","amount","value","min","max","sepia","name","passes","filter"],"sources":["../../../../src/modules/image-adjust-filters/sepia.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nconst fs = `\\\nuniform float amount;\n\nvec4 sepia_filterColor(vec4 color) {\n float r = color.r;\n float g = color.g;\n float b = color.b;\n\n color.r =\n min(1.0, (r * (1.0 - (0.607 * amount))) + (g * (0.769 * amount)) + (b * (0.189 * amount)));\n color.g = min(1.0, (r * 0.349 * amount) + (g * (1.0 - (0.314 * amount))) + (b * 0.168 * amount));\n color.b = min(1.0, (r * 0.272 * amount) + (g * 0.534 * amount) + (b * (1.0 - (0.869 * amount))));\n\n return color;\n}\n\nvec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n return sepia_filterColor(color);\n}\n`;\n\nconst uniforms = {\n amount: {value: 0.5, min: 0, max: 1}\n};\n\n/** @type {ShaderPass} */\nexport const sepia = {\n name: 'sepia',\n uniforms,\n fs,\n passes: [{filter: true}]\n};\n"],"mappings":";;;;;;AAEA,IAAMA,EAAE,kkBAAR;AAqBA,IAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,GAAG,EAAE;EAA1B;AADO,CAAjB;AAKO,IAAMC,KAAK,GAAG;EACnBC,IAAI,EAAE,OADa;EAEnBN,QAAQ,EAARA,QAFmB;EAGnBD,EAAE,EAAFA,EAHmB;EAInBQ,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJW,CAAd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"vibrance.js","names":["fs","uniforms","amount","value","min","max","vibrance","name","passes","filter"],"sources":["../../../../src/modules/image-adjust-filters/vibrance.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nconst fs = `\\\nuniform float amount;\n\nvec4 vibrance_filterColor(vec4 color) {\n float average = (color.r + color.g + color.b) / 3.0;\n float mx = max(color.r, max(color.g, color.b));\n float amt = (mx - average) * (-amount * 3.0);\n color.rgb = mix(color.rgb, vec3(mx), amt);\n return color;\n}\n\nvec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n return vibrance_filterColor(color);\n}\n`;\n\nconst uniforms = {\n amount: {value: 0, min: -1, max: 1}\n};\n\n/** @type {ShaderPass} */\nexport const vibrance = {\n name: 'vibrance',\n uniforms,\n fs,\n passes: [{filter: true}]\n};\n"],"mappings":";;;;;;AAEA,IAAMA,EAAE,uZAAR;AAgBA,IAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE;IAACC,KAAK,EAAE,CAAR;IAAWC,GAAG,EAAE,CAAC,CAAjB;IAAoBC,GAAG,EAAE;EAAzB;AADO,CAAjB;AAKO,IAAMC,QAAQ,GAAG;EACtBC,IAAI,EAAE,UADgB;EAEtBN,QAAQ,EAARA,QAFsB;EAGtBD,EAAE,EAAFA,EAHsB;EAItBQ,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJc,CAAjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"vignette.js","names":["fs","uniforms","radius","value","min","max","amount","vignette","name","passes","filter"],"sources":["../../../../src/modules/image-adjust-filters/vignette.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\n\nconst fs = `\\\nuniform float radius;\nuniform float amount;\n\nvec4 vignette_filterColor(vec4 color, vec2 texCoord) {\n float dist = distance(texCoord, vec2(0.5, 0.5));\n float ratio = smoothstep(0.8, radius * 0.799, dist * (amount + radius));\n return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);\n}\n\nvec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {\n return vignette_filterColor(color, texCoord);\n}\n`;\n\nconst uniforms = {\n radius: {value: 0.5, min: 0, max: 1},\n amount: {value: 0.5, min: 0, max: 1}\n};\n\n/** @type {ShaderPass} */\nexport const vignette = {\n name: 'vignette',\n fs,\n uniforms,\n passes: [{filter: true}]\n};\n"],"mappings":";;;;;;AAEA,IAAMA,EAAE,mbAAR;AAeA,IAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,GAAG,EAAE;EAA1B,CADO;EAEfC,MAAM,EAAE;IAACH,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,GAAG,EAAE;EAA1B;AAFO,CAAjB;AAMO,IAAME,QAAQ,GAAG;EACtBC,IAAI,EAAE,UADgB;EAEtBR,EAAE,EAAFA,EAFsB;EAGtBC,QAAQ,EAARA,QAHsB;EAItBQ,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJc,CAAjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"tiltshift.js","names":["fs","uniforms","blurRadius","value","min","max","gradientRadius","start","end","invert","private","tiltShift","name","dependencies","random","passes","sampler"],"sources":["../../../../src/modules/image-blur-filters/tiltshift.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\nimport {random} from '../utils/random';\n\nconst fs = `\\\nuniform float blurRadius;\nuniform float gradientRadius;\nuniform vec2 start;\nuniform vec2 end;\nuniform bool invert;\n\nvec2 tiltShift_getDelta(vec2 texSize) {\n vec2 vector = normalize((end - start) * texSize);\n return invert ? vec2(-vector.y, vector.x) : vector;\n}\n\nvec4 tiltShift_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec4 color = vec4(0.0);\n float total = 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 vec2 normal = normalize(vec2((start.y - end.y) * texSize.y, (end.x - start.x) * texSize.x));\n float radius = smoothstep(0.0, 1.0,\n abs(dot(texCoord * texSize - start * texSize, normal)) / gradientRadius) * blurRadius;\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 vec4 sample = texture2D(texture, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);\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 blurRadius: {value: 15, min: 0, max: 50},\n gradientRadius: {value: 200, min: 0, max: 400},\n start: [0, 0],\n end: [1, 1],\n invert: {value: false, private: true}\n};\n\n/** @type {ShaderPass} */\nexport const tiltShift = {\n name: 'tiltShift',\n uniforms,\n fs,\n dependencies: [random],\n passes: [{sampler: true, uniforms: {invert: false}}, {sampler: true, uniforms: {invert: true}}]\n};\n\n/*\nfunction tiltShift(startX, startY, endX, endY, blurRadius, gradientRadius) {\n var dx = endX - startX;\n var dy = endY - startY;\n var d = Math.sqrt(dx * dx + dy * dy);\n simpleShader.call(this, gl.tiltShift, {\n blurRadius: blurRadius,\n gradientRadius: gradientRadius,\n start: [startX, startY],\n end: [endX, endY],\n delta: [dx / d, dy / d],\n texSize: [this.width, this.height]\n });\n simpleShader.call(this, gl.tiltShift, {\n blurRadius: blurRadius,\n gradientRadius: gradientRadius,\n start: [startX, startY],\n end: [endX, endY],\n delta: [-dy / d, dx / d],\n texSize: [this.width, this.height]\n });\n\n return this;\n}\n*/\n"],"mappings":";;;;;;;AACA;;AAEA,IAAMA,EAAE,4lCAAR;AA4CA,IAAMC,QAAQ,GAAG;EACfC,UAAU,EAAE;IAACC,KAAK,EAAE,EAAR;IAAYC,GAAG,EAAE,CAAjB;IAAoBC,GAAG,EAAE;EAAzB,CADG;EAEfC,cAAc,EAAE;IAACH,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,GAAG,EAAE;EAA1B,CAFD;EAGfE,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ,CAHQ;EAIfC,GAAG,EAAE,CAAC,CAAD,EAAI,CAAJ,CAJU;EAKfC,MAAM,EAAE;IAACN,KAAK,EAAE,KAAR;IAAeO,OAAO,EAAE;EAAxB;AALO,CAAjB;AASO,IAAMC,SAAS,GAAG;EACvBC,IAAI,EAAE,WADiB;EAEvBX,QAAQ,EAARA,QAFuB;EAGvBD,EAAE,EAAFA,EAHuB;EAIvBa,YAAY,EAAE,CAACC,cAAD,CAJS;EAKvBC,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE,IAAV;IAAgBf,QAAQ,EAAE;MAACQ,MAAM,EAAE;IAAT;EAA1B,CAAD,EAA6C;IAACO,OAAO,EAAE,IAAV;IAAgBf,QAAQ,EAAE;MAACQ,MAAM,EAAE;IAAT;EAA1B,CAA7C;AALe,CAAlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"triangleblur.js","names":["fs","uniforms","radius","value","min","softMax","delta","private","triangleBlur","name","dependencies","random","passes","sampler"],"sources":["../../../../src/modules/image-blur-filters/triangleblur.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderPass} ShaderPass */\nimport {random} from '../utils/random';\n\nconst fs = `\\\nuniform float radius;\nuniform vec2 delta;\n\nvec4 triangleBlur_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {\n vec2 adjustedDelta = delta * radius / texSize;\n\n vec4 color = vec4(0.0);\n float total = 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 vec4 sample = texture2D(texture, texCoord + adjustedDelta * percent);\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 radius: {value: 20, min: 0, softMax: 100},\n delta: {value: [1, 0], private: true}\n};\n\n/** @type {ShaderPass} */\nexport const triangleBlur = {\n name: 'triangleBlur',\n uniforms,\n fs,\n dependencies: [random],\n passes: [{sampler: true, uniforms: {delta: [1, 0]}}, {sampler: true, uniforms: {delta: [0, 1]}}]\n};\n"],"mappings":";;;;;;;AACA;;AAEA,IAAMA,EAAE,uqBAAR;AAkCA,IAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE;IAACC,KAAK,EAAE,EAAR;IAAYC,GAAG,EAAE,CAAjB;IAAoBC,OAAO,EAAE;EAA7B,CADO;EAEfC,KAAK,EAAE;IAACH,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ,CAAR;IAAgBI,OAAO,EAAE;EAAzB;AAFQ,CAAjB;AAMO,IAAMC,YAAY,GAAG;EAC1BC,IAAI,EAAE,cADoB;EAE1BR,QAAQ,EAARA,QAF0B;EAG1BD,EAAE,EAAFA,EAH0B;EAI1BU,YAAY,EAAE,CAACC,cAAD,CAJY;EAK1BC,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE,IAAV;IAAgBZ,QAAQ,EAAE;MAACK,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;IAAR;EAA1B,CAAD,EAA6C;IAACO,OAAO,EAAE,IAAV;IAAgBZ,QAAQ,EAAE;MAACK,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;IAAR;EAA1B,CAA7C;AALkB,CAArB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"zoomblur.js","names":["fs","uniforms","center","strength","value","min","softMax","zoomBlur","name","dependencies","random","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;;AAEA,IAAMA,EAAE,usBAAR;AAiCA,IAAMC,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;AAMO,IAAMC,QAAQ,GAAG;EACtBC,IAAI,EAAE,UADgB;EAEtBP,QAAQ,EAARA,QAFsB;EAGtBD,EAAE,EAAFA,EAHsB;EAItBS,YAAY,EAAE,CAACC,cAAD,CAJQ;EAKtBC,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AALc,CAAjB"}
|
|
@@ -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,IAAMA,EAAE,q5BAAR;AAmCA,IAAMC,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;AAOO,IAAMK,aAAa,GAAG;EAC3BC,IAAI,EAAE,eADqB;EAE3BX,QAAQ,EAARA,QAF2B;EAG3BD,EAAE,EAAFA,EAH2B;EAI3Ba,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJmB,CAAtB"}
|
|
@@ -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,IAAMA,EAAE,ylBAAR;AAuBA,IAAMC,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;AAOO,IAAMK,SAAS,GAAG;EACvBC,IAAI,EAAE,WADiB;EAEvBX,QAAQ,EAARA,QAFuB;EAGvBD,EAAE,EAAFA,EAHuB;EAIvBa,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJe,CAAlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"edgework.js","names":["fs","uniforms","radius","value","min","softMax","delta","private","edgeWork","name","dependencies","random","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;;AAEA,IAAMA,EAAE,klDAAR;AAuDA,IAAMC,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;AAMO,IAAMC,QAAQ,GAAG;EACtBC,IAAI,EAAE,UADgB;EAEtBR,QAAQ,EAARA,QAFsB;EAGtBD,EAAE,EAAFA,EAHsB;EAItBU,YAAY,EAAE,CAACC,cAAD,CAJQ;EAKtBC,MAAM,EAAE,CACN;IACEC,OAAO,EAAE,uBADX;IAEEZ,QAAQ,EAAE;MAACK,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;IAAR;EAFZ,CADM,EAKN;IACEO,OAAO,EAAE,uBADX;IAEEZ,QAAQ,EAAE;MAACK,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;IAAR;EAFZ,CALM;AALc,CAAjB"}
|
|
@@ -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,IAAMA,EAAE,slCAAR;AA2CA,IAAMC,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;AAMO,IAAMC,iBAAiB,GAAG;EAC/BC,IAAI,EAAE,mBADyB;EAE/BT,QAAQ,EAARA,QAF+B;EAG/BD,EAAE,EAAFA,EAH+B;EAI/BW,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AAJuB,CAA1B"}
|
|
@@ -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,IAAMA,EAAE,q5BAAR;AA4BA,IAAMC,QAAQ,GAAG;EACfC,QAAQ,EAAE;IAACC,KAAK,EAAE,IAAR;IAAcC,GAAG,EAAE,CAAnB;IAAsBC,OAAO,EAAE;EAA/B;AADK,CAAjB;AAKO,IAAMC,GAAG,GAAG;EACjBC,IAAI,EAAE,KADW;EAEjBN,QAAQ,EAARA,QAFiB;EAGjBD,EAAE,EAAFA,EAHiB;EAIjBQ,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AAJS,CAAZ"}
|
|
@@ -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,IAAMA,EAAE,yiBAAR;AAqBA,IAAMC,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;AASO,IAAMC,OAAO,GAAG;EACrBC,IAAI,EAAE,SADe;EAErBP,QAAQ,EAARA,QAFqB;EAGrBD,EAAE,EAAFA,EAHqB;EAIrBS,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AAJa,CAAhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"bulgepinch.js","names":["fs","uniforms","center","radius","value","min","softMax","strength","max","bulgePinch","name","dependencies","warp","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;;AAEA,IAAMA,EAAE,6vBAAR;AA4BA,IAAMC,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;AAOO,IAAMC,UAAU,GAAG;EACxBC,IAAI,EAAE,YADkB;EAExBV,EAAE,EAAFA,EAFwB;EAGxBC,QAAQ,EAARA,QAHwB;EAIxBU,YAAY,EAAE,CAACC,UAAD,CAJU;EAKxBC,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AALgB,CAAnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"swirl.js","names":["fs","uniforms","center","radius","value","min","softMax","angle","softMin","swirl","name","dependencies","warp","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;;AAEA,IAAMA,EAAE,8sBAAR;AA8BA,IAAMC,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;AAOO,IAAMG,KAAK,GAAG;EACnBC,IAAI,EAAE,OADa;EAEnBV,EAAE,EAAFA,EAFmB;EAGnBC,QAAQ,EAARA,QAHmB;EAInBU,YAAY,EAAE,CAACC,UAAD,CAJK;EAKnBC,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AALW,CAAd"}
|
|
@@ -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,IAAMA,EAAE,kTAAR;AAcO,IAAMC,IAAI,GAAG;EAClBC,IAAI,EAAE,MADY;EAElBF,EAAE,EAAFA;AAFkB,CAAb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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;;AAGA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AAGA;;AAGA"}
|
|
@@ -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":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"lights.js","names":["INITIAL_MODULE_OPTIONS","lightSources","convertColor","color","intensity","map","component","getLightSourceUniforms","ambientLight","pointLights","directionalLights","lightSourceUniforms","forEach","pointLight","index","position","attenuation","lighting_uPointLightCount","length","directionalLight","direction","lighting_uDirectionalLightCount","getUniforms","opts","hasLights","lighting_uEnabled","Object","assign","lights","light","type","push","name","vs","lightingShader","fs","defines","MAX_LIGHTS"],"sources":["../../../../src/modules/lights/lights.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nimport lightingShader from './lights.glsl';\n\nconst INITIAL_MODULE_OPTIONS = {\n lightSources: {}\n};\n\n// Take color 0-255 and intensity as input and output 0.0-1.0 range\nfunction convertColor({color = [0, 0, 0], intensity = 1.0} = {}) {\n return color.map(component => (component * intensity) / 255.0);\n}\n\nfunction getLightSourceUniforms({ambientLight, pointLights = [], directionalLights = []}) {\n const lightSourceUniforms = {};\n\n if (ambientLight) {\n lightSourceUniforms['lighting_uAmbientLight.color'] = convertColor(ambientLight);\n } else {\n lightSourceUniforms['lighting_uAmbientLight.color'] = [0, 0, 0];\n }\n\n pointLights.forEach((pointLight, index) => {\n lightSourceUniforms[`lighting_uPointLight[${index}].color`] = convertColor(pointLight);\n lightSourceUniforms[`lighting_uPointLight[${index}].position`] = pointLight.position;\n lightSourceUniforms[`lighting_uPointLight[${index}].attenuation`] = pointLight.attenuation || [\n 1,\n 0,\n 0\n ];\n });\n lightSourceUniforms.lighting_uPointLightCount = pointLights.length;\n\n directionalLights.forEach((directionalLight, index) => {\n lightSourceUniforms[`lighting_uDirectionalLight[${index}].color`] = convertColor(\n directionalLight\n );\n lightSourceUniforms[`lighting_uDirectionalLight[${index}].direction`] =\n directionalLight.direction;\n });\n lightSourceUniforms.lighting_uDirectionalLightCount = directionalLights.length;\n\n return lightSourceUniforms;\n}\n\n// eslint-disable-next-line complexity\nfunction getUniforms(opts = INITIAL_MODULE_OPTIONS) {\n // Specify lights separately\n if ('lightSources' in opts) {\n const {ambientLight, pointLights, directionalLights} = opts.lightSources || {};\n const hasLights =\n ambientLight ||\n (pointLights && pointLights.length > 0) ||\n (directionalLights && directionalLights.length > 0);\n\n if (!hasLights) {\n return {lighting_uEnabled: false};\n }\n\n return Object.assign(\n {},\n getLightSourceUniforms({ambientLight, pointLights, directionalLights}),\n {\n lighting_uEnabled: true\n }\n );\n }\n\n // Support for array of lights. Type of light is detected by type field\n if ('lights' in opts) {\n const lightSources = {pointLights: [], directionalLights: []};\n // @ts-ignore\n for (const light of opts.lights || []) {\n switch (light.type) {\n case 'ambient':\n // Note: Only uses last ambient light\n // TODO - add ambient light sources on CPU?\n lightSources.ambientLight = light;\n break;\n case 'directional':\n lightSources.directionalLights.push(light);\n break;\n case 'point':\n lightSources.pointLights.push(light);\n break;\n default:\n // eslint-disable-next-line\n // console.warn(light.type);\n }\n }\n\n // Call the `opts.lightSources`` version\n return getUniforms({lightSources});\n }\n\n return {};\n}\n\n/** @type {ShaderModule} */\nexport const lights = {\n name: 'lights',\n vs: lightingShader,\n fs: lightingShader,\n getUniforms,\n defines: {\n MAX_LIGHTS: 3\n }\n};\n"],"mappings":";;;;;;;;;AAEA;;;;;;;;AAEA,IAAMA,sBAAsB,GAAG;EAC7BC,YAAY,EAAE;AADe,CAA/B;;AAKA,SAASC,YAAT,GAAiE;EAAA,+EAAJ,EAAI;EAAA,sBAA1CC,KAA0C;EAAA,IAA1CA,KAA0C,2BAAlC,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAkC;EAAA,0BAAvBC,SAAuB;EAAA,IAAvBA,SAAuB,+BAAX,GAAW;;EAC/D,OAAOD,KAAK,CAACE,GAAN,CAAU,UAAAC,SAAS;IAAA,OAAKA,SAAS,GAAGF,SAAb,GAA0B,KAA9B;EAAA,CAAnB,CAAP;AACD;;AAED,SAASG,sBAAT,QAA0F;EAAA,IAAzDC,YAAyD,SAAzDA,YAAyD;EAAA,8BAA3CC,WAA2C;EAAA,IAA3CA,WAA2C,kCAA7B,EAA6B;EAAA,kCAAzBC,iBAAyB;EAAA,IAAzBA,iBAAyB,sCAAL,EAAK;EACxF,IAAMC,mBAAmB,GAAG,EAA5B;;EAEA,IAAIH,YAAJ,EAAkB;IAChBG,mBAAmB,CAAC,8BAAD,CAAnB,GAAsDT,YAAY,CAACM,YAAD,CAAlE;EACD,CAFD,MAEO;IACLG,mBAAmB,CAAC,8BAAD,CAAnB,GAAsD,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAtD;EACD;;EAEDF,WAAW,CAACG,OAAZ,CAAoB,UAACC,UAAD,EAAaC,KAAb,EAAuB;IACzCH,mBAAmB,gCAAyBG,KAAzB,aAAnB,GAA8DZ,YAAY,CAACW,UAAD,CAA1E;IACAF,mBAAmB,gCAAyBG,KAAzB,gBAAnB,GAAiED,UAAU,CAACE,QAA5E;IACAJ,mBAAmB,gCAAyBG,KAAzB,mBAAnB,GAAoED,UAAU,CAACG,WAAX,IAA0B,CAC5F,CAD4F,EAE5F,CAF4F,EAG5F,CAH4F,CAA9F;EAKD,CARD;EASAL,mBAAmB,CAACM,yBAApB,GAAgDR,WAAW,CAACS,MAA5D;EAEAR,iBAAiB,CAACE,OAAlB,CAA0B,UAACO,gBAAD,EAAmBL,KAAnB,EAA6B;IACrDH,mBAAmB,sCAA+BG,KAA/B,aAAnB,GAAoEZ,YAAY,CAC9EiB,gBAD8E,CAAhF;IAGAR,mBAAmB,sCAA+BG,KAA/B,iBAAnB,GACEK,gBAAgB,CAACC,SADnB;EAED,CAND;EAOAT,mBAAmB,CAACU,+BAApB,GAAsDX,iBAAiB,CAACQ,MAAxE;EAEA,OAAOP,mBAAP;AACD;;AAGD,SAASW,WAAT,GAAoD;EAAA,IAA/BC,IAA+B,uEAAxBvB,sBAAwB;;EAElD,IAAI,kBAAkBuB,IAAtB,EAA4B;IAC1B,YAAuDA,IAAI,CAACtB,YAAL,IAAqB,EAA5E;IAAA,IAAOO,YAAP,SAAOA,YAAP;IAAA,IAAqBC,WAArB,SAAqBA,WAArB;IAAA,IAAkCC,iBAAlC,SAAkCA,iBAAlC;;IACA,IAAMc,SAAS,GACbhB,YAAY,IACXC,WAAW,IAAIA,WAAW,CAACS,MAAZ,GAAqB,CADrC,IAECR,iBAAiB,IAAIA,iBAAiB,CAACQ,MAAlB,GAA2B,CAHnD;;IAKA,IAAI,CAACM,SAAL,EAAgB;MACd,OAAO;QAACC,iBAAiB,EAAE;MAApB,CAAP;IACD;;IAED,OAAOC,MAAM,CAACC,MAAP,CACL,EADK,EAELpB,sBAAsB,CAAC;MAACC,YAAY,EAAZA,YAAD;MAAeC,WAAW,EAAXA,WAAf;MAA4BC,iBAAiB,EAAjBA;IAA5B,CAAD,CAFjB,EAGL;MACEe,iBAAiB,EAAE;IADrB,CAHK,CAAP;EAOD;;EAGD,IAAI,YAAYF,IAAhB,EAAsB;IACpB,IAAMtB,YAAY,GAAG;MAACQ,WAAW,EAAE,EAAd;MAAkBC,iBAAiB,EAAE;IAArC,CAArB;;IADoB,2CAGAa,IAAI,CAACK,MAAL,IAAe,EAHf;IAAA;;IAAA;MAGpB,oDAAuC;QAAA,IAA5BC,KAA4B;;QACrC,QAAQA,KAAK,CAACC,IAAd;UACE,KAAK,SAAL;YAGE7B,YAAY,CAACO,YAAb,GAA4BqB,KAA5B;YACA;;UACF,KAAK,aAAL;YACE5B,YAAY,CAACS,iBAAb,CAA+BqB,IAA/B,CAAoCF,KAApC;YACA;;UACF,KAAK,OAAL;YACE5B,YAAY,CAACQ,WAAb,CAAyBsB,IAAzB,CAA8BF,KAA9B;YACA;;UACF;QAZF;MAgBD;IApBmB;MAAA;IAAA;MAAA;IAAA;;IAuBpB,OAAOP,WAAW,CAAC;MAACrB,YAAY,EAAZA;IAAD,CAAD,CAAlB;EACD;;EAED,OAAO,EAAP;AACD;;AAGM,IAAM2B,MAAM,GAAG;EACpBI,IAAI,EAAE,QADc;EAEpBC,EAAE,EAAEC,eAFgB;EAGpBC,EAAE,EAAED,eAHgB;EAIpBZ,WAAW,EAAXA,WAJoB;EAKpBc,OAAO,EAAE;IACPC,UAAU,EAAE;EADL;AALW,CAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"module-injectors.js","names":["MODULE_INJECTORS_VS","MODULE_INJECTORS_FS"],"sources":["../../../src/modules/module-injectors.js"],"sourcesContent":["export const MODULE_INJECTORS_VS = `\\\n#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n`;\n\nexport const MODULE_INJECTORS_FS = `\\\n#ifdef MODULE_MATERIAL\n gl_FragColor = material_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n gl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_FOG\n gl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_PICKING\n gl_FragColor = picking_filterHighlightColor(gl_FragColor);\n gl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n`;\n"],"mappings":";;;;;;AAAO,IAAMA,mBAAmB,8EAAzB;;AAMA,IAAMC,mBAAmB,0dAAzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"pbr-fragment.glsl.js"}
|
|
1
|
+
{"version":3,"file":"pbr-fragment.glsl.js","names":[],"sources":["../../../../src/modules/pbr/pbr-fragment.glsl.js"],"sourcesContent":["// This fragment shader defines a reference implementation for Physically Based Shading of\n// a microfacet surface material defined by a glTF model.\n//\n// Attribution:\n// MIT license, Copyright (c) 2016-2017 Mohamad Moneimne and Contributors\n\n// TODO - better do the checks outside of shader\nexport default `\\\n#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)\n# error PBR fragment shader: Texture LOD is not available\n#endif\n\n#if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)\n# error PBR fragment shader: Derivatives are not available\n#endif\n\n// WebGL 1.0 does not support non-constant in for loops\n// This provides an easy way to handle these cases\n// and still take advantage of WebGL 2.0\n#if (__VERSION__ < 300)\n #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)\n#else\n #define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)\n#endif\n\nprecision highp float;\n\nuniform bool pbr_uUnlit;\n\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\n\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\n\nuniform vec3 u_Camera;\n\n// debugging flags used for shader output of intermediate PBR variables\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\n\nvarying vec3 pbr_vPosition;\n\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n#else\nvarying vec3 pbr_vNormal;\n#endif\n#endif\n\n// Encapsulate the various inputs used by the various functions in the shading equation\n// We store values in this struct to simplify the integration of alternative implementations\n// of the shading terms, outlined in the Readme.MD Appendix.\nstruct PBRInfo\n{\n float NdotL; // cos angle between normal and light direction\n float NdotV; // cos angle between normal and view direction\n float NdotH; // cos angle between normal and half vector\n float LdotH; // cos angle between light direction and half vector\n float VdotH; // cos angle between view direction and half vector\n float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)\n float metalness; // metallic value at the surface\n vec3 reflectance0; // full reflectance color (normal incidence angle)\n vec3 reflectance90; // reflectance color at grazing angle\n float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])\n vec3 diffuseColor; // color contribution from diffuse lighting\n vec3 specularColor; // color contribution from specular lighting\n vec3 n; // normal at surface point\n vec3 v; // vector from surface point to camera\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\n vec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else //SRGB_FAST_APPROXIMATION\n vec3 bLess = step(vec3(0.04045),srgbIn.xyz);\n vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif //SRGB_FAST_APPROXIMATION\n return vec4(linOut,srgbIn.w);;\n#else //MANUAL_SRGB\n return srgbIn;\n#endif //MANUAL_SRGB\n}\n\n// Find the normal for this fragment, pulling either from a predefined normal map\n// or from the interpolated mesh normal and tangent attributes.\nvec3 getNormal()\n{\n // Retrieve the tangent space matrix\n#ifndef HAS_TANGENTS\n vec3 pos_dx = dFdx(pbr_vPosition);\n vec3 pos_dy = dFdy(pbr_vPosition);\n vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\n vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));\n vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n\n#ifdef HAS_NORMALS\n vec3 ng = normalize(pbr_vNormal);\n#else\n vec3 ng = cross(pos_dx, pos_dy);\n#endif\n\n t = normalize(t - ng * dot(ng, t));\n vec3 b = normalize(cross(ng, t));\n mat3 tbn = mat3(t, b, ng);\n#else // HAS_TANGENTS\n mat3 tbn = pbr_vTBN;\n#endif\n\n#ifdef HAS_NORMALMAP\n vec3 n = texture2D(u_NormalSampler, pbr_vUV).rgb;\n n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\n#else\n // The tbn matrix is linearly interpolated, so we need to re-normalize\n vec3 n = normalize(tbn[2].xyz);\n#endif\n\n return n;\n}\n\n// Calculation of the lighting contribution from an optional Image Based Light source.\n// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].\n// See our README.md on Environment Maps [3] for additional discussion.\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)\n{\n float mipCount = 9.0; // resolution of 512x512\n float lod = (pbrInputs.perceptualRoughness * mipCount);\n // retrieve a scale and bias to F0. See [1], Figure 3\n vec3 brdf = SRGBtoLINEAR(texture2D(u_brdfLUT,\n vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n\n#ifdef USE_TEX_LOD\n vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\n vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\n\n vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\n vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\n\n // For presentation, this allows us to disable IBL terms\n diffuse *= u_ScaleIBLAmbient.x;\n specular *= u_ScaleIBLAmbient.y;\n\n return diffuse + specular;\n}\n#endif\n\n// Basic Lambertian diffuse\n// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog\n// See also [1], Equation 1\nvec3 diffuse(PBRInfo pbrInputs)\n{\n return pbrInputs.diffuseColor / M_PI;\n}\n\n// The following equation models the Fresnel reflectance term of the spec equation (aka F())\n// Implementation of fresnel from [4], Equation 15\nvec3 specularReflection(PBRInfo pbrInputs)\n{\n return pbrInputs.reflectance0 +\n (pbrInputs.reflectance90 - pbrInputs.reflectance0) *\n pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);\n}\n\n// This calculates the specular geometric attenuation (aka G()),\n// where rougher material will reflect less light back to the viewer.\n// This implementation is based on [1] Equation 4, and we adopt their modifications to\n// alphaRoughness as input as originally proposed in [2].\nfloat geometricOcclusion(PBRInfo pbrInputs)\n{\n float NdotL = pbrInputs.NdotL;\n float NdotV = pbrInputs.NdotV;\n float r = pbrInputs.alphaRoughness;\n\n float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n return attenuationL * attenuationV;\n}\n\n// The following equation(s) model the distribution of microfacet normals across\n// the area being drawn (aka D())\n// Implementation from \"Average Irregularity Representation of a Roughened Surface\n// for Ray Reflection\" by T. S. Trowbridge, and K. P. Reitz\n// Follows the distribution function recommended in the SIGGRAPH 2013 course notes\n// from EPIC Games [1], Equation 3.\nfloat microfacetDistribution(PBRInfo pbrInputs)\n{\n float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\n float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\n pbrInputs.NdotL = 1.0;\n pbrInputs.NdotH = 0.0;\n pbrInputs.LdotH = 0.0;\n pbrInputs.VdotH = 1.0;\n}\n\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\n vec3 n = pbrInputs.n;\n vec3 v = pbrInputs.v;\n vec3 l = normalize(lightDirection); // Vector from surface point to light\n vec3 h = normalize(l+v); // Half vector between both l and v\n\n pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\n pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\n pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\n pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\n vec3 light_direction = normalize(pointLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\n // Calculate the shading terms for the microfacet specular shading model\n vec3 F = specularReflection(pbrInputs);\n float G = geometricOcclusion(pbrInputs);\n float D = microfacetDistribution(pbrInputs);\n\n // Calculation of analytical lighting contribution\n vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\n vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\n // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)\n return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n // The albedo may be defined from a base texture or a flat color\n#ifdef HAS_BASECOLORMAP\n vec4 baseColor = SRGBtoLINEAR(texture2D(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\n vec4 baseColor = u_BaseColorFactor;\n#endif\n\n#ifdef ALPHA_CUTOFF\n if (baseColor.a < u_AlphaCutoff) {\n discard;\n }\n#endif\n\n vec3 color = vec3(0, 0, 0);\n\n if(pbr_uUnlit){\n color.rgb = baseColor.rgb;\n }\n else{\n // Metallic and Roughness material properties are packed together\n // In glTF, these factors can be specified by fixed scalar values\n // or from a metallic-roughness map\n float perceptualRoughness = u_MetallicRoughnessValues.y;\n float metallic = u_MetallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\n // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.\n // This layout intentionally reserves the 'r' channel for (optional) occlusion map data\n vec4 mrSample = texture2D(u_MetallicRoughnessSampler, pbr_vUV);\n perceptualRoughness = mrSample.g * perceptualRoughness;\n metallic = mrSample.b * metallic;\n#endif\n perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n metallic = clamp(metallic, 0.0, 1.0);\n // Roughness is authored as perceptual roughness; as is convention,\n // convert to material roughness by squaring the perceptual roughness [2].\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n vec3 f0 = vec3(0.04);\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n diffuseColor *= 1.0 - metallic;\n vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n\n // Compute reflectance.\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n // For typical incident reflectance range (between 4% to 100%) set the grazing\n // reflectance to 100% for typical fresnel effect.\n // For very low reflectance range on highly diffuse objects (below 4%),\n // incrementally reduce grazing reflecance to 0%.\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n\n vec3 n = getNormal(); // normal at surface point\n vec3 v = normalize(u_Camera - pbr_vPosition); // Vector from surface point to camera\n\n float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInputs = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v\n );\n\n#ifdef USE_LIGHTS\n // Apply ambient light\n PBRInfo_setAmbientLight(pbrInputs);\n color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\n\n // Apply directional light\n SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uDirectionalLightCount, i++) {\n if (i < lighting_uDirectionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\n color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n }\n }\n\n // Apply point light\n SMART_FOR(int i = 0, i < MAX_LIGHTS, i < lighting_uPointLightCount, i++) {\n if (i < lighting_uPointLightCount) {\n PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\n float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\n color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n }\n }\n#endif\n\n // Calculate lighting contribution from image based lighting source (IBL)\n#ifdef USE_IBL\n color += getIBLContribution(pbrInputs, n, reflection);\n#endif\n\n // Apply optional PBR terms for additional (optional) shading\n#ifdef HAS_OCCLUSIONMAP\n float ao = texture2D(u_OcclusionSampler, pbr_vUV).r;\n color = mix(color, color * ao, u_OcclusionStrength);\n#endif\n\n#ifdef HAS_EMISSIVEMAP\n vec3 emissive = SRGBtoLINEAR(texture2D(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\n color += emissive;\n#endif\n\n // This section uses mix to override final color for reference app visualization\n // of various parameters in the lighting equation.\n#ifdef PBR_DEBUG\n // TODO: Figure out how to debug multiple lights\n\n // color = mix(color, F, u_ScaleFGDSpec.x);\n // color = mix(color, vec3(G), u_ScaleFGDSpec.y);\n // color = mix(color, vec3(D), u_ScaleFGDSpec.z);\n // color = mix(color, specContrib, u_ScaleFGDSpec.w);\n\n // color = mix(color, diffuseContrib, u_ScaleDiffBaseMR.x);\n color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n\n }\n\n return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n`;\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"pbr-vertex.glsl.js","names":[],"sources":["../../../../src/modules/pbr/pbr-vertex.glsl.js"],"sourcesContent":["export default `\\\nuniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\n\nvarying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else // HAS_TANGENTS != 1\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n`;\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"pbr.js","names":["pbr","name","vs","fs","defines","LIGHTING_FRAGMENT","dependencies","lights"],"sources":["../../../../src/modules/pbr/pbr.js"],"sourcesContent":["/** @typedef {import('../../types').ShaderModule} ShaderModule */\n\nimport {lights} from '../lights/lights';\n\nimport vs from './pbr-vertex.glsl';\nimport fs from './pbr-fragment.glsl';\n\n/**\n * @type {ShaderModule}\n * PBR lighting shader module\n */\nexport const pbr = {\n name: 'pbr',\n vs,\n fs,\n defines: {\n LIGHTING_FRAGMENT: 1\n },\n dependencies: [lights]\n};\n"],"mappings":";;;;;;;;;AAEA;;AAEA;;AACA;;AAMO,IAAMA,GAAG,GAAG;EACjBC,IAAI,EAAE,KADW;EAEjBC,EAAE,EAAFA,kBAFiB;EAGjBC,EAAE,EAAFA,oBAHiB;EAIjBC,OAAO,EAAE;IACPC,iBAAiB,EAAE;EADZ,CAJQ;EAOjBC,YAAY,EAAE,CAACC,cAAD;AAPG,CAAZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"phong-lighting.glsl.js","names":[],"sources":["../../../../src/modules/phong-lighting/phong-lighting.glsl.js"],"sourcesContent":["export default `\\\n\nuniform float lighting_uAmbient;\nuniform float lighting_uDiffuse;\nuniform float lighting_uShininess;\nuniform vec3 lighting_uSpecularColor;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, lighting_uShininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting_uEnabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uPointLightCount) {\n break;\n }\n PointLight pointLight = lighting_uPointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uDirectionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = vec3(0, 0, 0);\n vec3 surfaceColor = vec3(0, 0, 0);\n\n if (lighting_uEnabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uPointLightCount) {\n break;\n }\n PointLight pointLight = lighting_uPointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting_uDirectionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting_uDirectionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n`;\n"],"mappings":""}
|