@luma.gl/shadertools 9.1.0-alpha.9 → 9.1.0-beta.3
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 +426 -1881
- package/dist/dist.min.js +291 -1364
- package/dist/index.cjs +426 -1882
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +4 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -23
- package/dist/index.js.map +1 -0
- package/dist/lib/filters/prop-types.js +1 -0
- package/dist/lib/filters/prop-types.js.map +1 -0
- package/dist/lib/glsl-utils/get-shader-info.js +1 -0
- package/dist/lib/glsl-utils/get-shader-info.js.map +1 -0
- package/dist/lib/glsl-utils/shader-utils.js +1 -0
- package/dist/lib/glsl-utils/shader-utils.js.map +1 -0
- package/dist/lib/preprocessor/preprocessor.js +1 -0
- package/dist/lib/preprocessor/preprocessor.js.map +1 -0
- package/dist/lib/shader-assembler.js +1 -0
- package/dist/lib/shader-assembler.js.map +1 -0
- package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-shaders.js +24 -17
- package/dist/lib/shader-assembly/assemble-shaders.js.map +1 -0
- package/dist/lib/shader-assembly/platform-defines.js +1 -0
- package/dist/lib/shader-assembly/platform-defines.js.map +1 -0
- package/dist/lib/shader-assembly/platform-info.js +1 -0
- package/dist/lib/shader-assembly/platform-info.js.map +1 -0
- package/dist/lib/shader-assembly/shader-hooks.js +1 -0
- package/dist/lib/shader-assembly/shader-hooks.js.map +1 -0
- package/dist/lib/shader-assembly/shader-injections.js +1 -0
- package/dist/lib/shader-assembly/shader-injections.js.map +1 -0
- package/dist/lib/shader-generator/generate-shader.js +1 -0
- package/dist/lib/shader-generator/generate-shader.js.map +1 -0
- package/dist/lib/shader-generator/glsl/generate-glsl.js +1 -0
- package/dist/lib/shader-generator/glsl/generate-glsl.js.map +1 -0
- package/dist/lib/shader-generator/utils/capitalize.js +1 -0
- package/dist/lib/shader-generator/utils/capitalize.js.map +1 -0
- package/dist/lib/shader-generator/wgsl/generate-wgsl.js +1 -0
- package/dist/lib/shader-generator/wgsl/generate-wgsl.js.map +1 -0
- package/dist/lib/shader-module/shader-module-dependencies.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module-dependencies.js +2 -1
- package/dist/lib/shader-module/shader-module-dependencies.js.map +1 -0
- package/dist/lib/shader-module/shader-module.d.ts +25 -15
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module.js +19 -4
- package/dist/lib/shader-module/shader-module.js.map +1 -0
- package/dist/lib/shader-module/shader-pass.d.ts +17 -8
- package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-pass.js +1 -0
- package/dist/lib/shader-module/shader-pass.js.map +1 -0
- package/dist/lib/shader-transpiler/transpile-glsl-shader.js +1 -0
- package/dist/lib/shader-transpiler/transpile-glsl-shader.js.map +1 -0
- package/dist/lib/utils/assert.js +1 -0
- package/dist/lib/utils/assert.js.map +1 -0
- package/dist/lib/utils/uniform-types.d.ts +11 -0
- package/dist/lib/utils/uniform-types.d.ts.map +1 -0
- package/dist/lib/utils/uniform-types.js +2 -0
- package/dist/lib/utils/uniform-types.js.map +1 -0
- package/dist/lib/wgsl/get-shader-layout-wgsl.d.ts.map +1 -1
- package/dist/lib/wgsl/get-shader-layout-wgsl.js +19 -2
- package/dist/lib/wgsl/get-shader-layout-wgsl.js.map +1 -0
- package/dist/module-injectors.d.ts +1 -1
- package/dist/module-injectors.d.ts.map +1 -1
- package/dist/module-injectors.js +6 -5
- package/dist/module-injectors.js.map +1 -0
- package/dist/modules/engine/geometry/geometry.js +1 -0
- package/dist/modules/engine/geometry/geometry.js.map +1 -0
- package/dist/modules/engine/picking/picking.d.ts +7 -7
- package/dist/modules/engine/picking/picking.d.ts.map +1 -1
- package/dist/modules/engine/picking/picking.js +3 -2
- package/dist/modules/engine/picking/picking.js.map +1 -0
- package/dist/modules/engine/project/project.d.ts +9 -8
- package/dist/modules/engine/project/project.d.ts.map +1 -1
- package/dist/modules/engine/project/project.js +1 -0
- package/dist/modules/engine/project/project.js.map +1 -0
- package/dist/modules/engine/transform/transform.js +1 -0
- package/dist/modules/engine/transform/transform.js.map +1 -0
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +3 -56
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.js +10 -6
- package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -0
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +1 -1
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +37 -13
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.js.map +1 -0
- package/dist/modules/lighting/lights/lighting-uniforms-wgsl.d.ts +2 -0
- package/dist/modules/lighting/lights/lighting-uniforms-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/lights/lighting-uniforms-wgsl.js +57 -0
- package/dist/modules/lighting/lights/lighting-uniforms-wgsl.js.map +1 -0
- package/dist/modules/lighting/lights/lighting.d.ts +56 -29
- package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting.js +53 -38
- package/dist/modules/lighting/lights/lighting.js.map +1 -0
- package/dist/modules/lighting/no-material/dirlight.d.ts +5 -5
- package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
- package/dist/modules/lighting/no-material/dirlight.js +24 -12
- package/dist/modules/lighting/no-material/dirlight.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +57 -60
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts +57 -98
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material.js +15 -22
- package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.d.ts +10 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.js +25 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +1 -0
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +9 -16
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js.map +1 -0
- package/dist/modules/lighting/phong-material/phong-material.d.ts +5 -57
- package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-material.js +9 -4
- package/dist/modules/lighting/phong-material/phong-material.js.map +1 -0
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +1 -40
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +9 -87
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts +41 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +131 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js.map +1 -0
- package/dist/modules/math/fp16/fp16-utils.js +1 -0
- package/dist/modules/math/fp16/fp16-utils.js.map +1 -0
- package/dist/modules/math/fp32/fp32.js +1 -0
- package/dist/modules/math/fp32/fp32.js.map +1 -0
- package/dist/modules/math/fp64/fp64-utils.d.ts +3 -3
- package/dist/modules/math/fp64/fp64-utils.d.ts.map +1 -1
- package/dist/modules/math/fp64/fp64-utils.js +1 -0
- package/dist/modules/math/fp64/fp64-utils.js.map +1 -0
- package/dist/modules/math/random/random.js +1 -0
- package/dist/modules/math/random/random.js.map +1 -0
- package/dist/modules/module-injectors.d.ts +1 -1
- package/dist/modules/module-injectors.d.ts.map +1 -1
- package/dist/modules/module-injectors.js +6 -5
- package/dist/modules/module-injectors.js.map +1 -0
- package/dist/modules-webgl1/geometry/geometry.js +1 -0
- package/dist/modules-webgl1/geometry/geometry.js.map +1 -0
- package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts +2 -2
- package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/dirlight/dirlight.js +1 -0
- package/dist/modules-webgl1/lighting/dirlight/dirlight.js.map +1 -0
- package/dist/modules-webgl1/lighting/lights/lights-glsl.js +1 -0
- package/dist/modules-webgl1/lighting/lights/lights-glsl.js.map +1 -0
- package/dist/modules-webgl1/lighting/lights/lights.js +1 -0
- package/dist/modules-webgl1/lighting/lights/lights.js.map +1 -0
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +1 -0
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js.map +1 -0
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +1 -0
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js.map +1 -0
- package/dist/modules-webgl1/lighting/pbr/pbr.js +1 -0
- package/dist/modules-webgl1/lighting/pbr/pbr.js.map +1 -0
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +1 -0
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js.map +1 -0
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js +1 -0
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js.map +1 -0
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +1 -0
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js.map +1 -0
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +1 -0
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js.map +1 -0
- package/dist/modules-webgl1/math/fp64/fp64.js +1 -0
- package/dist/modules-webgl1/math/fp64/fp64.js.map +1 -0
- package/dist/modules-webgl1/project/project.d.ts +6 -4
- package/dist/modules-webgl1/project/project.d.ts.map +1 -1
- package/dist/modules-webgl1/project/project.js +1 -0
- package/dist/modules-webgl1/project/project.js.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +5 -5
- package/src/index.ts +8 -98
- package/src/lib/shader-assembly/assemble-shaders.ts +13 -12
- package/src/lib/shader-module/shader-module-dependencies.ts +1 -2
- package/src/lib/shader-module/shader-module.ts +59 -25
- package/src/lib/shader-module/shader-pass.ts +24 -9
- package/src/lib/utils/uniform-types.ts +66 -0
- package/src/lib/wgsl/get-shader-layout-wgsl.ts +20 -2
- package/src/module-injectors.ts +5 -5
- package/src/modules/engine/picking/README.md +9 -9
- package/src/modules/engine/picking/picking.ts +9 -9
- package/src/modules/engine/project/project.ts +10 -9
- package/src/modules/lighting/gouraud-material/gouraud-material.ts +14 -12
- package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +36 -13
- package/src/modules/lighting/lights/lighting-uniforms-wgsl.ts +57 -0
- package/src/modules/lighting/lights/lighting.ts +89 -57
- package/src/modules/lighting/no-material/dirlight.ts +25 -15
- package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +56 -60
- package/src/modules/lighting/pbr-material/pbr-material.ts +40 -74
- package/src/modules/lighting/pbr-material/pbr-projection.ts +39 -0
- package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +8 -16
- package/src/modules/lighting/phong-material/phong-material.ts +14 -12
- package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +8 -88
- package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +132 -0
- package/src/modules/math/fp64/fp64-utils.ts +3 -3
- package/src/modules/module-injectors.ts +5 -5
- package/src/modules-webgl1/lighting/dirlight/dirlight.ts +2 -2
- package/src/modules-webgl1/project/project.ts +8 -7
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +0 -42
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +0 -1
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +0 -134
- package/dist/modules/postprocessing/fxaa/fxaa.d.ts +0 -15
- package/dist/modules/postprocessing/fxaa/fxaa.d.ts.map +0 -1
- package/dist/modules/postprocessing/fxaa/fxaa.js +0 -684
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +0 -39
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js +0 -45
- package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts +0 -42
- package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/denoise.js +0 -47
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts +0 -46
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js +0 -60
- package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts +0 -32
- package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/noise.js +0 -41
- package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts +0 -29
- package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/sepia.js +0 -43
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts +0 -26
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.js +0 -31
- package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts +0 -40
- package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/vignette.js +0 -38
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +0 -79
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.js +0 -110
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +0 -56
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.js +0 -64
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +0 -42
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.js +0 -58
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +0 -52
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js +0 -63
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +0 -50
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.js +0 -49
- package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts +0 -50
- package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/edgework.js +0 -88
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +0 -43
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js +0 -67
- package/dist/modules/postprocessing/image-fun-filters/ink.d.ts +0 -40
- package/dist/modules/postprocessing/image-fun-filters/ink.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/ink.js +0 -51
- package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +0 -45
- package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/magnify.js +0 -48
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +0 -49
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js +0 -55
- package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts +0 -50
- package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-warp-filters/swirl.js +0 -56
- package/dist/modules/postprocessing/image-warp-filters/warp.d.ts +0 -8
- package/dist/modules/postprocessing/image-warp-filters/warp.d.ts.map +0 -1
- package/dist/modules/postprocessing/image-warp-filters/warp.js +0 -20
- package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +0 -137
- package/src/modules/postprocessing/fxaa/fxaa.ts +0 -694
- package/src/modules/postprocessing/image-adjust-filters/brightnesscontrast.ts +0 -57
- package/src/modules/postprocessing/image-adjust-filters/denoise.ts +0 -68
- package/src/modules/postprocessing/image-adjust-filters/huesaturation.ts +0 -79
- package/src/modules/postprocessing/image-adjust-filters/noise.ts +0 -56
- package/src/modules/postprocessing/image-adjust-filters/sepia.ts +0 -54
- package/src/modules/postprocessing/image-adjust-filters/vibrance.ts +0 -45
- package/src/modules/postprocessing/image-adjust-filters/vignette.ts +0 -58
- package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +0 -135
- package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +0 -84
- package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +0 -75
- package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +0 -85
- package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +0 -70
- package/src/modules/postprocessing/image-fun-filters/edgework.ts +0 -109
- package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +0 -86
- package/src/modules/postprocessing/image-fun-filters/ink.ts +0 -73
- package/src/modules/postprocessing/image-fun-filters/magnify.ts +0 -70
- package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +0 -72
- package/src/modules/postprocessing/image-warp-filters/swirl.ts +0 -77
- package/src/modules/postprocessing/image-warp-filters/warp.ts +0 -28
package/dist/dist.dev.js
CHANGED
|
@@ -56,20 +56,13 @@ var __exports__ = (() => {
|
|
|
56
56
|
ShaderAssembler: () => ShaderAssembler,
|
|
57
57
|
_getDependencyGraph: () => getDependencyGraph,
|
|
58
58
|
_resolveModules: () => resolveModules,
|
|
59
|
-
_warp: () => warp,
|
|
60
59
|
assembleGLSLShaderPair: () => assembleGLSLShaderPair,
|
|
61
|
-
brightnessContrast: () => brightnessContrast,
|
|
62
|
-
bulgePinch: () => bulgePinch,
|
|
63
60
|
capitalize: () => capitalize,
|
|
64
61
|
checkShaderModuleDeprecations: () => checkShaderModuleDeprecations,
|
|
65
|
-
colorHalftone: () => colorHalftone,
|
|
66
62
|
combineInjects: () => combineInjects,
|
|
67
63
|
convertToVec4: () => convertToVec4,
|
|
68
|
-
denoise: () => denoise,
|
|
69
64
|
dirlight: () => dirlight,
|
|
70
65
|
dirlight1: () => dirlight2,
|
|
71
|
-
dotScreen: () => dotScreen,
|
|
72
|
-
edgeWork: () => edgeWork,
|
|
73
66
|
fp32: () => fp32,
|
|
74
67
|
fp64: () => fp64,
|
|
75
68
|
fp64LowPart: () => fp64LowPart,
|
|
@@ -77,7 +70,6 @@ var __exports__ = (() => {
|
|
|
77
70
|
fp64ify: () => fp64ify,
|
|
78
71
|
fp64ifyMatrix4: () => fp64ifyMatrix4,
|
|
79
72
|
fromHalfFloat: () => fromHalfFloat,
|
|
80
|
-
fxaa: () => fxaa,
|
|
81
73
|
generateShaderForModule: () => generateShaderForModule,
|
|
82
74
|
geometry1: () => geometry,
|
|
83
75
|
getPassthroughFS: () => getPassthroughFS,
|
|
@@ -89,15 +81,10 @@ var __exports__ = (() => {
|
|
|
89
81
|
getShaderModuleUniforms: () => getShaderModuleUniforms,
|
|
90
82
|
gouraudLighting: () => gouraudLighting,
|
|
91
83
|
gouraudMaterial: () => gouraudMaterial,
|
|
92
|
-
hexagonalPixelate: () => hexagonalPixelate,
|
|
93
|
-
hueSaturation: () => hueSaturation,
|
|
94
84
|
initializeShaderModule: () => initializeShaderModule,
|
|
95
85
|
initializeShaderModules: () => initializeShaderModules,
|
|
96
|
-
ink: () => ink,
|
|
97
86
|
lighting: () => lighting,
|
|
98
87
|
lights1: () => lights,
|
|
99
|
-
magnify: () => magnify,
|
|
100
|
-
noise: () => noise,
|
|
101
88
|
pbr: () => pbr,
|
|
102
89
|
pbrMaterial: () => pbrMaterial,
|
|
103
90
|
phongLighting: () => phongLighting,
|
|
@@ -106,16 +93,9 @@ var __exports__ = (() => {
|
|
|
106
93
|
preprocess: () => preprocess,
|
|
107
94
|
project1: () => project,
|
|
108
95
|
random: () => random,
|
|
109
|
-
sepia: () => sepia,
|
|
110
|
-
swirl: () => swirl,
|
|
111
|
-
tiltShift: () => tiltShift,
|
|
112
96
|
toHalfFloat: () => toHalfFloat,
|
|
113
|
-
triangleBlur: () => triangleBlur,
|
|
114
97
|
typeToChannelCount: () => typeToChannelCount,
|
|
115
|
-
typeToChannelSuffix: () => typeToChannelSuffix
|
|
116
|
-
vibrance: () => vibrance,
|
|
117
|
-
vignette: () => vignette,
|
|
118
|
-
zoomBlur: () => zoomBlur
|
|
98
|
+
typeToChannelSuffix: () => typeToChannelSuffix
|
|
119
99
|
});
|
|
120
100
|
__reExport(bundle_exports, __toESM(require_core(), 1));
|
|
121
101
|
|
|
@@ -203,20 +183,20 @@ var __exports__ = (() => {
|
|
|
203
183
|
var MODULE_INJECTORS_FS = (
|
|
204
184
|
/* glsl */
|
|
205
185
|
`#ifdef MODULE_MATERIAL
|
|
206
|
-
|
|
186
|
+
fragColor = material_filterColor(fragColor);
|
|
207
187
|
#endif
|
|
208
188
|
|
|
209
189
|
#ifdef MODULE_LIGHTING
|
|
210
|
-
|
|
190
|
+
fragColor = lighting_filterColor(fragColor);
|
|
211
191
|
#endif
|
|
212
192
|
|
|
213
193
|
#ifdef MODULE_FOG
|
|
214
|
-
|
|
194
|
+
fragColor = fog_filterColor(fragColor);
|
|
215
195
|
#endif
|
|
216
196
|
|
|
217
197
|
#ifdef MODULE_PICKING
|
|
218
|
-
|
|
219
|
-
|
|
198
|
+
fragColor = picking_filterHighlightColor(fragColor);
|
|
199
|
+
fragColor = picking_filterPickingColor(fragColor);
|
|
220
200
|
#endif
|
|
221
201
|
|
|
222
202
|
#ifdef MODULE_LOGDEPTH
|
|
@@ -334,7 +314,7 @@ ${inject[key]}` : inject[key];
|
|
|
334
314
|
}
|
|
335
315
|
initializeShaderModules(module.dependencies || []);
|
|
336
316
|
const {
|
|
337
|
-
|
|
317
|
+
propTypes = {},
|
|
338
318
|
deprecations = [],
|
|
339
319
|
// defines = {},
|
|
340
320
|
inject = {}
|
|
@@ -343,26 +323,40 @@ ${inject[key]}` : inject[key];
|
|
|
343
323
|
normalizedInjections: normalizeInjections(inject),
|
|
344
324
|
parsedDeprecations: parseDeprecationDefinitions(deprecations)
|
|
345
325
|
};
|
|
346
|
-
if (
|
|
347
|
-
instance.propValidators = makePropValidators(
|
|
326
|
+
if (propTypes) {
|
|
327
|
+
instance.propValidators = makePropValidators(propTypes);
|
|
348
328
|
}
|
|
349
329
|
module.instance = instance;
|
|
330
|
+
let defaultProps = {};
|
|
331
|
+
if (propTypes) {
|
|
332
|
+
defaultProps = Object.entries(propTypes).reduce(
|
|
333
|
+
(obj, [key, propType]) => {
|
|
334
|
+
const value = propType?.value;
|
|
335
|
+
if (value) {
|
|
336
|
+
obj[key] = value;
|
|
337
|
+
}
|
|
338
|
+
return obj;
|
|
339
|
+
},
|
|
340
|
+
{}
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
module.defaultUniforms = { ...module.defaultUniforms, ...defaultProps };
|
|
350
344
|
}
|
|
351
345
|
function getShaderModuleUniforms(module, props, oldUniforms) {
|
|
352
346
|
initializeShaderModule(module);
|
|
353
347
|
const uniforms = oldUniforms || { ...module.defaultUniforms };
|
|
354
|
-
if (module.getUniforms) {
|
|
348
|
+
if (props && module.getUniforms) {
|
|
355
349
|
return module.getUniforms(props, uniforms);
|
|
356
350
|
}
|
|
357
351
|
return getValidatedProperties(props, module.instance?.propValidators, module.name);
|
|
358
352
|
}
|
|
359
|
-
function checkShaderModuleDeprecations(shaderModule, shaderSource,
|
|
353
|
+
function checkShaderModuleDeprecations(shaderModule, shaderSource, log3) {
|
|
360
354
|
shaderModule.deprecations?.forEach((def) => {
|
|
361
355
|
if (def.regex?.test(shaderSource)) {
|
|
362
356
|
if (def.deprecated) {
|
|
363
|
-
|
|
357
|
+
log3.deprecated(def.old, def.new)();
|
|
364
358
|
} else {
|
|
365
|
-
|
|
359
|
+
log3.removed(def.old, def.new)();
|
|
366
360
|
}
|
|
367
361
|
}
|
|
368
362
|
});
|
|
@@ -627,7 +621,7 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
627
621
|
};
|
|
628
622
|
}
|
|
629
623
|
function assembleGLSLShaderPair(options) {
|
|
630
|
-
const { vs: vs6, fs:
|
|
624
|
+
const { vs: vs6, fs: fs8 } = options;
|
|
631
625
|
const modules = getShaderModuleDependencies(options.modules || []);
|
|
632
626
|
return {
|
|
633
627
|
vs: assembleShaderGLSL(options.platformInfo, {
|
|
@@ -639,7 +633,7 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
639
633
|
fs: assembleShaderGLSL(options.platformInfo, {
|
|
640
634
|
...options,
|
|
641
635
|
// @ts-expect-error
|
|
642
|
-
source:
|
|
636
|
+
source: fs8,
|
|
643
637
|
stage: "fragment",
|
|
644
638
|
modules
|
|
645
639
|
}),
|
|
@@ -655,7 +649,7 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
655
649
|
// defines = {},
|
|
656
650
|
hookFunctions = [],
|
|
657
651
|
inject = {},
|
|
658
|
-
log:
|
|
652
|
+
log: log3
|
|
659
653
|
} = options;
|
|
660
654
|
assert(typeof source === "string", "shader source must be a string");
|
|
661
655
|
const coreSource = source;
|
|
@@ -683,14 +677,14 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
683
677
|
mainInjections[key] = [injection];
|
|
684
678
|
}
|
|
685
679
|
}
|
|
686
|
-
const modulesToInject =
|
|
680
|
+
const modulesToInject = modules;
|
|
687
681
|
for (const module of modulesToInject) {
|
|
688
|
-
if (
|
|
689
|
-
checkShaderModuleDeprecations(module, coreSource,
|
|
682
|
+
if (log3) {
|
|
683
|
+
checkShaderModuleDeprecations(module, coreSource, log3);
|
|
690
684
|
}
|
|
691
|
-
const moduleSource = getShaderModuleSource(module,
|
|
685
|
+
const moduleSource = getShaderModuleSource(module, "wgsl");
|
|
692
686
|
assembledSource += moduleSource;
|
|
693
|
-
const injections = module.injections[stage];
|
|
687
|
+
const injections = module.injections?.[stage] || {};
|
|
694
688
|
for (const key in injections) {
|
|
695
689
|
const match = /^(v|f)s:#([\w-]+)$/.exec(key);
|
|
696
690
|
if (match) {
|
|
@@ -713,7 +707,6 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
713
707
|
}
|
|
714
708
|
function assembleShaderGLSL(platformInfo, options) {
|
|
715
709
|
const {
|
|
716
|
-
id,
|
|
717
710
|
source,
|
|
718
711
|
stage,
|
|
719
712
|
language = "glsl",
|
|
@@ -722,7 +715,7 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
722
715
|
hookFunctions = [],
|
|
723
716
|
inject = {},
|
|
724
717
|
prologue = true,
|
|
725
|
-
log:
|
|
718
|
+
log: log3
|
|
726
719
|
} = options;
|
|
727
720
|
assert(typeof source === "string", "shader source must be a string");
|
|
728
721
|
const sourceVersion = language === "glsl" ? getShaderInfo(source).version : -1;
|
|
@@ -743,7 +736,6 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
743
736
|
assembledSource = prologue ? `${sourceVersionDirective}
|
|
744
737
|
|
|
745
738
|
// ----- PROLOGUE -------------------------
|
|
746
|
-
${getShaderNameDefine({ id, source, stage })}
|
|
747
739
|
${`#define SHADER_TYPE_${stage.toUpperCase()}`}
|
|
748
740
|
|
|
749
741
|
${getPlatformShaderDefines(platformInfo)}
|
|
@@ -781,8 +773,8 @@ ${getApplicationDefines(allDefines)}
|
|
|
781
773
|
}
|
|
782
774
|
}
|
|
783
775
|
for (const module of modules) {
|
|
784
|
-
if (
|
|
785
|
-
checkShaderModuleDeprecations(module, coreSource,
|
|
776
|
+
if (log3) {
|
|
777
|
+
checkShaderModuleDeprecations(module, coreSource, log3);
|
|
786
778
|
}
|
|
787
779
|
const moduleSource = getShaderModuleSource(module, stage);
|
|
788
780
|
assembledSource += moduleSource;
|
|
@@ -821,12 +813,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
821
813
|
return uniforms;
|
|
822
814
|
};
|
|
823
815
|
}
|
|
824
|
-
function getShaderNameDefine(options) {
|
|
825
|
-
const { id, source, stage } = options;
|
|
826
|
-
const injectShaderName = id && source.indexOf("SHADER_NAME") === -1;
|
|
827
|
-
return injectShaderName ? `
|
|
828
|
-
#define SHADER_NAME ${id}_${stage}` : "";
|
|
829
|
-
}
|
|
830
816
|
function getApplicationDefines(defines = {}) {
|
|
831
817
|
let sourceText = "";
|
|
832
818
|
for (const define in defines) {
|
|
@@ -857,12 +843,16 @@ ${getApplicationDefines(allDefines)}
|
|
|
857
843
|
throw new Error("Shader module must have a name");
|
|
858
844
|
}
|
|
859
845
|
const moduleName = module.name.toUpperCase().replace(/[^0-9a-z]/gi, "_");
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
#define MODULE_${moduleName}
|
|
863
|
-
${moduleSource}
|
|
846
|
+
let source = `// ----- MODULE ${module.name} ---------------
|
|
864
847
|
|
|
865
848
|
`;
|
|
849
|
+
if (stage !== "wgsl") {
|
|
850
|
+
source += `#define MODULE_${moduleName}
|
|
851
|
+
`;
|
|
852
|
+
}
|
|
853
|
+
source += `${moduleSource}
|
|
854
|
+
`;
|
|
855
|
+
return source;
|
|
866
856
|
}
|
|
867
857
|
|
|
868
858
|
// src/lib/preprocessor/preprocessor.ts
|
|
@@ -4642,12 +4632,28 @@ void main() {
|
|
|
4642
4632
|
shaderLayout.bindings.push({
|
|
4643
4633
|
type: "uniform",
|
|
4644
4634
|
name: uniform.name,
|
|
4645
|
-
location: uniform.binding,
|
|
4646
|
-
// @ts-expect-error
|
|
4647
4635
|
group: uniform.group,
|
|
4636
|
+
location: uniform.binding,
|
|
4637
|
+
// @ts-expect-error TODO - unused for now but needs fixing
|
|
4648
4638
|
members
|
|
4649
4639
|
});
|
|
4650
4640
|
}
|
|
4641
|
+
for (const texture of parsedWGSL.textures) {
|
|
4642
|
+
shaderLayout.bindings.push({
|
|
4643
|
+
type: "texture",
|
|
4644
|
+
name: texture.name,
|
|
4645
|
+
group: texture.group,
|
|
4646
|
+
location: texture.binding
|
|
4647
|
+
});
|
|
4648
|
+
}
|
|
4649
|
+
for (const sampler of parsedWGSL.samplers) {
|
|
4650
|
+
shaderLayout.bindings.push({
|
|
4651
|
+
type: "sampler",
|
|
4652
|
+
name: sampler.name,
|
|
4653
|
+
group: sampler.group,
|
|
4654
|
+
location: sampler.binding
|
|
4655
|
+
});
|
|
4656
|
+
}
|
|
4651
4657
|
const vertex = parsedWGSL.entry.vertex[0];
|
|
4652
4658
|
const attributeCount = vertex?.inputs.length || 0;
|
|
4653
4659
|
for (let i = 0; i < attributeCount; i++) {
|
|
@@ -6657,7 +6663,7 @@ float tan_fp32(float a) {
|
|
|
6657
6663
|
};
|
|
6658
6664
|
|
|
6659
6665
|
// src/modules/engine/picking/picking.ts
|
|
6660
|
-
var DEFAULT_HIGHLIGHT_COLOR =
|
|
6666
|
+
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
6661
6667
|
var vs = (
|
|
6662
6668
|
/* glsl */
|
|
6663
6669
|
`uniform pickingUniforms {
|
|
@@ -6810,7 +6816,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
6810
6816
|
isAttribute: false,
|
|
6811
6817
|
isHighlightActive: false,
|
|
6812
6818
|
useFloatColors: true,
|
|
6813
|
-
highlightedObjectColor:
|
|
6819
|
+
highlightedObjectColor: [0, 0, 0],
|
|
6814
6820
|
highlightColor: DEFAULT_HIGHLIGHT_COLOR
|
|
6815
6821
|
},
|
|
6816
6822
|
vs,
|
|
@@ -6844,8 +6850,11 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
6844
6850
|
return uniforms;
|
|
6845
6851
|
}
|
|
6846
6852
|
|
|
6853
|
+
// src/modules/lighting/lights/lighting.ts
|
|
6854
|
+
var import_core3 = __toESM(require_core(), 1);
|
|
6855
|
+
|
|
6847
6856
|
// src/modules/lighting/lights/lighting-uniforms-glsl.ts
|
|
6848
|
-
var
|
|
6857
|
+
var lightingUniformsGLSL = (
|
|
6849
6858
|
/* glsl */
|
|
6850
6859
|
`precision highp int;
|
|
6851
6860
|
|
|
@@ -6867,28 +6876,51 @@ struct DirectionalLight {
|
|
|
6867
6876
|
|
|
6868
6877
|
uniform lightingUniforms {
|
|
6869
6878
|
int enabled;
|
|
6870
|
-
int
|
|
6879
|
+
int lightType;
|
|
6880
|
+
|
|
6871
6881
|
int directionalLightCount;
|
|
6882
|
+
int pointLightCount;
|
|
6872
6883
|
|
|
6873
6884
|
vec3 ambientColor;
|
|
6874
6885
|
|
|
6875
|
-
|
|
6876
|
-
vec3
|
|
6877
|
-
vec3
|
|
6878
|
-
vec3
|
|
6879
|
-
vec3 lightAttenuation;
|
|
6886
|
+
vec3 lightColor0;
|
|
6887
|
+
vec3 lightPosition0;
|
|
6888
|
+
vec3 lightDirection0;
|
|
6889
|
+
vec3 lightAttenuation0;
|
|
6880
6890
|
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6891
|
+
vec3 lightColor1;
|
|
6892
|
+
vec3 lightPosition1;
|
|
6893
|
+
vec3 lightDirection1;
|
|
6894
|
+
vec3 lightAttenuation1;
|
|
6895
|
+
|
|
6896
|
+
vec3 lightColor2;
|
|
6897
|
+
vec3 lightPosition2;
|
|
6898
|
+
vec3 lightDirection2;
|
|
6899
|
+
vec3 lightAttenuation2;
|
|
6884
6900
|
} lighting;
|
|
6885
6901
|
|
|
6886
6902
|
PointLight lighting_getPointLight(int index) {
|
|
6887
|
-
|
|
6903
|
+
switch (index) {
|
|
6904
|
+
case 0:
|
|
6905
|
+
return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);
|
|
6906
|
+
case 1:
|
|
6907
|
+
return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
|
|
6908
|
+
case 2:
|
|
6909
|
+
default:
|
|
6910
|
+
return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
|
|
6911
|
+
}
|
|
6888
6912
|
}
|
|
6889
6913
|
|
|
6890
6914
|
DirectionalLight lighting_getDirectionalLight(int index) {
|
|
6891
|
-
|
|
6915
|
+
switch (index) {
|
|
6916
|
+
case 0:
|
|
6917
|
+
return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);
|
|
6918
|
+
case 1:
|
|
6919
|
+
return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
|
|
6920
|
+
case 2:
|
|
6921
|
+
default:
|
|
6922
|
+
return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
|
|
6923
|
+
}
|
|
6892
6924
|
}
|
|
6893
6925
|
|
|
6894
6926
|
float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
@@ -6901,8 +6933,65 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
6901
6933
|
`
|
|
6902
6934
|
);
|
|
6903
6935
|
|
|
6936
|
+
// src/modules/lighting/lights/lighting-uniforms-wgsl.ts
|
|
6937
|
+
var lightingUniformsWGSL = (
|
|
6938
|
+
/* wgsl */
|
|
6939
|
+
`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
6940
|
+
struct AmbientLight {
|
|
6941
|
+
color: vec3<f32>,
|
|
6942
|
+
};
|
|
6943
|
+
|
|
6944
|
+
struct PointLight {
|
|
6945
|
+
color: vec3<f32>,
|
|
6946
|
+
position: vec3<f32>,
|
|
6947
|
+
attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential
|
|
6948
|
+
};
|
|
6949
|
+
|
|
6950
|
+
struct DirectionalLight {
|
|
6951
|
+
color: vec3<f32>,
|
|
6952
|
+
direction: vec3<f32>,
|
|
6953
|
+
};
|
|
6954
|
+
|
|
6955
|
+
struct lightingUniforms {
|
|
6956
|
+
enabled: i32,
|
|
6957
|
+
poightCount: i32,
|
|
6958
|
+
directionalLightCount: i32,
|
|
6959
|
+
|
|
6960
|
+
ambientColor: vec3<f32>,
|
|
6961
|
+
|
|
6962
|
+
// TODO - support multiple lights by uncommenting arrays below
|
|
6963
|
+
lightType: i32,
|
|
6964
|
+
lightColor: vec3<f32>,
|
|
6965
|
+
lightDirection: vec3<f32>,
|
|
6966
|
+
lightPosition: vec3<f32>,
|
|
6967
|
+
lightAttenuation: vec3<f32>,
|
|
6968
|
+
|
|
6969
|
+
// AmbientLight ambientLight;
|
|
6970
|
+
// PointLight pointLight[MAX_LIGHTS];
|
|
6971
|
+
// DirectionalLight directionalLight[MAX_LIGHTS];
|
|
6972
|
+
};
|
|
6973
|
+
|
|
6974
|
+
// Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)
|
|
6975
|
+
@binding(1) @group(0) var<uniform> lighting : lightingUniforms;
|
|
6976
|
+
|
|
6977
|
+
fn lighting_getPointLight(index: i32) -> PointLight {
|
|
6978
|
+
return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);
|
|
6979
|
+
}
|
|
6980
|
+
|
|
6981
|
+
fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
|
|
6982
|
+
return DirectionalLight(lighting.lightColor, lighting.lightDirection);
|
|
6983
|
+
}
|
|
6984
|
+
|
|
6985
|
+
fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
|
|
6986
|
+
return pointLight.attenuation.x
|
|
6987
|
+
+ pointLight.attenuation.y * distance
|
|
6988
|
+
+ pointLight.attenuation.z * distance * distance;
|
|
6989
|
+
}
|
|
6990
|
+
`
|
|
6991
|
+
);
|
|
6992
|
+
|
|
6904
6993
|
// src/modules/lighting/lights/lighting.ts
|
|
6905
|
-
var MAX_LIGHTS =
|
|
6994
|
+
var MAX_LIGHTS = 3;
|
|
6906
6995
|
var COLOR_FACTOR = 255;
|
|
6907
6996
|
var lighting = {
|
|
6908
6997
|
props: {},
|
|
@@ -6913,34 +7002,48 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
6913
7002
|
},
|
|
6914
7003
|
uniformTypes: {
|
|
6915
7004
|
enabled: "i32",
|
|
6916
|
-
ambientLightColor: "vec3<f32>",
|
|
6917
|
-
numberOfLights: "i32",
|
|
6918
|
-
// , array: MAX_LIGHTS,
|
|
6919
7005
|
lightType: "i32",
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
7006
|
+
directionalLightCount: "i32",
|
|
7007
|
+
pointLightCount: "i32",
|
|
7008
|
+
ambientLightColor: "vec3<f32>",
|
|
7009
|
+
// TODO define as arrays once we have appropriate uniformTypes
|
|
7010
|
+
lightColor0: "vec3<f32>",
|
|
7011
|
+
lightPosition0: "vec3<f32>",
|
|
6925
7012
|
// TODO - could combine direction and attenuation
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
7013
|
+
lightDirection0: "vec3<f32>",
|
|
7014
|
+
lightAttenuation0: "vec3<f32>",
|
|
7015
|
+
lightColor1: "vec3<f32>",
|
|
7016
|
+
lightPosition1: "vec3<f32>",
|
|
7017
|
+
lightDirection1: "vec3<f32>",
|
|
7018
|
+
lightAttenuation1: "vec3<f32>",
|
|
7019
|
+
lightColor2: "vec3<f32>",
|
|
7020
|
+
lightPosition2: "vec3<f32>",
|
|
7021
|
+
lightDirection2: "vec3<f32>",
|
|
7022
|
+
lightAttenuation2: "vec3<f32>"
|
|
6930
7023
|
},
|
|
6931
7024
|
defaultUniforms: {
|
|
6932
7025
|
enabled: 1,
|
|
6933
|
-
ambientLightColor: [0.1, 0.1, 0.1],
|
|
6934
|
-
numberOfLights: 0,
|
|
6935
7026
|
lightType: 0 /* POINT */,
|
|
6936
|
-
|
|
6937
|
-
|
|
7027
|
+
directionalLightCount: 0,
|
|
7028
|
+
pointLightCount: 0,
|
|
7029
|
+
ambientLightColor: [0.1, 0.1, 0.1],
|
|
7030
|
+
lightColor0: [1, 1, 1],
|
|
7031
|
+
lightPosition0: [1, 1, 2],
|
|
6938
7032
|
// TODO - could combine direction and attenuation
|
|
6939
|
-
|
|
6940
|
-
|
|
7033
|
+
lightDirection0: [1, 1, 1],
|
|
7034
|
+
lightAttenuation0: [1, 0, 0],
|
|
7035
|
+
lightColor1: [1, 1, 1],
|
|
7036
|
+
lightPosition1: [1, 1, 2],
|
|
7037
|
+
lightDirection1: [1, 1, 1],
|
|
7038
|
+
lightAttenuation1: [1, 0, 0],
|
|
7039
|
+
lightColor2: [1, 1, 1],
|
|
7040
|
+
lightPosition2: [1, 1, 2],
|
|
7041
|
+
lightDirection2: [1, 1, 1],
|
|
7042
|
+
lightAttenuation2: [1, 0, 0]
|
|
6941
7043
|
},
|
|
6942
|
-
|
|
6943
|
-
|
|
7044
|
+
source: lightingUniformsWGSL,
|
|
7045
|
+
vs: lightingUniformsGLSL,
|
|
7046
|
+
fs: lightingUniformsGLSL,
|
|
6944
7047
|
getUniforms: getUniforms2
|
|
6945
7048
|
};
|
|
6946
7049
|
function getUniforms2(props, prevUniforms = {}) {
|
|
@@ -6971,30 +7074,29 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
6971
7074
|
pointLights = [],
|
|
6972
7075
|
directionalLights = []
|
|
6973
7076
|
}) {
|
|
6974
|
-
const lightSourceUniforms = {
|
|
6975
|
-
// lightType: new Array(MAX_LIGHTS).fill(0),
|
|
6976
|
-
// lightColor: new Array(MAX_LIGHTS).fill([0, 0, 0]),
|
|
6977
|
-
// lightPosition: new Array(MAX_LIGHTS).fill([0, 0, 0]),
|
|
6978
|
-
// lightDirection: new Array(MAX_LIGHTS).fill([0, 0, 0]),
|
|
6979
|
-
// lightAttenuation: new Array(MAX_LIGHTS).fill([0, 0, 0])
|
|
6980
|
-
};
|
|
7077
|
+
const lightSourceUniforms = {};
|
|
6981
7078
|
lightSourceUniforms.ambientLightColor = convertColor(ambientLight);
|
|
6982
7079
|
let currentLight = 0;
|
|
6983
7080
|
for (const pointLight of pointLights) {
|
|
6984
7081
|
lightSourceUniforms.lightType = 0 /* POINT */;
|
|
6985
|
-
|
|
6986
|
-
lightSourceUniforms
|
|
6987
|
-
lightSourceUniforms
|
|
7082
|
+
const i = currentLight;
|
|
7083
|
+
lightSourceUniforms[`lightColor${i}`] = convertColor(pointLight);
|
|
7084
|
+
lightSourceUniforms[`lightPosition${i}`] = pointLight.position;
|
|
7085
|
+
lightSourceUniforms[`lightAttenuation${i}`] = pointLight.attenuation || [1, 0, 0];
|
|
6988
7086
|
currentLight++;
|
|
6989
7087
|
}
|
|
6990
7088
|
for (const directionalLight of directionalLights) {
|
|
6991
7089
|
lightSourceUniforms.lightType = 1 /* DIRECTIONAL */;
|
|
6992
|
-
|
|
6993
|
-
lightSourceUniforms
|
|
6994
|
-
lightSourceUniforms
|
|
7090
|
+
const i = currentLight;
|
|
7091
|
+
lightSourceUniforms[`lightColor${i}`] = convertColor(directionalLight);
|
|
7092
|
+
lightSourceUniforms[`lightDirection${i}`] = directionalLight.direction;
|
|
6995
7093
|
currentLight++;
|
|
6996
7094
|
}
|
|
6997
|
-
|
|
7095
|
+
if (currentLight > MAX_LIGHTS) {
|
|
7096
|
+
import_core3.log.warn("MAX_LIGHTS exceeded")();
|
|
7097
|
+
}
|
|
7098
|
+
lightSourceUniforms.directionalLightCount = directionalLights.length;
|
|
7099
|
+
lightSourceUniforms.pointLightCount = pointLights.length;
|
|
6998
7100
|
return lightSourceUniforms;
|
|
6999
7101
|
}
|
|
7000
7102
|
function extractLightTypes(lights2) {
|
|
@@ -7021,6 +7123,36 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
7021
7123
|
}
|
|
7022
7124
|
|
|
7023
7125
|
// src/modules/lighting/no-material/dirlight.ts
|
|
7126
|
+
var SOURCE_WGSL = (
|
|
7127
|
+
/* WGSL */
|
|
7128
|
+
`
|
|
7129
|
+
struct dirlightUniforms {
|
|
7130
|
+
lightDirection: vec3<f32>,
|
|
7131
|
+
};
|
|
7132
|
+
|
|
7133
|
+
alias DirlightNormal = vec3<f32>;
|
|
7134
|
+
|
|
7135
|
+
struct DirlightInputs {
|
|
7136
|
+
normal: DirlightNormal,
|
|
7137
|
+
};
|
|
7138
|
+
|
|
7139
|
+
@binding(1) @group(0) var<uniform> dirlight : dirlightUniforms;
|
|
7140
|
+
|
|
7141
|
+
// For vertex
|
|
7142
|
+
fn dirlight_setNormal(normal: vec3<f32>) -> DirlightNormal {
|
|
7143
|
+
return normalize(normal);
|
|
7144
|
+
}
|
|
7145
|
+
|
|
7146
|
+
// Returns color attenuated by angle from light source
|
|
7147
|
+
fn dirlight_filterColor(color: vec4<f32>, inputs: DirlightInputs) -> vec4<f32> {
|
|
7148
|
+
// TODO - fix default light direction
|
|
7149
|
+
// let lightDirection = dirlight.lightDirection;
|
|
7150
|
+
let lightDirection = vec3<f32>(1, 1, 1);
|
|
7151
|
+
let d: f32 = abs(dot(inputs.normal, normalize(lightDirection)));
|
|
7152
|
+
return vec4<f32>(color.rgb * d, color.a);
|
|
7153
|
+
}
|
|
7154
|
+
`
|
|
7155
|
+
);
|
|
7024
7156
|
var VS_GLSL = (
|
|
7025
7157
|
/* glsl */
|
|
7026
7158
|
`out vec3 dirlight_vNormal;
|
|
@@ -7050,6 +7182,7 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
7050
7182
|
uniforms: {},
|
|
7051
7183
|
name: "dirlight",
|
|
7052
7184
|
dependencies: [],
|
|
7185
|
+
source: SOURCE_WGSL,
|
|
7053
7186
|
vs: VS_GLSL,
|
|
7054
7187
|
fs: FS_GLSL,
|
|
7055
7188
|
// fragmentInputs: [
|
|
@@ -7062,7 +7195,7 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
7062
7195
|
lightDirection: "vec3<f32>"
|
|
7063
7196
|
},
|
|
7064
7197
|
defaultUniforms: {
|
|
7065
|
-
lightDirection:
|
|
7198
|
+
lightDirection: [1, 1, 2]
|
|
7066
7199
|
},
|
|
7067
7200
|
getUniforms: getUniforms3
|
|
7068
7201
|
};
|
|
@@ -7074,10 +7207,10 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
7074
7207
|
return uniforms;
|
|
7075
7208
|
}
|
|
7076
7209
|
|
|
7077
|
-
// src/modules/lighting/
|
|
7078
|
-
var
|
|
7210
|
+
// src/modules/lighting/phong-material/phong-shaders-glsl.ts
|
|
7211
|
+
var PHONG_VS = (
|
|
7079
7212
|
/* glsl */
|
|
7080
|
-
`uniform
|
|
7213
|
+
`uniform phongMaterialUniforms {
|
|
7081
7214
|
uniform float ambient;
|
|
7082
7215
|
uniform float diffuse;
|
|
7083
7216
|
uniform float shininess;
|
|
@@ -7085,9 +7218,9 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
7085
7218
|
} material;
|
|
7086
7219
|
`
|
|
7087
7220
|
);
|
|
7088
|
-
var
|
|
7221
|
+
var PHONG_FS = (
|
|
7089
7222
|
/* glsl */
|
|
7090
|
-
`uniform
|
|
7223
|
+
`uniform phongMaterialUniforms {
|
|
7091
7224
|
uniform float ambient;
|
|
7092
7225
|
uniform float diffuse;
|
|
7093
7226
|
uniform float shininess;
|
|
@@ -7109,63 +7242,27 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
|
|
|
7109
7242
|
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
|
|
7110
7243
|
vec3 lightColor = surfaceColor;
|
|
7111
7244
|
|
|
7112
|
-
if (lighting.enabled) {
|
|
7113
|
-
|
|
7114
|
-
lightColor = material.ambient * surfaceColor * lighting.ambientColor;
|
|
7115
|
-
|
|
7116
|
-
if (lighting.lightType == 0) {
|
|
7117
|
-
PointLight pointLight = lighting_getPointLight(0);
|
|
7118
|
-
vec3 light_position_worldspace = pointLight.position;
|
|
7119
|
-
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
7120
|
-
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
7121
|
-
} else if (lighting.lightType == 1) {
|
|
7122
|
-
DirectionalLight directionalLight = lighting_getDirectionalLight(0);
|
|
7123
|
-
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
7124
|
-
}
|
|
7125
|
-
/*
|
|
7126
|
-
for (int i = 0; i < MAX_LIGHTS; i++) {
|
|
7127
|
-
if (i >= lighting.pointLightCount) {
|
|
7128
|
-
break;
|
|
7129
|
-
}
|
|
7130
|
-
PointLight pointLight = lighting.pointLight[i];
|
|
7131
|
-
vec3 light_position_worldspace = pointLight.position;
|
|
7132
|
-
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
7133
|
-
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
7134
|
-
}
|
|
7135
|
-
|
|
7136
|
-
for (int i = 0; i < MAX_LIGHTS; i++) {
|
|
7137
|
-
if (i >= lighting.directionalLightCount) {
|
|
7138
|
-
break;
|
|
7139
|
-
}
|
|
7140
|
-
DirectionalLight directionalLight = lighting.directionalLight[i];
|
|
7141
|
-
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
7142
|
-
}
|
|
7143
|
-
*/
|
|
7245
|
+
if (lighting.enabled == 0) {
|
|
7246
|
+
return lightColor;
|
|
7144
7247
|
}
|
|
7145
|
-
return lightColor;
|
|
7146
|
-
}
|
|
7147
|
-
|
|
7148
|
-
vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
|
|
7149
|
-
vec3 lightColor = vec3(0, 0, 0);
|
|
7150
|
-
vec3 surfaceColor = vec3(0, 0, 0);
|
|
7151
7248
|
|
|
7152
|
-
|
|
7153
|
-
|
|
7249
|
+
vec3 view_direction = normalize(cameraPosition - position_worldspace);
|
|
7250
|
+
lightColor = material.ambient * surfaceColor * lighting.ambientColor;
|
|
7154
7251
|
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7252
|
+
for (int i = 0; i < lighting.pointLightCount; i++) {
|
|
7253
|
+
PointLight pointLight = lighting_getPointLight(i);
|
|
7254
|
+
vec3 light_position_worldspace = pointLight.position;
|
|
7255
|
+
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
7256
|
+
float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));
|
|
7257
|
+
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);
|
|
7258
|
+
}
|
|
7162
7259
|
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
}
|
|
7260
|
+
int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);
|
|
7261
|
+
for (int i = lighting.pointLightCount; i < totalLights; i++) {
|
|
7262
|
+
DirectionalLight directionalLight = lighting_getDirectionalLight(i);
|
|
7263
|
+
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
7168
7264
|
}
|
|
7265
|
+
|
|
7169
7266
|
return lightColor;
|
|
7170
7267
|
}
|
|
7171
7268
|
`
|
|
@@ -7174,11 +7271,10 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
7174
7271
|
// src/modules/lighting/gouraud-material/gouraud-material.ts
|
|
7175
7272
|
var gouraudMaterial = {
|
|
7176
7273
|
props: {},
|
|
7177
|
-
|
|
7178
|
-
name: "gouraud-lighting",
|
|
7274
|
+
name: "gouraudMaterial",
|
|
7179
7275
|
// Note these are switched between phong and gouraud
|
|
7180
|
-
vs:
|
|
7181
|
-
fs:
|
|
7276
|
+
vs: PHONG_FS.replace("phongMaterial", "gouraudMaterial"),
|
|
7277
|
+
fs: PHONG_VS.replace("phongMaterial", "gouraudMaterial"),
|
|
7182
7278
|
defines: {
|
|
7183
7279
|
LIGHTING_VERTEX: 1
|
|
7184
7280
|
},
|
|
@@ -7196,62 +7292,59 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
7196
7292
|
specularColor: [0.15, 0.15, 0.15]
|
|
7197
7293
|
},
|
|
7198
7294
|
getUniforms(props) {
|
|
7199
|
-
|
|
7295
|
+
const uniforms = { ...props };
|
|
7296
|
+
if (uniforms.specularColor) {
|
|
7297
|
+
uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
|
|
7298
|
+
}
|
|
7299
|
+
return { ...gouraudMaterial.defaultUniforms, ...uniforms };
|
|
7200
7300
|
}
|
|
7201
7301
|
};
|
|
7202
7302
|
|
|
7203
|
-
// src/modules/lighting/phong-material/phong-shaders-
|
|
7204
|
-
var
|
|
7205
|
-
/*
|
|
7206
|
-
`
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
}
|
|
7212
|
-
`
|
|
7213
|
-
);
|
|
7214
|
-
var PHONG_FS = (
|
|
7215
|
-
/* glsl */
|
|
7216
|
-
`uniform phongMaterialUniforms {
|
|
7217
|
-
uniform float ambient;
|
|
7218
|
-
uniform float diffuse;
|
|
7219
|
-
uniform float shininess;
|
|
7220
|
-
uniform vec3 specularColor;
|
|
7221
|
-
} material;
|
|
7303
|
+
// src/modules/lighting/phong-material/phong-shaders-wgsl.ts
|
|
7304
|
+
var PHONG_WGSL = (
|
|
7305
|
+
/* wgsl */
|
|
7306
|
+
`struct phongMaterialUniforms {
|
|
7307
|
+
ambient: f32,
|
|
7308
|
+
diffuse: f32,
|
|
7309
|
+
shininess: f32,
|
|
7310
|
+
specularColor: vec3<f32>,
|
|
7311
|
+
};
|
|
7222
7312
|
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7313
|
+
@binding(2) @group(0) var<uniform> material : phongMaterialUniforms;
|
|
7314
|
+
|
|
7315
|
+
fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {
|
|
7316
|
+
let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);
|
|
7317
|
+
var lambertian: f32 = dot(light_direction, normal_worldspace);
|
|
7318
|
+
var specular: f32 = 0.0;
|
|
7227
7319
|
if (lambertian > 0.0) {
|
|
7228
|
-
|
|
7320
|
+
let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);
|
|
7229
7321
|
specular = pow(specular_angle, material.shininess);
|
|
7230
7322
|
}
|
|
7231
7323
|
lambertian = max(lambertian, 0.0);
|
|
7232
7324
|
return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;
|
|
7233
7325
|
}
|
|
7234
7326
|
|
|
7235
|
-
|
|
7236
|
-
|
|
7327
|
+
fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {
|
|
7328
|
+
var lightColor: vec3<f32> = surfaceColor;
|
|
7237
7329
|
|
|
7238
7330
|
if (lighting.enabled == 0) {
|
|
7239
7331
|
return lightColor;
|
|
7240
7332
|
}
|
|
7241
7333
|
|
|
7242
|
-
|
|
7334
|
+
let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);
|
|
7243
7335
|
lightColor = material.ambient * surfaceColor * lighting.ambientColor;
|
|
7244
7336
|
|
|
7245
7337
|
if (lighting.lightType == 0) {
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7338
|
+
let pointLight: PointLight = lighting_getPointLight(0);
|
|
7339
|
+
let light_position_worldspace: vec3<f32> = pointLight.position;
|
|
7340
|
+
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
|
|
7249
7341
|
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
7250
7342
|
} else if (lighting.lightType == 1) {
|
|
7251
|
-
|
|
7343
|
+
var directionalLight: DirectionalLight = lighting_getDirectionalLight(0);
|
|
7252
7344
|
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
7253
7345
|
}
|
|
7254
7346
|
|
|
7347
|
+
return lightColor;
|
|
7255
7348
|
/*
|
|
7256
7349
|
for (int i = 0; i < MAX_LIGHTS; i++) {
|
|
7257
7350
|
if (i >= lighting.pointLightCount) {
|
|
@@ -7271,28 +7364,26 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
|
|
|
7271
7364
|
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
7272
7365
|
}
|
|
7273
7366
|
*/
|
|
7274
|
-
return lightColor;
|
|
7275
7367
|
}
|
|
7276
7368
|
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7369
|
+
fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{
|
|
7370
|
+
var lightColor = vec3<f32>(0, 0, 0);
|
|
7371
|
+
let surfaceColor = vec3<f32>(0, 0, 0);
|
|
7280
7372
|
|
|
7281
7373
|
if (lighting.enabled == 0) {
|
|
7282
|
-
|
|
7374
|
+
let view_direction = normalize(cameraPosition - position_worldspace);
|
|
7283
7375
|
|
|
7284
7376
|
switch (lighting.lightType) {
|
|
7285
|
-
case 0:
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7377
|
+
case 0, default: {
|
|
7378
|
+
let pointLight: PointLight = lighting_getPointLight(0);
|
|
7379
|
+
let light_position_worldspace: vec3<f32> = pointLight.position;
|
|
7380
|
+
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
|
|
7289
7381
|
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
DirectionalLight directionalLight = lighting_getDirectionalLight(0);
|
|
7382
|
+
}
|
|
7383
|
+
case 1: {
|
|
7384
|
+
let directionalLight: DirectionalLight = lighting_getDirectionalLight(0);
|
|
7294
7385
|
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
7295
|
-
|
|
7386
|
+
}
|
|
7296
7387
|
}
|
|
7297
7388
|
}
|
|
7298
7389
|
return lightColor;
|
|
@@ -7302,11 +7393,10 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
7302
7393
|
|
|
7303
7394
|
// src/modules/lighting/phong-material/phong-material.ts
|
|
7304
7395
|
var phongMaterial = {
|
|
7305
|
-
|
|
7306
|
-
uniforms: {},
|
|
7307
|
-
name: "phong-lighting",
|
|
7396
|
+
name: "phongMaterial",
|
|
7308
7397
|
dependencies: [lighting],
|
|
7309
7398
|
// Note these are switched between phong and gouraud
|
|
7399
|
+
source: PHONG_WGSL,
|
|
7310
7400
|
vs: PHONG_VS,
|
|
7311
7401
|
fs: PHONG_FS,
|
|
7312
7402
|
defines: {
|
|
@@ -7325,45 +7415,41 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
7325
7415
|
specularColor: [0.15, 0.15, 0.15]
|
|
7326
7416
|
},
|
|
7327
7417
|
getUniforms(props) {
|
|
7328
|
-
|
|
7418
|
+
const uniforms = { ...props };
|
|
7419
|
+
if (uniforms.specularColor) {
|
|
7420
|
+
uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
|
|
7421
|
+
}
|
|
7422
|
+
return { ...phongMaterial.defaultUniforms, ...uniforms };
|
|
7329
7423
|
}
|
|
7330
7424
|
};
|
|
7331
7425
|
|
|
7332
7426
|
// src/modules/lighting/pbr-material/pbr-vertex-glsl.ts
|
|
7333
7427
|
var vs2 = (
|
|
7334
7428
|
/* glsl */
|
|
7335
|
-
`
|
|
7336
|
-
|
|
7337
|
-
mat4 u_ModelMatrix;
|
|
7338
|
-
mat4 u_NormalMatrix;
|
|
7339
|
-
// Projection
|
|
7340
|
-
vec3 u_Camera;
|
|
7341
|
-
}
|
|
7342
|
-
|
|
7343
|
-
varying vec3 pbr_vPosition;
|
|
7344
|
-
varying vec2 pbr_vUV;
|
|
7429
|
+
`out vec3 pbr_vPosition;
|
|
7430
|
+
out vec2 pbr_vUV;
|
|
7345
7431
|
|
|
7346
7432
|
#ifdef HAS_NORMALS
|
|
7347
7433
|
# ifdef HAS_TANGENTS
|
|
7348
|
-
|
|
7434
|
+
out mat3 pbr_vTBN;
|
|
7349
7435
|
# else
|
|
7350
|
-
|
|
7436
|
+
out vec3 pbr_vNormal;
|
|
7351
7437
|
# endif
|
|
7352
7438
|
#endif
|
|
7353
7439
|
|
|
7354
7440
|
void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
|
|
7355
7441
|
{
|
|
7356
|
-
vec4 pos =
|
|
7442
|
+
vec4 pos = pbrProjection.modelMatrix * position;
|
|
7357
7443
|
pbr_vPosition = vec3(pos.xyz) / pos.w;
|
|
7358
7444
|
|
|
7359
7445
|
#ifdef HAS_NORMALS
|
|
7360
7446
|
#ifdef HAS_TANGENTS
|
|
7361
|
-
vec3 normalW = normalize(vec3(
|
|
7362
|
-
vec3 tangentW = normalize(vec3(
|
|
7447
|
+
vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
|
|
7448
|
+
vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
|
|
7363
7449
|
vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
|
|
7364
7450
|
pbr_vTBN = mat3(tangentW, bitangentW, normalW);
|
|
7365
7451
|
#else // HAS_TANGENTS != 1
|
|
7366
|
-
pbr_vNormal = normalize(vec3(
|
|
7452
|
+
pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
|
|
7367
7453
|
#endif
|
|
7368
7454
|
#endif
|
|
7369
7455
|
|
|
@@ -7381,12 +7467,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
|
|
|
7381
7467
|
/* glsl */
|
|
7382
7468
|
`precision highp float;
|
|
7383
7469
|
|
|
7384
|
-
uniform
|
|
7385
|
-
// Projection
|
|
7386
|
-
uniform vec3 u_Camera;
|
|
7387
|
-
};
|
|
7388
|
-
|
|
7389
|
-
uniform pbrMaterial {
|
|
7470
|
+
uniform pbrMaterialUniforms {
|
|
7390
7471
|
// Material is unlit
|
|
7391
7472
|
bool unlit;
|
|
7392
7473
|
|
|
@@ -7418,40 +7499,40 @@ uniform pbrMaterial {
|
|
|
7418
7499
|
vec4 scaleDiffBaseMR;
|
|
7419
7500
|
vec4 scaleFGDSpec;
|
|
7420
7501
|
// #endif
|
|
7421
|
-
}
|
|
7502
|
+
} pbrMaterial;
|
|
7422
7503
|
|
|
7423
7504
|
// Samplers
|
|
7424
7505
|
#ifdef HAS_BASECOLORMAP
|
|
7425
|
-
uniform sampler2D
|
|
7506
|
+
uniform sampler2D pbr_baseColorSampler;
|
|
7426
7507
|
#endif
|
|
7427
7508
|
#ifdef HAS_NORMALMAP
|
|
7428
|
-
uniform sampler2D
|
|
7509
|
+
uniform sampler2D pbr_normalSampler;
|
|
7429
7510
|
#endif
|
|
7430
7511
|
#ifdef HAS_EMISSIVEMAP
|
|
7431
|
-
uniform sampler2D
|
|
7512
|
+
uniform sampler2D pbr_emissiveSampler;
|
|
7432
7513
|
#endif
|
|
7433
7514
|
#ifdef HAS_METALROUGHNESSMAP
|
|
7434
|
-
uniform sampler2D
|
|
7515
|
+
uniform sampler2D pbr_metallicRoughnessSampler;
|
|
7435
7516
|
#endif
|
|
7436
7517
|
#ifdef HAS_OCCLUSIONMAP
|
|
7437
|
-
uniform sampler2D
|
|
7518
|
+
uniform sampler2D pbr_occlusionSampler;
|
|
7438
7519
|
#endif
|
|
7439
7520
|
#ifdef USE_IBL
|
|
7440
|
-
uniform samplerCube
|
|
7441
|
-
uniform samplerCube
|
|
7442
|
-
uniform sampler2D
|
|
7521
|
+
uniform samplerCube pbr_diffuseEnvSampler;
|
|
7522
|
+
uniform samplerCube pbr_specularEnvSampler;
|
|
7523
|
+
uniform sampler2D pbr_brdfLUT;
|
|
7443
7524
|
#endif
|
|
7444
7525
|
|
|
7445
7526
|
// Inputs from vertex shader
|
|
7446
7527
|
|
|
7447
|
-
|
|
7448
|
-
|
|
7528
|
+
in vec3 pbr_vPosition;
|
|
7529
|
+
in vec2 pbr_vUV;
|
|
7449
7530
|
|
|
7450
7531
|
#ifdef HAS_NORMALS
|
|
7451
7532
|
#ifdef HAS_TANGENTS
|
|
7452
|
-
|
|
7533
|
+
in mat3 pbr_vTBN;
|
|
7453
7534
|
#else
|
|
7454
|
-
|
|
7535
|
+
in vec3 pbr_vNormal;
|
|
7455
7536
|
#endif
|
|
7456
7537
|
#endif
|
|
7457
7538
|
|
|
@@ -7519,8 +7600,8 @@ vec3 getNormal()
|
|
|
7519
7600
|
#endif
|
|
7520
7601
|
|
|
7521
7602
|
#ifdef HAS_NORMALMAP
|
|
7522
|
-
vec3 n =
|
|
7523
|
-
n = normalize(tbn * ((2.0 * n - 1.0) * vec3(
|
|
7603
|
+
vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
|
|
7604
|
+
n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
|
|
7524
7605
|
#else
|
|
7525
7606
|
// The tbn matrix is linearly interpolated, so we need to re-normalize
|
|
7526
7607
|
vec3 n = normalize(tbn[2].xyz);
|
|
@@ -7538,22 +7619,22 @@ vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)
|
|
|
7538
7619
|
float mipCount = 9.0; // resolution of 512x512
|
|
7539
7620
|
float lod = (pbrInfo.perceptualRoughness * mipCount);
|
|
7540
7621
|
// retrieve a scale and bias to F0. See [1], Figure 3
|
|
7541
|
-
vec3 brdf = SRGBtoLINEAR(
|
|
7622
|
+
vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
|
|
7542
7623
|
vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
|
|
7543
|
-
vec3 diffuseLight = SRGBtoLINEAR(
|
|
7624
|
+
vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
|
|
7544
7625
|
|
|
7545
7626
|
#ifdef USE_TEX_LOD
|
|
7546
|
-
vec3 specularLight = SRGBtoLINEAR(
|
|
7627
|
+
vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
|
|
7547
7628
|
#else
|
|
7548
|
-
vec3 specularLight = SRGBtoLINEAR(
|
|
7629
|
+
vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
|
|
7549
7630
|
#endif
|
|
7550
7631
|
|
|
7551
7632
|
vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
|
|
7552
7633
|
vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
|
|
7553
7634
|
|
|
7554
7635
|
// For presentation, this allows us to disable IBL terms
|
|
7555
|
-
diffuse *=
|
|
7556
|
-
specular *=
|
|
7636
|
+
diffuse *= pbrMaterial.scaleIBLAmbient.x;
|
|
7637
|
+
specular *= pbrMaterial.scaleIBLAmbient.y;
|
|
7557
7638
|
|
|
7558
7639
|
return diffuse + specular;
|
|
7559
7640
|
}
|
|
@@ -7645,32 +7726,32 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
7645
7726
|
{
|
|
7646
7727
|
// The albedo may be defined from a base texture or a flat color
|
|
7647
7728
|
#ifdef HAS_BASECOLORMAP
|
|
7648
|
-
vec4 baseColor = SRGBtoLINEAR(
|
|
7729
|
+
vec4 baseColor = SRGBtoLINEAR(texture(pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor;
|
|
7649
7730
|
#else
|
|
7650
|
-
vec4 baseColor =
|
|
7731
|
+
vec4 baseColor = pbrMaterial.baseColorFactor;
|
|
7651
7732
|
#endif
|
|
7652
7733
|
|
|
7653
7734
|
#ifdef ALPHA_CUTOFF
|
|
7654
|
-
if (baseColor.a <
|
|
7735
|
+
if (baseColor.a < pbrMaterial.alphaCutoff) {
|
|
7655
7736
|
discard;
|
|
7656
7737
|
}
|
|
7657
7738
|
#endif
|
|
7658
7739
|
|
|
7659
7740
|
vec3 color = vec3(0, 0, 0);
|
|
7660
7741
|
|
|
7661
|
-
if(
|
|
7742
|
+
if(pbrMaterial.unlit){
|
|
7662
7743
|
color.rgb = baseColor.rgb;
|
|
7663
7744
|
}
|
|
7664
7745
|
else{
|
|
7665
7746
|
// Metallic and Roughness material properties are packed together
|
|
7666
7747
|
// In glTF, these factors can be specified by fixed scalar values
|
|
7667
7748
|
// or from a metallic-roughness map
|
|
7668
|
-
float perceptualRoughness =
|
|
7669
|
-
float metallic =
|
|
7749
|
+
float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
|
|
7750
|
+
float metallic = pbrMaterial.metallicRoughnessValues.x;
|
|
7670
7751
|
#ifdef HAS_METALROUGHNESSMAP
|
|
7671
7752
|
// Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
|
|
7672
7753
|
// This layout intentionally reserves the 'r' channel for (optional) occlusion map data
|
|
7673
|
-
vec4 mrSample =
|
|
7754
|
+
vec4 mrSample = texture(pbr_metallicRoughnessSampler, pbr_vUV);
|
|
7674
7755
|
perceptualRoughness = mrSample.g * perceptualRoughness;
|
|
7675
7756
|
metallic = mrSample.b * metallic;
|
|
7676
7757
|
#endif
|
|
@@ -7697,7 +7778,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
7697
7778
|
vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
|
|
7698
7779
|
|
|
7699
7780
|
vec3 n = getNormal(); // normal at surface point
|
|
7700
|
-
vec3 v = normalize(
|
|
7781
|
+
vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
|
|
7701
7782
|
|
|
7702
7783
|
float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
|
|
7703
7784
|
vec3 reflection = -normalize(reflect(v, n));
|
|
@@ -7719,47 +7800,48 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
7719
7800
|
v
|
|
7720
7801
|
);
|
|
7721
7802
|
|
|
7803
|
+
|
|
7722
7804
|
#ifdef USE_LIGHTS
|
|
7723
7805
|
// Apply ambient light
|
|
7724
7806
|
PBRInfo_setAmbientLight(pbrInfo);
|
|
7725
|
-
color += calculateFinalColor(pbrInfo,
|
|
7807
|
+
color += calculateFinalColor(pbrInfo, lighting.ambientColor);
|
|
7726
7808
|
|
|
7727
7809
|
// Apply directional light
|
|
7728
|
-
for(int i = 0; i <
|
|
7729
|
-
if (i <
|
|
7730
|
-
PBRInfo_setDirectionalLight(pbrInfo,
|
|
7731
|
-
color += calculateFinalColor(pbrInfo,
|
|
7810
|
+
for(int i = 0; i < lighting.directionalLightCount; i++) {
|
|
7811
|
+
if (i < lighting.directionalLightCount) {
|
|
7812
|
+
PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
|
|
7813
|
+
color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
|
|
7732
7814
|
}
|
|
7733
7815
|
}
|
|
7734
7816
|
|
|
7735
7817
|
// Apply point light
|
|
7736
|
-
for(int i = 0; i <
|
|
7737
|
-
if (i <
|
|
7738
|
-
PBRInfo_setPointLight(pbrInfo,
|
|
7739
|
-
float attenuation = getPointLightAttenuation(
|
|
7740
|
-
color += calculateFinalColor(pbrInfo,
|
|
7818
|
+
for(int i = 0; i < lighting.pointLightCount; i++) {
|
|
7819
|
+
if (i < lighting.pointLightCount) {
|
|
7820
|
+
PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
|
|
7821
|
+
float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
|
|
7822
|
+
color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
|
|
7741
7823
|
}
|
|
7742
7824
|
}
|
|
7743
7825
|
#endif
|
|
7744
7826
|
|
|
7745
7827
|
// Calculate lighting contribution from image based lighting source (IBL)
|
|
7746
7828
|
#ifdef USE_IBL
|
|
7747
|
-
if (
|
|
7829
|
+
if (pbrMaterial.IBLenabled) {
|
|
7748
7830
|
color += getIBLContribution(pbrInfo, n, reflection);
|
|
7749
7831
|
}
|
|
7750
7832
|
#endif
|
|
7751
7833
|
|
|
7752
|
-
|
|
7834
|
+
// Apply optional PBR terms for additional (optional) shading
|
|
7753
7835
|
#ifdef HAS_OCCLUSIONMAP
|
|
7754
|
-
if (
|
|
7755
|
-
float ao =
|
|
7756
|
-
color = mix(color, color * ao,
|
|
7836
|
+
if (pbrMaterial.occlusionMapEnabled) {
|
|
7837
|
+
float ao = texture(pbr_occlusionSampler, pbr_vUV).r;
|
|
7838
|
+
color = mix(color, color * ao, pbrMaterial.occlusionStrength);
|
|
7757
7839
|
}
|
|
7758
7840
|
#endif
|
|
7759
7841
|
|
|
7760
7842
|
#ifdef HAS_EMISSIVEMAP
|
|
7761
|
-
if (
|
|
7762
|
-
vec3 emissive = SRGBtoLINEAR(
|
|
7843
|
+
if (pbrMaterial.emissiveMapEnabled) {
|
|
7844
|
+
vec3 emissive = SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
|
|
7763
7845
|
color += emissive;
|
|
7764
7846
|
}
|
|
7765
7847
|
#endif
|
|
@@ -7769,15 +7851,15 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
7769
7851
|
#ifdef PBR_DEBUG
|
|
7770
7852
|
// TODO: Figure out how to debug multiple lights
|
|
7771
7853
|
|
|
7772
|
-
// color = mix(color, F,
|
|
7773
|
-
// color = mix(color, vec3(G),
|
|
7774
|
-
// color = mix(color, vec3(D),
|
|
7775
|
-
// color = mix(color, specContrib,
|
|
7854
|
+
// color = mix(color, F, pbr_scaleFGDSpec.x);
|
|
7855
|
+
// color = mix(color, vec3(G), pbr_scaleFGDSpec.y);
|
|
7856
|
+
// color = mix(color, vec3(D), pbr_scaleFGDSpec.z);
|
|
7857
|
+
// color = mix(color, specContrib, pbr_scaleFGDSpec.w);
|
|
7776
7858
|
|
|
7777
|
-
// color = mix(color, diffuseContrib,
|
|
7778
|
-
color = mix(color, baseColor.rgb,
|
|
7779
|
-
color = mix(color, vec3(metallic),
|
|
7780
|
-
color = mix(color, vec3(perceptualRoughness),
|
|
7859
|
+
// color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);
|
|
7860
|
+
color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
|
|
7861
|
+
color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);
|
|
7862
|
+
color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
|
|
7781
7863
|
#endif
|
|
7782
7864
|
|
|
7783
7865
|
}
|
|
@@ -7787,25 +7869,52 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
7787
7869
|
`
|
|
7788
7870
|
);
|
|
7789
7871
|
|
|
7872
|
+
// src/modules/lighting/pbr-material/pbr-projection.ts
|
|
7873
|
+
var uniformBlock = (
|
|
7874
|
+
/* glsl */
|
|
7875
|
+
`uniform pbrProjectionUniforms {
|
|
7876
|
+
mat4 modelViewProjectionMatrix;
|
|
7877
|
+
mat4 modelMatrix;
|
|
7878
|
+
mat4 normalMatrix;
|
|
7879
|
+
vec3 camera;
|
|
7880
|
+
} pbrProjection;
|
|
7881
|
+
`
|
|
7882
|
+
);
|
|
7883
|
+
var pbrProjection = {
|
|
7884
|
+
name: "pbrProjection",
|
|
7885
|
+
vs: uniformBlock,
|
|
7886
|
+
fs: uniformBlock,
|
|
7887
|
+
// TODO why is this needed?
|
|
7888
|
+
getUniforms: (props) => props,
|
|
7889
|
+
uniformTypes: {
|
|
7890
|
+
modelViewProjectionMatrix: "mat4x4<f32>",
|
|
7891
|
+
modelMatrix: "mat4x4<f32>",
|
|
7892
|
+
normalMatrix: "mat4x4<f32>",
|
|
7893
|
+
camera: "vec3<i32>"
|
|
7894
|
+
}
|
|
7895
|
+
};
|
|
7896
|
+
|
|
7790
7897
|
// src/modules/lighting/pbr-material/pbr-material.ts
|
|
7791
7898
|
var pbrMaterial = {
|
|
7792
7899
|
props: {},
|
|
7793
7900
|
uniforms: {},
|
|
7794
|
-
name: "
|
|
7795
|
-
dependencies: [lighting],
|
|
7901
|
+
name: "pbrMaterial",
|
|
7902
|
+
dependencies: [lighting, pbrProjection],
|
|
7796
7903
|
vs: vs2,
|
|
7797
7904
|
fs: fs3,
|
|
7798
7905
|
defines: {
|
|
7799
|
-
LIGHTING_FRAGMENT: 1
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7906
|
+
LIGHTING_FRAGMENT: 1
|
|
7907
|
+
// TODO defining these as 0 breaks shader
|
|
7908
|
+
// HAS_NORMALMAP: 0
|
|
7909
|
+
// HAS_EMISSIVEMAP: 0,
|
|
7910
|
+
// HAS_OCCLUSIONMAP: 0,
|
|
7911
|
+
// HAS_BASECOLORMAP: 0,
|
|
7912
|
+
// HAS_METALROUGHNESSMAP: 0,
|
|
7913
|
+
// ALPHA_CUTOFF: 0
|
|
7914
|
+
// USE_IBL: 0
|
|
7915
|
+
// PBR_DEBUG: 0
|
|
7808
7916
|
},
|
|
7917
|
+
getUniforms: (props) => props,
|
|
7809
7918
|
uniformTypes: {
|
|
7810
7919
|
// Material is unlit
|
|
7811
7920
|
unlit: "i32",
|
|
@@ -7834,1548 +7943,13 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
7834
7943
|
// #ifdef PBR_DEBUG
|
|
7835
7944
|
scaleDiffBaseMR: "vec4<f32>",
|
|
7836
7945
|
scaleFGDSpec: "vec4<f32>"
|
|
7837
|
-
},
|
|
7838
|
-
bindings: {
|
|
7839
|
-
baseColorSampler: { type: "texture", location: 8 },
|
|
7840
|
-
// #ifdef HAS_BASECOLORMAP
|
|
7841
|
-
normalSampler: { type: "texture", location: 9 },
|
|
7842
|
-
// #ifdef HAS_NORMALMAP
|
|
7843
|
-
emissiveSampler: { type: "texture", location: 10 },
|
|
7844
|
-
// #ifdef HAS_EMISSIVEMAP
|
|
7845
|
-
metallicRoughnessSampler: { type: "texture", location: 11 },
|
|
7846
|
-
// #ifdef HAS_METALROUGHNESSMAP
|
|
7847
|
-
occlusionSampler: { type: "texture", location: 12 },
|
|
7848
|
-
// #ifdef HAS_OCCLUSIONMAP
|
|
7849
|
-
// IBL Samplers
|
|
7850
|
-
diffuseEnvSampler: { type: "texture", location: 13 },
|
|
7851
|
-
// #ifdef USE_IBL (samplerCube)
|
|
7852
|
-
specularEnvSampler: { type: "texture", location: 14 },
|
|
7853
|
-
// #ifdef USE_IBL (samplerCube)
|
|
7854
|
-
brdfLUT: { type: "texture", location: 15 }
|
|
7855
|
-
// #ifdef USE_IBL
|
|
7856
7946
|
}
|
|
7857
7947
|
};
|
|
7858
7948
|
|
|
7859
|
-
// src/modules/
|
|
7860
|
-
var
|
|
7949
|
+
// src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts
|
|
7950
|
+
var fp64arithmeticShader = (
|
|
7861
7951
|
/* glsl */
|
|
7862
|
-
`
|
|
7863
|
-
uniform brightnessContrastUniforms {
|
|
7864
|
-
float brightness;
|
|
7865
|
-
float contrast;
|
|
7866
|
-
} brightnessContrast;
|
|
7867
|
-
|
|
7868
|
-
vec4 brightnessContrast_filterColor(vec4 color) {
|
|
7869
|
-
color.rgb += brightnessContrast.brightness;
|
|
7870
|
-
if (brightnessContrast.contrast > 0.0) {
|
|
7871
|
-
color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;
|
|
7872
|
-
} else {
|
|
7873
|
-
color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;
|
|
7874
|
-
}
|
|
7875
|
-
return color;
|
|
7876
|
-
}
|
|
7877
|
-
|
|
7878
|
-
vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
|
|
7879
|
-
return brightnessContrast_filterColor(color);
|
|
7880
|
-
}
|
|
7881
|
-
`
|
|
7882
|
-
);
|
|
7883
|
-
var brightnessContrast = {
|
|
7884
|
-
props: {},
|
|
7885
|
-
uniforms: {},
|
|
7886
|
-
name: "brightnessContrast",
|
|
7887
|
-
uniformTypes: {
|
|
7888
|
-
brightness: "f32",
|
|
7889
|
-
contrast: "f32"
|
|
7890
|
-
},
|
|
7891
|
-
uniformPropTypes: {
|
|
7892
|
-
brightness: { format: "f32", value: 0, min: -1, max: 1 },
|
|
7893
|
-
contrast: { format: "f32", value: 0, min: -1, max: 1 }
|
|
7894
|
-
},
|
|
7895
|
-
fs: fs4,
|
|
7896
|
-
passes: [{ filter: true }]
|
|
7897
|
-
};
|
|
7898
|
-
|
|
7899
|
-
// src/modules/postprocessing/image-adjust-filters/denoise.ts
|
|
7900
|
-
var fs5 = (
|
|
7901
|
-
/* glsl */
|
|
7902
|
-
`uniform denoiseUniforms {
|
|
7903
|
-
float strength;
|
|
7904
|
-
} noise;
|
|
7905
|
-
|
|
7906
|
-
vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
7907
|
-
float adjustedExponent = 3. + 200. * pow(1. - noise.strength, 4.);
|
|
7908
|
-
|
|
7909
|
-
vec4 center = texture(source, texCoord);
|
|
7910
|
-
vec4 color = vec4(0.0);
|
|
7911
|
-
float total = 0.0;
|
|
7912
|
-
for (float x = -4.0; x <= 4.0; x += 1.0) {
|
|
7913
|
-
for (float y = -4.0; y <= 4.0; y += 1.0) {
|
|
7914
|
-
vec4 offsetColor = texture(source, texCoord + vec2(x, y) / texSize);
|
|
7915
|
-
float weight = 1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3(0.25)));
|
|
7916
|
-
weight = pow(weight, adjustedExponent);
|
|
7917
|
-
color += offsetColor * weight;
|
|
7918
|
-
total += weight;
|
|
7919
|
-
}
|
|
7920
|
-
}
|
|
7921
|
-
|
|
7922
|
-
return color / total;
|
|
7923
|
-
}
|
|
7924
|
-
`
|
|
7925
|
-
);
|
|
7926
|
-
var denoise = {
|
|
7927
|
-
props: {},
|
|
7928
|
-
uniforms: {},
|
|
7929
|
-
name: "denoise",
|
|
7930
|
-
uniformTypes: {
|
|
7931
|
-
strength: "f32"
|
|
7932
|
-
},
|
|
7933
|
-
uniformPropTypes: {
|
|
7934
|
-
strength: { format: "f32", value: 0.5, min: 0, max: 1 }
|
|
7935
|
-
// strength: {..., adjust: (strength: number): number => 0.53 + 200 * Math.pow(1 - strength, 4) // TODO - JS preprocessing
|
|
7936
|
-
},
|
|
7937
|
-
fs: fs5,
|
|
7938
|
-
passes: [{ sampler: true }, { sampler: true }]
|
|
7939
|
-
};
|
|
7940
|
-
|
|
7941
|
-
// src/modules/postprocessing/image-adjust-filters/huesaturation.ts
|
|
7942
|
-
var fs6 = (
|
|
7943
|
-
/* glsl */
|
|
7944
|
-
`uniform hueSaturationUniforms {
|
|
7945
|
-
float hue;
|
|
7946
|
-
float saturation;
|
|
7947
|
-
} hueSaturation;
|
|
7948
|
-
|
|
7949
|
-
vec4 hueSaturation_filterColor(vec4 color) {
|
|
7950
|
-
// hue adjustment, wolfram alpha: RotationTransform[angle, {1, 1, 1}][{x, y, z}]
|
|
7951
|
-
float angle = hueSaturation.hue * 3.14159265;
|
|
7952
|
-
float s = sin(angle), c = cos(angle);
|
|
7953
|
-
vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;
|
|
7954
|
-
float len = length(color.rgb);
|
|
7955
|
-
color.rgb = vec3(
|
|
7956
|
-
dot(color.rgb, weights.xyz),
|
|
7957
|
-
dot(color.rgb, weights.zxy),
|
|
7958
|
-
dot(color.rgb, weights.yzx)
|
|
7959
|
-
);
|
|
7960
|
-
|
|
7961
|
-
// saturation adjustment
|
|
7962
|
-
float average = (color.r + color.g + color.b) / 3.0;
|
|
7963
|
-
if (hueSaturation.saturation > 0.0) {
|
|
7964
|
-
color.rgb += (average - color.rgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));
|
|
7965
|
-
} else {
|
|
7966
|
-
color.rgb += (average - color.rgb) * (-hueSaturation.saturation);
|
|
7967
|
-
}
|
|
7968
|
-
|
|
7969
|
-
return color;
|
|
7970
|
-
}
|
|
7971
|
-
|
|
7972
|
-
vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
7973
|
-
return hueSaturation_filterColor(color);
|
|
7974
|
-
}
|
|
7975
|
-
`
|
|
7976
|
-
);
|
|
7977
|
-
var hueSaturation = {
|
|
7978
|
-
props: {},
|
|
7979
|
-
uniforms: {},
|
|
7980
|
-
name: "hueSaturation",
|
|
7981
|
-
fs: fs6,
|
|
7982
|
-
uniformTypes: {
|
|
7983
|
-
hue: "f32",
|
|
7984
|
-
saturation: "f32"
|
|
7985
|
-
},
|
|
7986
|
-
uniformPropTypes: {
|
|
7987
|
-
hue: { value: 0, min: -1, max: 1 },
|
|
7988
|
-
saturation: { value: 0, min: -1, max: 1 }
|
|
7989
|
-
},
|
|
7990
|
-
passes: [{ filter: true }]
|
|
7991
|
-
};
|
|
7992
|
-
|
|
7993
|
-
// src/modules/postprocessing/image-adjust-filters/noise.ts
|
|
7994
|
-
var fs7 = (
|
|
7995
|
-
/* glsl */
|
|
7996
|
-
`uniform noiseUniforms {
|
|
7997
|
-
float amount;
|
|
7998
|
-
} noise;
|
|
7999
|
-
|
|
8000
|
-
float rand(vec2 co) {
|
|
8001
|
-
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
|
8002
|
-
}
|
|
8003
|
-
|
|
8004
|
-
vec4 noise_filterColor(vec4 color, vec2 texCoord) {
|
|
8005
|
-
float diff = (rand(texCoord) - 0.5) * noise.amount;
|
|
8006
|
-
color.r += diff;
|
|
8007
|
-
color.g += diff;
|
|
8008
|
-
color.b += diff;
|
|
8009
|
-
return color;
|
|
8010
|
-
}
|
|
8011
|
-
|
|
8012
|
-
vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
8013
|
-
return noise_filterColor(color, texCoord);
|
|
8014
|
-
}
|
|
8015
|
-
`
|
|
8016
|
-
);
|
|
8017
|
-
var noise = {
|
|
8018
|
-
props: {},
|
|
8019
|
-
uniforms: {},
|
|
8020
|
-
name: "noise",
|
|
8021
|
-
uniformTypes: {
|
|
8022
|
-
amount: "f32"
|
|
8023
|
-
},
|
|
8024
|
-
uniformPropTypes: {
|
|
8025
|
-
amount: { value: 0.5, min: 0, max: 1 }
|
|
8026
|
-
},
|
|
8027
|
-
fs: fs7,
|
|
8028
|
-
passes: [{ filter: true }]
|
|
8029
|
-
};
|
|
8030
|
-
|
|
8031
|
-
// src/modules/postprocessing/image-adjust-filters/sepia.ts
|
|
8032
|
-
var fs8 = (
|
|
8033
|
-
/* glsl */
|
|
8034
|
-
`uniform sepiaUniforms {
|
|
8035
|
-
float amount;
|
|
8036
|
-
} sepia;
|
|
8037
|
-
|
|
8038
|
-
vec4 sepia_filterColor(vec4 color) {
|
|
8039
|
-
float r = color.r;
|
|
8040
|
-
float g = color.g;
|
|
8041
|
-
float b = color.b;
|
|
8042
|
-
|
|
8043
|
-
color.r =
|
|
8044
|
-
min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));
|
|
8045
|
-
color.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));
|
|
8046
|
-
color.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));
|
|
8047
|
-
|
|
8048
|
-
return color;
|
|
8049
|
-
}
|
|
8050
|
-
|
|
8051
|
-
vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
8052
|
-
return sepia_filterColor(color);
|
|
8053
|
-
}
|
|
8054
|
-
`
|
|
8055
|
-
);
|
|
8056
|
-
var sepia = {
|
|
8057
|
-
props: {},
|
|
8058
|
-
uniforms: {},
|
|
8059
|
-
name: "sepia",
|
|
8060
|
-
uniformTypes: {
|
|
8061
|
-
amount: "f32"
|
|
8062
|
-
},
|
|
8063
|
-
uniformPropTypes: {
|
|
8064
|
-
amount: { value: 0.5, min: 0, max: 1 }
|
|
8065
|
-
},
|
|
8066
|
-
fs: fs8,
|
|
8067
|
-
passes: [{ filter: true }]
|
|
8068
|
-
};
|
|
8069
|
-
|
|
8070
|
-
// src/modules/postprocessing/image-adjust-filters/vibrance.ts
|
|
8071
|
-
var fs9 = (
|
|
8072
|
-
/* glsl */
|
|
8073
|
-
`uniform vibranceUniforms {
|
|
8074
|
-
float amount;
|
|
8075
|
-
} vibrance;
|
|
8076
|
-
|
|
8077
|
-
vec4 vibrance_filterColor(vec4 color) {
|
|
8078
|
-
float average = (color.r + color.g + color.b) / 3.0;
|
|
8079
|
-
float mx = max(color.r, max(color.g, color.b));
|
|
8080
|
-
float amt = (mx - average) * (-vibrance.amount * 3.0);
|
|
8081
|
-
color.rgb = mix(color.rgb, vec3(mx), amt);
|
|
8082
|
-
return color;
|
|
8083
|
-
}
|
|
8084
|
-
|
|
8085
|
-
vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
8086
|
-
return vibrance_filterColor(color);
|
|
8087
|
-
}
|
|
8088
|
-
`
|
|
8089
|
-
);
|
|
8090
|
-
var vibrance = {
|
|
8091
|
-
props: {},
|
|
8092
|
-
uniforms: {},
|
|
8093
|
-
name: "vibrance",
|
|
8094
|
-
uniformPropTypes: {
|
|
8095
|
-
amount: { value: 0, min: -1, max: 1 }
|
|
8096
|
-
},
|
|
8097
|
-
fs: fs9,
|
|
8098
|
-
passes: [{ filter: true }]
|
|
8099
|
-
};
|
|
8100
|
-
|
|
8101
|
-
// src/modules/postprocessing/image-adjust-filters/vignette.ts
|
|
8102
|
-
var fs10 = (
|
|
8103
|
-
/* glsl */
|
|
8104
|
-
`uniform vignetteUniforms {
|
|
8105
|
-
float radius;
|
|
8106
|
-
float amount;
|
|
8107
|
-
} vignette;
|
|
8108
|
-
|
|
8109
|
-
vec4 vignette_filterColor(vec4 color, vec2 texCoord) {
|
|
8110
|
-
float dist = distance(texCoord, vec2(0.5, 0.5));
|
|
8111
|
-
float ratio = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
|
|
8112
|
-
return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);
|
|
8113
|
-
}
|
|
8114
|
-
|
|
8115
|
-
vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
8116
|
-
return vignette_filterColor(color, texCoord);
|
|
8117
|
-
}
|
|
8118
|
-
`
|
|
8119
|
-
);
|
|
8120
|
-
var vignette = {
|
|
8121
|
-
props: {},
|
|
8122
|
-
uniforms: {},
|
|
8123
|
-
name: "vignette",
|
|
8124
|
-
uniformTypes: {
|
|
8125
|
-
radius: "f32",
|
|
8126
|
-
amount: "f32"
|
|
8127
|
-
},
|
|
8128
|
-
uniformPropTypes: {
|
|
8129
|
-
radius: { value: 0.5, min: 0, max: 1 },
|
|
8130
|
-
amount: { value: 0.5, min: 0, max: 1 }
|
|
8131
|
-
},
|
|
8132
|
-
passes: [{ filter: true }],
|
|
8133
|
-
fs: fs10
|
|
8134
|
-
};
|
|
8135
|
-
|
|
8136
|
-
// src/modules/postprocessing/image-blur-filters/tiltshift.ts
|
|
8137
|
-
var fs11 = (
|
|
8138
|
-
/* glsl */
|
|
8139
|
-
`uniform tiltShiftUniforms {
|
|
8140
|
-
float blurRadius;
|
|
8141
|
-
float gradientRadius;
|
|
8142
|
-
vec2 start;
|
|
8143
|
-
vec2 end;
|
|
8144
|
-
bool invert;
|
|
8145
|
-
} tiltShift;
|
|
8146
|
-
|
|
8147
|
-
vec2 tiltShift_getDelta(vec2 texSize) {
|
|
8148
|
-
vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);
|
|
8149
|
-
return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;
|
|
8150
|
-
}
|
|
8151
|
-
|
|
8152
|
-
vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
8153
|
-
vec4 color = vec4(0.0);
|
|
8154
|
-
float total = 0.0;
|
|
8155
|
-
|
|
8156
|
-
/* randomize the lookup values to hide the fixed number of samples */
|
|
8157
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
8158
|
-
|
|
8159
|
-
vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));
|
|
8160
|
-
float radius = smoothstep(0.0, 1.0,
|
|
8161
|
-
abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;
|
|
8162
|
-
|
|
8163
|
-
for (float t = -30.0; t <= 30.0; t++) {
|
|
8164
|
-
float percent = (t + offset - 0.5) / 30.0;
|
|
8165
|
-
float weight = 1.0 - abs(percent);
|
|
8166
|
-
vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
|
|
8167
|
-
|
|
8168
|
-
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
8169
|
-
offsetColor.rgb *= offsetColor.a;
|
|
8170
|
-
|
|
8171
|
-
color += offsetColor * weight;
|
|
8172
|
-
total += weight;
|
|
8173
|
-
}
|
|
8174
|
-
|
|
8175
|
-
color = color / total;
|
|
8176
|
-
|
|
8177
|
-
/* switch back from pre-multiplied alpha */
|
|
8178
|
-
color.rgb /= color.a + 0.00001;
|
|
8179
|
-
|
|
8180
|
-
return color;
|
|
8181
|
-
}
|
|
8182
|
-
`
|
|
8183
|
-
);
|
|
8184
|
-
var tiltShift = {
|
|
8185
|
-
props: {},
|
|
8186
|
-
uniforms: {},
|
|
8187
|
-
name: "tiltShift",
|
|
8188
|
-
dependencies: [random],
|
|
8189
|
-
uniformTypes: {
|
|
8190
|
-
blurRadius: "f32",
|
|
8191
|
-
gradientRadius: "f32",
|
|
8192
|
-
start: "vec2<f32>",
|
|
8193
|
-
end: "vec2<f32>",
|
|
8194
|
-
invert: "i32"
|
|
8195
|
-
},
|
|
8196
|
-
uniformPropTypes: {
|
|
8197
|
-
blurRadius: { value: 15, min: 0, max: 50 },
|
|
8198
|
-
gradientRadius: { value: 200, min: 0, max: 400 },
|
|
8199
|
-
start: { value: [0, 0] },
|
|
8200
|
-
end: { value: [1, 1] },
|
|
8201
|
-
invert: { value: false, private: true }
|
|
8202
|
-
},
|
|
8203
|
-
passes: [
|
|
8204
|
-
{ sampler: true, uniforms: { invert: false } },
|
|
8205
|
-
{ sampler: true, uniforms: { invert: true } }
|
|
8206
|
-
],
|
|
8207
|
-
fs: fs11
|
|
8208
|
-
};
|
|
8209
|
-
|
|
8210
|
-
// src/modules/postprocessing/image-blur-filters/triangleblur.ts
|
|
8211
|
-
var fs12 = (
|
|
8212
|
-
/* glsl */
|
|
8213
|
-
`uniform triangleBlurUniforms {
|
|
8214
|
-
float radius;
|
|
8215
|
-
vec2 delta;
|
|
8216
|
-
} triangleBlur;
|
|
8217
|
-
|
|
8218
|
-
vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
8219
|
-
vec2 adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
|
|
8220
|
-
|
|
8221
|
-
vec4 color = vec4(0.0);
|
|
8222
|
-
float total = 0.0;
|
|
8223
|
-
|
|
8224
|
-
/* randomize the lookup values to hide the fixed number of samples */
|
|
8225
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
8226
|
-
|
|
8227
|
-
for (float t = -30.0; t <= 30.0; t++) {
|
|
8228
|
-
float percent = (t + offset - 0.5) / 30.0;
|
|
8229
|
-
float weight = 1.0 - abs(percent);
|
|
8230
|
-
vec4 offsetColor = texture(source, texCoord + adjustedDelta * percent);
|
|
8231
|
-
|
|
8232
|
-
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
8233
|
-
offsetColor.rgb *= offsetColor.a;
|
|
8234
|
-
|
|
8235
|
-
color += offsetColor * weight;
|
|
8236
|
-
total += weight;
|
|
8237
|
-
}
|
|
8238
|
-
|
|
8239
|
-
color = color / total;
|
|
8240
|
-
|
|
8241
|
-
/* switch back from pre-multiplied alpha */
|
|
8242
|
-
color.rgb /= color.a + 0.00001;
|
|
8243
|
-
|
|
8244
|
-
return color;
|
|
8245
|
-
}
|
|
8246
|
-
`
|
|
8247
|
-
);
|
|
8248
|
-
var triangleBlur = {
|
|
8249
|
-
props: {},
|
|
8250
|
-
uniforms: {},
|
|
8251
|
-
name: "triangleBlur",
|
|
8252
|
-
uniformTypes: {
|
|
8253
|
-
radius: "f32",
|
|
8254
|
-
delta: "vec2<f32>"
|
|
8255
|
-
},
|
|
8256
|
-
uniformPropTypes: {
|
|
8257
|
-
radius: { value: 20, min: 0, softMax: 100 },
|
|
8258
|
-
delta: { value: [1, 0], private: true }
|
|
8259
|
-
},
|
|
8260
|
-
fs: fs12,
|
|
8261
|
-
dependencies: [random],
|
|
8262
|
-
passes: [
|
|
8263
|
-
{ sampler: true, uniforms: { delta: [1, 0] } },
|
|
8264
|
-
{ sampler: true, uniforms: { delta: [0, 1] } }
|
|
8265
|
-
]
|
|
8266
|
-
};
|
|
8267
|
-
|
|
8268
|
-
// src/modules/postprocessing/image-blur-filters/zoomblur.ts
|
|
8269
|
-
var fs13 = `
|
|
8270
|
-
uniform zoomBlurUniforms {
|
|
8271
|
-
vec2 center;
|
|
8272
|
-
float strength;
|
|
8273
|
-
} zoomBlur;
|
|
8274
|
-
|
|
8275
|
-
vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
8276
|
-
vec4 color = vec4(0.0);
|
|
8277
|
-
float total = 0.0;
|
|
8278
|
-
vec2 toCenter = zoomBlur.center * texSize - texCoord * texSize;
|
|
8279
|
-
|
|
8280
|
-
/* randomize the lookup values to hide the fixed number of samples */
|
|
8281
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
8282
|
-
|
|
8283
|
-
for (float t = 0.0; t <= 40.0; t++) {
|
|
8284
|
-
float percent = (t + offset) / 40.0;
|
|
8285
|
-
float weight = 4.0 * (percent - percent * percent);
|
|
8286
|
-
vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);
|
|
8287
|
-
|
|
8288
|
-
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
8289
|
-
offsetColor.rgb *= offsetColor.a;
|
|
8290
|
-
|
|
8291
|
-
color += offsetColor * weight;
|
|
8292
|
-
total += weight;
|
|
8293
|
-
}
|
|
8294
|
-
|
|
8295
|
-
color = color / total;
|
|
8296
|
-
|
|
8297
|
-
/* switch back from pre-multiplied alpha */
|
|
8298
|
-
color.rgb /= color.a + 0.00001;
|
|
8299
|
-
|
|
8300
|
-
return color;
|
|
8301
|
-
}
|
|
8302
|
-
`;
|
|
8303
|
-
var zoomBlur = {
|
|
8304
|
-
props: {},
|
|
8305
|
-
uniforms: {},
|
|
8306
|
-
name: "zoomBlur",
|
|
8307
|
-
uniformTypes: {
|
|
8308
|
-
center: "vec2<f32>",
|
|
8309
|
-
strength: "f32"
|
|
8310
|
-
},
|
|
8311
|
-
uniformPropTypes: {
|
|
8312
|
-
center: { value: [0.5, 0.5] },
|
|
8313
|
-
strength: { value: 0.3, min: 0, softMax: 1 }
|
|
8314
|
-
},
|
|
8315
|
-
fs: fs13,
|
|
8316
|
-
dependencies: [random],
|
|
8317
|
-
passes: [{ sampler: true }]
|
|
8318
|
-
};
|
|
8319
|
-
|
|
8320
|
-
// src/modules/postprocessing/image-fun-filters/colorhalftone.ts
|
|
8321
|
-
var fs14 = (
|
|
8322
|
-
/* glsl */
|
|
8323
|
-
`uniform colorHalftoneUniforms {
|
|
8324
|
-
vec2 center;
|
|
8325
|
-
float angle;
|
|
8326
|
-
float size;
|
|
8327
|
-
} colorHalftone;
|
|
8328
|
-
|
|
8329
|
-
float pattern(float angle, float scale, vec2 texSize, vec2 texCoord) {
|
|
8330
|
-
float s = sin(angle), c = cos(angle);
|
|
8331
|
-
vec2 tex = texCoord * texSize - colorHalftone.center * texSize;
|
|
8332
|
-
vec2 point = vec2(
|
|
8333
|
-
c * tex.x - s * tex.y,
|
|
8334
|
-
s * tex.x + c * tex.y
|
|
8335
|
-
) * scale;
|
|
8336
|
-
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
8337
|
-
}
|
|
8338
|
-
|
|
8339
|
-
vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
8340
|
-
float scale = 3.1514 / colorHalftone.size;
|
|
8341
|
-
vec3 cmy = 1.0 - color.rgb;
|
|
8342
|
-
float k = min(cmy.x, min(cmy.y, cmy.z));
|
|
8343
|
-
|
|
8344
|
-
cmy = (cmy - k) / (1.0 - k);
|
|
8345
|
-
cmy = clamp(
|
|
8346
|
-
cmy * 10.0 - 3.0 + vec3(
|
|
8347
|
-
pattern(colorHalftone.angle + 0.26179, scale, texSize, texCoord),
|
|
8348
|
-
pattern(colorHalftone.angle + 1.30899, scale, texSize, texCoord),
|
|
8349
|
-
pattern(colorHalftone.angle, scale, texSize, texCoord)
|
|
8350
|
-
),
|
|
8351
|
-
0.0,
|
|
8352
|
-
1.0
|
|
8353
|
-
);
|
|
8354
|
-
k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
|
|
8355
|
-
return vec4(1.0 - cmy - k, color.a);
|
|
8356
|
-
}
|
|
8357
|
-
`
|
|
8358
|
-
);
|
|
8359
|
-
var colorHalftone = {
|
|
8360
|
-
props: {},
|
|
8361
|
-
uniforms: {},
|
|
8362
|
-
name: "colorHalftone",
|
|
8363
|
-
uniformTypes: {
|
|
8364
|
-
center: "vec2<f32>",
|
|
8365
|
-
angle: "f32",
|
|
8366
|
-
size: "f32"
|
|
8367
|
-
},
|
|
8368
|
-
uniformPropTypes: {
|
|
8369
|
-
center: { value: [0.5, 0.5] },
|
|
8370
|
-
angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
|
|
8371
|
-
size: { value: 4, min: 1, softMin: 3, softMax: 20 }
|
|
8372
|
-
},
|
|
8373
|
-
fs: fs14,
|
|
8374
|
-
passes: [{ filter: true }]
|
|
8375
|
-
};
|
|
8376
|
-
|
|
8377
|
-
// src/modules/postprocessing/image-fun-filters/dotscreen.ts
|
|
8378
|
-
var fs15 = (
|
|
8379
|
-
/* glsl */
|
|
8380
|
-
`uniform dotScreenUniforms {
|
|
8381
|
-
vec2 center;
|
|
8382
|
-
float angle;
|
|
8383
|
-
float size;
|
|
8384
|
-
} dotScreen;
|
|
8385
|
-
|
|
8386
|
-
float pattern(vec2 texSize, vec2 texCoord) {
|
|
8387
|
-
float scale = 3.1415 / dotScreen.size;
|
|
8388
|
-
|
|
8389
|
-
float s = sin(dotScreen.angle), c = cos(dotScreen.angle);
|
|
8390
|
-
vec2 tex = texCoord * texSize - dotScreen.center * texSize;
|
|
8391
|
-
vec2 point = vec2(
|
|
8392
|
-
c * tex.x - s * tex.y,
|
|
8393
|
-
s * tex.x + c * tex.y
|
|
8394
|
-
) * scale;
|
|
8395
|
-
return (sin(point.x) * sin(point.y)) * 4.0;
|
|
8396
|
-
}
|
|
8397
|
-
|
|
8398
|
-
vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
8399
|
-
float average = (color.r + color.g + color.b) / 3.0;
|
|
8400
|
-
return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
|
|
8401
|
-
}
|
|
8402
|
-
`
|
|
8403
|
-
);
|
|
8404
|
-
var dotScreen = {
|
|
8405
|
-
props: {},
|
|
8406
|
-
uniforms: {},
|
|
8407
|
-
name: "dotScreen",
|
|
8408
|
-
uniformTypes: {
|
|
8409
|
-
center: "vec2<f32>",
|
|
8410
|
-
angle: "f32",
|
|
8411
|
-
size: "f32"
|
|
8412
|
-
},
|
|
8413
|
-
uniformPropTypes: {
|
|
8414
|
-
center: { value: [0.5, 0.5] },
|
|
8415
|
-
angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
|
|
8416
|
-
size: { value: 3, min: 1, softMin: 3, softMax: 20 }
|
|
8417
|
-
},
|
|
8418
|
-
fs: fs15,
|
|
8419
|
-
passes: [{ filter: true }]
|
|
8420
|
-
};
|
|
8421
|
-
|
|
8422
|
-
// src/modules/postprocessing/image-fun-filters/edgework.ts
|
|
8423
|
-
var fs16 = (
|
|
8424
|
-
/* glsl */
|
|
8425
|
-
`uniform edgeWorkUniforms {
|
|
8426
|
-
float radius;
|
|
8427
|
-
vec2 delta;
|
|
8428
|
-
} edgeWork;
|
|
8429
|
-
|
|
8430
|
-
vec4 edgeWork_sampleColor1(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
8431
|
-
vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;
|
|
8432
|
-
|
|
8433
|
-
vec2 color = vec2(0.0);
|
|
8434
|
-
vec2 total = vec2(0.0);
|
|
8435
|
-
|
|
8436
|
-
/* randomize the lookup values to hide the fixed number of samples */
|
|
8437
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
8438
|
-
|
|
8439
|
-
for (float t = -30.0; t <= 30.0; t++) {
|
|
8440
|
-
float percent = (t + offset - 0.5) / 30.0;
|
|
8441
|
-
float weight = 1.0 - abs(percent);
|
|
8442
|
-
vec3 sampleColor = texture(source, texCoord + relativeDelta * percent).rgb;
|
|
8443
|
-
float average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;
|
|
8444
|
-
color.x += average * weight;
|
|
8445
|
-
total.x += weight;
|
|
8446
|
-
if (abs(t) < 15.0) {
|
|
8447
|
-
weight = weight * 2.0 - 1.0;
|
|
8448
|
-
color.y += average * weight;
|
|
8449
|
-
total.y += weight;
|
|
8450
|
-
}
|
|
8451
|
-
}
|
|
8452
|
-
return vec4(color / total, 0.0, 1.0);
|
|
8453
|
-
}
|
|
8454
|
-
|
|
8455
|
-
vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
8456
|
-
vec2 relativeDelta = edgeWork.radius * edgeWork.delta / texSize;
|
|
8457
|
-
|
|
8458
|
-
vec2 color = vec2(0.0);
|
|
8459
|
-
vec2 total = vec2(0.0);
|
|
8460
|
-
|
|
8461
|
-
/* randomize the lookup values to hide the fixed number of samples */
|
|
8462
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
8463
|
-
|
|
8464
|
-
for (float t = -30.0; t <= 30.0; t++) {
|
|
8465
|
-
float percent = (t + offset - 0.5) / 30.0;
|
|
8466
|
-
float weight = 1.0 - abs(percent);
|
|
8467
|
-
vec2 sampleColor = texture(source, texCoord + relativeDelta * percent).xy;
|
|
8468
|
-
color.x += sampleColor.x * weight;
|
|
8469
|
-
total.x += weight;
|
|
8470
|
-
if (abs(t) < 15.0) {
|
|
8471
|
-
weight = weight * 2.0 - 1.0;
|
|
8472
|
-
color.y += sampleColor.y * weight;
|
|
8473
|
-
total.y += weight;
|
|
8474
|
-
}
|
|
8475
|
-
}
|
|
8476
|
-
float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
|
|
8477
|
-
return vec4(c, c, c, 1.0);
|
|
8478
|
-
}
|
|
8479
|
-
`
|
|
8480
|
-
);
|
|
8481
|
-
var edgeWork = {
|
|
8482
|
-
props: {},
|
|
8483
|
-
uniforms: {},
|
|
8484
|
-
name: "edgeWork",
|
|
8485
|
-
dependencies: [random],
|
|
8486
|
-
fs: fs16,
|
|
8487
|
-
uniformPropTypes: {
|
|
8488
|
-
radius: { value: 2, min: 1, softMax: 50 },
|
|
8489
|
-
delta: { value: [1, 0], private: true }
|
|
8490
|
-
},
|
|
8491
|
-
passes: [
|
|
8492
|
-
{
|
|
8493
|
-
// @ts-expect-error
|
|
8494
|
-
sampler: "edgeWork_sampleColor1",
|
|
8495
|
-
uniformPropTypes: { delta: [1, 0] }
|
|
8496
|
-
},
|
|
8497
|
-
{
|
|
8498
|
-
// @ts-expect-error
|
|
8499
|
-
sampler: "edgeWork_sampleColor2",
|
|
8500
|
-
uniformPropTypes: { delta: [0, 1] }
|
|
8501
|
-
}
|
|
8502
|
-
]
|
|
8503
|
-
};
|
|
8504
|
-
|
|
8505
|
-
// src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts
|
|
8506
|
-
var fs17 = (
|
|
8507
|
-
/* glsl */
|
|
8508
|
-
`uniform hexagonalPixelateUniforms {
|
|
8509
|
-
vec2 center;
|
|
8510
|
-
float scale;
|
|
8511
|
-
} hexagonalPixelate;
|
|
8512
|
-
|
|
8513
|
-
vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
8514
|
-
vec2 tex = (texCoord * texSize - hexagonalPixelate.center * texSize) / hexagonalPixelate.scale;
|
|
8515
|
-
tex.y /= 0.866025404;
|
|
8516
|
-
tex.x -= tex.y * 0.5;
|
|
8517
|
-
|
|
8518
|
-
vec2 a;
|
|
8519
|
-
if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {
|
|
8520
|
-
a = vec2(floor(tex.x), floor(tex.y));
|
|
8521
|
-
}
|
|
8522
|
-
else a = vec2(ceil(tex.x), ceil(tex.y));
|
|
8523
|
-
vec2 b = vec2(ceil(tex.x), floor(tex.y));
|
|
8524
|
-
vec2 c = vec2(floor(tex.x), ceil(tex.y));
|
|
8525
|
-
|
|
8526
|
-
vec3 TEX = vec3(tex.x, tex.y, 1.0 - tex.x - tex.y);
|
|
8527
|
-
vec3 A = vec3(a.x, a.y, 1.0 - a.x - a.y);
|
|
8528
|
-
vec3 B = vec3(b.x, b.y, 1.0 - b.x - b.y);
|
|
8529
|
-
vec3 C = vec3(c.x, c.y, 1.0 - c.x - c.y);
|
|
8530
|
-
|
|
8531
|
-
float alen = length(TEX - A);
|
|
8532
|
-
float blen = length(TEX - B);
|
|
8533
|
-
float clen = length(TEX - C);
|
|
8534
|
-
|
|
8535
|
-
vec2 choice;
|
|
8536
|
-
if (alen < blen) {
|
|
8537
|
-
if (alen < clen) choice = a;
|
|
8538
|
-
else choice = c;
|
|
8539
|
-
} else {
|
|
8540
|
-
if (blen < clen) choice = b;
|
|
8541
|
-
else choice = c;
|
|
8542
|
-
}
|
|
8543
|
-
|
|
8544
|
-
choice.x += choice.y * 0.5;
|
|
8545
|
-
choice.y *= 0.866025404;
|
|
8546
|
-
choice *= hexagonalPixelate.scale / texSize;
|
|
8547
|
-
|
|
8548
|
-
return texture(source, choice + hexagonalPixelate.center);
|
|
8549
|
-
}
|
|
8550
|
-
`
|
|
8551
|
-
);
|
|
8552
|
-
var hexagonalPixelate = {
|
|
8553
|
-
props: {},
|
|
8554
|
-
uniforms: {},
|
|
8555
|
-
name: "hexagonalPixelate",
|
|
8556
|
-
uniformTypes: {
|
|
8557
|
-
center: "vec2<f32>",
|
|
8558
|
-
scale: "f32"
|
|
8559
|
-
},
|
|
8560
|
-
uniformPropTypes: {
|
|
8561
|
-
center: { value: [0.5, 0.5], hint: "screenspace" },
|
|
8562
|
-
scale: { value: 10, min: 1, softMin: 5, softMax: 50 }
|
|
8563
|
-
},
|
|
8564
|
-
fs: fs17,
|
|
8565
|
-
passes: [{ sampler: true }]
|
|
8566
|
-
};
|
|
8567
|
-
|
|
8568
|
-
// src/modules/postprocessing/image-fun-filters/ink.ts
|
|
8569
|
-
var fs18 = (
|
|
8570
|
-
/* glsl */
|
|
8571
|
-
`uniform inkUniforms {
|
|
8572
|
-
float strength;
|
|
8573
|
-
} ink;
|
|
8574
|
-
|
|
8575
|
-
vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
8576
|
-
vec2 dx = vec2(1.0 / texSize.x, 0.0);
|
|
8577
|
-
vec2 dy = vec2(0.0, 1.0 / texSize.y);
|
|
8578
|
-
vec4 color = texture(source, texCoord);
|
|
8579
|
-
float bigTotal = 0.0;
|
|
8580
|
-
float smallTotal = 0.0;
|
|
8581
|
-
vec3 bigAverage = vec3(0.0);
|
|
8582
|
-
vec3 smallAverage = vec3(0.0);
|
|
8583
|
-
for (float x = -2.0; x <= 2.0; x += 1.0) {
|
|
8584
|
-
for (float y = -2.0; y <= 2.0; y += 1.0) {
|
|
8585
|
-
vec3 offsetColor = texture(source, texCoord + dx * x + dy * y).rgb;
|
|
8586
|
-
bigAverage += offsetColor;
|
|
8587
|
-
bigTotal += 1.0;
|
|
8588
|
-
if (abs(x) + abs(y) < 2.0) {
|
|
8589
|
-
smallAverage += offsetColor;
|
|
8590
|
-
smallTotal += 1.0;
|
|
8591
|
-
}
|
|
8592
|
-
}
|
|
8593
|
-
}
|
|
8594
|
-
vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
|
|
8595
|
-
float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
|
|
8596
|
-
return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
|
|
8597
|
-
}
|
|
8598
|
-
`
|
|
8599
|
-
);
|
|
8600
|
-
var ink = {
|
|
8601
|
-
props: {},
|
|
8602
|
-
uniforms: {},
|
|
8603
|
-
name: "ink",
|
|
8604
|
-
fs: fs18,
|
|
8605
|
-
uniformTypes: {
|
|
8606
|
-
strength: "f32"
|
|
8607
|
-
},
|
|
8608
|
-
uniformPropTypes: {
|
|
8609
|
-
strength: { value: 0.25, min: 0, softMax: 1 }
|
|
8610
|
-
},
|
|
8611
|
-
passes: [{ sampler: true }]
|
|
8612
|
-
};
|
|
8613
|
-
|
|
8614
|
-
// src/modules/postprocessing/image-fun-filters/magnify.ts
|
|
8615
|
-
var fs19 = (
|
|
8616
|
-
/* glsl */
|
|
8617
|
-
`uniform magnifyUniforms {
|
|
8618
|
-
vec2 screenXY;
|
|
8619
|
-
float radiusPixels;
|
|
8620
|
-
float zoom;
|
|
8621
|
-
float borderWidthPixels;
|
|
8622
|
-
vec4 borderColor;
|
|
8623
|
-
} magnify;
|
|
8624
|
-
|
|
8625
|
-
vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
8626
|
-
vec2 pos = vec2(magnify.screenXY.x, 1.0 - magnify.screenXY.y);
|
|
8627
|
-
float dist = distance(texCoord * texSize, pos * texSize);
|
|
8628
|
-
if (dist < magnify.radiusPixels) {
|
|
8629
|
-
return texture(source, (texCoord - pos) / magnify.zoom + pos);
|
|
8630
|
-
}
|
|
8631
|
-
|
|
8632
|
-
if (dist <= magnify.radiusPixels + magnify.borderWidthPixels) {
|
|
8633
|
-
return magnify.borderColor;
|
|
8634
|
-
}
|
|
8635
|
-
return texture(source, texCoord);
|
|
8636
|
-
}
|
|
8637
|
-
`
|
|
8638
|
-
);
|
|
8639
|
-
var magnify = {
|
|
8640
|
-
name: "magnify",
|
|
8641
|
-
uniformTypes: {
|
|
8642
|
-
screenXY: "vec2<f32>",
|
|
8643
|
-
radiusPixels: "f32",
|
|
8644
|
-
zoom: "f32",
|
|
8645
|
-
borderWidthPixels: "f32",
|
|
8646
|
-
borderColor: "vec4<f32>"
|
|
8647
|
-
},
|
|
8648
|
-
uniformPropTypes: {
|
|
8649
|
-
// range 0 to 1
|
|
8650
|
-
screenXY: { value: [0, 0] },
|
|
8651
|
-
radiusPixels: 200,
|
|
8652
|
-
zoom: 2,
|
|
8653
|
-
borderWidthPixels: 0,
|
|
8654
|
-
borderColor: { value: [255, 255, 255, 255] }
|
|
8655
|
-
},
|
|
8656
|
-
fs: fs19,
|
|
8657
|
-
passes: [{ sampler: true }]
|
|
8658
|
-
};
|
|
8659
|
-
|
|
8660
|
-
// src/modules/postprocessing/image-warp-filters/warp.ts
|
|
8661
|
-
var fs20 = (
|
|
8662
|
-
/* glsl */
|
|
8663
|
-
`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
|
|
8664
|
-
vec4 color = texture(source, coord / texSize);
|
|
8665
|
-
vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
|
|
8666
|
-
if (coord != clampedCoord) {
|
|
8667
|
-
/* fade to transparent if we are outside the image */
|
|
8668
|
-
color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
|
|
8669
|
-
}
|
|
8670
|
-
|
|
8671
|
-
return color;
|
|
8672
|
-
}
|
|
8673
|
-
`
|
|
8674
|
-
);
|
|
8675
|
-
var warp = {
|
|
8676
|
-
name: "warp",
|
|
8677
|
-
passes: [],
|
|
8678
|
-
fs: fs20
|
|
8679
|
-
};
|
|
8680
|
-
|
|
8681
|
-
// src/modules/postprocessing/image-warp-filters/bulgepinch.ts
|
|
8682
|
-
var fs21 = (
|
|
8683
|
-
/* glsl */
|
|
8684
|
-
`uniform bulgePinchUniforms {
|
|
8685
|
-
float radius;
|
|
8686
|
-
float strength;
|
|
8687
|
-
vec2 center;
|
|
8688
|
-
} bulgePinch;
|
|
8689
|
-
|
|
8690
|
-
vec2 bulgePinch_warp(vec2 coord, vec2 texCenter) {
|
|
8691
|
-
coord -= texCenter;
|
|
8692
|
-
float distance = length(coord);
|
|
8693
|
-
if (distance < bulgePinch.radius) {
|
|
8694
|
-
float percent = distance / bulgePinch.radius;
|
|
8695
|
-
if (bulgePinch.strength > 0.0) {
|
|
8696
|
-
coord *= mix(1.0, smoothstep(0.0, bulgePinch.radius / distance, percent), bulgePinch.strength * 0.75);
|
|
8697
|
-
} else {
|
|
8698
|
-
coord *= mix(1.0, pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / distance, 1.0 - percent);
|
|
8699
|
-
}
|
|
8700
|
-
}
|
|
8701
|
-
coord += texCenter;
|
|
8702
|
-
return coord;
|
|
8703
|
-
}
|
|
8704
|
-
|
|
8705
|
-
vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
8706
|
-
vec2 coord = texCoord * texSize;
|
|
8707
|
-
coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
|
|
8708
|
-
|
|
8709
|
-
return warp_sampleColor(source, texSize, coord);
|
|
8710
|
-
}
|
|
8711
|
-
`
|
|
8712
|
-
);
|
|
8713
|
-
var bulgePinch = {
|
|
8714
|
-
props: {},
|
|
8715
|
-
uniforms: {},
|
|
8716
|
-
name: "bulgePinch",
|
|
8717
|
-
dependencies: [warp],
|
|
8718
|
-
fs: fs21,
|
|
8719
|
-
uniformTypes: {
|
|
8720
|
-
center: "vec2<f32>",
|
|
8721
|
-
radius: "f32",
|
|
8722
|
-
strength: "f32"
|
|
8723
|
-
},
|
|
8724
|
-
uniformPropTypes: {
|
|
8725
|
-
center: { value: [0.5, 0.5] },
|
|
8726
|
-
radius: { value: 200, min: 1, softMax: 600 },
|
|
8727
|
-
strength: { value: 0.5, min: -1, max: 1 }
|
|
8728
|
-
},
|
|
8729
|
-
passes: [{ sampler: true }]
|
|
8730
|
-
};
|
|
8731
|
-
|
|
8732
|
-
// src/modules/postprocessing/image-warp-filters/swirl.ts
|
|
8733
|
-
var fs22 = (
|
|
8734
|
-
/* glsl */
|
|
8735
|
-
`uniform swirlUniforms {
|
|
8736
|
-
float radius;
|
|
8737
|
-
float angle;
|
|
8738
|
-
vec2 center;
|
|
8739
|
-
} swirl;
|
|
8740
|
-
|
|
8741
|
-
vec2 swirl_warp(vec2 coord, vec2 texCenter) {
|
|
8742
|
-
coord -= texCenter;
|
|
8743
|
-
float distance = length(coord);
|
|
8744
|
-
if (distance < swirl.radius) {
|
|
8745
|
-
float percent = (swirl.radius - distance) / swirl.radius;
|
|
8746
|
-
float theta = percent * percent * swirl.angle;
|
|
8747
|
-
float s = sin(theta);
|
|
8748
|
-
float c = cos(theta);
|
|
8749
|
-
coord = vec2(
|
|
8750
|
-
coord.x * c - coord.y * s,
|
|
8751
|
-
coord.x * s + coord.y * c
|
|
8752
|
-
);
|
|
8753
|
-
}
|
|
8754
|
-
coord += texCenter;
|
|
8755
|
-
return coord;
|
|
8756
|
-
}
|
|
8757
|
-
|
|
8758
|
-
vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
8759
|
-
vec2 coord = texCoord * texSize;
|
|
8760
|
-
coord = swirl_warp(coord, swirl.center * texSize);
|
|
8761
|
-
|
|
8762
|
-
return warp_sampleColor(source, texSize, coord);
|
|
8763
|
-
}
|
|
8764
|
-
`
|
|
8765
|
-
);
|
|
8766
|
-
var swirl = {
|
|
8767
|
-
props: {},
|
|
8768
|
-
uniforms: {},
|
|
8769
|
-
name: "swirl",
|
|
8770
|
-
dependencies: [warp],
|
|
8771
|
-
fs: fs22,
|
|
8772
|
-
uniformTypes: {
|
|
8773
|
-
center: "vec2<f32>",
|
|
8774
|
-
radius: "f32",
|
|
8775
|
-
angle: "f32"
|
|
8776
|
-
},
|
|
8777
|
-
uniformPropTypes: {
|
|
8778
|
-
center: { value: [0.5, 0.5] },
|
|
8779
|
-
radius: { value: 200, min: 1, softMax: 600 },
|
|
8780
|
-
angle: { value: 3, softMin: -25, softMax: 25 }
|
|
8781
|
-
},
|
|
8782
|
-
passes: [{ sampler: true }]
|
|
8783
|
-
};
|
|
8784
|
-
|
|
8785
|
-
// src/modules/postprocessing/fxaa/fxaa.ts
|
|
8786
|
-
var fs23 = `
|
|
8787
|
-
#define FXAA_QUALITY_PRESET 29
|
|
8788
|
-
|
|
8789
|
-
#if (FXAA_QUALITY_PRESET == 10)
|
|
8790
|
-
#define FXAA_QUALITY_PS 3
|
|
8791
|
-
#define FXAA_QUALITY_P0 1.5
|
|
8792
|
-
#define FXAA_QUALITY_P1 3.0
|
|
8793
|
-
#define FXAA_QUALITY_P2 12.0
|
|
8794
|
-
#endif
|
|
8795
|
-
#if (FXAA_QUALITY_PRESET == 11)
|
|
8796
|
-
#define FXAA_QUALITY_PS 4
|
|
8797
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8798
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8799
|
-
#define FXAA_QUALITY_P2 3.0
|
|
8800
|
-
#define FXAA_QUALITY_P3 12.0
|
|
8801
|
-
#endif
|
|
8802
|
-
#if (FXAA_QUALITY_PRESET == 12)
|
|
8803
|
-
#define FXAA_QUALITY_PS 5
|
|
8804
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8805
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8806
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8807
|
-
#define FXAA_QUALITY_P3 4.0
|
|
8808
|
-
#define FXAA_QUALITY_P4 12.0
|
|
8809
|
-
#endif
|
|
8810
|
-
#if (FXAA_QUALITY_PRESET == 13)
|
|
8811
|
-
#define FXAA_QUALITY_PS 6
|
|
8812
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8813
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8814
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8815
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8816
|
-
#define FXAA_QUALITY_P4 4.0
|
|
8817
|
-
#define FXAA_QUALITY_P5 12.0
|
|
8818
|
-
#endif
|
|
8819
|
-
#if (FXAA_QUALITY_PRESET == 14)
|
|
8820
|
-
#define FXAA_QUALITY_PS 7
|
|
8821
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8822
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8823
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8824
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8825
|
-
#define FXAA_QUALITY_P4 2.0
|
|
8826
|
-
#define FXAA_QUALITY_P5 4.0
|
|
8827
|
-
#define FXAA_QUALITY_P6 12.0
|
|
8828
|
-
#endif
|
|
8829
|
-
#if (FXAA_QUALITY_PRESET == 15)
|
|
8830
|
-
#define FXAA_QUALITY_PS 8
|
|
8831
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8832
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8833
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8834
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8835
|
-
#define FXAA_QUALITY_P4 2.0
|
|
8836
|
-
#define FXAA_QUALITY_P5 2.0
|
|
8837
|
-
#define FXAA_QUALITY_P6 4.0
|
|
8838
|
-
#define FXAA_QUALITY_P7 12.0
|
|
8839
|
-
#endif
|
|
8840
|
-
#if (FXAA_QUALITY_PRESET == 20)
|
|
8841
|
-
#define FXAA_QUALITY_PS 3
|
|
8842
|
-
#define FXAA_QUALITY_P0 1.5
|
|
8843
|
-
#define FXAA_QUALITY_P1 2.0
|
|
8844
|
-
#define FXAA_QUALITY_P2 8.0
|
|
8845
|
-
#endif
|
|
8846
|
-
#if (FXAA_QUALITY_PRESET == 21)
|
|
8847
|
-
#define FXAA_QUALITY_PS 4
|
|
8848
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8849
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8850
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8851
|
-
#define FXAA_QUALITY_P3 8.0
|
|
8852
|
-
#endif
|
|
8853
|
-
#if (FXAA_QUALITY_PRESET == 22)
|
|
8854
|
-
#define FXAA_QUALITY_PS 5
|
|
8855
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8856
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8857
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8858
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8859
|
-
#define FXAA_QUALITY_P4 8.0
|
|
8860
|
-
#endif
|
|
8861
|
-
#if (FXAA_QUALITY_PRESET == 23)
|
|
8862
|
-
#define FXAA_QUALITY_PS 6
|
|
8863
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8864
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8865
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8866
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8867
|
-
#define FXAA_QUALITY_P4 2.0
|
|
8868
|
-
#define FXAA_QUALITY_P5 8.0
|
|
8869
|
-
#endif
|
|
8870
|
-
#if (FXAA_QUALITY_PRESET == 24)
|
|
8871
|
-
#define FXAA_QUALITY_PS 7
|
|
8872
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8873
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8874
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8875
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8876
|
-
#define FXAA_QUALITY_P4 2.0
|
|
8877
|
-
#define FXAA_QUALITY_P5 3.0
|
|
8878
|
-
#define FXAA_QUALITY_P6 8.0
|
|
8879
|
-
#endif
|
|
8880
|
-
#if (FXAA_QUALITY_PRESET == 25)
|
|
8881
|
-
#define FXAA_QUALITY_PS 8
|
|
8882
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8883
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8884
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8885
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8886
|
-
#define FXAA_QUALITY_P4 2.0
|
|
8887
|
-
#define FXAA_QUALITY_P5 2.0
|
|
8888
|
-
#define FXAA_QUALITY_P6 4.0
|
|
8889
|
-
#define FXAA_QUALITY_P7 8.0
|
|
8890
|
-
#endif
|
|
8891
|
-
#if (FXAA_QUALITY_PRESET == 26)
|
|
8892
|
-
#define FXAA_QUALITY_PS 9
|
|
8893
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8894
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8895
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8896
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8897
|
-
#define FXAA_QUALITY_P4 2.0
|
|
8898
|
-
#define FXAA_QUALITY_P5 2.0
|
|
8899
|
-
#define FXAA_QUALITY_P6 2.0
|
|
8900
|
-
#define FXAA_QUALITY_P7 4.0
|
|
8901
|
-
#define FXAA_QUALITY_P8 8.0
|
|
8902
|
-
#endif
|
|
8903
|
-
#if (FXAA_QUALITY_PRESET == 27)
|
|
8904
|
-
#define FXAA_QUALITY_PS 10
|
|
8905
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8906
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8907
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8908
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8909
|
-
#define FXAA_QUALITY_P4 2.0
|
|
8910
|
-
#define FXAA_QUALITY_P5 2.0
|
|
8911
|
-
#define FXAA_QUALITY_P6 2.0
|
|
8912
|
-
#define FXAA_QUALITY_P7 2.0
|
|
8913
|
-
#define FXAA_QUALITY_P8 4.0
|
|
8914
|
-
#define FXAA_QUALITY_P9 8.0
|
|
8915
|
-
#endif
|
|
8916
|
-
#if (FXAA_QUALITY_PRESET == 28)
|
|
8917
|
-
#define FXAA_QUALITY_PS 11
|
|
8918
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8919
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8920
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8921
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8922
|
-
#define FXAA_QUALITY_P4 2.0
|
|
8923
|
-
#define FXAA_QUALITY_P5 2.0
|
|
8924
|
-
#define FXAA_QUALITY_P6 2.0
|
|
8925
|
-
#define FXAA_QUALITY_P7 2.0
|
|
8926
|
-
#define FXAA_QUALITY_P8 2.0
|
|
8927
|
-
#define FXAA_QUALITY_P9 4.0
|
|
8928
|
-
#define FXAA_QUALITY_P10 8.0
|
|
8929
|
-
#endif
|
|
8930
|
-
#if (FXAA_QUALITY_PRESET == 29)
|
|
8931
|
-
#define FXAA_QUALITY_PS 12
|
|
8932
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8933
|
-
#define FXAA_QUALITY_P1 1.5
|
|
8934
|
-
#define FXAA_QUALITY_P2 2.0
|
|
8935
|
-
#define FXAA_QUALITY_P3 2.0
|
|
8936
|
-
#define FXAA_QUALITY_P4 2.0
|
|
8937
|
-
#define FXAA_QUALITY_P5 2.0
|
|
8938
|
-
#define FXAA_QUALITY_P6 2.0
|
|
8939
|
-
#define FXAA_QUALITY_P7 2.0
|
|
8940
|
-
#define FXAA_QUALITY_P8 2.0
|
|
8941
|
-
#define FXAA_QUALITY_P9 2.0
|
|
8942
|
-
#define FXAA_QUALITY_P10 4.0
|
|
8943
|
-
#define FXAA_QUALITY_P11 8.0
|
|
8944
|
-
#endif
|
|
8945
|
-
#if (FXAA_QUALITY_PRESET == 39)
|
|
8946
|
-
#define FXAA_QUALITY_PS 12
|
|
8947
|
-
#define FXAA_QUALITY_P0 1.0
|
|
8948
|
-
#define FXAA_QUALITY_P1 1.0
|
|
8949
|
-
#define FXAA_QUALITY_P2 1.0
|
|
8950
|
-
#define FXAA_QUALITY_P3 1.0
|
|
8951
|
-
#define FXAA_QUALITY_P4 1.0
|
|
8952
|
-
#define FXAA_QUALITY_P5 1.5
|
|
8953
|
-
#define FXAA_QUALITY_P6 2.0
|
|
8954
|
-
#define FXAA_QUALITY_P7 2.0
|
|
8955
|
-
#define FXAA_QUALITY_P8 2.0
|
|
8956
|
-
#define FXAA_QUALITY_P9 2.0
|
|
8957
|
-
#define FXAA_QUALITY_P10 4.0
|
|
8958
|
-
#define FXAA_QUALITY_P11 8.0
|
|
8959
|
-
#endif
|
|
8960
|
-
|
|
8961
|
-
#define FxaaBool bool
|
|
8962
|
-
#define FxaaFloat float
|
|
8963
|
-
#define FxaaFloat2 vec2
|
|
8964
|
-
#define FxaaFloat3 vec3
|
|
8965
|
-
#define FxaaFloat4 vec4
|
|
8966
|
-
#define FxaaHalf float
|
|
8967
|
-
#define FxaaHalf2 vec2
|
|
8968
|
-
#define FxaaHalf3 vec3
|
|
8969
|
-
#define FxaaHalf4 vec4
|
|
8970
|
-
#define FxaaInt2 vec2
|
|
8971
|
-
#define FxaaTex sampler2D
|
|
8972
|
-
|
|
8973
|
-
#define FxaaSat(x) clamp(x, 0.0, 1.0)
|
|
8974
|
-
#define FxaaTexTop(t, p) texture(t, p)
|
|
8975
|
-
#define FxaaTexOff(t, p, o, r) texture(t, p + (o * r))
|
|
8976
|
-
|
|
8977
|
-
FxaaFloat FxaaLuma_(FxaaFloat4 rgba) { return dot(rgba.rgb, vec3(0.2126, 0.7152, 0.0722)); }
|
|
8978
|
-
|
|
8979
|
-
FxaaFloat4 FxaaPixelShader_(
|
|
8980
|
-
//
|
|
8981
|
-
// Use noperspective interpolation here (turn off perspective interpolation).
|
|
8982
|
-
// {xy} = center of pixel
|
|
8983
|
-
FxaaFloat2 pos,
|
|
8984
|
-
//
|
|
8985
|
-
// Input color texture.
|
|
8986
|
-
// {rgb_} = color in linear or perceptual color space
|
|
8987
|
-
// if (FXAA_GREEN_AS_LUMA == 0)
|
|
8988
|
-
// {___a} = luma in perceptual color space (not linear)
|
|
8989
|
-
FxaaTex tex,
|
|
8990
|
-
//
|
|
8991
|
-
// Only used on FXAA Quality.
|
|
8992
|
-
// This must be from a constant/uniform.
|
|
8993
|
-
// {x_} = 1.0/screenWidthInPixels
|
|
8994
|
-
// {_y} = 1.0/screenHeightInPixels
|
|
8995
|
-
FxaaFloat2 fxaaQualityRcpFrame,
|
|
8996
|
-
//
|
|
8997
|
-
// Only used on FXAA Quality.
|
|
8998
|
-
// This used to be the FXAA_QUALITY_SUBPIX define.
|
|
8999
|
-
// It is here now to allow easier tuning.
|
|
9000
|
-
// Choose the amount of sub-pixel aliasing removal.
|
|
9001
|
-
// This can effect sharpness.
|
|
9002
|
-
// 1.00 - upper limit (softer)
|
|
9003
|
-
// 0.75 - default amount of filtering
|
|
9004
|
-
// 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
|
|
9005
|
-
// 0.25 - almost off
|
|
9006
|
-
// 0.00 - completely off
|
|
9007
|
-
FxaaFloat fxaaQualitySubpix,
|
|
9008
|
-
//
|
|
9009
|
-
// Only used on FXAA Quality.
|
|
9010
|
-
// This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.
|
|
9011
|
-
// It is here now to allow easier tuning.
|
|
9012
|
-
// The minimum amount of local contrast required to apply algorithm.
|
|
9013
|
-
// 0.333 - too little (faster)
|
|
9014
|
-
// 0.250 - low quality
|
|
9015
|
-
// 0.166 - default
|
|
9016
|
-
// 0.125 - high quality
|
|
9017
|
-
// 0.063 - overkill (slower)
|
|
9018
|
-
FxaaFloat fxaaQualityEdgeThreshold,
|
|
9019
|
-
//
|
|
9020
|
-
// Only used on FXAA Quality.
|
|
9021
|
-
// This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.
|
|
9022
|
-
// It is here now to allow easier tuning.
|
|
9023
|
-
// Trims the algorithm from processing darks.
|
|
9024
|
-
// 0.0833 - upper limit (default, the start of visible unfiltered edges)
|
|
9025
|
-
// 0.0625 - high quality (faster)
|
|
9026
|
-
// 0.0312 - visible limit (slower)
|
|
9027
|
-
// Special notes when using FXAA_GREEN_AS_LUMA,
|
|
9028
|
-
// Likely want to set this to zero.
|
|
9029
|
-
// As colors that are mostly not-green
|
|
9030
|
-
// will appear very dark in the green channel!
|
|
9031
|
-
// Tune by looking at mostly non-green content,
|
|
9032
|
-
// then start at zero and increase until aliasing is a problem.
|
|
9033
|
-
FxaaFloat fxaaQualityEdgeThresholdMin
|
|
9034
|
-
) {
|
|
9035
|
-
/*--------------------------------------------------------------------------*/
|
|
9036
|
-
FxaaFloat2 posM;
|
|
9037
|
-
posM.x = pos.x;
|
|
9038
|
-
posM.y = pos.y;
|
|
9039
|
-
FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
|
|
9040
|
-
#define lumaM rgbyM.y
|
|
9041
|
-
FxaaFloat lumaS = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));
|
|
9042
|
-
FxaaFloat lumaE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));
|
|
9043
|
-
FxaaFloat lumaN = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));
|
|
9044
|
-
FxaaFloat lumaW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));
|
|
9045
|
-
/*--------------------------------------------------------------------------*/
|
|
9046
|
-
FxaaFloat maxSM = max(lumaS, lumaM);
|
|
9047
|
-
FxaaFloat minSM = min(lumaS, lumaM);
|
|
9048
|
-
FxaaFloat maxESM = max(lumaE, maxSM);
|
|
9049
|
-
FxaaFloat minESM = min(lumaE, minSM);
|
|
9050
|
-
FxaaFloat maxWN = max(lumaN, lumaW);
|
|
9051
|
-
FxaaFloat minWN = min(lumaN, lumaW);
|
|
9052
|
-
FxaaFloat rangeMax = max(maxWN, maxESM);
|
|
9053
|
-
FxaaFloat rangeMin = min(minWN, minESM);
|
|
9054
|
-
FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;
|
|
9055
|
-
FxaaFloat range = rangeMax - rangeMin;
|
|
9056
|
-
FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);
|
|
9057
|
-
FxaaBool earlyExit = range < rangeMaxClamped;
|
|
9058
|
-
/*--------------------------------------------------------------------------*/
|
|
9059
|
-
if(earlyExit)
|
|
9060
|
-
return rgbyM;
|
|
9061
|
-
/*--------------------------------------------------------------------------*/
|
|
9062
|
-
FxaaFloat lumaNW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));
|
|
9063
|
-
FxaaFloat lumaSE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));
|
|
9064
|
-
FxaaFloat lumaNE = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));
|
|
9065
|
-
FxaaFloat lumaSW = FxaaLuma_(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
|
|
9066
|
-
/*--------------------------------------------------------------------------*/
|
|
9067
|
-
FxaaFloat lumaNS = lumaN + lumaS;
|
|
9068
|
-
FxaaFloat lumaWE = lumaW + lumaE;
|
|
9069
|
-
FxaaFloat subpixRcpRange = 1.0/range;
|
|
9070
|
-
FxaaFloat subpixNSWE = lumaNS + lumaWE;
|
|
9071
|
-
FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;
|
|
9072
|
-
FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;
|
|
9073
|
-
/*--------------------------------------------------------------------------*/
|
|
9074
|
-
FxaaFloat lumaNESE = lumaNE + lumaSE;
|
|
9075
|
-
FxaaFloat lumaNWNE = lumaNW + lumaNE;
|
|
9076
|
-
FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
|
|
9077
|
-
FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;
|
|
9078
|
-
/*--------------------------------------------------------------------------*/
|
|
9079
|
-
FxaaFloat lumaNWSW = lumaNW + lumaSW;
|
|
9080
|
-
FxaaFloat lumaSWSE = lumaSW + lumaSE;
|
|
9081
|
-
FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);
|
|
9082
|
-
FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);
|
|
9083
|
-
FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;
|
|
9084
|
-
FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;
|
|
9085
|
-
FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;
|
|
9086
|
-
FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;
|
|
9087
|
-
/*--------------------------------------------------------------------------*/
|
|
9088
|
-
FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;
|
|
9089
|
-
FxaaFloat lengthSign = fxaaQualityRcpFrame.x;
|
|
9090
|
-
FxaaBool horzSpan = edgeHorz >= edgeVert;
|
|
9091
|
-
FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
|
|
9092
|
-
/*--------------------------------------------------------------------------*/
|
|
9093
|
-
if(!horzSpan) lumaN = lumaW;
|
|
9094
|
-
if(!horzSpan) lumaS = lumaE;
|
|
9095
|
-
if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;
|
|
9096
|
-
FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;
|
|
9097
|
-
/*--------------------------------------------------------------------------*/
|
|
9098
|
-
FxaaFloat gradientN = lumaN - lumaM;
|
|
9099
|
-
FxaaFloat gradientS = lumaS - lumaM;
|
|
9100
|
-
FxaaFloat lumaNN = lumaN + lumaM;
|
|
9101
|
-
FxaaFloat lumaSS = lumaS + lumaM;
|
|
9102
|
-
FxaaBool pairN = abs(gradientN) >= abs(gradientS);
|
|
9103
|
-
FxaaFloat gradient = max(abs(gradientN), abs(gradientS));
|
|
9104
|
-
if(pairN) lengthSign = -lengthSign;
|
|
9105
|
-
FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);
|
|
9106
|
-
/*--------------------------------------------------------------------------*/
|
|
9107
|
-
FxaaFloat2 posB;
|
|
9108
|
-
posB.x = posM.x;
|
|
9109
|
-
posB.y = posM.y;
|
|
9110
|
-
FxaaFloat2 offNP;
|
|
9111
|
-
offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;
|
|
9112
|
-
offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;
|
|
9113
|
-
if(!horzSpan) posB.x += lengthSign * 0.5;
|
|
9114
|
-
if( horzSpan) posB.y += lengthSign * 0.5;
|
|
9115
|
-
/*--------------------------------------------------------------------------*/
|
|
9116
|
-
FxaaFloat2 posN;
|
|
9117
|
-
posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;
|
|
9118
|
-
posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;
|
|
9119
|
-
FxaaFloat2 posP;
|
|
9120
|
-
posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;
|
|
9121
|
-
posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;
|
|
9122
|
-
FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;
|
|
9123
|
-
FxaaFloat lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN));
|
|
9124
|
-
FxaaFloat subpixE = subpixC * subpixC;
|
|
9125
|
-
FxaaFloat lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP));
|
|
9126
|
-
/*--------------------------------------------------------------------------*/
|
|
9127
|
-
if(!pairN) lumaNN = lumaSS;
|
|
9128
|
-
FxaaFloat gradientScaled = gradient * 1.0/4.0;
|
|
9129
|
-
FxaaFloat lumaMM = lumaM - lumaNN * 0.5;
|
|
9130
|
-
FxaaFloat subpixF = subpixD * subpixE;
|
|
9131
|
-
FxaaBool lumaMLTZero = lumaMM < 0.0;
|
|
9132
|
-
/*--------------------------------------------------------------------------*/
|
|
9133
|
-
lumaEndN -= lumaNN * 0.5;
|
|
9134
|
-
lumaEndP -= lumaNN * 0.5;
|
|
9135
|
-
FxaaBool doneN = abs(lumaEndN) >= gradientScaled;
|
|
9136
|
-
FxaaBool doneP = abs(lumaEndP) >= gradientScaled;
|
|
9137
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;
|
|
9138
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;
|
|
9139
|
-
FxaaBool doneNP = (!doneN) || (!doneP);
|
|
9140
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;
|
|
9141
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;
|
|
9142
|
-
/*--------------------------------------------------------------------------*/
|
|
9143
|
-
if(doneNP) {
|
|
9144
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9145
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9146
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9147
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9148
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9149
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9150
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;
|
|
9151
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;
|
|
9152
|
-
doneNP = (!doneN) || (!doneP);
|
|
9153
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;
|
|
9154
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;
|
|
9155
|
-
/*--------------------------------------------------------------------------*/
|
|
9156
|
-
#if (FXAA_QUALITY_PS > 3)
|
|
9157
|
-
if(doneNP) {
|
|
9158
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9159
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9160
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9161
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9162
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9163
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9164
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;
|
|
9165
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;
|
|
9166
|
-
doneNP = (!doneN) || (!doneP);
|
|
9167
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;
|
|
9168
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;
|
|
9169
|
-
/*--------------------------------------------------------------------------*/
|
|
9170
|
-
#if (FXAA_QUALITY_PS > 4)
|
|
9171
|
-
if(doneNP) {
|
|
9172
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9173
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9174
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9175
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9176
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9177
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9178
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;
|
|
9179
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;
|
|
9180
|
-
doneNP = (!doneN) || (!doneP);
|
|
9181
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;
|
|
9182
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;
|
|
9183
|
-
/*--------------------------------------------------------------------------*/
|
|
9184
|
-
#if (FXAA_QUALITY_PS > 5)
|
|
9185
|
-
if(doneNP) {
|
|
9186
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9187
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9188
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9189
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9190
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9191
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9192
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;
|
|
9193
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;
|
|
9194
|
-
doneNP = (!doneN) || (!doneP);
|
|
9195
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;
|
|
9196
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;
|
|
9197
|
-
/*--------------------------------------------------------------------------*/
|
|
9198
|
-
#if (FXAA_QUALITY_PS > 6)
|
|
9199
|
-
if(doneNP) {
|
|
9200
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9201
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9202
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9203
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9204
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9205
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9206
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;
|
|
9207
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;
|
|
9208
|
-
doneNP = (!doneN) || (!doneP);
|
|
9209
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;
|
|
9210
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;
|
|
9211
|
-
/*--------------------------------------------------------------------------*/
|
|
9212
|
-
#if (FXAA_QUALITY_PS > 7)
|
|
9213
|
-
if(doneNP) {
|
|
9214
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9215
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9216
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9217
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9218
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9219
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9220
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;
|
|
9221
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;
|
|
9222
|
-
doneNP = (!doneN) || (!doneP);
|
|
9223
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;
|
|
9224
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;
|
|
9225
|
-
/*--------------------------------------------------------------------------*/
|
|
9226
|
-
#if (FXAA_QUALITY_PS > 8)
|
|
9227
|
-
if(doneNP) {
|
|
9228
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9229
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9230
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9231
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9232
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9233
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9234
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;
|
|
9235
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;
|
|
9236
|
-
doneNP = (!doneN) || (!doneP);
|
|
9237
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;
|
|
9238
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;
|
|
9239
|
-
/*--------------------------------------------------------------------------*/
|
|
9240
|
-
#if (FXAA_QUALITY_PS > 9)
|
|
9241
|
-
if(doneNP) {
|
|
9242
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9243
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9244
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9245
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9246
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9247
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9248
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;
|
|
9249
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;
|
|
9250
|
-
doneNP = (!doneN) || (!doneP);
|
|
9251
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;
|
|
9252
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;
|
|
9253
|
-
/*--------------------------------------------------------------------------*/
|
|
9254
|
-
#if (FXAA_QUALITY_PS > 10)
|
|
9255
|
-
if(doneNP) {
|
|
9256
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9257
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9258
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9259
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9260
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9261
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9262
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;
|
|
9263
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;
|
|
9264
|
-
doneNP = (!doneN) || (!doneP);
|
|
9265
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;
|
|
9266
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;
|
|
9267
|
-
/*--------------------------------------------------------------------------*/
|
|
9268
|
-
#if (FXAA_QUALITY_PS > 11)
|
|
9269
|
-
if(doneNP) {
|
|
9270
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9271
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9272
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9273
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9274
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9275
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9276
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;
|
|
9277
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;
|
|
9278
|
-
doneNP = (!doneN) || (!doneP);
|
|
9279
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;
|
|
9280
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;
|
|
9281
|
-
/*--------------------------------------------------------------------------*/
|
|
9282
|
-
#if (FXAA_QUALITY_PS > 12)
|
|
9283
|
-
if(doneNP) {
|
|
9284
|
-
if(!doneN) lumaEndN = FxaaLuma_(FxaaTexTop(tex, posN.xy));
|
|
9285
|
-
if(!doneP) lumaEndP = FxaaLuma_(FxaaTexTop(tex, posP.xy));
|
|
9286
|
-
if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
|
|
9287
|
-
if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
|
|
9288
|
-
doneN = abs(lumaEndN) >= gradientScaled;
|
|
9289
|
-
doneP = abs(lumaEndP) >= gradientScaled;
|
|
9290
|
-
if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;
|
|
9291
|
-
if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;
|
|
9292
|
-
doneNP = (!doneN) || (!doneP);
|
|
9293
|
-
if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;
|
|
9294
|
-
if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;
|
|
9295
|
-
/*--------------------------------------------------------------------------*/
|
|
9296
|
-
}
|
|
9297
|
-
#endif
|
|
9298
|
-
/*--------------------------------------------------------------------------*/
|
|
9299
|
-
}
|
|
9300
|
-
#endif
|
|
9301
|
-
/*--------------------------------------------------------------------------*/
|
|
9302
|
-
}
|
|
9303
|
-
#endif
|
|
9304
|
-
/*--------------------------------------------------------------------------*/
|
|
9305
|
-
}
|
|
9306
|
-
#endif
|
|
9307
|
-
/*--------------------------------------------------------------------------*/
|
|
9308
|
-
}
|
|
9309
|
-
#endif
|
|
9310
|
-
/*--------------------------------------------------------------------------*/
|
|
9311
|
-
}
|
|
9312
|
-
#endif
|
|
9313
|
-
/*--------------------------------------------------------------------------*/
|
|
9314
|
-
}
|
|
9315
|
-
#endif
|
|
9316
|
-
/*--------------------------------------------------------------------------*/
|
|
9317
|
-
}
|
|
9318
|
-
#endif
|
|
9319
|
-
/*--------------------------------------------------------------------------*/
|
|
9320
|
-
}
|
|
9321
|
-
#endif
|
|
9322
|
-
/*--------------------------------------------------------------------------*/
|
|
9323
|
-
}
|
|
9324
|
-
#endif
|
|
9325
|
-
/*--------------------------------------------------------------------------*/
|
|
9326
|
-
}
|
|
9327
|
-
/*--------------------------------------------------------------------------*/
|
|
9328
|
-
FxaaFloat dstN = posM.x - posN.x;
|
|
9329
|
-
FxaaFloat dstP = posP.x - posM.x;
|
|
9330
|
-
if(!horzSpan) dstN = posM.y - posN.y;
|
|
9331
|
-
if(!horzSpan) dstP = posP.y - posM.y;
|
|
9332
|
-
/*--------------------------------------------------------------------------*/
|
|
9333
|
-
FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;
|
|
9334
|
-
FxaaFloat spanLength = (dstP + dstN);
|
|
9335
|
-
FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;
|
|
9336
|
-
FxaaFloat spanLengthRcp = 1.0/spanLength;
|
|
9337
|
-
/*--------------------------------------------------------------------------*/
|
|
9338
|
-
FxaaBool directionN = dstN < dstP;
|
|
9339
|
-
FxaaFloat dst = min(dstN, dstP);
|
|
9340
|
-
FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;
|
|
9341
|
-
FxaaFloat subpixG = subpixF * subpixF;
|
|
9342
|
-
FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;
|
|
9343
|
-
FxaaFloat subpixH = subpixG * fxaaQualitySubpix;
|
|
9344
|
-
/*--------------------------------------------------------------------------*/
|
|
9345
|
-
FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;
|
|
9346
|
-
FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
|
|
9347
|
-
if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
|
|
9348
|
-
if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
|
|
9349
|
-
return FxaaTexTop(tex, posM);
|
|
9350
|
-
}
|
|
9351
|
-
|
|
9352
|
-
vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
9353
|
-
const float fxaa_QualitySubpix = 0.5;
|
|
9354
|
-
const float fxaa_QualityEdgeThreshold = 0.125;
|
|
9355
|
-
const float fxaa_QualityEdgeThresholdMin = 0.0833;
|
|
9356
|
-
|
|
9357
|
-
return FxaaPixelShader_(
|
|
9358
|
-
texCoord,
|
|
9359
|
-
source,
|
|
9360
|
-
vec2(1.0) / texSize,
|
|
9361
|
-
fxaa_QualitySubpix,
|
|
9362
|
-
fxaa_QualityEdgeThreshold,
|
|
9363
|
-
fxaa_QualityEdgeThresholdMin
|
|
9364
|
-
);
|
|
9365
|
-
}
|
|
9366
|
-
`;
|
|
9367
|
-
var fxaa = {
|
|
9368
|
-
name: "fxaa",
|
|
9369
|
-
uniformPropTypes: {},
|
|
9370
|
-
fs: fs23,
|
|
9371
|
-
passes: [{ sampler: true }],
|
|
9372
|
-
getUniforms: (props) => props
|
|
9373
|
-
};
|
|
9374
|
-
|
|
9375
|
-
// src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts
|
|
9376
|
-
var fp64arithmeticShader = (
|
|
9377
|
-
/* glsl */
|
|
9378
|
-
`uniform float ONE;
|
|
7952
|
+
`uniform float ONE;
|
|
9379
7953
|
|
|
9380
7954
|
/*
|
|
9381
7955
|
About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
@@ -10263,7 +8837,7 @@ void geometry_setPosition(vec3 position) {
|
|
|
10263
8837
|
}
|
|
10264
8838
|
`
|
|
10265
8839
|
);
|
|
10266
|
-
var
|
|
8840
|
+
var fs4 = (
|
|
10267
8841
|
/* glsl */
|
|
10268
8842
|
`varying vec4 geometry_vPosition;
|
|
10269
8843
|
varying vec3 geometry_vNormal;
|
|
@@ -10280,7 +8854,7 @@ vec3 geometry_getNormal() {
|
|
|
10280
8854
|
var geometry = {
|
|
10281
8855
|
name: "geometry",
|
|
10282
8856
|
vs: vs3,
|
|
10283
|
-
fs:
|
|
8857
|
+
fs: fs4
|
|
10284
8858
|
};
|
|
10285
8859
|
|
|
10286
8860
|
// src/modules-webgl1/project/project.ts
|
|
@@ -10380,13 +8954,13 @@ vec4 project_to_clipspace(vec3 position) {
|
|
|
10380
8954
|
return viewProjectionMatrix * vec4(position, 1.);
|
|
10381
8955
|
}
|
|
10382
8956
|
`;
|
|
10383
|
-
var
|
|
8957
|
+
var fs5 = `
|
|
10384
8958
|
${common}`;
|
|
10385
8959
|
var project = {
|
|
10386
8960
|
name: "project",
|
|
10387
8961
|
getUniforms: getUniforms5,
|
|
10388
8962
|
vs: vs4,
|
|
10389
|
-
fs:
|
|
8963
|
+
fs: fs5
|
|
10390
8964
|
};
|
|
10391
8965
|
|
|
10392
8966
|
// src/modules-webgl1/lighting/lights/lights-glsl.ts
|
|
@@ -10521,7 +9095,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
10521
9095
|
}
|
|
10522
9096
|
return uniforms;
|
|
10523
9097
|
}
|
|
10524
|
-
var
|
|
9098
|
+
var fs6 = (
|
|
10525
9099
|
/* glsl */
|
|
10526
9100
|
`uniform vec3 dirlight_uLightDirection;
|
|
10527
9101
|
|
|
@@ -10538,7 +9112,7 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
10538
9112
|
var dirlight2 = {
|
|
10539
9113
|
name: "dirlight",
|
|
10540
9114
|
// vs // TODO - reuse normal from geometry module
|
|
10541
|
-
fs:
|
|
9115
|
+
fs: fs6,
|
|
10542
9116
|
getUniforms: getUniforms7,
|
|
10543
9117
|
dependencies: [project]
|
|
10544
9118
|
};
|
|
@@ -10706,7 +9280,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
|
|
|
10706
9280
|
);
|
|
10707
9281
|
|
|
10708
9282
|
// src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts
|
|
10709
|
-
var
|
|
9283
|
+
var fs7 = (
|
|
10710
9284
|
/* glsl */
|
|
10711
9285
|
`precision highp float;
|
|
10712
9286
|
|
|
@@ -11096,7 +9670,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
11096
9670
|
var pbr = {
|
|
11097
9671
|
name: "pbr",
|
|
11098
9672
|
vs: vs5,
|
|
11099
|
-
fs:
|
|
9673
|
+
fs: fs7,
|
|
11100
9674
|
defines: {
|
|
11101
9675
|
LIGHTING_FRAGMENT: 1
|
|
11102
9676
|
},
|
|
@@ -11105,34 +9679,5 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
11105
9679
|
};
|
|
11106
9680
|
return __toCommonJS(bundle_exports);
|
|
11107
9681
|
})();
|
|
11108
|
-
/**
|
|
11109
|
-
* ORIGINAL LICENCE
|
|
11110
|
-
* @license
|
|
11111
|
-
* Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
|
|
11112
|
-
*
|
|
11113
|
-
* Redistribution and use in source and binary forms, with or without
|
|
11114
|
-
* modification, are permitted provided that the following conditions
|
|
11115
|
-
* are met:
|
|
11116
|
-
* * Redistributions of source code must retain the above copyright
|
|
11117
|
-
* notice, this list of conditions and the following disclaimer.
|
|
11118
|
-
* * Redistributions in binary form must reproduce the above copyright
|
|
11119
|
-
* notice, this list of conditions and the following disclaimer in the
|
|
11120
|
-
* documentation and/or other materials provided with the distribution.
|
|
11121
|
-
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
11122
|
-
* contributors may be used to endorse or promote products derived
|
|
11123
|
-
* from this software without specific prior written permission.
|
|
11124
|
-
*
|
|
11125
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
|
11126
|
-
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
11127
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
11128
|
-
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
11129
|
-
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
11130
|
-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
11131
|
-
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
11132
|
-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
11133
|
-
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
11134
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
11135
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
11136
|
-
*/
|
|
11137
9682
|
return __exports__;
|
|
11138
9683
|
});
|