@luma.gl/shadertools 8.5.15 → 8.5.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.js +25 -25
- package/dist/dist.min.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/index.js +10 -10
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/assemble-shaders.js +6 -2
- package/dist/es5/lib/assemble-shaders.js.map +1 -1
- package/dist/es5/lib/constants.js +1 -1
- package/dist/es5/lib/constants.js.map +1 -1
- package/dist/es5/lib/filters/prop-types.js.map +1 -1
- package/dist/es5/lib/inject-shader.js +2 -2
- package/dist/es5/lib/inject-shader.js.map +1 -1
- package/dist/es5/lib/platform-defines.js.map +1 -1
- package/dist/es5/lib/resolve-modules.js +2 -2
- package/dist/es5/lib/resolve-modules.js.map +1 -1
- package/dist/es5/lib/shader-module.js +1 -1
- package/dist/es5/lib/shader-module.js.map +1 -1
- package/dist/es5/lib/transpile-shader.js +1 -1
- package/dist/es5/lib/transpile-shader.js.map +1 -1
- package/dist/es5/modules/dirlight/dirlight.js.map +1 -1
- package/dist/es5/modules/fp32/fp32.js.map +1 -1
- package/dist/es5/modules/fp64/fp64-arithmetic.glsl.js.map +1 -1
- package/dist/es5/modules/fp64/fp64-functions.glsl.js.map +1 -1
- package/dist/es5/modules/fp64/fp64-utils.js +1 -1
- package/dist/es5/modules/fp64/fp64-utils.js.map +1 -1
- package/dist/es5/modules/fp64/fp64.js +6 -5
- package/dist/es5/modules/fp64/fp64.js.map +1 -1
- package/dist/es5/modules/fxaa/fxaa.js.map +1 -1
- package/dist/es5/modules/geometry/geometry.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/denoise.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/noise.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/sepia.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/es5/modules/image-adjust-filters/vignette.js.map +1 -1
- package/dist/es5/modules/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/es5/modules/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/es5/modules/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/dotscreen.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/edgework.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/ink.js.map +1 -1
- package/dist/es5/modules/image-fun-filters/magnify.js.map +1 -1
- package/dist/es5/modules/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/es5/modules/image-warp-filters/swirl.js.map +1 -1
- package/dist/es5/modules/image-warp-filters/warp.js.map +1 -1
- package/dist/es5/modules/index.js +62 -62
- package/dist/es5/modules/index.js.map +1 -1
- package/dist/es5/modules/lights/lights.glsl.js.map +1 -1
- package/dist/es5/modules/lights/lights.js +1 -1
- package/dist/es5/modules/lights/lights.js.map +1 -1
- package/dist/es5/modules/module-injectors.js +1 -1
- package/dist/es5/modules/module-injectors.js.map +1 -1
- package/dist/es5/modules/pbr/pbr-fragment.glsl.js.map +1 -1
- package/dist/es5/modules/pbr/pbr-vertex.glsl.js.map +1 -1
- package/dist/es5/modules/pbr/pbr.js.map +1 -1
- package/dist/es5/modules/phong-lighting/phong-lighting.glsl.js.map +1 -1
- package/dist/es5/modules/phong-lighting/phong-lighting.js.map +1 -1
- package/dist/es5/modules/picking/picking.js.map +1 -1
- package/dist/es5/modules/project/project.js.map +1 -1
- package/dist/es5/modules/transform/transform.js.map +1 -1
- package/dist/es5/modules/utils/random.js.map +1 -1
- package/dist/es5/utils/assert.js.map +1 -1
- package/dist/es5/utils/index.js.map +1 -1
- package/dist/es5/utils/is-old-ie.js.map +1 -1
- package/dist/es5/utils/shader-utils.js +3 -3
- package/dist/es5/utils/shader-utils.js.map +1 -1
- package/dist/es5/utils/webgl-info.js +2 -2
- package/dist/es5/utils/webgl-info.js.map +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/assemble-shaders.js +38 -51
- package/dist/esm/lib/assemble-shaders.js.map +1 -1
- package/dist/esm/lib/constants.js.map +1 -1
- package/dist/esm/lib/filters/prop-types.js.map +1 -1
- package/dist/esm/lib/inject-shader.js +4 -3
- package/dist/esm/lib/inject-shader.js.map +1 -1
- package/dist/esm/lib/platform-defines.js +9 -80
- package/dist/esm/lib/platform-defines.js.map +1 -1
- package/dist/esm/lib/resolve-modules.js +9 -7
- package/dist/esm/lib/resolve-modules.js.map +1 -1
- package/dist/esm/lib/shader-module.js +20 -23
- package/dist/esm/lib/shader-module.js.map +1 -1
- package/dist/esm/lib/transpile-shader.js +5 -5
- package/dist/esm/lib/transpile-shader.js.map +1 -1
- package/dist/esm/modules/dirlight/dirlight.js +3 -9
- package/dist/esm/modules/dirlight/dirlight.js.map +1 -1
- package/dist/esm/modules/fp32/fp32.js +1 -148
- package/dist/esm/modules/fp32/fp32.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-arithmetic.glsl.js +1 -143
- package/dist/esm/modules/fp64/fp64-arithmetic.glsl.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-functions.glsl.js +1 -630
- package/dist/esm/modules/fp64/fp64-functions.glsl.js.map +1 -1
- package/dist/esm/modules/fp64/fp64-utils.js +3 -1
- package/dist/esm/modules/fp64/fp64-utils.js.map +1 -1
- package/dist/esm/modules/fp64/fp64.js.map +1 -1
- package/dist/esm/modules/fxaa/fxaa.js +1 -535
- package/dist/esm/modules/fxaa/fxaa.js.map +1 -1
- package/dist/esm/modules/geometry/geometry.js +2 -28
- package/dist/esm/modules/geometry/geometry.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/brightnesscontrast.js +1 -18
- package/dist/esm/modules/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/denoise.js +1 -22
- package/dist/esm/modules/image-adjust-filters/denoise.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/huesaturation.js +1 -28
- package/dist/esm/modules/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/noise.js +1 -19
- package/dist/esm/modules/image-adjust-filters/noise.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/sepia.js +1 -20
- package/dist/esm/modules/image-adjust-filters/sepia.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/vibrance.js +1 -15
- package/dist/esm/modules/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/esm/modules/image-adjust-filters/vignette.js +1 -14
- package/dist/esm/modules/image-adjust-filters/vignette.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/tiltshift.js +1 -37
- package/dist/esm/modules/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/triangleblur.js +1 -27
- package/dist/esm/modules/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/esm/modules/image-blur-filters/zoomblur.js +1 -26
- package/dist/esm/modules/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/colorhalftone.js +1 -34
- package/dist/esm/modules/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/dotscreen.js +1 -22
- package/dist/esm/modules/image-fun-filters/dotscreen.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/edgework.js +1 -50
- package/dist/esm/modules/image-fun-filters/edgework.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/hexagonalpixelate.js +1 -42
- package/dist/esm/modules/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/ink.js +1 -27
- package/dist/esm/modules/image-fun-filters/ink.js.map +1 -1
- package/dist/esm/modules/image-fun-filters/magnify.js +1 -20
- package/dist/esm/modules/image-fun-filters/magnify.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/bulgepinch.js +1 -27
- package/dist/esm/modules/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/swirl.js +1 -29
- package/dist/esm/modules/image-warp-filters/swirl.js.map +1 -1
- package/dist/esm/modules/image-warp-filters/warp.js +1 -11
- package/dist/esm/modules/image-warp-filters/warp.js.map +1 -1
- package/dist/esm/modules/index.js.map +1 -1
- package/dist/esm/modules/lights/lights.glsl.js +1 -34
- package/dist/esm/modules/lights/lights.glsl.js.map +1 -1
- package/dist/esm/modules/lights/lights.js +19 -15
- package/dist/esm/modules/lights/lights.js.map +1 -1
- package/dist/esm/modules/module-injectors.js +2 -27
- package/dist/esm/modules/module-injectors.js.map +1 -1
- package/dist/esm/modules/pbr/pbr-fragment.glsl.js +1 -351
- package/dist/esm/modules/pbr/pbr-fragment.glsl.js.map +1 -1
- package/dist/esm/modules/pbr/pbr-vertex.glsl.js +1 -39
- package/dist/esm/modules/pbr/pbr-vertex.glsl.js.map +1 -1
- package/dist/esm/modules/pbr/pbr.js.map +1 -1
- package/dist/esm/modules/phong-lighting/phong-lighting.glsl.js +1 -75
- package/dist/esm/modules/phong-lighting/phong-lighting.glsl.js.map +1 -1
- package/dist/esm/modules/phong-lighting/phong-lighting.js +3 -1
- package/dist/esm/modules/phong-lighting/phong-lighting.js.map +1 -1
- package/dist/esm/modules/picking/picking.js +4 -87
- package/dist/esm/modules/picking/picking.js.map +1 -1
- package/dist/esm/modules/project/project.js +6 -69
- package/dist/esm/modules/project/project.js.map +1 -1
- package/dist/esm/modules/transform/transform.js +1 -28
- package/dist/esm/modules/transform/transform.js.map +1 -1
- package/dist/esm/modules/utils/random.js +1 -5
- package/dist/esm/modules/utils/random.js.map +1 -1
- package/dist/esm/utils/assert.js.map +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/is-old-ie.js +2 -1
- package/dist/esm/utils/is-old-ie.js.map +1 -1
- package/dist/esm/utils/shader-utils.js +11 -24
- package/dist/esm/utils/shader-utils.js.map +1 -1
- package/dist/esm/utils/webgl-info.js +3 -2
- package/dist/esm/utils/webgl-info.js.map +1 -1
- package/package.json +2 -2
- package/src/.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,MAAMA,EAAE,GAAI;AACZ;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;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;AACA,CAthBA;AAukBA,OAAO,MAAMC,IAAI,GAAG;AAClBC,EAAAA,IAAI,EAAE,MADY;AAElBC,EAAAA,QAAQ,EAAE,EAFQ;AAGlBH,EAAAA,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,MAAMA,EAAE,2mpBAAR;AAukBA,OAAO,MAAMC,IAAI,GAAG;EAClBC,IAAI,EAAE,MADY;EAElBC,QAAQ,EAAE,EAFQ;EAGlBH,EAHkB;EAIlBI,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD;AAJU,CAAb"}
|
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
const vs =
|
|
2
|
-
varying vec4 geometry_vPosition;
|
|
3
|
-
varying vec3 geometry_vNormal;
|
|
4
|
-
|
|
5
|
-
void geometry_setNormal(vec3 normal) {
|
|
6
|
-
geometry_vNormal = normal;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
void geometry_setPosition(vec4 position) {
|
|
10
|
-
geometry_vPosition = position;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
void geometry_setPosition(vec3 position) {
|
|
14
|
-
geometry_vPosition = vec4(position, 1.);
|
|
15
|
-
}
|
|
16
|
-
`;
|
|
17
|
-
const fs = `\
|
|
18
|
-
varying vec4 geometry_vPosition;
|
|
19
|
-
varying vec3 geometry_vNormal;
|
|
20
|
-
|
|
21
|
-
vec4 geometry_getPosition() {
|
|
22
|
-
return geometry_vPosition;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
vec3 geometry_getNormal() {
|
|
26
|
-
return geometry_vNormal;
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
1
|
+
const vs = "varying 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";
|
|
2
|
+
const fs = "varying 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";
|
|
29
3
|
export const geometry = {
|
|
30
4
|
name: 'geometry',
|
|
31
5
|
vs,
|
|
@@ -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,MAAMA,EAAE,kUAAR;AAiBA,MAAMC,EAAE,uMAAR;AAcA,OAAO,MAAMC,QAAQ,GAAG;EACtBC,IAAI,EAAE,UADgB;EAEtBH,EAFsB;EAGtBC;AAHsB,CAAjB"}
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform float brightness;
|
|
3
|
-
uniform float contrast;
|
|
4
|
-
|
|
5
|
-
vec4 brightnessContrast_filterColor(vec4 color) {
|
|
6
|
-
color.rgb += brightness;
|
|
7
|
-
if (contrast > 0.0) {
|
|
8
|
-
color.rgb = (color.rgb - 0.5) / (1.0 - contrast) + 0.5;
|
|
9
|
-
} else {
|
|
10
|
-
color.rgb = (color.rgb - 0.5) * (1.0 + contrast) + 0.5;
|
|
11
|
-
}
|
|
12
|
-
return color;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
|
|
16
|
-
return brightnessContrast_filterColor(color);
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
1
|
+
const fs = "uniform 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";
|
|
19
2
|
const uniforms = {
|
|
20
3
|
brightness: {
|
|
21
4
|
value: 0,
|
|
@@ -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,MAAMA,EAAE,ycAAR;AAmBA,MAAMC,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;AAMA,OAAO,MAAME,kBAAkB,GAAG;EAChCC,IAAI,EAAE,oBAD0B;EAEhCP,QAFgC;EAGhCD,EAHgC;EAIhCS,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJwB,CAA3B"}
|
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform float strength;
|
|
3
|
-
|
|
4
|
-
vec4 denoise_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
|
|
5
|
-
float adjustedExponent = 3. + 200. * pow(1. - strength, 4.);
|
|
6
|
-
|
|
7
|
-
vec4 center = texture2D(texture, texCoord);
|
|
8
|
-
vec4 color = vec4(0.0);
|
|
9
|
-
float total = 0.0;
|
|
10
|
-
for (float x = -4.0; x <= 4.0; x += 1.0) {
|
|
11
|
-
for (float y = -4.0; y <= 4.0; y += 1.0) {
|
|
12
|
-
vec4 sample = texture2D(texture, texCoord + vec2(x, y) / texSize);
|
|
13
|
-
float weight = 1.0 - abs(dot(sample.rgb - center.rgb, vec3(0.25)));
|
|
14
|
-
weight = pow(weight, adjustedExponent);
|
|
15
|
-
color += sample * weight;
|
|
16
|
-
total += weight;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return color / total;
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
1
|
+
const fs = "uniform 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";
|
|
23
2
|
const uniforms = {
|
|
24
3
|
strength: {
|
|
25
4
|
value: 0.5,
|
|
@@ -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,MAAMA,EAAE,mpBAAR;AAuBA,MAAMC,QAAQ,GAAG;EACfC,QAAQ,EAAE;IACRC,KAAK,EAAE,GADC;IAERC,GAAG,EAAE,CAFG;IAGRC,GAAG,EAAE,GAHG;IAIRC,MAAM,EAAEJ,QAAQ,IAAI,OAAO,MAAMK,IAAI,CAACC,GAAL,CAAS,IAAIN,QAAb,EAAuB,CAAvB;EAJzB;AADK,CAAjB;AAUA,OAAO,MAAMO,OAAO,GAAG;EACrBC,IAAI,EAAE,SADe;EAErBT,QAFqB;EAGrBD,EAHqB;EAIrBW,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE;EAAV,CAAD,EAAkB;IAACA,OAAO,EAAE;EAAV,CAAlB;AAJa,CAAhB"}
|
|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform float hue;
|
|
3
|
-
uniform float saturation;
|
|
4
|
-
|
|
5
|
-
vec4 hueSaturation_filterColor(vec4 color) {
|
|
6
|
-
float angle = hue * 3.14159265;
|
|
7
|
-
float s = sin(angle), c = cos(angle);
|
|
8
|
-
vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;
|
|
9
|
-
float len = length(color.rgb);
|
|
10
|
-
color.rgb = vec3(
|
|
11
|
-
dot(color.rgb, weights.xyz),
|
|
12
|
-
dot(color.rgb, weights.zxy),
|
|
13
|
-
dot(color.rgb, weights.yzx)
|
|
14
|
-
);
|
|
15
|
-
float average = (color.r + color.g + color.b) / 3.0;
|
|
16
|
-
if (saturation > 0.0) {
|
|
17
|
-
color.rgb += (average - color.rgb) * (1.0 - 1.0 / (1.001 - saturation));
|
|
18
|
-
} else {
|
|
19
|
-
color.rgb += (average - color.rgb) * (-saturation);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return color;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
26
|
-
return hueSaturation_filterColor(color);
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
1
|
+
const fs = "uniform float hue;\nuniform float saturation;\n\nvec4 hueSaturation_filterColor(vec4 color) {\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 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";
|
|
29
2
|
const uniforms = {
|
|
30
3
|
hue: {
|
|
31
4
|
value: 0,
|
|
@@ -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,MAAMA,EAAE,qyBAAR;AAgCA,MAAMC,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;AAMA,OAAO,MAAME,aAAa,GAAG;EAC3BC,IAAI,EAAE,eADqB;EAE3BP,QAF2B;EAG3BD,EAH2B;EAI3BS,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJmB,CAAtB"}
|
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform float amount;
|
|
3
|
-
|
|
4
|
-
float rand(vec2 co) {
|
|
5
|
-
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
vec4 noise_filterColor(vec4 color, vec2 texCoord) {
|
|
9
|
-
float diff = (rand(texCoord) - 0.5) * amount;
|
|
10
|
-
color.r += diff;
|
|
11
|
-
color.g += diff;
|
|
12
|
-
color.b += diff;
|
|
13
|
-
return color;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
17
|
-
return noise_filterColor(color, texCoord);
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
1
|
+
const fs = "uniform 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";
|
|
20
2
|
const uniforms = {
|
|
21
3
|
amount: {
|
|
22
4
|
value: 0.5,
|
|
@@ -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,MAAMA,EAAE,2aAAR;AAoBA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,GAAG,EAAE;EAA1B;AADO,CAAjB;AAKA,OAAO,MAAMC,KAAK,GAAG;EACnBC,IAAI,EAAE,OADa;EAEnBN,QAFmB;EAGnBD,EAHmB;EAInBQ,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJW,CAAd"}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform float amount;
|
|
3
|
-
|
|
4
|
-
vec4 sepia_filterColor(vec4 color) {
|
|
5
|
-
float r = color.r;
|
|
6
|
-
float g = color.g;
|
|
7
|
-
float b = color.b;
|
|
8
|
-
|
|
9
|
-
color.r =
|
|
10
|
-
min(1.0, (r * (1.0 - (0.607 * amount))) + (g * (0.769 * amount)) + (b * (0.189 * amount)));
|
|
11
|
-
color.g = min(1.0, (r * 0.349 * amount) + (g * (1.0 - (0.314 * amount))) + (b * 0.168 * amount));
|
|
12
|
-
color.b = min(1.0, (r * 0.272 * amount) + (g * 0.534 * amount) + (b * (1.0 - (0.869 * amount))));
|
|
13
|
-
|
|
14
|
-
return color;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
18
|
-
return sepia_filterColor(color);
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
1
|
+
const fs = "uniform 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";
|
|
21
2
|
const uniforms = {
|
|
22
3
|
amount: {
|
|
23
4
|
value: 0.5,
|
|
@@ -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,MAAMA,EAAE,kkBAAR;AAqBA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE;IAACC,KAAK,EAAE,GAAR;IAAaC,GAAG,EAAE,CAAlB;IAAqBC,GAAG,EAAE;EAA1B;AADO,CAAjB;AAKA,OAAO,MAAMC,KAAK,GAAG;EACnBC,IAAI,EAAE,OADa;EAEnBN,QAFmB;EAGnBD,EAHmB;EAInBQ,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJW,CAAd"}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform float amount;
|
|
3
|
-
|
|
4
|
-
vec4 vibrance_filterColor(vec4 color) {
|
|
5
|
-
float average = (color.r + color.g + color.b) / 3.0;
|
|
6
|
-
float mx = max(color.r, max(color.g, color.b));
|
|
7
|
-
float amt = (mx - average) * (-amount * 3.0);
|
|
8
|
-
color.rgb = mix(color.rgb, vec3(mx), amt);
|
|
9
|
-
return color;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
13
|
-
return vibrance_filterColor(color);
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
1
|
+
const fs = "uniform 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";
|
|
16
2
|
const uniforms = {
|
|
17
3
|
amount: {
|
|
18
4
|
value: 0,
|
|
@@ -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,MAAMA,EAAE,uZAAR;AAgBA,MAAMC,QAAQ,GAAG;EACfC,MAAM,EAAE;IAACC,KAAK,EAAE,CAAR;IAAWC,GAAG,EAAE,CAAC,CAAjB;IAAoBC,GAAG,EAAE;EAAzB;AADO,CAAjB;AAKA,OAAO,MAAMC,QAAQ,GAAG;EACtBC,IAAI,EAAE,UADgB;EAEtBN,QAFsB;EAGtBD,EAHsB;EAItBQ,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJc,CAAjB"}
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
const fs =
|
|
2
|
-
uniform float radius;
|
|
3
|
-
uniform float amount;
|
|
4
|
-
|
|
5
|
-
vec4 vignette_filterColor(vec4 color, vec2 texCoord) {
|
|
6
|
-
float dist = distance(texCoord, vec2(0.5, 0.5));
|
|
7
|
-
float ratio = smoothstep(0.8, radius * 0.799, dist * (amount + radius));
|
|
8
|
-
return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
12
|
-
return vignette_filterColor(color, texCoord);
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
1
|
+
const fs = "uniform 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";
|
|
15
2
|
const uniforms = {
|
|
16
3
|
radius: {
|
|
17
4
|
value: 0.5,
|
|
@@ -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,MAAMA,EAAE,mbAAR;AAeA,MAAMC,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;AAMA,OAAO,MAAME,QAAQ,GAAG;EACtBC,IAAI,EAAE,UADgB;EAEtBR,EAFsB;EAGtBC,QAHsB;EAItBQ,MAAM,EAAE,CAAC;IAACC,MAAM,EAAE;EAAT,CAAD;AAJc,CAAjB"}
|
|
@@ -1,41 +1,5 @@
|
|
|
1
1
|
import { random } from '../utils/random';
|
|
2
|
-
const fs =
|
|
3
|
-
uniform float blurRadius;
|
|
4
|
-
uniform float gradientRadius;
|
|
5
|
-
uniform vec2 start;
|
|
6
|
-
uniform vec2 end;
|
|
7
|
-
uniform bool invert;
|
|
8
|
-
|
|
9
|
-
vec2 tiltShift_getDelta(vec2 texSize) {
|
|
10
|
-
vec2 vector = normalize((end - start) * texSize);
|
|
11
|
-
return invert ? vec2(-vector.y, vector.x) : vector;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
vec4 tiltShift_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
|
|
15
|
-
vec4 color = vec4(0.0);
|
|
16
|
-
float total = 0.0;
|
|
17
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
18
|
-
|
|
19
|
-
vec2 normal = normalize(vec2((start.y - end.y) * texSize.y, (end.x - start.x) * texSize.x));
|
|
20
|
-
float radius = smoothstep(0.0, 1.0,
|
|
21
|
-
abs(dot(texCoord * texSize - start * texSize, normal)) / gradientRadius) * blurRadius;
|
|
22
|
-
|
|
23
|
-
for (float t = -30.0; t <= 30.0; t++) {
|
|
24
|
-
float percent = (t + offset - 0.5) / 30.0;
|
|
25
|
-
float weight = 1.0 - abs(percent);
|
|
26
|
-
vec4 sample = texture2D(texture, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
|
|
27
|
-
sample.rgb *= sample.a;
|
|
28
|
-
|
|
29
|
-
color += sample * weight;
|
|
30
|
-
total += weight;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
color = color / total;
|
|
34
|
-
color.rgb /= color.a + 0.00001;
|
|
35
|
-
|
|
36
|
-
return color;
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
2
|
+
const fs = "uniform 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 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 sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n }\n\n color = color / total;\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n";
|
|
39
3
|
const uniforms = {
|
|
40
4
|
blurRadius: {
|
|
41
5
|
value: 15,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"tiltshift.js","names":["random","fs","uniforms","blurRadius","value","min","max","gradientRadius","start","end","invert","private","tiltShift","name","dependencies","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,SAAQA,MAAR,QAAqB,iBAArB;AAEA,MAAMC,EAAE,4lCAAR;AA4CA,MAAMC,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;AASA,OAAO,MAAMC,SAAS,GAAG;EACvBC,IAAI,EAAE,WADiB;EAEvBX,QAFuB;EAGvBD,EAHuB;EAIvBa,YAAY,EAAE,CAACd,MAAD,CAJS;EAKvBe,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE,IAAV;IAAgBd,QAAQ,EAAE;MAACQ,MAAM,EAAE;IAAT;EAA1B,CAAD,EAA6C;IAACM,OAAO,EAAE,IAAV;IAAgBd,QAAQ,EAAE;MAACQ,MAAM,EAAE;IAAT;EAA1B,CAA7C;AALe,CAAlB"}
|
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
import { random } from '../utils/random';
|
|
2
|
-
const fs =
|
|
3
|
-
uniform float radius;
|
|
4
|
-
uniform vec2 delta;
|
|
5
|
-
|
|
6
|
-
vec4 triangleBlur_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
|
|
7
|
-
vec2 adjustedDelta = delta * radius / texSize;
|
|
8
|
-
|
|
9
|
-
vec4 color = vec4(0.0);
|
|
10
|
-
float total = 0.0;
|
|
11
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
12
|
-
|
|
13
|
-
for (float t = -30.0; t <= 30.0; t++) {
|
|
14
|
-
float percent = (t + offset - 0.5) / 30.0;
|
|
15
|
-
float weight = 1.0 - abs(percent);
|
|
16
|
-
vec4 sample = texture2D(texture, texCoord + adjustedDelta * percent);
|
|
17
|
-
sample.rgb *= sample.a;
|
|
18
|
-
|
|
19
|
-
color += sample * weight;
|
|
20
|
-
total += weight;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
color = color / total;
|
|
24
|
-
color.rgb /= color.a + 0.00001;
|
|
25
|
-
|
|
26
|
-
return color;
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
2
|
+
const fs = "uniform 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 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 sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n }\n\n color = color / total;\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n";
|
|
29
3
|
const uniforms = {
|
|
30
4
|
radius: {
|
|
31
5
|
value: 20,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"triangleblur.js","names":["random","fs","uniforms","radius","value","min","softMax","delta","private","triangleBlur","name","dependencies","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,SAAQA,MAAR,QAAqB,iBAArB;AAEA,MAAMC,EAAE,uqBAAR;AAkCA,MAAMC,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;AAMA,OAAO,MAAMC,YAAY,GAAG;EAC1BC,IAAI,EAAE,cADoB;EAE1BR,QAF0B;EAG1BD,EAH0B;EAI1BU,YAAY,EAAE,CAACX,MAAD,CAJY;EAK1BY,MAAM,EAAE,CAAC;IAACC,OAAO,EAAE,IAAV;IAAgBX,QAAQ,EAAE;MAACK,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;IAAR;EAA1B,CAAD,EAA6C;IAACM,OAAO,EAAE,IAAV;IAAgBX,QAAQ,EAAE;MAACK,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;IAAR;EAA1B,CAA7C;AALkB,CAArB"}
|
|
@@ -1,30 +1,5 @@
|
|
|
1
1
|
import { random } from '../utils/random';
|
|
2
|
-
const fs =
|
|
3
|
-
uniform vec2 center;
|
|
4
|
-
uniform float strength;
|
|
5
|
-
|
|
6
|
-
vec4 zoomBlur_sampleColor(sampler2D texture, vec2 texSize, vec2 texCoord) {
|
|
7
|
-
vec4 color = vec4(0.0);
|
|
8
|
-
float total = 0.0;
|
|
9
|
-
vec2 toCenter = center * texSize - texCoord * texSize;
|
|
10
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
11
|
-
|
|
12
|
-
for (float t = 0.0; t <= 40.0; t++) {
|
|
13
|
-
float percent = (t + offset) / 40.0;
|
|
14
|
-
float weight = 4.0 * (percent - percent * percent);
|
|
15
|
-
vec4 sample = texture2D(texture, texCoord + toCenter * percent * strength / texSize);
|
|
16
|
-
sample.rgb *= sample.a;
|
|
17
|
-
|
|
18
|
-
color += sample * weight;
|
|
19
|
-
total += weight;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
color = color / total;
|
|
23
|
-
color.rgb /= color.a + 0.00001;
|
|
24
|
-
|
|
25
|
-
return color;
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
2
|
+
const 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 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 sample.rgb *= sample.a;\n\n color += sample * weight;\n total += weight;\n }\n\n color = color / total;\n color.rgb /= color.a + 0.00001;\n\n return color;\n}\n";
|
|
28
3
|
const uniforms = {
|
|
29
4
|
center: [0.5, 0.5],
|
|
30
5
|
strength: {
|