three-stdlib 2.35.12 → 2.35.14
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/exporters/GLTFExporter.cjs +9 -2
- package/exporters/GLTFExporter.cjs.map +1 -1
- package/exporters/GLTFExporter.js +9 -2
- package/exporters/GLTFExporter.js.map +1 -1
- package/package.json +1 -1
- package/shaders/ACESFilmicToneMappingShader.cjs +35 -35
- package/shaders/ACESFilmicToneMappingShader.cjs.map +1 -1
- package/shaders/ACESFilmicToneMappingShader.js +35 -35
- package/shaders/ACESFilmicToneMappingShader.js.map +1 -1
- package/shaders/FXAAShader.cjs +4 -4
- package/shaders/FXAAShader.cjs.map +1 -1
- package/shaders/FXAAShader.js +4 -4
- package/shaders/FXAAShader.js.map +1 -1
- package/shaders/GodRaysShader.cjs +4 -4
- package/shaders/GodRaysShader.cjs.map +1 -1
- package/shaders/GodRaysShader.js +4 -4
- package/shaders/GodRaysShader.js.map +1 -1
- package/shaders/ParallaxShader.cjs +1 -1
- package/shaders/ParallaxShader.cjs.map +1 -1
- package/shaders/ParallaxShader.js +1 -1
- package/shaders/ParallaxShader.js.map +1 -1
- package/shaders/VignetteShader.cjs +4 -4
- package/shaders/VignetteShader.cjs.map +1 -1
- package/shaders/VignetteShader.js +4 -4
- package/shaders/VignetteShader.js.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"FXAAShader.js","sources":["../../src/shaders/FXAAShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * NVIDIA FXAA by Timothy Lottes\n * http://timothylottes.blogspot.com/2011/06/fxaa3-source-released.html\n * - WebGL port by @supereggbert\n * http://www.glge.org/demos/fxaa/\n */\n\nexport const FXAAShader = {\n uniforms: {\n tDiffuse: { value: null },\n resolution: { value: /* @__PURE__ */ new Vector2(1 / 1024, 1 / 512) },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n precision highp float;\n \n uniform sampler2D tDiffuse;\n \n uniform vec2 resolution;\n \n varying vec2 vUv;\n \n // FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n \n //----------------------------------------------------------------------------------\n // File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n // SDK Version: v3.00\n // Email: gameworks@nvidia.com\n // Site: http://developer.nvidia.com/\n //\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 \n #define FXAA_PC 1\n #define FXAA_GLSL_100 1\n #define FXAA_QUALITY_PRESET 12\n \n #define FXAA_GREEN_AS_LUMA 1\n \n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_PC_CONSOLE\n //\n // The console algorithm for PC is included\n // for developers targeting really low spec machines.\n // Likely better to just run FXAA_PC, and use a really low preset.\n //\n #define FXAA_PC_CONSOLE 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_GLSL_120\n #define FXAA_GLSL_120 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_GLSL_130\n #define FXAA_GLSL_130 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_HLSL_3\n #define FXAA_HLSL_3 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_HLSL_4\n #define FXAA_HLSL_4 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_HLSL_5\n #define FXAA_HLSL_5 0\n #endif\n /*==========================================================================*/\n #ifndef FXAA_GREEN_AS_LUMA\n //\n // For those using non-linear color,\n // and either not able to get luma in alpha, or not wanting to,\n // this enables FXAA to run using green as a proxy for luma.\n // So with this enabled, no need to pack luma in alpha.\n //\n // This will turn off AA on anything which lacks some amount of green.\n // Pure red and blue or combination of only R and B, will get no AA.\n //\n // Might want to lower the settings for both,\n // fxaaConsoleEdgeThresholdMin\n // fxaaQualityEdgeThresholdMin\n // In order to insure AA does not get turned off on colors\n // which contain a minor amount of green.\n //\n // 1 = On.\n // 0 = Off.\n //\n #define FXAA_GREEN_AS_LUMA 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_EARLY_EXIT\n //\n \" // Controls algorithms early exit path.\",\n // On PS3 turning this ON adds 2 cycles to the shader.\n // On 360 turning this OFF adds 10ths of a millisecond to the shader.\n // Turning this off on console will result in a more blurry image.\n // So this defaults to on.\n //\n // 1 = On.\n // 0 = Off.\n //\n #define FXAA_EARLY_EXIT 1\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_DISCARD\n //\n // Only valid for PC OpenGL currently.\n // Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n //\n \" // 1 = Use discard on pixels which dont need AA.\",\n // For APIs which enable concurrent TEX+ROP from same surface.\n \" // 0 = Return unchanged color on pixels which dont need AA.\",\n //\n #define FXAA_DISCARD 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_FAST_PIXEL_OFFSET\n //\n // Used for GLSL 120 only.\n //\n // 1 = GL API supports fast pixel offsets\n // 0 = do not use fast pixel offsets\n //\n #ifdef GL_EXT_gpu_shader4\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifdef GL_NV_gpu_shader5\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifdef GL_ARB_gpu_shader5\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifndef FXAA_FAST_PIXEL_OFFSET\n #define FXAA_FAST_PIXEL_OFFSET 0\n #endif\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_GATHER4_ALPHA\n //\n // 1 = API supports gather4 on alpha channel.\n // 0 = API does not support gather4 on alpha channel.\n //\n #if (FXAA_HLSL_5 == 1)\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifdef GL_ARB_gpu_shader5\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifdef GL_NV_gpu_shader5\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifndef FXAA_GATHER4_ALPHA\n #define FXAA_GATHER4_ALPHA 0\n #endif\n #endif\n \n \n /*============================================================================\n FXAA QUALITY - TUNING KNOBS\n ------------------------------------------------------------------------------\n NOTE the other tuning knobs are now in the shader function inputs!\n ============================================================================*/\n #ifndef FXAA_QUALITY_PRESET\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 #define FXAA_QUALITY_PRESET 12\n #endif\n \n \n /*============================================================================\n \n FXAA QUALITY - PRESETS\n \n ============================================================================*/\n \n /*============================================================================\n FXAA QUALITY - MEDIUM DITHER PRESETS\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 \n /*============================================================================\n FXAA QUALITY - LOW DITHER PRESETS\n ============================================================================*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 \n /*============================================================================\n FXAA QUALITY - EXTREME QUALITY\n ============================================================================*/\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 \n \n /*============================================================================\n \n API PORTING\n \n ============================================================================*/\n #if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)\n #define FxaaBool bool\n #define FxaaDiscard discard\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 ivec2\n #define FxaaSat(x) clamp(x, 0.0, 1.0)\n #define FxaaTex sampler2D\n #else\n #define FxaaBool bool\n #define FxaaDiscard clip(-1)\n #define FxaaFloat float\n #define FxaaFloat2 float2\n #define FxaaFloat3 float3\n #define FxaaFloat4 float4\n #define FxaaHalf half\n #define FxaaHalf2 half2\n #define FxaaHalf3 half3\n #define FxaaHalf4 half4\n #define FxaaSat(x) saturate(x)\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_GLSL_100 == 1)\n #define FxaaTexTop(t, p) texture2D(t, p, 0.0)\n #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_GLSL_120 == 1)\n // Requires,\n // #version 120\n // And at least,\n // #extension GL_EXT_gpu_shader4 : enable\n // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)\n #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)\n #if (FXAA_FAST_PIXEL_OFFSET == 1)\n #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)\n #else\n #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)\n #endif\n #if (FXAA_GATHER4_ALPHA == 1)\n // use #extension GL_ARB_gpu_shader5 : enable\n #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n #define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n #endif\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_GLSL_130 == 1)\n // Requires \"#version 130\" or better\n #define FxaaTexTop(t, p) textureLod(t, p, 0.0)\n #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)\n #if (FXAA_GATHER4_ALPHA == 1)\n // use #extension GL_ARB_gpu_shader5 : enable\n #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n #define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n #endif\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_HLSL_3 == 1)\n #define FxaaInt2 float2\n #define FxaaTex sampler2D\n #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))\n #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_HLSL_4 == 1)\n #define FxaaInt2 int2\n struct FxaaTex { SamplerState smpl; Texture2D tex; };\n #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_HLSL_5 == 1)\n #define FxaaInt2 int2\n struct FxaaTex { SamplerState smpl; Texture2D tex; };\n #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)\n #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)\n #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)\n #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)\n #endif\n \n \n /*============================================================================\n GREEN AS LUMA OPTION SUPPORT FUNCTION\n ============================================================================*/\n #if (FXAA_GREEN_AS_LUMA == 0)\n FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }\n #else\n FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }\n #endif\n \n \n \n \n /*============================================================================\n \n FXAA3 QUALITY - PC\n \n ============================================================================*/\n #if (FXAA_PC == 1)\n /*--------------------------------------------------------------------------*/\n FxaaFloat4 FxaaPixelShader(\n //\n // Use noperspective interpolation here (turn off perspective interpolation).\n // {xy} = center of pixel\n FxaaFloat2 pos,\n //\n // Used only for FXAA Console, and not used on the 360 version.\n // Use noperspective interpolation here (turn off perspective interpolation).\n // {xy_} = upper left of pixel\n // {_zw} = lower right of pixel\n FxaaFloat4 fxaaConsolePosPos,\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 the optimized 360 version of FXAA Console.\n // For everything but 360, just use the same input here as for \"tex\".\n // For 360, same texture, just alias with a 2nd sampler.\n // This sampler needs to have an exponent bias of -1.\n FxaaTex fxaaConsole360TexExpBiasNegOne,\n //\n // Only used on the optimized 360 version of FXAA Console.\n // For everything but 360, just use the same input here as for \"tex\".\n // For 360, same texture, just alias with a 3nd sampler.\n // This sampler needs to have an exponent bias of -2.\n FxaaTex fxaaConsole360TexExpBiasNegTwo,\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 Console.\n // This must be from a constant/uniform.\n // This effects sub-pixel AA quality and inversely sharpness.\n // Where N ranges between,\n // N = 0.50 (default)\n // N = 0.33 (sharper)\n // {x__} = -N/screenWidthInPixels\n // {_y_} = -N/screenHeightInPixels\n // {_z_} = N/screenWidthInPixels\n // {__w} = N/screenHeightInPixels\n FxaaFloat4 fxaaConsoleRcpFrameOpt,\n //\n // Only used on FXAA Console.\n // Not used on 360, but used on PS3 and PC.\n // This must be from a constant/uniform.\n // {x__} = -2.0/screenWidthInPixels\n // {_y_} = -2.0/screenHeightInPixels\n // {_z_} = 2.0/screenWidthInPixels\n // {__w} = 2.0/screenHeightInPixels\n FxaaFloat4 fxaaConsoleRcpFrameOpt2,\n //\n // Only used on FXAA Console.\n // Only used on 360 in place of fxaaConsoleRcpFrameOpt2.\n // This must be from a constant/uniform.\n // {x__} = 8.0/screenWidthInPixels\n // {_y_} = 8.0/screenHeightInPixels\n // {_z_} = -4.0/screenWidthInPixels\n // {__w} = -4.0/screenHeightInPixels\n FxaaFloat4 fxaaConsole360RcpFrameOpt2,\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 // Only used on FXAA Console.\n // This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define.\n // It is here now to allow easier tuning.\n // This does not effect PS3, as this needs to be compiled in.\n // Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3.\n // Due to the PS3 being ALU bound,\n // there are only three safe values here: 2 and 4 and 8.\n // These options use the shaders ability to a free *|/ by 2|4|8.\n // For all other platforms can be a non-power of two.\n // 8.0 is sharper (default!!!)\n // 4.0 is softer\n // 2.0 is really soft (good only for vector graphics inputs)\n FxaaFloat fxaaConsoleEdgeSharpness,\n //\n // Only used on FXAA Console.\n // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define.\n // It is here now to allow easier tuning.\n // This does not effect PS3, as this needs to be compiled in.\n // Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3.\n // Due to the PS3 being ALU bound,\n // there are only two safe values here: 1/4 and 1/8.\n // These options use the shaders ability to a free *|/ by 2|4|8.\n // The console setting has a different mapping than the quality setting.\n // Other platforms can use other values.\n // 0.125 leaves less aliasing, but is softer (default!!!)\n // 0.25 leaves more aliasing, and is sharper\n FxaaFloat fxaaConsoleEdgeThreshold,\n //\n // Only used on FXAA Console.\n // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define.\n // It is here now to allow easier tuning.\n // Trims the algorithm from processing darks.\n // The console setting has a different mapping than the quality setting.\n // This only applies when FXAA_EARLY_EXIT is 1.\n // This does not apply to PS3,\n // PS3 was simplified to avoid more shader instructions.\n // 0.06 - faster but more aliasing in darks\n // 0.05 - default\n // 0.04 - slower and less aliasing in darks\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 fxaaConsoleEdgeThresholdMin,\n //\n // Extra constants for 360 FXAA Console only.\n // Use zeros or anything else for other platforms.\n // These must be in physical constant registers and NOT immediates.\n // Immediates will result in compiler un-optimizing.\n // {xyzw} = float4(1.0, -1.0, 0.25, -0.25)\n FxaaFloat4 fxaaConsole360ConstDir\n ) {\n /*--------------------------------------------------------------------------*/\n FxaaFloat2 posM;\n posM.x = pos.x;\n posM.y = pos.y;\n #if (FXAA_GATHER4_ALPHA == 1)\n #if (FXAA_DISCARD == 0)\n FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n #if (FXAA_GREEN_AS_LUMA == 0)\n #define lumaM rgbyM.w\n #else\n #define lumaM rgbyM.y\n #endif\n #endif\n #if (FXAA_GREEN_AS_LUMA == 0)\n FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);\n FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));\n #else\n FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);\n FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));\n #endif\n #if (FXAA_DISCARD == 1)\n #define lumaM luma4A.w\n #endif\n #define lumaE luma4A.z\n #define lumaS luma4A.x\n #define lumaSE luma4A.y\n #define lumaNW luma4B.w\n #define lumaN luma4B.z\n #define lumaW luma4B.x\n #else\n FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n #if (FXAA_GREEN_AS_LUMA == 0)\n #define lumaM rgbyM.w\n #else\n #define lumaM rgbyM.y\n #endif\n #if (FXAA_GLSL_100 == 1)\n FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0, 1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 0.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0,-1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));\n #else\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 #endif\n #endif\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 #if (FXAA_DISCARD == 1)\n FxaaDiscard;\n #else\n return rgbyM;\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_GATHER4_ALPHA == 0)\n #if (FXAA_GLSL_100 == 1)\n FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0,-1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));\n #else\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 #endif\n #else\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 #endif\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 #if (FXAA_DISCARD == 1)\n return FxaaTexTop(tex, posM);\n #else\n return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);\n #endif\n }\n /*==========================================================================*/\n #endif\n \n void main() {\n gl_FragColor = FxaaPixelShader(\n vUv,\n vec4(0.0),\n tDiffuse,\n tDiffuse,\n tDiffuse,\n resolution,\n vec4(0.0),\n vec4(0.0),\n vec4(0.0),\n 0.75,\n 0.166,\n 0.0833,\n 0.0,\n 0.0,\n 0.0,\n vec4(0.0)\n );\n \n // TODO avoid querying texture twice for same texel\n gl_FragColor.a = texture2D(tDiffuse, vUv).a;\n }\n `,\n}\n"],"names":[],"mappings":";AASO,MAAM,aAAa;AAAA,EACxB,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,YAAY,EAAE,OAAuB,oBAAI,QAAQ,IAAI,MAAM,IAAI,GAAG,EAAE;AAAA,EACtE;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyjC7B;"}
|
1
|
+
{"version":3,"file":"FXAAShader.js","sources":["../../src/shaders/FXAAShader.ts"],"sourcesContent":["import { Vector2 } from 'three'\n\n/**\n * NVIDIA FXAA by Timothy Lottes\n * http://timothylottes.blogspot.com/2011/06/fxaa3-source-released.html\n * - WebGL port by @supereggbert\n * http://www.glge.org/demos/fxaa/\n */\n\nexport const FXAAShader = {\n uniforms: {\n tDiffuse: { value: null },\n resolution: { value: /* @__PURE__ */ new Vector2(1 / 1024, 1 / 512) },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n precision highp float;\n \n uniform sampler2D tDiffuse;\n \n uniform vec2 resolution;\n \n varying vec2 vUv;\n \n // FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n \n //----------------------------------------------------------------------------------\n // File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n // SDK Version: v3.00\n // Email: gameworks@nvidia.com\n // Site: http://developer.nvidia.com/\n //\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 \n #define FXAA_PC 1\n #define FXAA_GLSL_100 1\n #define FXAA_QUALITY_PRESET 12\n \n #define FXAA_GREEN_AS_LUMA 1\n \n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_PC_CONSOLE\n //\n // The console algorithm for PC is included\n // for developers targeting really low spec machines.\n // Likely better to just run FXAA_PC, and use a really low preset.\n //\n #define FXAA_PC_CONSOLE 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_GLSL_120\n #define FXAA_GLSL_120 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_GLSL_130\n #define FXAA_GLSL_130 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_HLSL_3\n #define FXAA_HLSL_3 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_HLSL_4\n #define FXAA_HLSL_4 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_HLSL_5\n #define FXAA_HLSL_5 0\n #endif\n /*==========================================================================*/\n #ifndef FXAA_GREEN_AS_LUMA\n //\n // For those using non-linear color,\n // and either not able to get luma in alpha, or not wanting to,\n // this enables FXAA to run using green as a proxy for luma.\n // So with this enabled, no need to pack luma in alpha.\n //\n // This will turn off AA on anything which lacks some amount of green.\n // Pure red and blue or combination of only R and B, will get no AA.\n //\n // Might want to lower the settings for both,\n // fxaaConsoleEdgeThresholdMin\n // fxaaQualityEdgeThresholdMin\n // In order to insure AA does not get turned off on colors\n // which contain a minor amount of green.\n //\n // 1 = On.\n // 0 = Off.\n //\n #define FXAA_GREEN_AS_LUMA 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_EARLY_EXIT\n //\n // Controls algorithms early exit path.\n // On PS3 turning this ON adds 2 cycles to the shader.\n // On 360 turning this OFF adds 10ths of a millisecond to the shader.\n // Turning this off on console will result in a more blurry image.\n // So this defaults to on.\n //\n // 1 = On.\n // 0 = Off.\n //\n #define FXAA_EARLY_EXIT 1\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_DISCARD\n //\n // Only valid for PC OpenGL currently.\n // Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n //\n // 1 = Use discard on pixels which dont need AA.\n // For APIs which enable concurrent TEX+ROP from same surface.\n // 0 = Return unchanged color on pixels which dont need AA.\n //\n #define FXAA_DISCARD 0\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_FAST_PIXEL_OFFSET\n //\n // Used for GLSL 120 only.\n //\n // 1 = GL API supports fast pixel offsets\n // 0 = do not use fast pixel offsets\n //\n #ifdef GL_EXT_gpu_shader4\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifdef GL_NV_gpu_shader5\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifdef GL_ARB_gpu_shader5\n #define FXAA_FAST_PIXEL_OFFSET 1\n #endif\n #ifndef FXAA_FAST_PIXEL_OFFSET\n #define FXAA_FAST_PIXEL_OFFSET 0\n #endif\n #endif\n /*--------------------------------------------------------------------------*/\n #ifndef FXAA_GATHER4_ALPHA\n //\n // 1 = API supports gather4 on alpha channel.\n // 0 = API does not support gather4 on alpha channel.\n //\n #if (FXAA_HLSL_5 == 1)\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifdef GL_ARB_gpu_shader5\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifdef GL_NV_gpu_shader5\n #define FXAA_GATHER4_ALPHA 1\n #endif\n #ifndef FXAA_GATHER4_ALPHA\n #define FXAA_GATHER4_ALPHA 0\n #endif\n #endif\n \n \n /*============================================================================\n FXAA QUALITY - TUNING KNOBS\n ------------------------------------------------------------------------------\n NOTE the other tuning knobs are now in the shader function inputs!\n ============================================================================*/\n #ifndef FXAA_QUALITY_PRESET\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 #define FXAA_QUALITY_PRESET 12\n #endif\n \n \n /*============================================================================\n \n FXAA QUALITY - PRESETS\n \n ============================================================================*/\n \n /*============================================================================\n FXAA QUALITY - MEDIUM DITHER PRESETS\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 \n /*============================================================================\n FXAA QUALITY - LOW DITHER PRESETS\n ============================================================================*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 /*--------------------------------------------------------------------------*/\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 \n /*============================================================================\n FXAA QUALITY - EXTREME QUALITY\n ============================================================================*/\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 \n \n /*============================================================================\n \n API PORTING\n \n ============================================================================*/\n #if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)\n #define FxaaBool bool\n #define FxaaDiscard discard\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 ivec2\n #define FxaaSat(x) clamp(x, 0.0, 1.0)\n #define FxaaTex sampler2D\n #else\n #define FxaaBool bool\n #define FxaaDiscard clip(-1)\n #define FxaaFloat float\n #define FxaaFloat2 float2\n #define FxaaFloat3 float3\n #define FxaaFloat4 float4\n #define FxaaHalf half\n #define FxaaHalf2 half2\n #define FxaaHalf3 half3\n #define FxaaHalf4 half4\n #define FxaaSat(x) saturate(x)\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_GLSL_100 == 1)\n #define FxaaTexTop(t, p) texture2D(t, p, 0.0)\n #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_GLSL_120 == 1)\n // Requires,\n // #version 120\n // And at least,\n // #extension GL_EXT_gpu_shader4 : enable\n // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)\n #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)\n #if (FXAA_FAST_PIXEL_OFFSET == 1)\n #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)\n #else\n #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)\n #endif\n #if (FXAA_GATHER4_ALPHA == 1)\n // use #extension GL_ARB_gpu_shader5 : enable\n #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n #define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n #endif\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_GLSL_130 == 1)\n // Requires \"#version 130\" or better\n #define FxaaTexTop(t, p) textureLod(t, p, 0.0)\n #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)\n #if (FXAA_GATHER4_ALPHA == 1)\n // use #extension GL_ARB_gpu_shader5 : enable\n #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)\n #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)\n #define FxaaTexGreen4(t, p) textureGather(t, p, 1)\n #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)\n #endif\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_HLSL_3 == 1)\n #define FxaaInt2 float2\n #define FxaaTex sampler2D\n #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))\n #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_HLSL_4 == 1)\n #define FxaaInt2 int2\n struct FxaaTex { SamplerState smpl; Texture2D tex; };\n #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_HLSL_5 == 1)\n #define FxaaInt2 int2\n struct FxaaTex { SamplerState smpl; Texture2D tex; };\n #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)\n #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)\n #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)\n #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)\n #endif\n \n \n /*============================================================================\n GREEN AS LUMA OPTION SUPPORT FUNCTION\n ============================================================================*/\n #if (FXAA_GREEN_AS_LUMA == 0)\n FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }\n #else\n FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }\n #endif\n \n \n \n \n /*============================================================================\n \n FXAA3 QUALITY - PC\n \n ============================================================================*/\n #if (FXAA_PC == 1)\n /*--------------------------------------------------------------------------*/\n FxaaFloat4 FxaaPixelShader(\n //\n // Use noperspective interpolation here (turn off perspective interpolation).\n // {xy} = center of pixel\n FxaaFloat2 pos,\n //\n // Used only for FXAA Console, and not used on the 360 version.\n // Use noperspective interpolation here (turn off perspective interpolation).\n // {xy_} = upper left of pixel\n // {_zw} = lower right of pixel\n FxaaFloat4 fxaaConsolePosPos,\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 the optimized 360 version of FXAA Console.\n // For everything but 360, just use the same input here as for \"tex\".\n // For 360, same texture, just alias with a 2nd sampler.\n // This sampler needs to have an exponent bias of -1.\n FxaaTex fxaaConsole360TexExpBiasNegOne,\n //\n // Only used on the optimized 360 version of FXAA Console.\n // For everything but 360, just use the same input here as for \"tex\".\n // For 360, same texture, just alias with a 3nd sampler.\n // This sampler needs to have an exponent bias of -2.\n FxaaTex fxaaConsole360TexExpBiasNegTwo,\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 Console.\n // This must be from a constant/uniform.\n // This effects sub-pixel AA quality and inversely sharpness.\n // Where N ranges between,\n // N = 0.50 (default)\n // N = 0.33 (sharper)\n // {x__} = -N/screenWidthInPixels\n // {_y_} = -N/screenHeightInPixels\n // {_z_} = N/screenWidthInPixels\n // {__w} = N/screenHeightInPixels\n FxaaFloat4 fxaaConsoleRcpFrameOpt,\n //\n // Only used on FXAA Console.\n // Not used on 360, but used on PS3 and PC.\n // This must be from a constant/uniform.\n // {x__} = -2.0/screenWidthInPixels\n // {_y_} = -2.0/screenHeightInPixels\n // {_z_} = 2.0/screenWidthInPixels\n // {__w} = 2.0/screenHeightInPixels\n FxaaFloat4 fxaaConsoleRcpFrameOpt2,\n //\n // Only used on FXAA Console.\n // Only used on 360 in place of fxaaConsoleRcpFrameOpt2.\n // This must be from a constant/uniform.\n // {x__} = 8.0/screenWidthInPixels\n // {_y_} = 8.0/screenHeightInPixels\n // {_z_} = -4.0/screenWidthInPixels\n // {__w} = -4.0/screenHeightInPixels\n FxaaFloat4 fxaaConsole360RcpFrameOpt2,\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 // Only used on FXAA Console.\n // This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define.\n // It is here now to allow easier tuning.\n // This does not effect PS3, as this needs to be compiled in.\n // Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3.\n // Due to the PS3 being ALU bound,\n // there are only three safe values here: 2 and 4 and 8.\n // These options use the shaders ability to a free *|/ by 2|4|8.\n // For all other platforms can be a non-power of two.\n // 8.0 is sharper (default!!!)\n // 4.0 is softer\n // 2.0 is really soft (good only for vector graphics inputs)\n FxaaFloat fxaaConsoleEdgeSharpness,\n //\n // Only used on FXAA Console.\n // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define.\n // It is here now to allow easier tuning.\n // This does not effect PS3, as this needs to be compiled in.\n // Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3.\n // Due to the PS3 being ALU bound,\n // there are only two safe values here: 1/4 and 1/8.\n // These options use the shaders ability to a free *|/ by 2|4|8.\n // The console setting has a different mapping than the quality setting.\n // Other platforms can use other values.\n // 0.125 leaves less aliasing, but is softer (default!!!)\n // 0.25 leaves more aliasing, and is sharper\n FxaaFloat fxaaConsoleEdgeThreshold,\n //\n // Only used on FXAA Console.\n // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define.\n // It is here now to allow easier tuning.\n // Trims the algorithm from processing darks.\n // The console setting has a different mapping than the quality setting.\n // This only applies when FXAA_EARLY_EXIT is 1.\n // This does not apply to PS3,\n // PS3 was simplified to avoid more shader instructions.\n // 0.06 - faster but more aliasing in darks\n // 0.05 - default\n // 0.04 - slower and less aliasing in darks\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 fxaaConsoleEdgeThresholdMin,\n //\n // Extra constants for 360 FXAA Console only.\n // Use zeros or anything else for other platforms.\n // These must be in physical constant registers and NOT immediates.\n // Immediates will result in compiler un-optimizing.\n // {xyzw} = float4(1.0, -1.0, 0.25, -0.25)\n FxaaFloat4 fxaaConsole360ConstDir\n ) {\n /*--------------------------------------------------------------------------*/\n FxaaFloat2 posM;\n posM.x = pos.x;\n posM.y = pos.y;\n #if (FXAA_GATHER4_ALPHA == 1)\n #if (FXAA_DISCARD == 0)\n FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n #if (FXAA_GREEN_AS_LUMA == 0)\n #define lumaM rgbyM.w\n #else\n #define lumaM rgbyM.y\n #endif\n #endif\n #if (FXAA_GREEN_AS_LUMA == 0)\n FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);\n FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));\n #else\n FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);\n FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));\n #endif\n #if (FXAA_DISCARD == 1)\n #define lumaM luma4A.w\n #endif\n #define lumaE luma4A.z\n #define lumaS luma4A.x\n #define lumaSE luma4A.y\n #define lumaNW luma4B.w\n #define lumaN luma4B.z\n #define lumaW luma4B.x\n #else\n FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n #if (FXAA_GREEN_AS_LUMA == 0)\n #define lumaM rgbyM.w\n #else\n #define lumaM rgbyM.y\n #endif\n #if (FXAA_GLSL_100 == 1)\n FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0, 1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 0.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0,-1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));\n #else\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 #endif\n #endif\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 #if (FXAA_DISCARD == 1)\n FxaaDiscard;\n #else\n return rgbyM;\n #endif\n /*--------------------------------------------------------------------------*/\n #if (FXAA_GATHER4_ALPHA == 0)\n #if (FXAA_GLSL_100 == 1)\n FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0,-1.0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));\n #else\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 #endif\n #else\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 #endif\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 #if (FXAA_DISCARD == 1)\n return FxaaTexTop(tex, posM);\n #else\n return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);\n #endif\n }\n /*==========================================================================*/\n #endif\n \n void main() {\n gl_FragColor = FxaaPixelShader(\n vUv,\n vec4(0.0),\n tDiffuse,\n tDiffuse,\n tDiffuse,\n resolution,\n vec4(0.0),\n vec4(0.0),\n vec4(0.0),\n 0.75,\n 0.166,\n 0.0833,\n 0.0,\n 0.0,\n 0.0,\n vec4(0.0)\n );\n \n // TODO avoid querying texture twice for same texel\n gl_FragColor.a = texture2D(tDiffuse, vUv).a;\n }\n `,\n}\n"],"names":[],"mappings":";AASO,MAAM,aAAa;AAAA,EACxB,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,YAAY,EAAE,OAAuB,oBAAI,QAAQ,IAAI,MAAM,IAAI,GAAG,EAAE;AAAA,EACtE;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyjC7B;"}
|
@@ -97,7 +97,7 @@ const GodRaysGenerateShader = {
|
|
97
97
|
// Unrolling didnt do much on my hardware (ATI Mobility Radeon 3450),
|
98
98
|
// so ive just left the loop
|
99
99
|
|
100
|
-
|
100
|
+
for ( float i = 0.0; i < TAPS_PER_PASS; i += 1.0 ) {
|
101
101
|
|
102
102
|
// Accumulate samples, making sure we dont walk past the light source.
|
103
103
|
|
@@ -107,10 +107,10 @@ const GodRaysGenerateShader = {
|
|
107
107
|
// sun is to the left, right or bottom of screen as these cases are
|
108
108
|
// not specifically handled.
|
109
109
|
|
110
|
-
|
111
|
-
|
110
|
+
col += ( i <= iters && uv.y < 1.0 ? texture2D( tInput, uv ).r : 0.0 );
|
111
|
+
uv += stepv;
|
112
112
|
|
113
|
-
|
113
|
+
}
|
114
114
|
*/
|
115
115
|
|
116
116
|
// Unrolling loop manually makes it work in ANGLE
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GodRaysShader.cjs","sources":["../../src/shaders/GodRaysShader.ts"],"sourcesContent":["import { Color, Vector3 } from 'three'\n\n/**\n * God-rays (crepuscular rays)\n *\n * Similar implementation to the one used by Crytek for CryEngine 2 [Sousa2008].\n * Blurs a mask generated from the depth map along radial lines emanating from the light\n * source. The blur repeatedly applies a blur filter of increasing support but constant\n * sample count to produce a blur filter with large support.\n *\n * My implementation performs 3 passes, similar to the implementation from Sousa. I found\n * just 6 samples per pass produced acceptible results. The blur is applied three times,\n * with decreasing filter support. The result is equivalent to a single pass with\n * 6*6*6 = 216 samples.\n *\n * References:\n *\n * Sousa2008 - Crysis Next Gen Effects, GDC2008, http://www.crytek.com/sites/default/files/GDC08_SousaT_CrysisEffects.ppt\n */\n\nexport const GodRaysDepthMaskShader = {\n uniforms: {\n tInput: {\n value: null,\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n varying vec2 vUv;\n\n uniform sampler2D tInput;\n\n void main() {\n\n \tgl_FragColor = vec4( 1.0 ) - texture2D( tInput, vUv );\n\n }\n `,\n}\n\n/**\n * The god-ray generation shader.\n *\n * First pass:\n *\n * The depth map is blurred along radial lines towards the \"sun\". The\n * output is written to a temporary render target (I used a 1/4 sized\n * target).\n *\n * Pass two & three:\n *\n * The results of the previous pass are re-blurred, each time with a\n * decreased distance between samples.\n */\n\nexport const GodRaysGenerateShader = {\n uniforms: {\n tInput: {\n value: null,\n },\n fStepSize: {\n value: 1.0,\n },\n vSunPositionScreenSpace: {\n value: /* @__PURE__ */ new Vector3(),\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n #define TAPS_PER_PASS 6.0\n\n varying vec2 vUv;\n\n uniform sampler2D tInput;\n\n uniform vec3 vSunPositionScreenSpace;\n uniform float fStepSize; // filter step size\n\n void main() {\n\n // delta from current pixel to \"sun\" position\n\n \tvec2 delta = vSunPositionScreenSpace.xy - vUv;\n \tfloat dist = length( delta );\n\n // Step vector (uv space)\n\n \tvec2 stepv = fStepSize * delta / dist;\n\n // Number of iterations between pixel and sun\n\n \tfloat iters = dist/fStepSize;\n\n \tvec2 uv = vUv.xy;\n \tfloat col = 0.0;\n\n // This breaks ANGLE in Chrome 22\n //\t- see http://code.google.com/p/chromium/issues/detail?id=153105\n\n /*\n\t\t// Unrolling didnt do much on my hardware (ATI Mobility Radeon 3450),\n\t\t// so ive just left the loop\n\n\t\
|
1
|
+
{"version":3,"file":"GodRaysShader.cjs","sources":["../../src/shaders/GodRaysShader.ts"],"sourcesContent":["import { Color, Vector3 } from 'three'\n\n/**\n * God-rays (crepuscular rays)\n *\n * Similar implementation to the one used by Crytek for CryEngine 2 [Sousa2008].\n * Blurs a mask generated from the depth map along radial lines emanating from the light\n * source. The blur repeatedly applies a blur filter of increasing support but constant\n * sample count to produce a blur filter with large support.\n *\n * My implementation performs 3 passes, similar to the implementation from Sousa. I found\n * just 6 samples per pass produced acceptible results. The blur is applied three times,\n * with decreasing filter support. The result is equivalent to a single pass with\n * 6*6*6 = 216 samples.\n *\n * References:\n *\n * Sousa2008 - Crysis Next Gen Effects, GDC2008, http://www.crytek.com/sites/default/files/GDC08_SousaT_CrysisEffects.ppt\n */\n\nexport const GodRaysDepthMaskShader = {\n uniforms: {\n tInput: {\n value: null,\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n varying vec2 vUv;\n\n uniform sampler2D tInput;\n\n void main() {\n\n \tgl_FragColor = vec4( 1.0 ) - texture2D( tInput, vUv );\n\n }\n `,\n}\n\n/**\n * The god-ray generation shader.\n *\n * First pass:\n *\n * The depth map is blurred along radial lines towards the \"sun\". The\n * output is written to a temporary render target (I used a 1/4 sized\n * target).\n *\n * Pass two & three:\n *\n * The results of the previous pass are re-blurred, each time with a\n * decreased distance between samples.\n */\n\nexport const GodRaysGenerateShader = {\n uniforms: {\n tInput: {\n value: null,\n },\n fStepSize: {\n value: 1.0,\n },\n vSunPositionScreenSpace: {\n value: /* @__PURE__ */ new Vector3(),\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n #define TAPS_PER_PASS 6.0\n\n varying vec2 vUv;\n\n uniform sampler2D tInput;\n\n uniform vec3 vSunPositionScreenSpace;\n uniform float fStepSize; // filter step size\n\n void main() {\n\n // delta from current pixel to \"sun\" position\n\n \tvec2 delta = vSunPositionScreenSpace.xy - vUv;\n \tfloat dist = length( delta );\n\n // Step vector (uv space)\n\n \tvec2 stepv = fStepSize * delta / dist;\n\n // Number of iterations between pixel and sun\n\n \tfloat iters = dist/fStepSize;\n\n \tvec2 uv = vUv.xy;\n \tfloat col = 0.0;\n\n // This breaks ANGLE in Chrome 22\n //\t- see http://code.google.com/p/chromium/issues/detail?id=153105\n\n /*\n\t\t// Unrolling didnt do much on my hardware (ATI Mobility Radeon 3450),\n\t\t// so ive just left the loop\n\n\t\tfor ( float i = 0.0; i < TAPS_PER_PASS; i += 1.0 ) {\n\n\t\t// Accumulate samples, making sure we dont walk past the light source.\n\n\t\t// The check for uv.y < 1 would not be necessary with \"border\" UV wrap\n\t\t// mode, with a black border color. I dont think this is currently\n\t\t// exposed by three.js. As a result there might be artifacts when the\n\t\t// sun is to the left, right or bottom of screen as these cases are\n\t\t// not specifically handled.\n\n\t\tcol += ( i <= iters && uv.y < 1.0 ? texture2D( tInput, uv ).r : 0.0 );\n\t\tuv += stepv;\n\n\t\t}\n\t\t*/\n\n // Unrolling loop manually makes it work in ANGLE\n\n \tfloat f = min( 1.0, max( vSunPositionScreenSpace.z / 1000.0, 0.0 ) ); // used to fade out godrays\n\n \tif ( 0.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n \tif ( 1.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n \tif ( 2.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n \tif ( 3.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n \tif ( 4.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n \tif ( 5.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n // Should technically be dividing by iters but TAPS_PER_PASS smooths out\n // objectionable artifacts, in particular near the sun position. The side\n // effect is that the result is darker than it should be around the sun, as\n // TAPS_PER_PASS is greater than the number of samples actually accumulated.\n // When the result is inverted (in the shader godrays_combine this produces\n // a slight bright spot at the position of the sun, even when it is occluded.\n\n \tgl_FragColor = vec4( col/TAPS_PER_PASS );\n \tgl_FragColor.a = 1.0;\n\n }\n `,\n}\n\n/**\n * Additively applies god rays from texture tGodRays to a background (tColors).\n * fGodRayIntensity attenuates the god rays.\n */\n\nexport const GodRaysCombineShader = {\n uniforms: {\n tColors: {\n value: null,\n },\n\n tGodRays: {\n value: null,\n },\n\n fGodRayIntensity: {\n value: 0.69,\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n varying vec2 vUv;\n\n uniform sampler2D tColors;\n uniform sampler2D tGodRays;\n\n uniform float fGodRayIntensity;\n\n void main() {\n\n // Since THREE.MeshDepthMaterial renders foreground objects white and background\n // objects black, the god-rays will be white streaks. Therefore value is inverted\n // before being combined with tColors\n\n \tgl_FragColor = texture2D( tColors, vUv ) + fGodRayIntensity * vec4( 1.0 - texture2D( tGodRays, vUv ).r );\n \tgl_FragColor.a = 1.0;\n\n }\n `,\n}\n\n/**\n * A dodgy sun/sky shader. Makes a bright spot at the sun location. Would be\n * cheaper/faster/simpler to implement this as a simple sun sprite.\n */\n\nexport const GodRaysFakeSunShader = {\n uniforms: {\n vSunPositionScreenSpace: {\n value: /* @__PURE__ */ new Vector3(),\n },\n\n fAspect: {\n value: 1.0,\n },\n\n sunColor: {\n value: /* @__PURE__ */ new Color(0xffee00),\n },\n\n bgColor: {\n value: /* @__PURE__ */ new Color(0x000000),\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n varying vec2 vUv;\n\n uniform vec3 vSunPositionScreenSpace;\n uniform float fAspect;\n\n uniform vec3 sunColor;\n uniform vec3 bgColor;\n\n void main() {\n\n \tvec2 diff = vUv - vSunPositionScreenSpace.xy;\n\n // Correct for aspect ratio\n\n \tdiff.x *= fAspect;\n\n \tfloat prop = clamp( length( diff ) / 0.5, 0.0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
|
// Unrolling didnt do much on my hardware (ATI Mobility Radeon 3450),
|
96
96
|
// so ive just left the loop
|
97
97
|
|
98
|
-
|
98
|
+
for ( float i = 0.0; i < TAPS_PER_PASS; i += 1.0 ) {
|
99
99
|
|
100
100
|
// Accumulate samples, making sure we dont walk past the light source.
|
101
101
|
|
@@ -105,10 +105,10 @@ const GodRaysGenerateShader = {
|
|
105
105
|
// sun is to the left, right or bottom of screen as these cases are
|
106
106
|
// not specifically handled.
|
107
107
|
|
108
|
-
|
109
|
-
|
108
|
+
col += ( i <= iters && uv.y < 1.0 ? texture2D( tInput, uv ).r : 0.0 );
|
109
|
+
uv += stepv;
|
110
110
|
|
111
|
-
|
111
|
+
}
|
112
112
|
*/
|
113
113
|
|
114
114
|
// Unrolling loop manually makes it work in ANGLE
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GodRaysShader.js","sources":["../../src/shaders/GodRaysShader.ts"],"sourcesContent":["import { Color, Vector3 } from 'three'\n\n/**\n * God-rays (crepuscular rays)\n *\n * Similar implementation to the one used by Crytek for CryEngine 2 [Sousa2008].\n * Blurs a mask generated from the depth map along radial lines emanating from the light\n * source. The blur repeatedly applies a blur filter of increasing support but constant\n * sample count to produce a blur filter with large support.\n *\n * My implementation performs 3 passes, similar to the implementation from Sousa. I found\n * just 6 samples per pass produced acceptible results. The blur is applied three times,\n * with decreasing filter support. The result is equivalent to a single pass with\n * 6*6*6 = 216 samples.\n *\n * References:\n *\n * Sousa2008 - Crysis Next Gen Effects, GDC2008, http://www.crytek.com/sites/default/files/GDC08_SousaT_CrysisEffects.ppt\n */\n\nexport const GodRaysDepthMaskShader = {\n uniforms: {\n tInput: {\n value: null,\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n varying vec2 vUv;\n\n uniform sampler2D tInput;\n\n void main() {\n\n \tgl_FragColor = vec4( 1.0 ) - texture2D( tInput, vUv );\n\n }\n `,\n}\n\n/**\n * The god-ray generation shader.\n *\n * First pass:\n *\n * The depth map is blurred along radial lines towards the \"sun\". The\n * output is written to a temporary render target (I used a 1/4 sized\n * target).\n *\n * Pass two & three:\n *\n * The results of the previous pass are re-blurred, each time with a\n * decreased distance between samples.\n */\n\nexport const GodRaysGenerateShader = {\n uniforms: {\n tInput: {\n value: null,\n },\n fStepSize: {\n value: 1.0,\n },\n vSunPositionScreenSpace: {\n value: /* @__PURE__ */ new Vector3(),\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n #define TAPS_PER_PASS 6.0\n\n varying vec2 vUv;\n\n uniform sampler2D tInput;\n\n uniform vec3 vSunPositionScreenSpace;\n uniform float fStepSize; // filter step size\n\n void main() {\n\n // delta from current pixel to \"sun\" position\n\n \tvec2 delta = vSunPositionScreenSpace.xy - vUv;\n \tfloat dist = length( delta );\n\n // Step vector (uv space)\n\n \tvec2 stepv = fStepSize * delta / dist;\n\n // Number of iterations between pixel and sun\n\n \tfloat iters = dist/fStepSize;\n\n \tvec2 uv = vUv.xy;\n \tfloat col = 0.0;\n\n // This breaks ANGLE in Chrome 22\n //\t- see http://code.google.com/p/chromium/issues/detail?id=153105\n\n /*\n\t\t// Unrolling didnt do much on my hardware (ATI Mobility Radeon 3450),\n\t\t// so ive just left the loop\n\n\t\
|
1
|
+
{"version":3,"file":"GodRaysShader.js","sources":["../../src/shaders/GodRaysShader.ts"],"sourcesContent":["import { Color, Vector3 } from 'three'\n\n/**\n * God-rays (crepuscular rays)\n *\n * Similar implementation to the one used by Crytek for CryEngine 2 [Sousa2008].\n * Blurs a mask generated from the depth map along radial lines emanating from the light\n * source. The blur repeatedly applies a blur filter of increasing support but constant\n * sample count to produce a blur filter with large support.\n *\n * My implementation performs 3 passes, similar to the implementation from Sousa. I found\n * just 6 samples per pass produced acceptible results. The blur is applied three times,\n * with decreasing filter support. The result is equivalent to a single pass with\n * 6*6*6 = 216 samples.\n *\n * References:\n *\n * Sousa2008 - Crysis Next Gen Effects, GDC2008, http://www.crytek.com/sites/default/files/GDC08_SousaT_CrysisEffects.ppt\n */\n\nexport const GodRaysDepthMaskShader = {\n uniforms: {\n tInput: {\n value: null,\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n varying vec2 vUv;\n\n uniform sampler2D tInput;\n\n void main() {\n\n \tgl_FragColor = vec4( 1.0 ) - texture2D( tInput, vUv );\n\n }\n `,\n}\n\n/**\n * The god-ray generation shader.\n *\n * First pass:\n *\n * The depth map is blurred along radial lines towards the \"sun\". The\n * output is written to a temporary render target (I used a 1/4 sized\n * target).\n *\n * Pass two & three:\n *\n * The results of the previous pass are re-blurred, each time with a\n * decreased distance between samples.\n */\n\nexport const GodRaysGenerateShader = {\n uniforms: {\n tInput: {\n value: null,\n },\n fStepSize: {\n value: 1.0,\n },\n vSunPositionScreenSpace: {\n value: /* @__PURE__ */ new Vector3(),\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n #define TAPS_PER_PASS 6.0\n\n varying vec2 vUv;\n\n uniform sampler2D tInput;\n\n uniform vec3 vSunPositionScreenSpace;\n uniform float fStepSize; // filter step size\n\n void main() {\n\n // delta from current pixel to \"sun\" position\n\n \tvec2 delta = vSunPositionScreenSpace.xy - vUv;\n \tfloat dist = length( delta );\n\n // Step vector (uv space)\n\n \tvec2 stepv = fStepSize * delta / dist;\n\n // Number of iterations between pixel and sun\n\n \tfloat iters = dist/fStepSize;\n\n \tvec2 uv = vUv.xy;\n \tfloat col = 0.0;\n\n // This breaks ANGLE in Chrome 22\n //\t- see http://code.google.com/p/chromium/issues/detail?id=153105\n\n /*\n\t\t// Unrolling didnt do much on my hardware (ATI Mobility Radeon 3450),\n\t\t// so ive just left the loop\n\n\t\tfor ( float i = 0.0; i < TAPS_PER_PASS; i += 1.0 ) {\n\n\t\t// Accumulate samples, making sure we dont walk past the light source.\n\n\t\t// The check for uv.y < 1 would not be necessary with \"border\" UV wrap\n\t\t// mode, with a black border color. I dont think this is currently\n\t\t// exposed by three.js. As a result there might be artifacts when the\n\t\t// sun is to the left, right or bottom of screen as these cases are\n\t\t// not specifically handled.\n\n\t\tcol += ( i <= iters && uv.y < 1.0 ? texture2D( tInput, uv ).r : 0.0 );\n\t\tuv += stepv;\n\n\t\t}\n\t\t*/\n\n // Unrolling loop manually makes it work in ANGLE\n\n \tfloat f = min( 1.0, max( vSunPositionScreenSpace.z / 1000.0, 0.0 ) ); // used to fade out godrays\n\n \tif ( 0.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n \tif ( 1.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n \tif ( 2.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n \tif ( 3.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n \tif ( 4.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n \tif ( 5.0 <= iters && uv.y < 1.0 ) col += texture2D( tInput, uv ).r * f;\n \tuv += stepv;\n\n // Should technically be dividing by iters but TAPS_PER_PASS smooths out\n // objectionable artifacts, in particular near the sun position. The side\n // effect is that the result is darker than it should be around the sun, as\n // TAPS_PER_PASS is greater than the number of samples actually accumulated.\n // When the result is inverted (in the shader godrays_combine this produces\n // a slight bright spot at the position of the sun, even when it is occluded.\n\n \tgl_FragColor = vec4( col/TAPS_PER_PASS );\n \tgl_FragColor.a = 1.0;\n\n }\n `,\n}\n\n/**\n * Additively applies god rays from texture tGodRays to a background (tColors).\n * fGodRayIntensity attenuates the god rays.\n */\n\nexport const GodRaysCombineShader = {\n uniforms: {\n tColors: {\n value: null,\n },\n\n tGodRays: {\n value: null,\n },\n\n fGodRayIntensity: {\n value: 0.69,\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n varying vec2 vUv;\n\n uniform sampler2D tColors;\n uniform sampler2D tGodRays;\n\n uniform float fGodRayIntensity;\n\n void main() {\n\n // Since THREE.MeshDepthMaterial renders foreground objects white and background\n // objects black, the god-rays will be white streaks. Therefore value is inverted\n // before being combined with tColors\n\n \tgl_FragColor = texture2D( tColors, vUv ) + fGodRayIntensity * vec4( 1.0 - texture2D( tGodRays, vUv ).r );\n \tgl_FragColor.a = 1.0;\n\n }\n `,\n}\n\n/**\n * A dodgy sun/sky shader. Makes a bright spot at the sun location. Would be\n * cheaper/faster/simpler to implement this as a simple sun sprite.\n */\n\nexport const GodRaysFakeSunShader = {\n uniforms: {\n vSunPositionScreenSpace: {\n value: /* @__PURE__ */ new Vector3(),\n },\n\n fAspect: {\n value: 1.0,\n },\n\n sunColor: {\n value: /* @__PURE__ */ new Color(0xffee00),\n },\n\n bgColor: {\n value: /* @__PURE__ */ new Color(0x000000),\n },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n varying vec2 vUv;\n\n uniform vec3 vSunPositionScreenSpace;\n uniform float fAspect;\n\n uniform vec3 sunColor;\n uniform vec3 bgColor;\n\n void main() {\n\n \tvec2 diff = vUv - vSunPositionScreenSpace.xy;\n\n // Correct for aspect ratio\n\n \tdiff.x *= fAspect;\n\n \tfloat prop = clamp( length( diff ) / 0.5, 0.0, 1.0 );\n \tprop = 0.35 * pow( 1.0 - prop, 3.0 );\n\n \tgl_FragColor.xyz = ( vSunPositionScreenSpace.z > 0.0 ) ? mix( sunColor, bgColor, 1.0 - prop ) : bgColor;\n \tgl_FragColor.w = 1.0;\n\n }\n `,\n}\n"],"names":[],"mappings":";AAoBO,MAAM,yBAAyB;AAAA,EACpC,UAAU;AAAA,IACR,QAAQ;AAAA,MACN,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAW7B;AAiBO,MAAM,wBAAwB;AAAA,EACnC,UAAU;AAAA,IACR,QAAQ;AAAA,MACN,OAAO;AAAA,IACT;AAAA,IACA,WAAW;AAAA,MACT,OAAO;AAAA,IACT;AAAA,IACA,yBAAyB;AAAA,MACvB,2BAA2B,QAAQ;AAAA,IACrC;AAAA,EACF;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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A;AAyB7B;"}
|
@@ -56,7 +56,7 @@ const ParallaxShader = {
|
|
56
56
|
float initialHeight = texture2D( bumpMap, vUv ).r;
|
57
57
|
|
58
58
|
// No Offset Limitting: messy, floating output at grazing angles.
|
59
|
-
//
|
59
|
+
//vec2 texCoordOffset = parallaxScale * V.xy / V.z * initialHeight;
|
60
60
|
|
61
61
|
// Offset Limiting
|
62
62
|
vec2 texCoordOffset = parallaxScale * V.xy * initialHeight;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ParallaxShader.cjs","sources":["../../src/shaders/ParallaxShader.ts"],"sourcesContent":["// Parallax Occlusion shaders from\n// http://sunandblackcat.com/tipFullView.php?topicid=28\n// No tangent-space transforms logic based on\n// http://mmikkelsen3d.blogspot.sk/2012/02/parallaxpoc-mapping-and-no-tangent.html\n\nexport const ParallaxShader = {\n // Ordered from fastest to best quality.\n modes: {\n none: 'NO_PARALLAX',\n basic: 'USE_BASIC_PARALLAX',\n steep: 'USE_STEEP_PARALLAX',\n occlusion: 'USE_OCLUSION_PARALLAX', // a.k.a. POM\n relief: 'USE_RELIEF_PARALLAX',\n },\n\n uniforms: {\n bumpMap: { value: null },\n map: { value: null },\n parallaxScale: { value: null },\n parallaxMinLayers: { value: null },\n parallaxMaxLayers: { value: null },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n varying vec3 vViewPosition;\n varying vec3 vNormal;\n\n void main() {\n\n \tvUv = uv;\n \tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n \tvViewPosition = -mvPosition.xyz;\n \tvNormal = normalize( normalMatrix * normal );\n \tgl_Position = projectionMatrix * mvPosition;\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D bumpMap;\n uniform sampler2D map;\n\n uniform float parallaxScale;\n uniform float parallaxMinLayers;\n uniform float parallaxMaxLayers;\n\n varying vec2 vUv;\n varying vec3 vViewPosition;\n varying vec3 vNormal;\n\n #ifdef USE_BASIC_PARALLAX\n\n \tvec2 parallaxMap( in vec3 V ) {\n\n \t\tfloat initialHeight = texture2D( bumpMap, vUv ).r;\n\n // No Offset Limitting: messy, floating output at grazing angles.\n
|
1
|
+
{"version":3,"file":"ParallaxShader.cjs","sources":["../../src/shaders/ParallaxShader.ts"],"sourcesContent":["// Parallax Occlusion shaders from\n// http://sunandblackcat.com/tipFullView.php?topicid=28\n// No tangent-space transforms logic based on\n// http://mmikkelsen3d.blogspot.sk/2012/02/parallaxpoc-mapping-and-no-tangent.html\n\nexport const ParallaxShader = {\n // Ordered from fastest to best quality.\n modes: {\n none: 'NO_PARALLAX',\n basic: 'USE_BASIC_PARALLAX',\n steep: 'USE_STEEP_PARALLAX',\n occlusion: 'USE_OCLUSION_PARALLAX', // a.k.a. POM\n relief: 'USE_RELIEF_PARALLAX',\n },\n\n uniforms: {\n bumpMap: { value: null },\n map: { value: null },\n parallaxScale: { value: null },\n parallaxMinLayers: { value: null },\n parallaxMaxLayers: { value: null },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n varying vec3 vViewPosition;\n varying vec3 vNormal;\n\n void main() {\n\n \tvUv = uv;\n \tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n \tvViewPosition = -mvPosition.xyz;\n \tvNormal = normalize( normalMatrix * normal );\n \tgl_Position = projectionMatrix * mvPosition;\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D bumpMap;\n uniform sampler2D map;\n\n uniform float parallaxScale;\n uniform float parallaxMinLayers;\n uniform float parallaxMaxLayers;\n\n varying vec2 vUv;\n varying vec3 vViewPosition;\n varying vec3 vNormal;\n\n #ifdef USE_BASIC_PARALLAX\n\n \tvec2 parallaxMap( in vec3 V ) {\n\n \t\tfloat initialHeight = texture2D( bumpMap, vUv ).r;\n\n // No Offset Limitting: messy, floating output at grazing angles.\n //vec2 texCoordOffset = parallaxScale * V.xy / V.z * initialHeight;\n\n // Offset Limiting\n \t\tvec2 texCoordOffset = parallaxScale * V.xy * initialHeight;\n \t\treturn vUv - texCoordOffset;\n\n \t}\n\n #else\n\n \tvec2 parallaxMap( in vec3 V ) {\n\n // Determine number of layers from angle between V and N\n \t\tfloat numLayers = mix( parallaxMaxLayers, parallaxMinLayers, abs( dot( vec3( 0.0, 0.0, 1.0 ), V ) ) );\n\n \t\tfloat layerHeight = 1.0 / numLayers;\n \t\tfloat currentLayerHeight = 0.0;\n // Shift of texture coordinates for each iteration\n \t\tvec2 dtex = parallaxScale * V.xy / V.z / numLayers;\n\n \t\tvec2 currentTextureCoords = vUv;\n\n \t\tfloat heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;\n\n // while ( heightFromTexture > currentLayerHeight )\n // Infinite loops are not well supported. Do a \"large\" finite\n // loop, but not too large, as it slows down some compilers.\n \t\tfor ( int i = 0; i < 30; i += 1 ) {\n \t\t\tif ( heightFromTexture <= currentLayerHeight ) {\n \t\t\t\tbreak;\n \t\t\t}\n \t\t\tcurrentLayerHeight += layerHeight;\n // Shift texture coordinates along vector V\n \t\t\tcurrentTextureCoords -= dtex;\n \t\t\theightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;\n \t\t}\n\n \t\t#ifdef USE_STEEP_PARALLAX\n\n \t\t\treturn currentTextureCoords;\n\n \t\t#elif defined( USE_RELIEF_PARALLAX )\n\n \t\t\tvec2 deltaTexCoord = dtex / 2.0;\n \t\t\tfloat deltaHeight = layerHeight / 2.0;\n\n // Return to the mid point of previous layer\n \t\t\tcurrentTextureCoords += deltaTexCoord;\n \t\t\tcurrentLayerHeight -= deltaHeight;\n\n // Binary search to increase precision of Steep Parallax Mapping\n \t\t\tconst int numSearches = 5;\n \t\t\tfor ( int i = 0; i < numSearches; i += 1 ) {\n\n \t\t\t\tdeltaTexCoord /= 2.0;\n \t\t\t\tdeltaHeight /= 2.0;\n \t\t\t\theightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;\n // Shift along or against vector V\n \t\t\t\tif( heightFromTexture > currentLayerHeight ) { // Below the surface\n\n \t\t\t\t\tcurrentTextureCoords -= deltaTexCoord;\n \t\t\t\t\tcurrentLayerHeight += deltaHeight;\n\n \t\t\t\t} else { // above the surface\n\n \t\t\t\t\tcurrentTextureCoords += deltaTexCoord;\n \t\t\t\t\tcurrentLayerHeight -= deltaHeight;\n\n \t\t\t\t}\n\n \t\t\t}\n \t\t\treturn currentTextureCoords;\n\n \t\t#elif defined( USE_OCLUSION_PARALLAX )\n\n \t\t\tvec2 prevTCoords = currentTextureCoords + dtex;\n\n // Heights for linear interpolation\n \t\t\tfloat nextH = heightFromTexture - currentLayerHeight;\n \t\t\tfloat prevH = texture2D( bumpMap, prevTCoords ).r - currentLayerHeight + layerHeight;\n\n // Proportions for linear interpolation\n \t\t\tfloat weight = nextH / ( nextH - prevH );\n\n // Interpolation of texture coordinates\n \t\t\treturn prevTCoords * weight + currentTextureCoords * ( 1.0 - weight );\n\n \t\t#else // NO_PARALLAX\n\n \t\t\treturn vUv;\n\n \t\t#endif\n\n \t}\n #endif\n\n vec2 perturbUv( vec3 surfPosition, vec3 surfNormal, vec3 viewPosition ) {\n\n \tvec2 texDx = dFdx( vUv );\n \tvec2 texDy = dFdy( vUv );\n\n \tvec3 vSigmaX = dFdx( surfPosition );\n \tvec3 vSigmaY = dFdy( surfPosition );\n \tvec3 vR1 = cross( vSigmaY, surfNormal );\n \tvec3 vR2 = cross( surfNormal, vSigmaX );\n \tfloat fDet = dot( vSigmaX, vR1 );\n\n \tvec2 vProjVscr = ( 1.0 / fDet ) * vec2( dot( vR1, viewPosition ), dot( vR2, viewPosition ) );\n \tvec3 vProjVtex;\n \tvProjVtex.xy = texDx * vProjVscr.x + texDy * vProjVscr.y;\n \tvProjVtex.z = dot( surfNormal, viewPosition );\n\n \treturn parallaxMap( vProjVtex );\n }\n\n void main() {\n\n \tvec2 mapUv = perturbUv( -vViewPosition, normalize( vNormal ), normalize( vViewPosition ) );\n \tgl_FragColor = texture2D( map, mapUv );\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAKO,MAAM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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6I7B;;"}
|
@@ -54,7 +54,7 @@ const ParallaxShader = {
|
|
54
54
|
float initialHeight = texture2D( bumpMap, vUv ).r;
|
55
55
|
|
56
56
|
// No Offset Limitting: messy, floating output at grazing angles.
|
57
|
-
//
|
57
|
+
//vec2 texCoordOffset = parallaxScale * V.xy / V.z * initialHeight;
|
58
58
|
|
59
59
|
// Offset Limiting
|
60
60
|
vec2 texCoordOffset = parallaxScale * V.xy * initialHeight;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ParallaxShader.js","sources":["../../src/shaders/ParallaxShader.ts"],"sourcesContent":["// Parallax Occlusion shaders from\n// http://sunandblackcat.com/tipFullView.php?topicid=28\n// No tangent-space transforms logic based on\n// http://mmikkelsen3d.blogspot.sk/2012/02/parallaxpoc-mapping-and-no-tangent.html\n\nexport const ParallaxShader = {\n // Ordered from fastest to best quality.\n modes: {\n none: 'NO_PARALLAX',\n basic: 'USE_BASIC_PARALLAX',\n steep: 'USE_STEEP_PARALLAX',\n occlusion: 'USE_OCLUSION_PARALLAX', // a.k.a. POM\n relief: 'USE_RELIEF_PARALLAX',\n },\n\n uniforms: {\n bumpMap: { value: null },\n map: { value: null },\n parallaxScale: { value: null },\n parallaxMinLayers: { value: null },\n parallaxMaxLayers: { value: null },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n varying vec3 vViewPosition;\n varying vec3 vNormal;\n\n void main() {\n\n \tvUv = uv;\n \tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n \tvViewPosition = -mvPosition.xyz;\n \tvNormal = normalize( normalMatrix * normal );\n \tgl_Position = projectionMatrix * mvPosition;\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D bumpMap;\n uniform sampler2D map;\n\n uniform float parallaxScale;\n uniform float parallaxMinLayers;\n uniform float parallaxMaxLayers;\n\n varying vec2 vUv;\n varying vec3 vViewPosition;\n varying vec3 vNormal;\n\n #ifdef USE_BASIC_PARALLAX\n\n \tvec2 parallaxMap( in vec3 V ) {\n\n \t\tfloat initialHeight = texture2D( bumpMap, vUv ).r;\n\n // No Offset Limitting: messy, floating output at grazing angles.\n
|
1
|
+
{"version":3,"file":"ParallaxShader.js","sources":["../../src/shaders/ParallaxShader.ts"],"sourcesContent":["// Parallax Occlusion shaders from\n// http://sunandblackcat.com/tipFullView.php?topicid=28\n// No tangent-space transforms logic based on\n// http://mmikkelsen3d.blogspot.sk/2012/02/parallaxpoc-mapping-and-no-tangent.html\n\nexport const ParallaxShader = {\n // Ordered from fastest to best quality.\n modes: {\n none: 'NO_PARALLAX',\n basic: 'USE_BASIC_PARALLAX',\n steep: 'USE_STEEP_PARALLAX',\n occlusion: 'USE_OCLUSION_PARALLAX', // a.k.a. POM\n relief: 'USE_RELIEF_PARALLAX',\n },\n\n uniforms: {\n bumpMap: { value: null },\n map: { value: null },\n parallaxScale: { value: null },\n parallaxMinLayers: { value: null },\n parallaxMaxLayers: { value: null },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n varying vec3 vViewPosition;\n varying vec3 vNormal;\n\n void main() {\n\n \tvUv = uv;\n \tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n \tvViewPosition = -mvPosition.xyz;\n \tvNormal = normalize( normalMatrix * normal );\n \tgl_Position = projectionMatrix * mvPosition;\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform sampler2D bumpMap;\n uniform sampler2D map;\n\n uniform float parallaxScale;\n uniform float parallaxMinLayers;\n uniform float parallaxMaxLayers;\n\n varying vec2 vUv;\n varying vec3 vViewPosition;\n varying vec3 vNormal;\n\n #ifdef USE_BASIC_PARALLAX\n\n \tvec2 parallaxMap( in vec3 V ) {\n\n \t\tfloat initialHeight = texture2D( bumpMap, vUv ).r;\n\n // No Offset Limitting: messy, floating output at grazing angles.\n //vec2 texCoordOffset = parallaxScale * V.xy / V.z * initialHeight;\n\n // Offset Limiting\n \t\tvec2 texCoordOffset = parallaxScale * V.xy * initialHeight;\n \t\treturn vUv - texCoordOffset;\n\n \t}\n\n #else\n\n \tvec2 parallaxMap( in vec3 V ) {\n\n // Determine number of layers from angle between V and N\n \t\tfloat numLayers = mix( parallaxMaxLayers, parallaxMinLayers, abs( dot( vec3( 0.0, 0.0, 1.0 ), V ) ) );\n\n \t\tfloat layerHeight = 1.0 / numLayers;\n \t\tfloat currentLayerHeight = 0.0;\n // Shift of texture coordinates for each iteration\n \t\tvec2 dtex = parallaxScale * V.xy / V.z / numLayers;\n\n \t\tvec2 currentTextureCoords = vUv;\n\n \t\tfloat heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;\n\n // while ( heightFromTexture > currentLayerHeight )\n // Infinite loops are not well supported. Do a \"large\" finite\n // loop, but not too large, as it slows down some compilers.\n \t\tfor ( int i = 0; i < 30; i += 1 ) {\n \t\t\tif ( heightFromTexture <= currentLayerHeight ) {\n \t\t\t\tbreak;\n \t\t\t}\n \t\t\tcurrentLayerHeight += layerHeight;\n // Shift texture coordinates along vector V\n \t\t\tcurrentTextureCoords -= dtex;\n \t\t\theightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;\n \t\t}\n\n \t\t#ifdef USE_STEEP_PARALLAX\n\n \t\t\treturn currentTextureCoords;\n\n \t\t#elif defined( USE_RELIEF_PARALLAX )\n\n \t\t\tvec2 deltaTexCoord = dtex / 2.0;\n \t\t\tfloat deltaHeight = layerHeight / 2.0;\n\n // Return to the mid point of previous layer\n \t\t\tcurrentTextureCoords += deltaTexCoord;\n \t\t\tcurrentLayerHeight -= deltaHeight;\n\n // Binary search to increase precision of Steep Parallax Mapping\n \t\t\tconst int numSearches = 5;\n \t\t\tfor ( int i = 0; i < numSearches; i += 1 ) {\n\n \t\t\t\tdeltaTexCoord /= 2.0;\n \t\t\t\tdeltaHeight /= 2.0;\n \t\t\t\theightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;\n // Shift along or against vector V\n \t\t\t\tif( heightFromTexture > currentLayerHeight ) { // Below the surface\n\n \t\t\t\t\tcurrentTextureCoords -= deltaTexCoord;\n \t\t\t\t\tcurrentLayerHeight += deltaHeight;\n\n \t\t\t\t} else { // above the surface\n\n \t\t\t\t\tcurrentTextureCoords += deltaTexCoord;\n \t\t\t\t\tcurrentLayerHeight -= deltaHeight;\n\n \t\t\t\t}\n\n \t\t\t}\n \t\t\treturn currentTextureCoords;\n\n \t\t#elif defined( USE_OCLUSION_PARALLAX )\n\n \t\t\tvec2 prevTCoords = currentTextureCoords + dtex;\n\n // Heights for linear interpolation\n \t\t\tfloat nextH = heightFromTexture - currentLayerHeight;\n \t\t\tfloat prevH = texture2D( bumpMap, prevTCoords ).r - currentLayerHeight + layerHeight;\n\n // Proportions for linear interpolation\n \t\t\tfloat weight = nextH / ( nextH - prevH );\n\n // Interpolation of texture coordinates\n \t\t\treturn prevTCoords * weight + currentTextureCoords * ( 1.0 - weight );\n\n \t\t#else // NO_PARALLAX\n\n \t\t\treturn vUv;\n\n \t\t#endif\n\n \t}\n #endif\n\n vec2 perturbUv( vec3 surfPosition, vec3 surfNormal, vec3 viewPosition ) {\n\n \tvec2 texDx = dFdx( vUv );\n \tvec2 texDy = dFdy( vUv );\n\n \tvec3 vSigmaX = dFdx( surfPosition );\n \tvec3 vSigmaY = dFdy( surfPosition );\n \tvec3 vR1 = cross( vSigmaY, surfNormal );\n \tvec3 vR2 = cross( surfNormal, vSigmaX );\n \tfloat fDet = dot( vSigmaX, vR1 );\n\n \tvec2 vProjVscr = ( 1.0 / fDet ) * vec2( dot( vR1, viewPosition ), dot( vR2, viewPosition ) );\n \tvec3 vProjVtex;\n \tvProjVtex.xy = texDx * vProjVscr.x + texDy * vProjVscr.y;\n \tvProjVtex.z = dot( surfNormal, viewPosition );\n\n \treturn parallaxMap( vProjVtex );\n }\n\n void main() {\n\n \tvec2 mapUv =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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6I7B;"}
|
@@ -41,10 +41,10 @@ const VignetteShader = {
|
|
41
41
|
// alternative version from glfx.js
|
42
42
|
// this one makes more "dusty" look (as opposed to "burned")
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
vec4 color = texture2D( tDiffuse, vUv );
|
45
|
+
float dist = distance( vUv, vec2( 0.5 ) );
|
46
|
+
color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );
|
47
|
+
gl_FragColor = color;
|
48
48
|
*/
|
49
49
|
|
50
50
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"VignetteShader.cjs","sources":["../../src/shaders/VignetteShader.ts"],"sourcesContent":["/**\n * Vignette shader\n * based on PaintEffect postprocess from ro.me\n * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js\n */\n\nexport const VignetteShader = {\n uniforms: {\n tDiffuse: { value: null },\n offset: { value: 1.0 },\n darkness: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float offset;\n uniform float darkness;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n // Eskils vignette\n\n \tvec4 texel = texture2D( tDiffuse, vUv );\n \tvec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );\n \tgl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );\n\n /*\n\t\t// alternative version from glfx.js\n\t\t// this one makes more \"dusty\" look (as opposed to \"burned\")\n\n\t\
|
1
|
+
{"version":3,"file":"VignetteShader.cjs","sources":["../../src/shaders/VignetteShader.ts"],"sourcesContent":["/**\n * Vignette shader\n * based on PaintEffect postprocess from ro.me\n * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js\n */\n\nexport const VignetteShader = {\n uniforms: {\n tDiffuse: { value: null },\n offset: { value: 1.0 },\n darkness: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float offset;\n uniform float darkness;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n // Eskils vignette\n\n \tvec4 texel = texture2D( tDiffuse, vUv );\n \tvec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );\n \tgl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );\n\n /*\n\t\t// alternative version from glfx.js\n\t\t// this one makes more \"dusty\" look (as opposed to \"burned\")\n\n\t\tvec4 color = texture2D( tDiffuse, vUv );\n\t\tfloat dist = distance( vUv, vec2( 0.5 ) );\n\t\tcolor.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );\n\t\tgl_FragColor = color;\n\t\t*/\n\n }\n `,\n}\n"],"names":[],"mappings":";;AAMO,MAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,QAAQ,EAAE,OAAO,EAAI;AAAA,IACrB,UAAU,EAAE,OAAO,EAAI;AAAA,EACzB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4B7B;;"}
|
@@ -39,10 +39,10 @@ const VignetteShader = {
|
|
39
39
|
// alternative version from glfx.js
|
40
40
|
// this one makes more "dusty" look (as opposed to "burned")
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
vec4 color = texture2D( tDiffuse, vUv );
|
43
|
+
float dist = distance( vUv, vec2( 0.5 ) );
|
44
|
+
color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );
|
45
|
+
gl_FragColor = color;
|
46
46
|
*/
|
47
47
|
|
48
48
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"VignetteShader.js","sources":["../../src/shaders/VignetteShader.ts"],"sourcesContent":["/**\n * Vignette shader\n * based on PaintEffect postprocess from ro.me\n * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js\n */\n\nexport const VignetteShader = {\n uniforms: {\n tDiffuse: { value: null },\n offset: { value: 1.0 },\n darkness: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float offset;\n uniform float darkness;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n // Eskils vignette\n\n \tvec4 texel = texture2D( tDiffuse, vUv );\n \tvec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );\n \tgl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );\n\n /*\n\t\t// alternative version from glfx.js\n\t\t// this one makes more \"dusty\" look (as opposed to \"burned\")\n\n\t\
|
1
|
+
{"version":3,"file":"VignetteShader.js","sources":["../../src/shaders/VignetteShader.ts"],"sourcesContent":["/**\n * Vignette shader\n * based on PaintEffect postprocess from ro.me\n * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js\n */\n\nexport const VignetteShader = {\n uniforms: {\n tDiffuse: { value: null },\n offset: { value: 1.0 },\n darkness: { value: 1.0 },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform float offset;\n uniform float darkness;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n // Eskils vignette\n\n \tvec4 texel = texture2D( tDiffuse, vUv );\n \tvec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );\n \tgl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );\n\n /*\n\t\t// alternative version from glfx.js\n\t\t// this one makes more \"dusty\" look (as opposed to \"burned\")\n\n\t\tvec4 color = texture2D( tDiffuse, vUv );\n\t\tfloat dist = distance( vUv, vec2( 0.5 ) );\n\t\tcolor.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );\n\t\tgl_FragColor = color;\n\t\t*/\n\n }\n `,\n}\n"],"names":[],"mappings":"AAMO,MAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,KAAK;AAAA,IACxB,QAAQ,EAAE,OAAO,EAAI;AAAA,IACrB,UAAU,EAAE,OAAO,EAAI;AAAA,EACzB;AAAA,EAEA;AAAA;AAAA,IAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWzB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4B7B;"}
|