@luma.gl/effects 9.2.6 → 9.3.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +2686 -644
- package/dist/dist.min.js +10 -9
- package/dist/index.cjs +753 -302
- package/dist/index.cjs.map +3 -3
- package/dist/passes/postprocessing/fxaa/fxaa.d.ts +1 -0
- package/dist/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
- package/dist/passes/postprocessing/fxaa/fxaa.js +287 -0
- package/dist/passes/postprocessing/fxaa/fxaa.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +6 -7
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/denoise.js +32 -24
- package/dist/passes/postprocessing/image-adjust-filters/denoise.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js +26 -33
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/noise.js +10 -9
- package/dist/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js +12 -11
- package/dist/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +10 -10
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts +2 -2
- package/dist/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js +11 -15
- package/dist/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts +3 -3
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js +36 -18
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts +3 -3
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js +27 -18
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.js.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts +3 -3
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js +22 -13
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js +20 -18
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.js +12 -12
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts +3 -3
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/edgework.js +85 -14
- package/dist/passes/postprocessing/image-fun-filters/edgework.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js +35 -23
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/ink.js +26 -17
- package/dist/passes/postprocessing/image-fun-filters/ink.js.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.js +23 -13
- package/dist/passes/postprocessing/image-fun-filters/magnify.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts +3 -3
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js +28 -14
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts +3 -3
- package/dist/passes/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/swirl.js +21 -16
- package/dist/passes/postprocessing/image-warp-filters/swirl.js.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/warp.js +9 -4
- package/dist/passes/postprocessing/image-warp-filters/warp.js.map +1 -1
- package/package.json +4 -5
- package/src/passes/postprocessing/fxaa/fxaa.ts +288 -0
- package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +6 -7
- package/src/passes/postprocessing/image-adjust-filters/denoise.ts +34 -26
- package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +28 -35
- package/src/passes/postprocessing/image-adjust-filters/noise.ts +10 -9
- package/src/passes/postprocessing/image-adjust-filters/sepia.ts +12 -11
- package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +10 -10
- package/src/passes/postprocessing/image-adjust-filters/vignette.ts +11 -15
- package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +38 -20
- package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +27 -18
- package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +23 -14
- package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +20 -18
- package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +12 -12
- package/src/passes/postprocessing/image-fun-filters/edgework.ts +86 -15
- package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +39 -27
- package/src/passes/postprocessing/image-fun-filters/ink.ts +26 -17
- package/src/passes/postprocessing/image-fun-filters/magnify.ts +23 -13
- package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +28 -14
- package/src/passes/postprocessing/image-warp-filters/swirl.ts +21 -16
- package/src/passes/postprocessing/image-warp-filters/warp.ts +9 -4
|
@@ -6,6 +6,7 @@ export type FXAAUniforms = {};
|
|
|
6
6
|
export declare const fxaa: {
|
|
7
7
|
readonly name: "fxaa";
|
|
8
8
|
readonly propTypes: {};
|
|
9
|
+
readonly source: "fn fxaaSat(value: f32) -> f32 {\n return clamp(value, 0.0, 1.0);\n}\n\nfn fxaaTexTop(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texCoord: vec2f\n) -> vec4f {\n return textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0.0);\n}\n\nfn fxaaTexOff(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texCoord: vec2f,\n offset: vec2f,\n reciprocalFrame: vec2f\n) -> vec4f {\n return textureSampleLevel(\n sourceTexture,\n sourceTextureSampler,\n texCoord + offset * reciprocalFrame,\n 0.0\n );\n}\n\nfn fxaaLuma(color: vec4f) -> f32 {\n return dot(color.rgb, vec3f(0.2126, 0.7152, 0.0722));\n}\n\nfn fxaaGetQualityStep(stepIndex: u32) -> f32 {\n switch (stepIndex) {\n case 0u: {\n return 1.0;\n }\n case 1u: {\n return 1.5;\n }\n case 2u: {\n return 2.0;\n }\n case 3u: {\n return 2.0;\n }\n case 4u: {\n return 2.0;\n }\n case 5u: {\n return 2.0;\n }\n case 6u: {\n return 2.0;\n }\n case 7u: {\n return 2.0;\n }\n case 8u: {\n return 2.0;\n }\n case 9u: {\n return 2.0;\n }\n case 10u: {\n return 4.0;\n }\n default: {\n return 8.0;\n }\n }\n}\n\nfn fxaaPixelShader(\n texCoord: vec2f,\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n reciprocalFrame: vec2f,\n qualitySubpix: f32,\n qualityEdgeThreshold: f32,\n qualityEdgeThresholdMin: f32\n) -> vec4f {\n var posM = texCoord;\n let rgbyM = fxaaTexTop(sourceTexture, sourceTextureSampler, posM);\n let lumaM = rgbyM.g;\n var lumaS = fxaaLuma(\n fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(0.0, 1.0), reciprocalFrame)\n );\n let lumaE = fxaaLuma(\n fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, 0.0), reciprocalFrame)\n );\n var lumaN = fxaaLuma(\n fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(0.0, -1.0), reciprocalFrame)\n );\n let lumaW = fxaaLuma(\n fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, 0.0), reciprocalFrame)\n );\n\n let maxSM = max(lumaS, lumaM);\n let minSM = min(lumaS, lumaM);\n let maxESM = max(lumaE, maxSM);\n let minESM = min(lumaE, minSM);\n let maxWN = max(lumaN, lumaW);\n let minWN = min(lumaN, lumaW);\n let rangeMax = max(maxWN, maxESM);\n let rangeMin = min(minWN, minESM);\n let rangeMaxScaled = rangeMax * qualityEdgeThreshold;\n let range = rangeMax - rangeMin;\n let rangeMaxClamped = max(qualityEdgeThresholdMin, rangeMaxScaled);\n if (range < rangeMaxClamped) {\n return rgbyM;\n }\n\n let lumaNW = fxaaLuma(\n fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, -1.0), reciprocalFrame)\n );\n let lumaSE = fxaaLuma(\n fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, 1.0), reciprocalFrame)\n );\n let lumaNE = fxaaLuma(\n fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, -1.0), reciprocalFrame)\n );\n let lumaSW = fxaaLuma(\n fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, 1.0), reciprocalFrame)\n );\n\n let lumaNS = lumaN + lumaS;\n let lumaWE = lumaW + lumaE;\n let subpixReciprocalRange = 1.0 / range;\n let subpixNSWE = lumaNS + lumaWE;\n let edgeHorizontal1 = -2.0 * lumaM + lumaNS;\n let edgeVertical1 = -2.0 * lumaM + lumaWE;\n\n let lumaNESE = lumaNE + lumaSE;\n let lumaNWNE = lumaNW + lumaNE;\n let edgeHorizontal2 = -2.0 * lumaE + lumaNESE;\n let edgeVertical2 = -2.0 * lumaN + lumaNWNE;\n\n let lumaNWSW = lumaNW + lumaSW;\n let lumaSWSE = lumaSW + lumaSE;\n let edgeHorizontal4 = abs(edgeHorizontal1) * 2.0 + abs(edgeHorizontal2);\n let edgeVertical4 = abs(edgeVertical1) * 2.0 + abs(edgeVertical2);\n let edgeHorizontal3 = -2.0 * lumaW + lumaNWSW;\n let edgeVertical3 = -2.0 * lumaS + lumaSWSE;\n let edgeHorizontal = abs(edgeHorizontal3) + edgeHorizontal4;\n let edgeVertical = abs(edgeVertical3) + edgeVertical4;\n\n let subpixNWSWNESE = lumaNWSW + lumaNESE;\n let horizontalSpan = edgeHorizontal >= edgeVertical;\n var lengthSign = reciprocalFrame.x;\n let subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n if (!horizontalSpan) {\n lumaN = lumaW;\n lumaS = lumaE;\n }\n if (horizontalSpan) {\n lengthSign = reciprocalFrame.y;\n }\n let subpixB = subpixA * (1.0 / 12.0) - lumaM;\n\n let gradientN = lumaN - lumaM;\n let gradientS = lumaS - lumaM;\n var lumaNN = lumaN + lumaM;\n let lumaSS = lumaS + lumaM;\n let pairN = abs(gradientN) >= abs(gradientS);\n let gradient = max(abs(gradientN), abs(gradientS));\n if (pairN) {\n lengthSign = -lengthSign;\n }\n let subpixC = fxaaSat(abs(subpixB) * subpixReciprocalRange);\n\n var posB = posM;\n var offNP = vec2f(0.0);\n if (horizontalSpan) {\n offNP = vec2f(reciprocalFrame.x, 0.0);\n posB.y += lengthSign * 0.5;\n } else {\n offNP = vec2f(0.0, reciprocalFrame.y);\n posB.x += lengthSign * 0.5;\n }\n\n var posN = posB - offNP * fxaaGetQualityStep(0u);\n var posP = posB + offNP * fxaaGetQualityStep(0u);\n let subpixD = -2.0 * subpixC + 3.0;\n var lumaEndN = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posN));\n let subpixE = subpixC * subpixC;\n var lumaEndP = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posP));\n\n if (!pairN) {\n lumaNN = lumaSS;\n }\n let gradientScaled = gradient * 0.25;\n let lumaMM = lumaM - lumaNN * 0.5;\n let subpixF = subpixD * subpixE;\n let lumaMoreThanZero = lumaMM < 0.0;\n\n lumaEndN -= lumaNN * 0.5;\n lumaEndP -= lumaNN * 0.5;\n var doneN = abs(lumaEndN) >= gradientScaled;\n var doneP = abs(lumaEndP) >= gradientScaled;\n var doneNP = !doneN || !doneP;\n var qualityStepIndex = 1u;\n loop {\n if (!(doneNP && qualityStepIndex < 12u)) {\n break;\n }\n\n let qualityStep = fxaaGetQualityStep(qualityStepIndex);\n if (!doneN) {\n posN -= offNP * qualityStep;\n }\n if (!doneP) {\n posP += offNP * qualityStep;\n }\n\n qualityStepIndex += 1u;\n if (qualityStepIndex >= 12u) {\n break;\n }\n\n if (!doneN) {\n lumaEndN = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posN));\n lumaEndN -= lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n }\n if (!doneP) {\n lumaEndP = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posP));\n lumaEndP -= lumaNN * 0.5;\n doneP = abs(lumaEndP) >= gradientScaled;\n }\n\n doneNP = !doneN || !doneP;\n }\n\n var dstN = posM.x - posN.x;\n var dstP = posP.x - posM.x;\n if (!horizontalSpan) {\n dstN = posM.y - posN.y;\n dstP = posP.y - posM.y;\n }\n\n let goodSpanN = (lumaEndN < 0.0) != lumaMoreThanZero;\n let spanLength = dstP + dstN;\n let goodSpanP = (lumaEndP < 0.0) != lumaMoreThanZero;\n let spanLengthReciprocal = 1.0 / spanLength;\n\n let directionN = dstN < dstP;\n let dst = min(dstN, dstP);\n let goodSpan = select(goodSpanP, goodSpanN, directionN);\n let subpixG = subpixF * subpixF;\n let pixelOffset = dst * -spanLengthReciprocal + 0.5;\n let subpixH = subpixG * qualitySubpix;\n\n let pixelOffsetGood = select(0.0, pixelOffset, goodSpan);\n let pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n if (!horizontalSpan) {\n posM.x += pixelOffsetSubpix * lengthSign;\n }\n if (horizontalSpan) {\n posM.y += pixelOffsetSubpix * lengthSign;\n }\n\n return fxaaTexTop(sourceTexture, sourceTextureSampler, posM);\n}\n\nfn fxaa_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let qualitySubpix = 0.5;\n let qualityEdgeThreshold = 0.125;\n let qualityEdgeThresholdMin = 0.0833;\n\n return fxaaPixelShader(\n texCoord,\n sourceTexture,\n sourceTextureSampler,\n vec2f(1.0) / texSize,\n qualitySubpix,\n qualityEdgeThreshold,\n qualityEdgeThresholdMin\n );\n}\n";
|
|
9
10
|
readonly fs: "\n#define FXAA_QUALITY_PRESET 29\n\n#if (FXAA_QUALITY_PRESET == 10)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 3.0\n #define FXAA_QUALITY_P2 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 11)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 3.0\n #define FXAA_QUALITY_P3 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 12)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 4.0\n #define FXAA_QUALITY_P4 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 13)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 4.0\n #define FXAA_QUALITY_P5 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 14)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 4.0\n #define FXAA_QUALITY_P6 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 15)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 20)\n #define FXAA_QUALITY_PS 3\n #define FXAA_QUALITY_P0 1.5\n #define FXAA_QUALITY_P1 2.0\n #define FXAA_QUALITY_P2 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 21)\n #define FXAA_QUALITY_PS 4\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 22)\n #define FXAA_QUALITY_PS 5\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 23)\n #define FXAA_QUALITY_PS 6\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 24)\n #define FXAA_QUALITY_PS 7\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 3.0\n #define FXAA_QUALITY_P6 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 25)\n #define FXAA_QUALITY_PS 8\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 4.0\n #define FXAA_QUALITY_P7 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 26)\n #define FXAA_QUALITY_PS 9\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 4.0\n #define FXAA_QUALITY_P8 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 27)\n #define FXAA_QUALITY_PS 10\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 4.0\n #define FXAA_QUALITY_P9 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 28)\n #define FXAA_QUALITY_PS 11\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 4.0\n #define FXAA_QUALITY_P10 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 29)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.5\n #define FXAA_QUALITY_P2 2.0\n #define FXAA_QUALITY_P3 2.0\n #define FXAA_QUALITY_P4 2.0\n #define FXAA_QUALITY_P5 2.0\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 39)\n #define FXAA_QUALITY_PS 12\n #define FXAA_QUALITY_P0 1.0\n #define FXAA_QUALITY_P1 1.0\n #define FXAA_QUALITY_P2 1.0\n #define FXAA_QUALITY_P3 1.0\n #define FXAA_QUALITY_P4 1.0\n #define FXAA_QUALITY_P5 1.5\n #define FXAA_QUALITY_P6 2.0\n #define FXAA_QUALITY_P7 2.0\n #define FXAA_QUALITY_P8 2.0\n #define FXAA_QUALITY_P9 2.0\n #define FXAA_QUALITY_P10 4.0\n #define FXAA_QUALITY_P11 8.0\n#endif\n\n#define FxaaBool bool\n#define FxaaFloat float\n#define FxaaFloat2 vec2\n#define FxaaFloat3 vec3\n#define FxaaFloat4 vec4\n#define FxaaHalf float\n#define FxaaHalf2 vec2\n#define FxaaHalf3 vec3\n#define FxaaHalf4 vec4\n#define FxaaInt2 vec2\n#define FxaaTex sampler2D\n\n#define FxaaSat(x) clamp(x, 0.0, 1.0)\n#define FxaaTexTop(t, p) texture(t, p)\n#define FxaaTexOff(t, p, o, r) texture(t, p + (o * r))\n\nFxaaFloat FxaaLuma_(FxaaFloat4 rgba) { return dot(rgba.rgb, vec3(0.2126, 0.7152, 0.0722)); }\n\nFxaaFloat4 FxaaPixelShader_(\n //\n // Use noperspective interpolation here (turn off perspective interpolation).\n // {xy} = center of pixel\n FxaaFloat2 pos,\n //\n // Input color texture.\n // {rgb_} = color in linear or perceptual color space\n // if (FXAA_GREEN_AS_LUMA == 0)\n // {___a} = luma in perceptual color space (not linear)\n FxaaTex tex,\n //\n // Only used on FXAA Quality.\n // This must be from a constant/uniform.\n // {x_} = 1.0/screenWidthInPixels\n // {_y} = 1.0/screenHeightInPixels\n FxaaFloat2 fxaaQualityRcpFrame,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_SUBPIX define.\n // It is here now to allow easier tuning.\n // Choose the amount of sub-pixel aliasing removal.\n // This can effect sharpness.\n // 1.00 - upper limit (softer)\n // 0.75 - default amount of filtering\n // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)\n // 0.25 - almost off\n // 0.00 - completely off\n FxaaFloat fxaaQualitySubpix,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.\n // It is here now to allow easier tuning.\n // The minimum amount of local contrast required to apply algorithm.\n // 0.333 - too little (faster)\n // 0.250 - low quality\n // 0.166 - default\n // 0.125 - high quality\n // 0.063 - overkill (slower)\n FxaaFloat fxaaQualityEdgeThreshold,\n //\n // Only used on FXAA Quality.\n // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.\n // It is here now to allow easier tuning.\n // Trims the algorithm from processing darks.\n // 0.0833 - upper limit (default, the start of visible unfiltered edges)\n // 0.0625 - high quality (faster)\n // 0.0312 - visible limit (slower)\n // Special notes when using FXAA_GREEN_AS_LUMA,\n // Likely want to set this to zero.\n // As colors that are mostly not-green\n // will appear very dark in the green channel!\n // Tune by looking at mostly non-green content,\n // then start at zero and increase until aliasing is a problem.\n FxaaFloat fxaaQualityEdgeThresholdMin\n) {\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posM;\n posM.x = pos.x;\n posM.y = pos.y;\n FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n #define lumaM rgbyM.y\n FxaaFloat lumaS = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaN = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n/*--------------------------------------------------------------------------*/\n FxaaFloat maxSM = max(lumaS, lumaM);\n FxaaFloat minSM = min(lumaS, lumaM);\n FxaaFloat maxESM = max(lumaE, maxSM);\n FxaaFloat minESM = min(lumaE, minSM);\n FxaaFloat maxWN = max(lumaN, lumaW);\n FxaaFloat minWN = min(lumaN, lumaW);\n FxaaFloat rangeMax = max(maxWN, maxESM);\n FxaaFloat rangeMin = min(minWN, minESM);\n FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\n FxaaFloat range = rangeMax - rangeMin;\n FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\n FxaaBool earlyExit = range < rangeMaxClamped;\n/*--------------------------------------------------------------------------*/\n if(earlyExit)\n return rgbyM;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaNE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));\n FxaaFloat lumaSW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNS = lumaN + lumaS;\n FxaaFloat lumaWE = lumaW + lumaE;\n FxaaFloat subpixRcpRange = 1.0/range;\n FxaaFloat subpixNSWE = lumaNS + lumaWE;\n FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\n FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNESE = lumaNE + lumaSE;\n FxaaFloat lumaNWNE = lumaNW + lumaNE;\n FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n/*--------------------------------------------------------------------------*/\n FxaaFloat lumaNWSW = lumaNW + lumaSW;\n FxaaFloat lumaSWSE = lumaSW + lumaSE;\n FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\n FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\n/*--------------------------------------------------------------------------*/\n FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\n FxaaFloat lengthSign = fxaaQualityRcpFrame.x;\n FxaaBool horzSpan = edgeHorz >= edgeVert;\n FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n/*--------------------------------------------------------------------------*/\n if(!horzSpan) lumaN = lumaW;\n if(!horzSpan) lumaS = lumaE;\n if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\n FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\n/*--------------------------------------------------------------------------*/\n FxaaFloat gradientN = lumaN - lumaM;\n FxaaFloat gradientS = lumaS - lumaM;\n FxaaFloat lumaNN = lumaN + lumaM;\n FxaaFloat lumaSS = lumaS + lumaM;\n FxaaBool pairN = abs(gradientN) >= abs(gradientS);\n FxaaFloat gradient = max(abs(gradientN), abs(gradientS));\n if(pairN) lengthSign = -lengthSign;\n FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posB;\n posB.x = posM.x;\n posB.y = posM.y;\n FxaaFloat2 offNP;\n offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n if(!horzSpan) posB.x += lengthSign * 0.5;\n if( horzSpan) posB.y += lengthSign * 0.5;\n/*--------------------------------------------------------------------------*/\n FxaaFloat2 posN;\n posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\n posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\n FxaaFloat2 posP;\n posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\n posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\n FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\n FxaaFloat lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN));\n FxaaFloat subpixE = subpixC * subpixC;\n FxaaFloat lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP));\n/*--------------------------------------------------------------------------*/\n if(!pairN) lumaNN = lumaSS;\n FxaaFloat gradientScaled = gradient * 1.0/4.0;\n FxaaFloat lumaMM = lumaM - lumaNN * 0.5;\n FxaaFloat subpixF = subpixD * subpixE;\n FxaaBool lumaMLTZero = lumaMM < 0.0;\n/*--------------------------------------------------------------------------*/\n lumaEndN -= lumaNN * 0.5;\n lumaEndP -= lumaNN * 0.5;\n FxaaBool doneN = abs(lumaEndN) >= gradientScaled;\n FxaaBool doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\n FxaaBool doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\n/*--------------------------------------------------------------------------*/\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 3)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 4)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 5)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 6)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 7)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 8)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 9)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 10)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 11)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n/*--------------------------------------------------------------------------*/\n #if (FXAA_QUALITY_PS > 12)\n if(doneNP) {\n if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));\n if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));\n if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n doneN = abs(lumaEndN) >= gradientScaled;\n doneP = abs(lumaEndP) >= gradientScaled;\n if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\n if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\n doneNP = (!doneN) || (!doneP);\n if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\n if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n #endif\n/*--------------------------------------------------------------------------*/\n }\n/*--------------------------------------------------------------------------*/\n FxaaFloat dstN = posM.x - posN.x;\n FxaaFloat dstP = posP.x - posM.x;\n if(!horzSpan) dstN = posM.y - posN.y;\n if(!horzSpan) dstP = posP.y - posM.y;\n/*--------------------------------------------------------------------------*/\n FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n FxaaFloat spanLength = (dstP + dstN);\n FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n FxaaFloat spanLengthRcp = 1.0/spanLength;\n/*--------------------------------------------------------------------------*/\n FxaaBool directionN = dstN < dstP;\n FxaaFloat dst = min(dstN, dstP);\n FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\n FxaaFloat subpixG = subpixF * subpixF;\n FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n FxaaFloat subpixH = subpixG * fxaaQualitySubpix;\n/*--------------------------------------------------------------------------*/\n FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n return FxaaTexTop(tex, posM);\n}\n\nvec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n const float fxaa_QualitySubpix = 0.5;\n const float fxaa_QualityEdgeThreshold = 0.125;\n const float fxaa_QualityEdgeThresholdMin = 0.0833;\n\n return FxaaPixelShader_(\n texCoord,\n source,\n vec2(1.0) / texSize,\n fxaa_QualitySubpix,\n fxaa_QualityEdgeThreshold,\n fxaa_QualityEdgeThresholdMin\n );\n}\n";
|
|
10
11
|
readonly passes: [{
|
|
11
12
|
readonly sampler: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fxaa.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/fxaa/fxaa.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fxaa.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/fxaa/fxaa.ts"],"names":[],"mappings":"AAw8BA,MAAM,MAAM,SAAS,GAAG,EAAE,CAAC;AAC3B,MAAM,MAAM,YAAY,GAAG,EAAE,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;;CAO2C,CAAC"}
|
|
@@ -91,6 +91,292 @@
|
|
|
91
91
|
// _ = the lowest digit is directly related to performance
|
|
92
92
|
// _ = the highest digit is directly related to style
|
|
93
93
|
//
|
|
94
|
+
const source = /* wgsl */ `\
|
|
95
|
+
fn fxaaSat(value: f32) -> f32 {
|
|
96
|
+
return clamp(value, 0.0, 1.0);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
fn fxaaTexTop(
|
|
100
|
+
sourceTexture: texture_2d<f32>,
|
|
101
|
+
sourceTextureSampler: sampler,
|
|
102
|
+
texCoord: vec2f
|
|
103
|
+
) -> vec4f {
|
|
104
|
+
return textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0.0);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
fn fxaaTexOff(
|
|
108
|
+
sourceTexture: texture_2d<f32>,
|
|
109
|
+
sourceTextureSampler: sampler,
|
|
110
|
+
texCoord: vec2f,
|
|
111
|
+
offset: vec2f,
|
|
112
|
+
reciprocalFrame: vec2f
|
|
113
|
+
) -> vec4f {
|
|
114
|
+
return textureSampleLevel(
|
|
115
|
+
sourceTexture,
|
|
116
|
+
sourceTextureSampler,
|
|
117
|
+
texCoord + offset * reciprocalFrame,
|
|
118
|
+
0.0
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fn fxaaLuma(color: vec4f) -> f32 {
|
|
123
|
+
return dot(color.rgb, vec3f(0.2126, 0.7152, 0.0722));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
fn fxaaGetQualityStep(stepIndex: u32) -> f32 {
|
|
127
|
+
switch (stepIndex) {
|
|
128
|
+
case 0u: {
|
|
129
|
+
return 1.0;
|
|
130
|
+
}
|
|
131
|
+
case 1u: {
|
|
132
|
+
return 1.5;
|
|
133
|
+
}
|
|
134
|
+
case 2u: {
|
|
135
|
+
return 2.0;
|
|
136
|
+
}
|
|
137
|
+
case 3u: {
|
|
138
|
+
return 2.0;
|
|
139
|
+
}
|
|
140
|
+
case 4u: {
|
|
141
|
+
return 2.0;
|
|
142
|
+
}
|
|
143
|
+
case 5u: {
|
|
144
|
+
return 2.0;
|
|
145
|
+
}
|
|
146
|
+
case 6u: {
|
|
147
|
+
return 2.0;
|
|
148
|
+
}
|
|
149
|
+
case 7u: {
|
|
150
|
+
return 2.0;
|
|
151
|
+
}
|
|
152
|
+
case 8u: {
|
|
153
|
+
return 2.0;
|
|
154
|
+
}
|
|
155
|
+
case 9u: {
|
|
156
|
+
return 2.0;
|
|
157
|
+
}
|
|
158
|
+
case 10u: {
|
|
159
|
+
return 4.0;
|
|
160
|
+
}
|
|
161
|
+
default: {
|
|
162
|
+
return 8.0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
fn fxaaPixelShader(
|
|
168
|
+
texCoord: vec2f,
|
|
169
|
+
sourceTexture: texture_2d<f32>,
|
|
170
|
+
sourceTextureSampler: sampler,
|
|
171
|
+
reciprocalFrame: vec2f,
|
|
172
|
+
qualitySubpix: f32,
|
|
173
|
+
qualityEdgeThreshold: f32,
|
|
174
|
+
qualityEdgeThresholdMin: f32
|
|
175
|
+
) -> vec4f {
|
|
176
|
+
var posM = texCoord;
|
|
177
|
+
let rgbyM = fxaaTexTop(sourceTexture, sourceTextureSampler, posM);
|
|
178
|
+
let lumaM = rgbyM.g;
|
|
179
|
+
var lumaS = fxaaLuma(
|
|
180
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(0.0, 1.0), reciprocalFrame)
|
|
181
|
+
);
|
|
182
|
+
let lumaE = fxaaLuma(
|
|
183
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, 0.0), reciprocalFrame)
|
|
184
|
+
);
|
|
185
|
+
var lumaN = fxaaLuma(
|
|
186
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(0.0, -1.0), reciprocalFrame)
|
|
187
|
+
);
|
|
188
|
+
let lumaW = fxaaLuma(
|
|
189
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, 0.0), reciprocalFrame)
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
let maxSM = max(lumaS, lumaM);
|
|
193
|
+
let minSM = min(lumaS, lumaM);
|
|
194
|
+
let maxESM = max(lumaE, maxSM);
|
|
195
|
+
let minESM = min(lumaE, minSM);
|
|
196
|
+
let maxWN = max(lumaN, lumaW);
|
|
197
|
+
let minWN = min(lumaN, lumaW);
|
|
198
|
+
let rangeMax = max(maxWN, maxESM);
|
|
199
|
+
let rangeMin = min(minWN, minESM);
|
|
200
|
+
let rangeMaxScaled = rangeMax * qualityEdgeThreshold;
|
|
201
|
+
let range = rangeMax - rangeMin;
|
|
202
|
+
let rangeMaxClamped = max(qualityEdgeThresholdMin, rangeMaxScaled);
|
|
203
|
+
if (range < rangeMaxClamped) {
|
|
204
|
+
return rgbyM;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
let lumaNW = fxaaLuma(
|
|
208
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, -1.0), reciprocalFrame)
|
|
209
|
+
);
|
|
210
|
+
let lumaSE = fxaaLuma(
|
|
211
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, 1.0), reciprocalFrame)
|
|
212
|
+
);
|
|
213
|
+
let lumaNE = fxaaLuma(
|
|
214
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(1.0, -1.0), reciprocalFrame)
|
|
215
|
+
);
|
|
216
|
+
let lumaSW = fxaaLuma(
|
|
217
|
+
fxaaTexOff(sourceTexture, sourceTextureSampler, posM, vec2f(-1.0, 1.0), reciprocalFrame)
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
let lumaNS = lumaN + lumaS;
|
|
221
|
+
let lumaWE = lumaW + lumaE;
|
|
222
|
+
let subpixReciprocalRange = 1.0 / range;
|
|
223
|
+
let subpixNSWE = lumaNS + lumaWE;
|
|
224
|
+
let edgeHorizontal1 = -2.0 * lumaM + lumaNS;
|
|
225
|
+
let edgeVertical1 = -2.0 * lumaM + lumaWE;
|
|
226
|
+
|
|
227
|
+
let lumaNESE = lumaNE + lumaSE;
|
|
228
|
+
let lumaNWNE = lumaNW + lumaNE;
|
|
229
|
+
let edgeHorizontal2 = -2.0 * lumaE + lumaNESE;
|
|
230
|
+
let edgeVertical2 = -2.0 * lumaN + lumaNWNE;
|
|
231
|
+
|
|
232
|
+
let lumaNWSW = lumaNW + lumaSW;
|
|
233
|
+
let lumaSWSE = lumaSW + lumaSE;
|
|
234
|
+
let edgeHorizontal4 = abs(edgeHorizontal1) * 2.0 + abs(edgeHorizontal2);
|
|
235
|
+
let edgeVertical4 = abs(edgeVertical1) * 2.0 + abs(edgeVertical2);
|
|
236
|
+
let edgeHorizontal3 = -2.0 * lumaW + lumaNWSW;
|
|
237
|
+
let edgeVertical3 = -2.0 * lumaS + lumaSWSE;
|
|
238
|
+
let edgeHorizontal = abs(edgeHorizontal3) + edgeHorizontal4;
|
|
239
|
+
let edgeVertical = abs(edgeVertical3) + edgeVertical4;
|
|
240
|
+
|
|
241
|
+
let subpixNWSWNESE = lumaNWSW + lumaNESE;
|
|
242
|
+
let horizontalSpan = edgeHorizontal >= edgeVertical;
|
|
243
|
+
var lengthSign = reciprocalFrame.x;
|
|
244
|
+
let subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
|
|
245
|
+
if (!horizontalSpan) {
|
|
246
|
+
lumaN = lumaW;
|
|
247
|
+
lumaS = lumaE;
|
|
248
|
+
}
|
|
249
|
+
if (horizontalSpan) {
|
|
250
|
+
lengthSign = reciprocalFrame.y;
|
|
251
|
+
}
|
|
252
|
+
let subpixB = subpixA * (1.0 / 12.0) - lumaM;
|
|
253
|
+
|
|
254
|
+
let gradientN = lumaN - lumaM;
|
|
255
|
+
let gradientS = lumaS - lumaM;
|
|
256
|
+
var lumaNN = lumaN + lumaM;
|
|
257
|
+
let lumaSS = lumaS + lumaM;
|
|
258
|
+
let pairN = abs(gradientN) >= abs(gradientS);
|
|
259
|
+
let gradient = max(abs(gradientN), abs(gradientS));
|
|
260
|
+
if (pairN) {
|
|
261
|
+
lengthSign = -lengthSign;
|
|
262
|
+
}
|
|
263
|
+
let subpixC = fxaaSat(abs(subpixB) * subpixReciprocalRange);
|
|
264
|
+
|
|
265
|
+
var posB = posM;
|
|
266
|
+
var offNP = vec2f(0.0);
|
|
267
|
+
if (horizontalSpan) {
|
|
268
|
+
offNP = vec2f(reciprocalFrame.x, 0.0);
|
|
269
|
+
posB.y += lengthSign * 0.5;
|
|
270
|
+
} else {
|
|
271
|
+
offNP = vec2f(0.0, reciprocalFrame.y);
|
|
272
|
+
posB.x += lengthSign * 0.5;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
var posN = posB - offNP * fxaaGetQualityStep(0u);
|
|
276
|
+
var posP = posB + offNP * fxaaGetQualityStep(0u);
|
|
277
|
+
let subpixD = -2.0 * subpixC + 3.0;
|
|
278
|
+
var lumaEndN = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posN));
|
|
279
|
+
let subpixE = subpixC * subpixC;
|
|
280
|
+
var lumaEndP = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posP));
|
|
281
|
+
|
|
282
|
+
if (!pairN) {
|
|
283
|
+
lumaNN = lumaSS;
|
|
284
|
+
}
|
|
285
|
+
let gradientScaled = gradient * 0.25;
|
|
286
|
+
let lumaMM = lumaM - lumaNN * 0.5;
|
|
287
|
+
let subpixF = subpixD * subpixE;
|
|
288
|
+
let lumaMoreThanZero = lumaMM < 0.0;
|
|
289
|
+
|
|
290
|
+
lumaEndN -= lumaNN * 0.5;
|
|
291
|
+
lumaEndP -= lumaNN * 0.5;
|
|
292
|
+
var doneN = abs(lumaEndN) >= gradientScaled;
|
|
293
|
+
var doneP = abs(lumaEndP) >= gradientScaled;
|
|
294
|
+
var doneNP = !doneN || !doneP;
|
|
295
|
+
var qualityStepIndex = 1u;
|
|
296
|
+
loop {
|
|
297
|
+
if (!(doneNP && qualityStepIndex < 12u)) {
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
let qualityStep = fxaaGetQualityStep(qualityStepIndex);
|
|
302
|
+
if (!doneN) {
|
|
303
|
+
posN -= offNP * qualityStep;
|
|
304
|
+
}
|
|
305
|
+
if (!doneP) {
|
|
306
|
+
posP += offNP * qualityStep;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
qualityStepIndex += 1u;
|
|
310
|
+
if (qualityStepIndex >= 12u) {
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (!doneN) {
|
|
315
|
+
lumaEndN = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posN));
|
|
316
|
+
lumaEndN -= lumaNN * 0.5;
|
|
317
|
+
doneN = abs(lumaEndN) >= gradientScaled;
|
|
318
|
+
}
|
|
319
|
+
if (!doneP) {
|
|
320
|
+
lumaEndP = fxaaLuma(fxaaTexTop(sourceTexture, sourceTextureSampler, posP));
|
|
321
|
+
lumaEndP -= lumaNN * 0.5;
|
|
322
|
+
doneP = abs(lumaEndP) >= gradientScaled;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
doneNP = !doneN || !doneP;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
var dstN = posM.x - posN.x;
|
|
329
|
+
var dstP = posP.x - posM.x;
|
|
330
|
+
if (!horizontalSpan) {
|
|
331
|
+
dstN = posM.y - posN.y;
|
|
332
|
+
dstP = posP.y - posM.y;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
let goodSpanN = (lumaEndN < 0.0) != lumaMoreThanZero;
|
|
336
|
+
let spanLength = dstP + dstN;
|
|
337
|
+
let goodSpanP = (lumaEndP < 0.0) != lumaMoreThanZero;
|
|
338
|
+
let spanLengthReciprocal = 1.0 / spanLength;
|
|
339
|
+
|
|
340
|
+
let directionN = dstN < dstP;
|
|
341
|
+
let dst = min(dstN, dstP);
|
|
342
|
+
let goodSpan = select(goodSpanP, goodSpanN, directionN);
|
|
343
|
+
let subpixG = subpixF * subpixF;
|
|
344
|
+
let pixelOffset = dst * -spanLengthReciprocal + 0.5;
|
|
345
|
+
let subpixH = subpixG * qualitySubpix;
|
|
346
|
+
|
|
347
|
+
let pixelOffsetGood = select(0.0, pixelOffset, goodSpan);
|
|
348
|
+
let pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
|
|
349
|
+
if (!horizontalSpan) {
|
|
350
|
+
posM.x += pixelOffsetSubpix * lengthSign;
|
|
351
|
+
}
|
|
352
|
+
if (horizontalSpan) {
|
|
353
|
+
posM.y += pixelOffsetSubpix * lengthSign;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return fxaaTexTop(sourceTexture, sourceTextureSampler, posM);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
fn fxaa_sampleColor(
|
|
360
|
+
sourceTexture: texture_2d<f32>,
|
|
361
|
+
sourceTextureSampler: sampler,
|
|
362
|
+
texSize: vec2f,
|
|
363
|
+
texCoord: vec2f
|
|
364
|
+
) -> vec4f {
|
|
365
|
+
let qualitySubpix = 0.5;
|
|
366
|
+
let qualityEdgeThreshold = 0.125;
|
|
367
|
+
let qualityEdgeThresholdMin = 0.0833;
|
|
368
|
+
|
|
369
|
+
return fxaaPixelShader(
|
|
370
|
+
texCoord,
|
|
371
|
+
sourceTexture,
|
|
372
|
+
sourceTextureSampler,
|
|
373
|
+
vec2f(1.0) / texSize,
|
|
374
|
+
qualitySubpix,
|
|
375
|
+
qualityEdgeThreshold,
|
|
376
|
+
qualityEdgeThresholdMin
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
`;
|
|
94
380
|
const fs = /* glsl */ `
|
|
95
381
|
#define FXAA_QUALITY_PRESET 29
|
|
96
382
|
|
|
@@ -678,6 +964,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
678
964
|
export const fxaa = {
|
|
679
965
|
name: 'fxaa',
|
|
680
966
|
propTypes: {},
|
|
967
|
+
source,
|
|
681
968
|
fs,
|
|
682
969
|
passes: [{ sampler: true }],
|
|
683
970
|
getUniforms: props => props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fxaa.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/fxaa/fxaa.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,UAAU;AACV,+DAA+D;AAC/D,yEAAyE;AACzE,oCAAoC;AACpC,+CAA+C;AAC/C,uDAAuD;AACvD,oCAAoC;AAEpC,+BAA+B;AAC/B,oGAAoG;AACpG,oIAAoI;AACpI,EAAE;AACF,uCAAuC;AACvC,mCAAmC;AACnC,0BAA0B;AAC1B,+BAA+B;AAC/B,qCAAqC;AACrC,kCAAkC;AAClC,gCAAgC;AAChC,4FAA4F;AAC5F,iHAAiH;AACjH,qDAAqD;AACrD,qEAAqE;AACrE,+BAA+B;AAC/B,iBAAiB;AACjB,8BAA8B;AAC9B,8EAA8E;AAC9E,yDAAyD;AACzD,yEAAyE;AACzE,iBAAiB;AACjB,iDAAiD;AACjD,iEAAiE;AACjE,+GAA+G;AAC/G,gFAAgF;AAChF,0BAA0B;AAC1B,+BAA+B;AAC/B,gCAAgC;AAChC,mCAAmC;AACnC,iCAAiC;AACjC,iCAAiC;AACjC,mCAAmC;AACnC,+BAA+B;AAC/B,EAAE;AACF,6BAA6B;AAC7B,gEAAgE;AAChE,gDAAgD;AAChD,4DAA4D;AAC5D,EAAE;AACF,UAAU;AACV,0EAA0E;AAC1E,oEAAoE;AACpE,0EAA0E;AAC1E,uCAAuC;AACvC,EAAE;AACF,QAAQ;AACR,0EAA0E;AAC1E,uEAAuE;AACvE,uDAAuD;AACvD,yDAAyD;AACzD,2DAA2D;AAC3D,sDAAsD;AACtD,EAAE;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAokBrB,CAAC;AAKF;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,EAAE;IACb,EAAE;IACF,MAAM,EAAE,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;IACzB,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK;CAC+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"fxaa.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/fxaa/fxaa.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,UAAU;AACV,+DAA+D;AAC/D,yEAAyE;AACzE,oCAAoC;AACpC,+CAA+C;AAC/C,uDAAuD;AACvD,oCAAoC;AAEpC,+BAA+B;AAC/B,oGAAoG;AACpG,oIAAoI;AACpI,EAAE;AACF,uCAAuC;AACvC,mCAAmC;AACnC,0BAA0B;AAC1B,+BAA+B;AAC/B,qCAAqC;AACrC,kCAAkC;AAClC,gCAAgC;AAChC,4FAA4F;AAC5F,iHAAiH;AACjH,qDAAqD;AACrD,qEAAqE;AACrE,+BAA+B;AAC/B,iBAAiB;AACjB,8BAA8B;AAC9B,8EAA8E;AAC9E,yDAAyD;AACzD,yEAAyE;AACzE,iBAAiB;AACjB,iDAAiD;AACjD,iEAAiE;AACjE,+GAA+G;AAC/G,gFAAgF;AAChF,0BAA0B;AAC1B,+BAA+B;AAC/B,gCAAgC;AAChC,mCAAmC;AACnC,iCAAiC;AACjC,iCAAiC;AACjC,mCAAmC;AACnC,+BAA+B;AAC/B,EAAE;AACF,6BAA6B;AAC7B,gEAAgE;AAChE,gDAAgD;AAChD,4DAA4D;AAC5D,EAAE;AACF,UAAU;AACV,0EAA0E;AAC1E,oEAAoE;AACpE,0EAA0E;AAC1E,uCAAuC;AACvC,EAAE;AACF,QAAQ;AACR,0EAA0E;AAC1E,uEAAuE;AACvE,uDAAuD;AACvD,yDAAyD;AACzD,2DAA2D;AAC3D,sDAAsD;AACtD,EAAE;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6RzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAokBrB,CAAC;AAKF;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,EAAE;IACb,MAAM;IACN,EAAE;IACF,MAAM,EAAE,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;IACzB,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK;CAC+B,CAAC"}
|
|
@@ -11,8 +11,8 @@ export type BrightnessContrastUniforms = BrightnessContrastProps;
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const brightnessContrast: {
|
|
13
13
|
readonly name: "brightnessContrast";
|
|
14
|
-
readonly source: "struct brightnessContrastUniforms {\n brightness: f32,\n contrast: f32\n};\n\n
|
|
15
|
-
readonly fs: "uniform brightnessContrastUniforms {\n float brightness;\n float contrast;\n} brightnessContrast;\n\nvec4 brightnessContrast_filterColor(vec4 color) {\n color.rgb += brightnessContrast.brightness;\n if (brightnessContrast.contrast > 0.0) {\n color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;\n } else {\n color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;\n }\n return color;\n}\n\nvec4 brightnessContrast_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n return brightnessContrast_filterColor(color);\n}\n";
|
|
14
|
+
readonly source: "struct brightnessContrastUniforms {\n brightness: f32,\n contrast: f32\n};\n\n@group(0) @binding(auto) var<uniform> brightnessContrast : brightnessContrastUniforms;\n\nfn brightnessContrast_filterColor_ext(color: vec4f, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4f {\n var resultRgb = color.rgb + vec3f(brightnessContrast.brightness);\n if (brightnessContrast.contrast > 0.0) {\n resultRgb = (resultRgb - vec3f(0.5)) / (1.0 - brightnessContrast.contrast) + vec3f(0.5);\n } else {\n resultRgb = (resultRgb - vec3f(0.5)) * (1.0 + brightnessContrast.contrast) + vec3f(0.5);\n }\n return vec4f(resultRgb, color.a);\n}\n";
|
|
15
|
+
readonly fs: "layout(std140) uniform brightnessContrastUniforms {\n float brightness;\n float contrast;\n} brightnessContrast;\n\nvec4 brightnessContrast_filterColor(vec4 color) {\n color.rgb += brightnessContrast.brightness;\n if (brightnessContrast.contrast > 0.0) {\n color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;\n } else {\n color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;\n }\n return color;\n}\n\nvec4 brightnessContrast_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n return brightnessContrast_filterColor(color);\n}\n";
|
|
16
16
|
readonly props: BrightnessContrastProps;
|
|
17
17
|
readonly uniformTypes: {
|
|
18
18
|
readonly brightness: "f32";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brightnesscontrast.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"brightnesscontrast.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts"],"names":[],"mappings":"AA8CA,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;oBAKhB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;CAekB,CAAC"}
|
|
@@ -7,21 +7,20 @@ struct brightnessContrastUniforms {
|
|
|
7
7
|
contrast: f32
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
@group(0) @binding(1) var<uniform> brightnessContrast : brightnessContrastUniforms;
|
|
10
|
+
@group(0) @binding(auto) var<uniform> brightnessContrast : brightnessContrastUniforms;
|
|
12
11
|
|
|
13
12
|
fn brightnessContrast_filterColor_ext(color: vec4f, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4f {
|
|
14
|
-
color.rgb
|
|
13
|
+
var resultRgb = color.rgb + vec3f(brightnessContrast.brightness);
|
|
15
14
|
if (brightnessContrast.contrast > 0.0) {
|
|
16
|
-
|
|
15
|
+
resultRgb = (resultRgb - vec3f(0.5)) / (1.0 - brightnessContrast.contrast) + vec3f(0.5);
|
|
17
16
|
} else {
|
|
18
|
-
|
|
17
|
+
resultRgb = (resultRgb - vec3f(0.5)) * (1.0 + brightnessContrast.contrast) + vec3f(0.5);
|
|
19
18
|
}
|
|
20
|
-
return vec4f(
|
|
19
|
+
return vec4f(resultRgb, color.a);
|
|
21
20
|
}
|
|
22
21
|
`;
|
|
23
22
|
const fs = /* glsl */ `\
|
|
24
|
-
uniform brightnessContrastUniforms {
|
|
23
|
+
layout(std140) uniform brightnessContrastUniforms {
|
|
25
24
|
float brightness;
|
|
26
25
|
float contrast;
|
|
27
26
|
} brightnessContrast;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brightnesscontrast.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"brightnesscontrast.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;CAiBzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;CAmBrB,CAAC;AASF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,oBAAoB;IAC1B,MAAM;IACN,EAAE;IAEF,KAAK,EAAE,EAA6B;IACpC,YAAY,EAAE;QACZ,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;KAChB;IACD,eAAe,EAAE;QACf,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC;KACZ;IACD,SAAS,EAAE;QACT,UAAU,EAAE,EAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;QACtD,QAAQ,EAAE,EAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;KACrD;IAED,MAAM,EAAE,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;CAC8B,CAAC"}
|
|
@@ -32,8 +32,8 @@ export declare const denoise: {
|
|
|
32
32
|
readonly max: 1;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
readonly source: "
|
|
36
|
-
readonly fs: "uniform
|
|
35
|
+
readonly source: "struct denoiseUniforms {\n strength: f32,\n};\n\n@group(0) @binding(auto) var<uniform> denoise: denoiseUniforms;\n\nfn denoise_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let adjustedExponent = 3.0 + 200.0 * pow(1.0 - denoise.strength, 4.0);\n let center = textureSample(sourceTexture, sourceTextureSampler, texCoord);\n var color = vec4f(0.0);\n var total = 0.0;\n\n for (var x = -4.0; x <= 4.0; x += 1.0) {\n for (var y = -4.0; y <= 4.0; y += 1.0) {\n let offsetColor = textureSample(\n sourceTexture,\n sourceTextureSampler,\n texCoord + vec2f(x, y) / texSize\n );\n let weight = pow(\n 1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3f(0.25))),\n adjustedExponent\n );\n color += offsetColor * weight;\n total += weight;\n }\n }\n\n return color / total;\n}\n";
|
|
36
|
+
readonly fs: "layout(std140) uniform denoiseUniforms {\n float strength;\n} denoise;\n\nvec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n float adjustedExponent = 3. + 200. * pow(1. - denoise.strength, 4.);\n\n vec4 center = texture(source, texCoord);\n vec4 color = vec4(0.0);\n float total = 0.0;\n for (float x = -4.0; x <= 4.0; x += 1.0) {\n for (float y = -4.0; y <= 4.0; y += 1.0) {\n vec4 offsetColor = texture(source, texCoord + vec2(x, y) / texSize);\n float weight = 1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3(0.25)));\n weight = pow(weight, adjustedExponent);\n color += offsetColor * weight;\n total += weight;\n }\n }\n\n return color / total;\n}\n";
|
|
37
37
|
readonly passes: [{
|
|
38
38
|
readonly sampler: true;
|
|
39
39
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"denoise.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/denoise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"denoise.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/denoise.ts"],"names":[],"mappings":"AAsEA;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,OAAO;oBACL,YAAY;uBACT,eAAe;;;;;;;;;;;;;;;;;;;;CAe6B,CAAC"}
|
|
@@ -3,41 +3,49 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// Do a 9x9 bilateral box filter
|
|
5
5
|
const source = /* wgsl */ `\
|
|
6
|
-
|
|
7
6
|
struct denoiseUniforms {
|
|
8
|
-
strength: f32
|
|
7
|
+
strength: f32,
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
@group(0)
|
|
12
|
-
|
|
13
|
-
fn denoise_sampleColor(source: sampler2D, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {
|
|
14
|
-
let adjustedExponent: f32 = 3. + 200. * pow(1. - denoise.strength, 4.);
|
|
15
|
-
let center: vec4<f32> = sample_texture(BUFFER_source, texCoord);
|
|
16
|
-
var color: vec4<f32> = vec4<f32>(0.);
|
|
17
|
-
var total: f32 = 0.;
|
|
18
|
-
|
|
19
|
-
for (var x: f32 = -4.; x <= 4.; x = x + (1.)) {
|
|
10
|
+
@group(0) @binding(auto) var<uniform> denoise: denoiseUniforms;
|
|
20
11
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
fn denoise_sampleColor(
|
|
13
|
+
sourceTexture: texture_2d<f32>,
|
|
14
|
+
sourceTextureSampler: sampler,
|
|
15
|
+
texSize: vec2f,
|
|
16
|
+
texCoord: vec2f
|
|
17
|
+
) -> vec4f {
|
|
18
|
+
let adjustedExponent = 3.0 + 200.0 * pow(1.0 - denoise.strength, 4.0);
|
|
19
|
+
let center = textureSample(sourceTexture, sourceTextureSampler, texCoord);
|
|
20
|
+
var color = vec4f(0.0);
|
|
21
|
+
var total = 0.0;
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
for (var x = -4.0; x <= 4.0; x += 1.0) {
|
|
24
|
+
for (var y = -4.0; y <= 4.0; y += 1.0) {
|
|
25
|
+
let offsetColor = textureSample(
|
|
26
|
+
sourceTexture,
|
|
27
|
+
sourceTextureSampler,
|
|
28
|
+
texCoord + vec2f(x, y) / texSize
|
|
29
|
+
);
|
|
30
|
+
let weight = pow(
|
|
31
|
+
1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3f(0.25))),
|
|
32
|
+
adjustedExponent
|
|
33
|
+
);
|
|
34
|
+
color += offsetColor * weight;
|
|
35
|
+
total += weight;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
}
|
|
39
|
+
return color / total;
|
|
40
|
+
}
|
|
33
41
|
`;
|
|
34
42
|
const fs = /* glsl */ `\
|
|
35
|
-
uniform
|
|
43
|
+
layout(std140) uniform denoiseUniforms {
|
|
36
44
|
float strength;
|
|
37
45
|
} denoise;
|
|
38
46
|
|
|
39
|
-
vec4
|
|
40
|
-
float adjustedExponent = 3. + 200. * pow(1. -
|
|
47
|
+
vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
48
|
+
float adjustedExponent = 3. + 200. * pow(1. - denoise.strength, 4.);
|
|
41
49
|
|
|
42
50
|
vec4 center = texture(source, texCoord);
|
|
43
51
|
vec4 color = vec4(0.0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"denoise.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/denoise.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,gCAAgC;AAChC,MAAM,MAAM,GAAG,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"denoise.js","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/denoise.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,gCAAgC;AAChC,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCzB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;CAuBrB,CAAC;AAkBF;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,EAAkB;IACzB,QAAQ,EAAE,EAAqB;IAE/B,IAAI,EAAE,SAAS;IACf,YAAY,EAAE;QACZ,QAAQ,EAAE,KAAK;KAChB;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAC;QACrD,0HAA0H;KAC3H;IAED,MAAM;IACN,EAAE;IAEF,MAAM,EAAE,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;CACkB,CAAC"}
|
|
@@ -21,8 +21,8 @@ export type HueSaturationUniforms = HueSaturationProps;
|
|
|
21
21
|
export declare const hueSaturation: {
|
|
22
22
|
readonly props: HueSaturationProps;
|
|
23
23
|
readonly name: "hueSaturation";
|
|
24
|
-
readonly source: "
|
|
25
|
-
readonly fs: "uniform hueSaturationUniforms {\n float hue;\n float saturation;\n} hueSaturation;\n\nvec4 hueSaturation_filterColor(vec4 color) {\n // hue adjustment, wolfram alpha: RotationTransform[angle, {1, 1, 1}][{x, y, z}]\n float angle = hueSaturation.hue * 3.14159265;\n float s = sin(angle), c = cos(angle);\n vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;\n float len = length(color.rgb);\n color.rgb = vec3(\n dot(color.rgb, weights.xyz),\n dot(color.rgb, weights.zxy),\n dot(color.rgb, weights.yzx)\n );\n\n // saturation adjustment\n float average = (color.r + color.g + color.b) / 3.0;\n if (hueSaturation.saturation > 0.0) {\n color.rgb += (average - color.rgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));\n } else {\n color.rgb += (average - color.rgb) * (-hueSaturation.saturation);\n }\n\n return color;\n}\n\nvec4 hueSaturation_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n return hueSaturation_filterColor(color);\n}\n";
|
|
24
|
+
readonly source: "struct hueSaturationUniforms {\n hue: f32,\n saturation: f32,\n};\n\n@group(0) @binding(auto) var<uniform> hueSaturation: hueSaturationUniforms;\n\nfn hueSaturation_filterColor(color: vec4f) -> vec4f {\n let angle = hueSaturation.hue * 3.14159265;\n let s = sin(angle);\n let c = cos(angle);\n let weights = (vec3f(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + vec3f(1.0)) / 3.0;\n\n var resultRgb = vec3f(\n dot(color.rgb, weights.xyz),\n dot(color.rgb, weights.zxy),\n dot(color.rgb, weights.yzx)\n );\n\n let average = (resultRgb.r + resultRgb.g + resultRgb.b) / 3.0;\n if (hueSaturation.saturation > 0.0) {\n resultRgb += (vec3f(average) - resultRgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));\n } else {\n resultRgb += (vec3f(average) - resultRgb) * (-hueSaturation.saturation);\n }\n\n return vec4f(resultRgb, color.a);\n}\n\nfn hueSaturation_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {\n return hueSaturation_filterColor(color);\n}\n";
|
|
25
|
+
readonly fs: "layout(std140) uniform hueSaturationUniforms {\n float hue;\n float saturation;\n} hueSaturation;\n\nvec4 hueSaturation_filterColor(vec4 color) {\n // hue adjustment, wolfram alpha: RotationTransform[angle, {1, 1, 1}][{x, y, z}]\n float angle = hueSaturation.hue * 3.14159265;\n float s = sin(angle), c = cos(angle);\n vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;\n float len = length(color.rgb);\n color.rgb = vec3(\n dot(color.rgb, weights.xyz),\n dot(color.rgb, weights.zxy),\n dot(color.rgb, weights.yzx)\n );\n\n // saturation adjustment\n float average = (color.r + color.g + color.b) / 3.0;\n if (hueSaturation.saturation > 0.0) {\n color.rgb += (average - color.rgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));\n } else {\n color.rgb += (average - color.rgb) * (-hueSaturation.saturation);\n }\n\n return color;\n}\n\nvec4 hueSaturation_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n return hueSaturation_filterColor(color);\n}\n";
|
|
26
26
|
readonly uniformTypes: {
|
|
27
27
|
readonly hue: "f32";
|
|
28
28
|
readonly saturation: "f32";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"huesaturation.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/huesaturation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"huesaturation.d.ts","sourceRoot":"","sources":["../../../../src/passes/postprocessing/image-adjust-filters/huesaturation.ts"],"names":[],"mappings":"AA2EA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;iEAC6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEvD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;oBACX,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;CAekB,CAAC"}
|