@luma.gl/shadertools 9.1.0-alpha.1 → 9.1.0-alpha.12
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 +1005 -487
- package/dist/dist.min.js +2489 -1625
- package/dist/index.cjs +2864 -1817
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +29 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -12
- package/dist/lib/glsl-utils/shader-utils.d.ts.map +1 -1
- package/dist/lib/glsl-utils/shader-utils.js +2 -3
- package/dist/lib/shader-assembler.d.ts +3 -4
- package/dist/lib/shader-assembler.d.ts.map +1 -1
- package/dist/lib/shader-assembler.js +3 -2
- package/dist/lib/shader-assembly/assemble-shaders.d.ts +4 -3
- package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-shaders.js +46 -18
- package/dist/lib/shader-assembly/platform-defines.d.ts.map +1 -1
- package/dist/lib/shader-assembly/platform-defines.js +14 -6
- package/dist/lib/shader-module/shader-module-dependencies.d.ts +53 -0
- package/dist/lib/shader-module/shader-module-dependencies.d.ts.map +1 -0
- package/dist/lib/{shader-assembly/resolve-modules.js → shader-module/shader-module-dependencies.js} +38 -14
- package/dist/lib/shader-module/shader-module.d.ts +30 -12
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module.js +76 -6
- package/dist/lib/shader-module/shader-pass.d.ts +3 -2
- package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
- package/dist/module-injectors.d.ts +2 -2
- package/dist/module-injectors.d.ts.map +1 -1
- package/dist/module-injectors.js +13 -10
- package/dist/modules/engine/geometry/geometry.d.ts.map +1 -1
- package/dist/modules/engine/geometry/geometry.js +12 -8
- package/dist/modules/engine/picking/picking.d.ts +9 -9
- package/dist/modules/engine/picking/picking.d.ts.map +1 -1
- package/dist/modules/engine/picking/picking.js +103 -66
- package/dist/modules/engine/project/project.d.ts +2 -2
- package/dist/modules/engine/project/project.d.ts.map +1 -1
- package/dist/modules/engine/project/project.js +36 -22
- package/dist/modules/engine/transform/transform.d.ts.map +1 -1
- package/dist/modules/engine/transform/transform.js +28 -16
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +10 -7
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.js +2 -0
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +2 -2
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +79 -53
- 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 +38 -23
- 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 +56 -0
- package/dist/modules/lighting/lights/lighting.d.ts +5 -4
- package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting.js +7 -5
- package/dist/modules/lighting/no-material/dirlight.d.ts +8 -8
- package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
- package/dist/modules/lighting/no-material/dirlight.js +34 -20
- 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 +304 -181
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts +72 -69
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material.js +4 -2
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +38 -20
- 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 +21 -16
- package/dist/modules/lighting/phong-material/phong-material.d.ts +14 -12
- package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-material.js +5 -3
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +2 -2
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +82 -54
- 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 +130 -0
- package/dist/modules/math/fp32/fp32.d.ts.map +1 -1
- package/dist/modules/math/fp32/fp32.js +127 -100
- 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/random/random.d.ts +1 -1
- package/dist/modules/math/random/random.d.ts.map +1 -1
- package/dist/modules/math/random/random.js +3 -3
- package/dist/modules/module-injectors.d.ts +2 -2
- package/dist/modules/module-injectors.d.ts.map +1 -1
- package/dist/modules/module-injectors.js +13 -10
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js +16 -12
- package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/denoise.js +21 -17
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts +5 -2
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js +29 -22
- package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/noise.js +14 -10
- package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/sepia.js +17 -12
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.js +12 -9
- package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts +4 -1
- package/dist/modules/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-adjust-filters/vignette.js +13 -10
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +5 -2
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.js +40 -26
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +5 -2
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.js +32 -19
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +4 -1
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.js +2 -0
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +4 -1
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js +31 -27
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +4 -1
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.js +19 -15
- package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts +8 -5
- package/dist/modules/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/edgework.js +53 -42
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +4 -1
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js +41 -33
- package/dist/modules/postprocessing/image-fun-filters/ink.d.ts +4 -1
- package/dist/modules/postprocessing/image-fun-filters/ink.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/ink.js +27 -25
- package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +2 -1
- package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/magnify.js +17 -16
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +5 -2
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js +24 -20
- package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts +5 -2
- package/dist/modules/postprocessing/image-warp-filters/swirl.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-warp-filters/swirl.js +26 -22
- package/dist/modules/postprocessing/image-warp-filters/warp.d.ts +2 -1
- package/dist/modules/postprocessing/image-warp-filters/warp.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-warp-filters/warp.js +9 -8
- package/dist/modules-webgl1/geometry/geometry.d.ts.map +1 -1
- package/dist/modules-webgl1/geometry/geometry.js +12 -8
- 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 +8 -5
- package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +1 -1
- package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/lights/lights-glsl.js +19 -11
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +1 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +268 -157
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +1 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +16 -12
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +1 -1
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +64 -55
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +1 -1
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +113 -81
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +1 -1
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +588 -433
- package/dist/modules-webgl1/project/project.d.ts +2 -2
- package/dist/modules-webgl1/project/project.d.ts.map +1 -1
- package/dist/modules-webgl1/project/project.js +5 -4
- package/package.json +5 -5
- package/src/index.ts +78 -32
- package/src/lib/glsl-utils/shader-utils.ts +1 -3
- package/src/lib/shader-assembler.ts +7 -8
- package/src/lib/shader-assembly/assemble-shaders.ts +55 -22
- package/src/lib/shader-assembly/platform-defines.ts +5 -6
- package/src/lib/shader-module/shader-module-dependencies.ts +111 -0
- package/src/lib/shader-module/shader-module.ts +134 -19
- package/src/lib/shader-module/shader-pass.ts +3 -2
- package/src/module-injectors.ts +2 -4
- package/src/modules/engine/geometry/geometry.ts +2 -3
- package/src/modules/engine/picking/picking.ts +12 -10
- package/src/modules/engine/project/project.ts +2 -3
- package/src/modules/engine/transform/transform.ts +1 -3
- package/src/modules/lighting/gouraud-material/gouraud-material.ts +4 -0
- package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +2 -4
- package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +1 -3
- package/src/modules/lighting/lights/lighting-uniforms-wgsl.ts +57 -0
- package/src/modules/lighting/lights/lighting.ts +9 -5
- package/src/modules/lighting/no-material/dirlight.ts +30 -19
- package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +1 -2
- package/src/modules/lighting/pbr-material/pbr-material.ts +44 -38
- package/src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts +1 -3
- package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +1 -3
- package/src/modules/lighting/phong-material/phong-material.ts +6 -3
- package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +2 -4
- package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +132 -0
- package/src/modules/math/fp32/fp32.ts +1 -2
- package/src/modules/math/fp64/fp64-utils.ts +3 -3
- package/src/modules/math/random/random.ts +1 -2
- package/src/modules/module-injectors.ts +2 -4
- package/src/modules/postprocessing/image-adjust-filters/brightnesscontrast.ts +6 -2
- package/src/modules/postprocessing/image-adjust-filters/denoise.ts +7 -3
- package/src/modules/postprocessing/image-adjust-filters/huesaturation.ts +9 -4
- package/src/modules/postprocessing/image-adjust-filters/noise.ts +6 -2
- package/src/modules/postprocessing/image-adjust-filters/sepia.ts +6 -2
- package/src/modules/postprocessing/image-adjust-filters/vibrance.ts +5 -2
- package/src/modules/postprocessing/image-adjust-filters/vignette.ts +11 -4
- package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +6 -2
- package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +6 -2
- package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +5 -0
- package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +6 -2
- package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +6 -2
- package/src/modules/postprocessing/image-fun-filters/edgework.ts +10 -4
- package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +6 -2
- package/src/modules/postprocessing/image-fun-filters/ink.ts +8 -3
- package/src/modules/postprocessing/image-fun-filters/magnify.ts +3 -2
- package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +6 -2
- package/src/modules/postprocessing/image-warp-filters/swirl.ts +8 -2
- package/src/modules/postprocessing/image-warp-filters/warp.ts +3 -2
- package/src/modules-webgl1/geometry/geometry.ts +2 -3
- package/src/modules-webgl1/lighting/dirlight/dirlight.ts +3 -4
- package/src/modules-webgl1/lighting/lights/lights-glsl.ts +1 -3
- package/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts +1 -2
- package/src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts +1 -3
- package/src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts +1 -3
- package/src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts +1 -3
- package/src/modules-webgl1/math/fp64/fp64-functions-glsl.ts +1 -3
- package/src/modules-webgl1/project/project.ts +1 -2
- package/dist/lib/glsl-utils/highlight.d.ts +0 -6
- package/dist/lib/glsl-utils/highlight.d.ts.map +0 -1
- package/dist/lib/glsl-utils/highlight.js +0 -9
- package/dist/lib/shader-assembly/resolve-modules.d.ts +0 -40
- package/dist/lib/shader-assembly/resolve-modules.d.ts.map +0 -1
- package/dist/lib/shader-module/normalize-shader-module.d.ts +0 -3
- package/dist/lib/shader-module/normalize-shader-module.d.ts.map +0 -1
- package/dist/lib/shader-module/normalize-shader-module.js +0 -14
- package/dist/lib/shader-module/shader-module-instance.d.ts +0 -28
- package/dist/lib/shader-module/shader-module-instance.d.ts.map +0 -1
- package/dist/lib/shader-module/shader-module-instance.js +0 -126
- package/src/lib/glsl-utils/highlight.ts +0 -11
- package/src/lib/shader-assembly/resolve-modules.ts +0 -81
- package/src/lib/shader-module/normalize-shader-module.ts +0 -17
- package/src/lib/shader-module/shader-module-instance.ts +0 -167
package/dist/lib/{shader-assembly/resolve-modules.js → shader-module/shader-module-dependencies.js}
RENAMED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import {
|
|
5
|
-
/**
|
|
6
|
-
* Instantiate shader modules and esolve any dependencies
|
|
7
|
-
*/
|
|
8
|
-
export function resolveModules(modules) {
|
|
9
|
-
const instances = ShaderModuleInstance.instantiateModules(modules);
|
|
10
|
-
return getShaderDependencies(instances);
|
|
11
|
-
}
|
|
4
|
+
import { initializeShaderModules } from "./shader-module.js";
|
|
12
5
|
/**
|
|
13
6
|
* Takes a list of shader module names and returns a new list of
|
|
14
7
|
* shader module names that includes all dependencies, sorted so
|
|
@@ -21,14 +14,17 @@ export function resolveModules(modules) {
|
|
|
21
14
|
* @param modules - Array of modules (inline modules or module names)
|
|
22
15
|
* @return - Array of modules
|
|
23
16
|
*/
|
|
24
|
-
function
|
|
17
|
+
export function getShaderModuleDependencies(modules) {
|
|
18
|
+
initializeShaderModules(modules);
|
|
25
19
|
const moduleMap = {};
|
|
26
20
|
const moduleDepth = {};
|
|
27
21
|
getDependencyGraph({ modules, level: 0, moduleMap, moduleDepth });
|
|
28
22
|
// Return a reverse sort so that dependencies come before the modules that use them
|
|
29
|
-
|
|
23
|
+
const dependencies = Object.keys(moduleDepth)
|
|
30
24
|
.sort((a, b) => moduleDepth[b] - moduleDepth[a])
|
|
31
25
|
.map(name => moduleMap[name]);
|
|
26
|
+
initializeShaderModules(dependencies);
|
|
27
|
+
return dependencies;
|
|
32
28
|
}
|
|
33
29
|
/**
|
|
34
30
|
* Recursively checks module dependencies to calculate dependency level of each module.
|
|
@@ -59,7 +55,35 @@ export function getDependencyGraph(options) {
|
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Takes a list of shader module names and returns a new list of
|
|
60
|
+
* shader module names that includes all dependencies, sorted so
|
|
61
|
+
* that modules that are dependencies of other modules come first.
|
|
62
|
+
*
|
|
63
|
+
* If the shader glsl code from the returned modules is concatenated
|
|
64
|
+
* in the reverse order, it is guaranteed that all functions be resolved and
|
|
65
|
+
* that all function and variable definitions come before use.
|
|
66
|
+
*
|
|
67
|
+
* @param modules - Array of modules (inline modules or module names)
|
|
68
|
+
* @return - Array of modules
|
|
69
|
+
*/
|
|
70
|
+
export function getShaderDependencies(modules) {
|
|
71
|
+
initializeShaderModules(modules);
|
|
72
|
+
const moduleMap = {};
|
|
73
|
+
const moduleDepth = {};
|
|
74
|
+
getDependencyGraph({ modules, level: 0, moduleMap, moduleDepth });
|
|
75
|
+
// Return a reverse sort so that dependencies come before the modules that use them
|
|
76
|
+
modules = Object.keys(moduleDepth)
|
|
77
|
+
.sort((a, b) => moduleDepth[b] - moduleDepth[a])
|
|
78
|
+
.map(name => moduleMap[name]);
|
|
79
|
+
initializeShaderModules(modules);
|
|
80
|
+
return modules;
|
|
81
|
+
}
|
|
82
|
+
// DEPRECATED
|
|
83
|
+
/**
|
|
84
|
+
* Instantiate shader modules and resolve any dependencies
|
|
85
|
+
* @deprecated Use getShaderDpendencies
|
|
86
|
+
*/
|
|
87
|
+
export function resolveModules(modules) {
|
|
88
|
+
return getShaderDependencies(modules);
|
|
89
|
+
}
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import type { NumericArray } from '@math.gl/types';
|
|
2
|
+
import { Sampler, Texture } from '@luma.gl/core';
|
|
3
|
+
import type { UniformFormat } from "../../types.js";
|
|
4
|
+
import { PropType, PropValidator } from "../filters/prop-types.js";
|
|
5
|
+
import { ShaderInjection } from "../shader-assembly/shader-injections.js";
|
|
6
|
+
export type BindingValue = Buffer | Texture | Sampler;
|
|
7
|
+
export type UniformValue = number | boolean | Readonly<NumericArray>;
|
|
5
8
|
export type UniformInfo = {
|
|
6
9
|
format?: UniformFormat;
|
|
7
10
|
} & PropType;
|
|
8
11
|
/**
|
|
9
12
|
* A shader module definition object
|
|
10
|
-
*
|
|
13
|
+
*
|
|
14
|
+
* @note Needs to be initialized with `initializeShaderModules`
|
|
11
15
|
*/
|
|
12
|
-
export type ShaderModule<PropsT extends Record<string, unknown> = Record<string, unknown>, UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>, BindingsT extends Record<string,
|
|
16
|
+
export type ShaderModule<PropsT extends Record<string, unknown> = Record<string, unknown>, UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>, BindingsT extends Record<string, BindingValue> = Record<string, BindingValue>> = {
|
|
13
17
|
/** Used for type inference not for values */
|
|
14
|
-
props?:
|
|
18
|
+
props?: PropsT;
|
|
15
19
|
/** Used for type inference, not currently used for values */
|
|
16
20
|
uniforms?: UniformsT;
|
|
17
21
|
name: string;
|
|
22
|
+
/** WGSL code */
|
|
23
|
+
source?: string;
|
|
24
|
+
/** GLSL fragment shader code */
|
|
18
25
|
fs?: string;
|
|
26
|
+
/** GLSL vertex shader code */
|
|
19
27
|
vs?: string;
|
|
20
28
|
/** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */
|
|
21
29
|
uniformTypes?: Record<keyof UniformsT, UniformFormat>;
|
|
@@ -23,8 +31,8 @@ export type ShaderModule<PropsT extends Record<string, unknown> = Record<string,
|
|
|
23
31
|
uniformPropTypes?: Record<keyof UniformsT, UniformInfo>;
|
|
24
32
|
/** Default uniform values */
|
|
25
33
|
defaultUniforms?: Required<UniformsT>;
|
|
26
|
-
/** Function that maps
|
|
27
|
-
getUniforms?: (
|
|
34
|
+
/** Function that maps props to uniforms & bindings */
|
|
35
|
+
getUniforms?: (props?: any, oldProps?: any) => Record<string, BindingValue | UniformValue>;
|
|
28
36
|
/** uniform buffers, textures, samplers, storage, ... */
|
|
29
37
|
bindings?: Record<keyof BindingsT, {
|
|
30
38
|
location: number;
|
|
@@ -39,8 +47,15 @@ export type ShaderModule<PropsT extends Record<string, unknown> = Record<string,
|
|
|
39
47
|
dependencies?: ShaderModule<any, any>[];
|
|
40
48
|
/** Information on deprecated properties */
|
|
41
49
|
deprecations?: ShaderModuleDeprecation[];
|
|
42
|
-
/**
|
|
43
|
-
|
|
50
|
+
/** The instance field contains information that is generated at run-time */
|
|
51
|
+
instance?: {
|
|
52
|
+
propValidators?: Record<string, PropValidator>;
|
|
53
|
+
parsedDeprecations: ShaderModuleDeprecation[];
|
|
54
|
+
normalizedInjections: {
|
|
55
|
+
vertex: Record<string, ShaderInjection>;
|
|
56
|
+
fragment: Record<string, ShaderInjection>;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
44
59
|
};
|
|
45
60
|
/** Use to generate deprecations when shader module is used */
|
|
46
61
|
export type ShaderModuleDeprecation = {
|
|
@@ -50,6 +65,9 @@ export type ShaderModuleDeprecation = {
|
|
|
50
65
|
old: string;
|
|
51
66
|
deprecated?: boolean;
|
|
52
67
|
};
|
|
68
|
+
export declare function initializeShaderModules(modules: ShaderModule[]): void;
|
|
69
|
+
export declare function initializeShaderModule(module: ShaderModule): void;
|
|
53
70
|
/** Convert module props to uniforms */
|
|
54
|
-
export declare function getShaderModuleUniforms<ShaderModuleT extends ShaderModule<Record<string, unknown>, Record<string, UniformValue>>>(module: ShaderModuleT, props: ShaderModuleT['props']
|
|
71
|
+
export declare function getShaderModuleUniforms<ShaderModuleT extends ShaderModule<Record<string, unknown>, Record<string, UniformValue>>>(module: ShaderModuleT, props: ShaderModuleT['props'], oldUniforms?: ShaderModuleT['uniforms']): Record<string, BindingValue | UniformValue>;
|
|
72
|
+
export declare function checkShaderModuleDeprecations(shaderModule: ShaderModule, shaderSource: string, log: any): void;
|
|
55
73
|
//# sourceMappingURL=shader-module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-module.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-module.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,15 +1,85 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { makePropValidators, getValidatedProperties } from "../filters/prop-types.js";
|
|
5
|
+
import { normalizeInjections } from "../shader-assembly/shader-injections.js";
|
|
6
|
+
// SHNDER MODULE API
|
|
7
|
+
export function initializeShaderModules(modules) {
|
|
8
|
+
modules.map((module) => initializeShaderModule(module));
|
|
9
|
+
}
|
|
10
|
+
export function initializeShaderModule(module) {
|
|
11
|
+
if (module.instance) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
initializeShaderModules(module.dependencies || []);
|
|
15
|
+
const { uniformPropTypes = {}, deprecations = [],
|
|
16
|
+
// defines = {},
|
|
17
|
+
inject = {} } = module;
|
|
18
|
+
const instance = {
|
|
19
|
+
normalizedInjections: normalizeInjections(inject),
|
|
20
|
+
parsedDeprecations: parseDeprecationDefinitions(deprecations)
|
|
21
|
+
};
|
|
22
|
+
if (uniformPropTypes) {
|
|
23
|
+
instance.propValidators = makePropValidators(uniformPropTypes);
|
|
24
|
+
}
|
|
25
|
+
module.instance = instance;
|
|
26
|
+
}
|
|
4
27
|
/** Convert module props to uniforms */
|
|
5
|
-
export function getShaderModuleUniforms(module, props) {
|
|
6
|
-
|
|
28
|
+
export function getShaderModuleUniforms(module, props, oldUniforms) {
|
|
29
|
+
initializeShaderModule(module);
|
|
30
|
+
const uniforms = oldUniforms || { ...module.defaultUniforms };
|
|
31
|
+
// If module has a getUniforms function, use it
|
|
7
32
|
if (module.getUniforms) {
|
|
8
|
-
|
|
9
|
-
Object.assign(props, module.getUniforms(props));
|
|
33
|
+
return module.getUniforms(props, uniforms);
|
|
10
34
|
}
|
|
11
|
-
|
|
12
|
-
|
|
35
|
+
// Build uniforms from the uniforms array
|
|
36
|
+
// @ts-expect-error
|
|
37
|
+
return getValidatedProperties(props, module.instance?.propValidators, module.name);
|
|
38
|
+
}
|
|
39
|
+
/* TODO this looks like it was unused code
|
|
40
|
+
_defaultGetUniforms(opts: Record<string, any> = {}): Record<string, any> {
|
|
41
|
+
const uniforms: Record<string, any> = {};
|
|
42
|
+
const propTypes = this.uniforms;
|
|
43
|
+
|
|
44
|
+
for (const key in propTypes) {
|
|
45
|
+
const propDef = propTypes[key];
|
|
46
|
+
if (key in opts && !propDef.private) {
|
|
47
|
+
if (propDef.validate) {
|
|
48
|
+
assert(propDef.validate(opts[key], propDef), `${this.name}: invalid ${key}`);
|
|
49
|
+
}
|
|
50
|
+
uniforms[key] = opts[key];
|
|
51
|
+
} else {
|
|
52
|
+
uniforms[key] = propDef.value;
|
|
53
|
+
}
|
|
13
54
|
}
|
|
55
|
+
|
|
14
56
|
return uniforms;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
*/
|
|
60
|
+
// Warn about deprecated uniforms or functions
|
|
61
|
+
export function checkShaderModuleDeprecations(shaderModule, shaderSource, log) {
|
|
62
|
+
shaderModule.deprecations?.forEach(def => {
|
|
63
|
+
if (def.regex?.test(shaderSource)) {
|
|
64
|
+
if (def.deprecated) {
|
|
65
|
+
log.deprecated(def.old, def.new)();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
log.removed(def.old, def.new)();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// HELPERS
|
|
74
|
+
function parseDeprecationDefinitions(deprecations) {
|
|
75
|
+
deprecations.forEach(def => {
|
|
76
|
+
switch (def.type) {
|
|
77
|
+
case 'function':
|
|
78
|
+
def.regex = new RegExp(`\\b${def.old}\\(`);
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
def.regex = new RegExp(`${def.type} ${def.old};`);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return deprecations;
|
|
15
85
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ShaderModule, UniformValue } from "./shader-module.js";
|
|
2
2
|
/**
|
|
3
|
-
* A
|
|
4
|
-
* on how to run
|
|
3
|
+
* A ShaderPass is a ShaderModule that can be run "standalone" (e.g. post processing effects)
|
|
4
|
+
* It adds additional information on how to run the module in one or more passes.
|
|
5
5
|
*/
|
|
6
6
|
export type ShaderPass<PropsT extends Record<string, unknown> = Record<string, unknown>, UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>> = ShaderModule<PropsT, UniformsT> & {
|
|
7
7
|
passes: ShaderPassData[];
|
|
8
8
|
};
|
|
9
|
+
/** Information on how to run a specific pass */
|
|
9
10
|
type ShaderPassData = {
|
|
10
11
|
sampler?: boolean;
|
|
11
12
|
filter?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-pass.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-pass.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,2BAAwB;AAEhE;;;GAGG;AACH,MAAM,MAAM,UAAU,CACpB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,IAC3E,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG;IACpC,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACzC,CAAC"}
|
|
1
|
+
{"version":3,"file":"shader-pass.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-pass.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,2BAAwB;AAEhE;;;GAGG;AACH,MAAM,MAAM,UAAU,CACpB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,IAC3E,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG;IACpC,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B,CAAC;AAEF,gDAAgD;AAChD,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACzC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const MODULE_INJECTORS_VS
|
|
2
|
-
export declare const MODULE_INJECTORS_FS
|
|
1
|
+
export declare const MODULE_INJECTORS_VS = "#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n";
|
|
2
|
+
export declare const MODULE_INJECTORS_FS = "#ifdef MODULE_MATERIAL\n gl_FragColor = material_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n gl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_FOG\n gl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_PICKING\n gl_FragColor = picking_filterHighlightColor(gl_FragColor);\n gl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n";
|
|
3
3
|
//# sourceMappingURL=module-injectors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-injectors.d.ts","sourceRoot":"","sources":["../src/module-injectors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-injectors.d.ts","sourceRoot":"","sources":["../src/module-injectors.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,8EAI/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,0dAqB/B,CAAC"}
|
package/dist/module-injectors.js
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
export const MODULE_INJECTORS_VS = `\
|
|
4
|
+
export const MODULE_INJECTORS_VS = /* glsl */ `\
|
|
6
5
|
#ifdef MODULE_LOGDEPTH
|
|
7
|
-
logdepth_adjustPosition(gl_Position);
|
|
6
|
+
logdepth_adjustPosition(gl_Position);
|
|
8
7
|
#endif
|
|
9
8
|
`;
|
|
10
|
-
export const MODULE_INJECTORS_FS = `\
|
|
9
|
+
export const MODULE_INJECTORS_FS = /* glsl */ `\
|
|
11
10
|
#ifdef MODULE_MATERIAL
|
|
12
|
-
gl_FragColor = material_filterColor(gl_FragColor);
|
|
11
|
+
gl_FragColor = material_filterColor(gl_FragColor);
|
|
13
12
|
#endif
|
|
13
|
+
|
|
14
14
|
#ifdef MODULE_LIGHTING
|
|
15
|
-
gl_FragColor = lighting_filterColor(gl_FragColor);
|
|
15
|
+
gl_FragColor = lighting_filterColor(gl_FragColor);
|
|
16
16
|
#endif
|
|
17
|
+
|
|
17
18
|
#ifdef MODULE_FOG
|
|
18
|
-
gl_FragColor = fog_filterColor(gl_FragColor);
|
|
19
|
+
gl_FragColor = fog_filterColor(gl_FragColor);
|
|
19
20
|
#endif
|
|
21
|
+
|
|
20
22
|
#ifdef MODULE_PICKING
|
|
21
|
-
gl_FragColor = picking_filterHighlightColor(gl_FragColor);
|
|
22
|
-
gl_FragColor = picking_filterPickingColor(gl_FragColor);
|
|
23
|
+
gl_FragColor = picking_filterHighlightColor(gl_FragColor);
|
|
24
|
+
gl_FragColor = picking_filterPickingColor(gl_FragColor);
|
|
23
25
|
#endif
|
|
26
|
+
|
|
24
27
|
#ifdef MODULE_LOGDEPTH
|
|
25
|
-
logdepth_setFragDepth();
|
|
28
|
+
logdepth_setFragDepth();
|
|
26
29
|
#endif
|
|
27
30
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/geometry/geometry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/geometry/geometry.ts"],"names":[],"mappings":"AAqCA;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC"}
|
|
@@ -2,29 +2,33 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// import {ShaderModule} from '../../types';
|
|
5
|
-
import { glsl } from "../../../lib/glsl-utils/highlight.js";
|
|
6
5
|
// TODO - reuse normal from geometry module
|
|
7
|
-
const vs = `\
|
|
6
|
+
const vs = /* glsl */ `\
|
|
8
7
|
varying vec4 geometry_vPosition;
|
|
9
8
|
varying vec3 geometry_vNormal;
|
|
9
|
+
|
|
10
10
|
void geometry_setNormal(vec3 normal) {
|
|
11
|
-
geometry_vNormal = normal;
|
|
11
|
+
geometry_vNormal = normal;
|
|
12
12
|
}
|
|
13
|
+
|
|
13
14
|
void geometry_setPosition(vec4 position) {
|
|
14
|
-
geometry_vPosition = position;
|
|
15
|
+
geometry_vPosition = position;
|
|
15
16
|
}
|
|
17
|
+
|
|
16
18
|
void geometry_setPosition(vec3 position) {
|
|
17
|
-
geometry_vPosition = vec4(position, 1.);
|
|
19
|
+
geometry_vPosition = vec4(position, 1.);
|
|
18
20
|
}
|
|
19
21
|
`;
|
|
20
|
-
const fs = `\
|
|
22
|
+
const fs = /* glsl */ `\
|
|
21
23
|
varying vec4 geometry_vPosition;
|
|
22
24
|
varying vec3 geometry_vNormal;
|
|
25
|
+
|
|
23
26
|
vec4 geometry_getPosition() {
|
|
24
|
-
return geometry_vPosition;
|
|
27
|
+
return geometry_vPosition;
|
|
25
28
|
}
|
|
29
|
+
|
|
26
30
|
vec3 geometry_getNormal() {
|
|
27
|
-
return geometry_vNormal;
|
|
31
|
+
return geometry_vNormal;
|
|
28
32
|
}
|
|
29
33
|
`;
|
|
30
34
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NumericArray } from "../../../types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Props for the picking module, which depending on mode renders picking colors or highlighted item.
|
|
4
4
|
* When active, renders picking colors, assumed to be rendered to off-screen "picking" buffer.
|
|
@@ -10,9 +10,9 @@ export type PickingProps = {
|
|
|
10
10
|
/** Set to true when picking an attribute value instead of object index */
|
|
11
11
|
isAttribute?: boolean;
|
|
12
12
|
/** Set to a picking color to visually highlight that item, or `null` to explicitly clear **/
|
|
13
|
-
highlightedObjectColor?:
|
|
13
|
+
highlightedObjectColor?: NumericArray | null;
|
|
14
14
|
/** Color of visual highlight of "selected" item */
|
|
15
|
-
highlightColor?:
|
|
15
|
+
highlightColor?: NumericArray;
|
|
16
16
|
/** Color range 0-1 or 0-255 */
|
|
17
17
|
useFloatColors?: boolean;
|
|
18
18
|
};
|
|
@@ -34,9 +34,9 @@ export type PickingUniforms = {
|
|
|
34
34
|
/** Do we have a highlighted item? */
|
|
35
35
|
isHighlightActive?: boolean;
|
|
36
36
|
/** Set to a picking color to visually highlight that item */
|
|
37
|
-
highlightedObjectColor?:
|
|
37
|
+
highlightedObjectColor?: NumericArray;
|
|
38
38
|
/** Color of visual highlight of "selected" item */
|
|
39
|
-
highlightColor?:
|
|
39
|
+
highlightColor?: NumericArray;
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
42
42
|
* Provides support for color-coding-based picking and highlighting.
|
|
@@ -46,6 +46,8 @@ export type PickingUniforms = {
|
|
|
46
46
|
* primitives with the same picking color in non-instanced draw-calls
|
|
47
47
|
*/
|
|
48
48
|
export declare const picking: {
|
|
49
|
+
readonly props: PickingProps;
|
|
50
|
+
readonly uniforms: PickingUniforms;
|
|
49
51
|
readonly name: "picking";
|
|
50
52
|
readonly uniformTypes: {
|
|
51
53
|
readonly isActive: "f32";
|
|
@@ -63,10 +65,8 @@ export declare const picking: {
|
|
|
63
65
|
readonly highlightedObjectColor: Float32Array;
|
|
64
66
|
readonly highlightColor: Float32Array;
|
|
65
67
|
};
|
|
66
|
-
readonly vs:
|
|
67
|
-
readonly fs:
|
|
68
|
-
readonly props: Required<PickingProps>;
|
|
69
|
-
readonly uniforms: PickingUniforms;
|
|
68
|
+
readonly vs: "uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useFloatColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nout vec4 picking_vRGBcolor_Avalid;\n\n// Normalize unsigned byte color to 0-1 range\nvec3 picking_normalizeColor(vec3 color) {\n return picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\n\n// Normalize unsigned byte color to 0-1 range\nvec4 picking_normalizeColor(vec4 color) {\n return picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\n\nbool picking_isColorZero(vec3 color) {\n return dot(color, vec3(1.0)) < 0.00001;\n}\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.00001;\n}\n\n// Check if this vertex is highlighted \nbool isVertexHighlighted(vec3 vertexColor) {\n vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n return\n bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\n\n// Set the current picking color\nvoid picking_setPickingColor(vec3 pickingColor) {\n pickingColor = picking_normalizeColor(pickingColor);\n\n if (bool(picking.isActive)) {\n // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!bool(picking.isAttribute)) {\n // Stores the picking color so that the fragment shader can render it during picking\n picking_vRGBcolor_Avalid.rgb = pickingColor;\n }\n } else {\n // Do the comparison with selected item color in vertex shader as it should mean fewer compares\n picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec2 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec3 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n";
|
|
69
|
+
readonly fs: "uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useFloatColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nin vec4 picking_vRGBcolor_Avalid;\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 picking_filterHighlightColor(vec4 color) {\n // If we are still picking, we don't highlight\n if (picking.isActive > 0.5) {\n return color;\n }\n\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n // Blend in highlight color based on its alpha value\n float highLightAlpha = picking.highlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 picking_filterPickingColor(vec4 color) {\n if (bool(picking.isActive)) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 picking_filterColor(vec4 color) {\n vec4 highlightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highlightColor);\n}\n";
|
|
70
70
|
readonly getUniforms: typeof getUniforms;
|
|
71
71
|
};
|
|
72
72
|
declare function getUniforms(opts?: PickingProps, prevUniforms?: PickingUniforms): PickingUniforms;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picking.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/picking/picking.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"picking.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/picking/picking.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,0BAAuB;AAM5C;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,6FAA6F;IAC7F,sBAAsB,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7C,mDAAmD;IACnD,cAAc,CAAC,EAAE,YAAY,CAAC;IAC9B,+BAA+B;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+BAA+B;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qCAAqC;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,6DAA6D;IAC7D,sBAAsB,CAAC,EAAE,YAAY,CAAC;IACtC,mDAAmD;IACnD,cAAc,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAC;AAuIF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO;oBACL,YAAY;uBACT,eAAe;;;;;;;;;;;;;;;;;;;;;CAwB+B,CAAC;AAEjE,iBAAS,WAAW,CAAC,IAAI,GAAE,YAAiB,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,eAAe,CA+B7F"}
|