@luma.gl/shadertools 9.0.0-beta.4 → 9.0.0-beta.5
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 +500 -695
- package/dist/index.cjs +119 -225
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +69 -50
- package/dist/lib/filters/prop-types.js +80 -67
- package/dist/lib/glsl-utils/get-shader-info.js +25 -22
- package/dist/lib/glsl-utils/highlight.js +8 -2
- package/dist/lib/glsl-utils/shader-utils.d.ts +1 -2
- package/dist/lib/glsl-utils/shader-utils.d.ts.map +1 -1
- package/dist/lib/glsl-utils/shader-utils.js +67 -90
- package/dist/lib/shader-assembler.js +82 -63
- package/dist/lib/shader-assembly/assemble-shaders.js +320 -223
- package/dist/lib/shader-assembly/platform-defines.js +39 -32
- package/dist/lib/shader-assembly/platform-info.js +2 -1
- package/dist/lib/shader-assembly/resolve-modules.js +54 -38
- package/dist/lib/shader-assembly/select-shaders.js +35 -29
- package/dist/lib/shader-assembly/shader-hooks.js +53 -51
- package/dist/lib/shader-assembly/shader-injections.js +107 -87
- package/dist/lib/shader-generator/generate-shader.js +11 -9
- package/dist/lib/shader-generator/glsl/generate-glsl.js +66 -58
- package/dist/lib/shader-generator/utils/capitalize.js +8 -2
- package/dist/lib/shader-generator/wgsl/generate-wgsl.js +14 -12
- package/dist/lib/shader-module/normalize-shader-module.js +10 -9
- package/dist/lib/shader-module/shader-module-instance.js +109 -113
- package/dist/lib/shader-module/shader-module.js +2 -1
- package/dist/lib/shader-module/shader-pass.js +2 -1
- package/dist/lib/shader-transpiler/transpile-glsl-shader.d.ts +1 -1
- package/dist/lib/shader-transpiler/transpile-glsl-shader.d.ts.map +1 -1
- package/dist/lib/shader-transpiler/transpile-glsl-shader.js +59 -53
- package/dist/lib/utils/assert.js +7 -4
- package/dist/lib/wgsl/get-shader-layout-wgsl.js +56 -50
- package/dist/libs/wgsl-reflect/wgsl_reflect.module.js +3207 -2414
- package/dist/module-injectors.js +5 -4
- package/dist/modules/engine/geometry/geometry.js +13 -7
- package/dist/modules/engine/picking/picking.js +60 -49
- package/dist/modules/engine/project/project.js +52 -35
- package/dist/modules/engine/transform/transform.js +7 -5
- package/dist/modules/lighting/gouraud-material/gouraud-material.js +28 -28
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +42 -0
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +134 -0
- package/dist/modules/lighting/gouraud-material/gouraud-shaders.glsl.js +45 -4
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +2 -0
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +56 -0
- package/dist/modules/lighting/lights/lighting-uniforms.glsl.js +4 -3
- package/dist/modules/lighting/lights/lighting-uniforms.js +128 -128
- package/dist/modules/lighting/no-material/dirlight.js +38 -24
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +2 -0
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +425 -0
- package/dist/modules/lighting/pbr-material/pbr-fragment.glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment.glsl.js +10 -11
- package/dist/modules/lighting/pbr-material/pbr-material.js +56 -69
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +2 -0
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +66 -0
- package/dist/modules/lighting/pbr-material/pbr-uniforms.glsl.js +4 -3
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +2 -0
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +46 -0
- package/dist/modules/lighting/pbr-material/pbr-vertex.glsl.js +4 -3
- package/dist/modules/lighting/phong-material/phong-material.js +28 -28
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +42 -0
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +137 -0
- package/dist/modules/lighting/phong-material/phong-shaders.glsl.js +45 -4
- package/dist/modules/math/fp32/fp32.js +10 -5
- package/dist/modules/math/random/random.js +7 -5
- package/dist/modules/module-injectors.js +5 -4
- package/dist/modules/postprocessing/fxaa/fxaa.js +70 -7
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js +20 -25
- package/dist/modules/postprocessing/image-adjust-filters/denoise.js +20 -21
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js +23 -23
- package/dist/modules/postprocessing/image-adjust-filters/noise.js +17 -18
- package/dist/modules/postprocessing/image-adjust-filters/sepia.js +18 -18
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.js +11 -15
- package/dist/modules/postprocessing/image-adjust-filters/vignette.js +18 -23
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.js +60 -45
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.js +25 -32
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.js +18 -21
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js +22 -27
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.js +20 -27
- package/dist/modules/postprocessing/image-fun-filters/edgework.js +28 -28
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js +19 -23
- package/dist/modules/postprocessing/image-fun-filters/ink.js +19 -18
- package/dist/modules/postprocessing/image-fun-filters/magnify.js +24 -25
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js +21 -28
- package/dist/modules/postprocessing/image-warp-filters/swirl.js +20 -28
- package/dist/modules/postprocessing/image-warp-filters/warp.js +7 -6
- package/dist/modules-webgl1/geometry/geometry.js +11 -7
- package/dist/modules-webgl1/lighting/dirlight/dirlight.js +19 -16
- package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +2 -0
- package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +1 -0
- package/dist/modules-webgl1/lighting/lights/lights-glsl.js +37 -0
- package/dist/modules-webgl1/lighting/lights/lights.glsl.js +2 -3
- package/dist/modules-webgl1/lighting/lights/lights.js +80 -86
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +2 -0
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +1 -0
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +401 -0
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment.glsl.d.ts.map +1 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment.glsl.js +10 -11
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +2 -0
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +1 -0
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +40 -0
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex.glsl.js +2 -3
- package/dist/modules-webgl1/lighting/pbr/pbr.js +14 -11
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +2 -0
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +1 -0
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +76 -0
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.glsl.js +2 -3
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js +31 -42
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +2 -0
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -0
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +169 -0
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic.glsl.js +3 -3
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +2 -0
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +1 -0
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +673 -0
- package/dist/modules-webgl1/math/fp64/fp64-functions.glsl.js +3 -3
- package/dist/modules-webgl1/math/fp64/fp64-utils.js +32 -17
- package/dist/modules-webgl1/math/fp64/fp64.js +25 -18
- package/dist/modules-webgl1/project/project.js +35 -31
- package/dist/types.js +3 -2
- package/dist.min.js +1985 -4986
- package/package.json +8 -6
- package/src/lib/glsl-utils/shader-utils.ts +6 -24
- package/src/lib/shader-assembly/assemble-shaders.ts +1 -1
- package/src/lib/shader-transpiler/transpile-glsl-shader.ts +9 -78
- package/src/modules/lighting/gouraud-material/gouraud-material.ts +1 -1
- package/src/modules/lighting/lights/lighting-uniforms.ts +1 -1
- package/src/modules/lighting/pbr-material/{pbr-fragment.glsl.ts → pbr-fragment-glsl.ts} +2 -8
- package/src/modules/lighting/pbr-material/pbr-material.ts +2 -2
- package/src/modules/lighting/phong-material/phong-material.ts +1 -1
- package/src/modules-webgl1/lighting/lights/lights.ts +1 -1
- package/src/modules-webgl1/lighting/pbr/{pbr-fragment.glsl.ts → pbr-fragment-glsl.ts} +2 -8
- package/src/modules-webgl1/lighting/pbr/pbr.ts +2 -2
- package/src/modules-webgl1/lighting/phong-lighting/phong-lighting.ts +1 -1
- package/src/modules-webgl1/math/fp64/fp64-utils.ts +1 -1
- package/src/modules-webgl1/math/fp64/fp64.ts +2 -2
- package/dist/index.js.map +0 -1
- package/dist/lib/filters/prop-types.js.map +0 -1
- package/dist/lib/glsl-utils/get-shader-info.js.map +0 -1
- package/dist/lib/glsl-utils/highlight.js.map +0 -1
- package/dist/lib/glsl-utils/shader-utils.js.map +0 -1
- package/dist/lib/shader-assembler.js.map +0 -1
- package/dist/lib/shader-assembly/assemble-shaders.js.map +0 -1
- package/dist/lib/shader-assembly/platform-defines.js.map +0 -1
- package/dist/lib/shader-assembly/platform-info.js.map +0 -1
- package/dist/lib/shader-assembly/resolve-modules.js.map +0 -1
- package/dist/lib/shader-assembly/select-shaders.js.map +0 -1
- package/dist/lib/shader-assembly/shader-hooks.js.map +0 -1
- package/dist/lib/shader-assembly/shader-injections.js.map +0 -1
- package/dist/lib/shader-generator/generate-shader.js.map +0 -1
- package/dist/lib/shader-generator/glsl/generate-glsl.js.map +0 -1
- package/dist/lib/shader-generator/utils/capitalize.js.map +0 -1
- package/dist/lib/shader-generator/wgsl/generate-wgsl.js.map +0 -1
- package/dist/lib/shader-module/normalize-shader-module.js.map +0 -1
- package/dist/lib/shader-module/shader-module-instance.js.map +0 -1
- package/dist/lib/shader-module/shader-module.js.map +0 -1
- package/dist/lib/shader-module/shader-pass.js.map +0 -1
- package/dist/lib/shader-transpiler/transpile-glsl-shader.js.map +0 -1
- package/dist/lib/utils/assert.js.map +0 -1
- package/dist/lib/wgsl/get-shader-layout-wgsl.js.map +0 -1
- package/dist/libs/wgsl-reflect/wgsl_reflect.module.js.map +0 -1
- package/dist/module-injectors.js.map +0 -1
- package/dist/modules/engine/geometry/geometry.js.map +0 -1
- package/dist/modules/engine/picking/README.md +0 -88
- package/dist/modules/engine/picking/picking.js.map +0 -1
- package/dist/modules/engine/project/project.js.map +0 -1
- package/dist/modules/engine/transform/transform.js.map +0 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +0 -1
- package/dist/modules/lighting/gouraud-material/gouraud-shaders.glsl.js.map +0 -1
- package/dist/modules/lighting/lights/lighting-uniforms.glsl.js.map +0 -1
- package/dist/modules/lighting/lights/lighting-uniforms.js.map +0 -1
- package/dist/modules/lighting/no-material/dirlight.js.map +0 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment.glsl.js.map +0 -1
- package/dist/modules/lighting/pbr-material/pbr-material.js.map +0 -1
- package/dist/modules/lighting/pbr-material/pbr-uniforms.glsl.js.map +0 -1
- package/dist/modules/lighting/pbr-material/pbr-vertex.glsl.js.map +0 -1
- package/dist/modules/lighting/phong-material/phong-material.js.map +0 -1
- package/dist/modules/lighting/phong-material/phong-shaders.glsl.js.map +0 -1
- package/dist/modules/math/fp32/fp32.js.map +0 -1
- package/dist/modules/math/random/random.js.map +0 -1
- package/dist/modules/module-injectors.js.map +0 -1
- package/dist/modules/postprocessing/fxaa/fxaa.js.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/brightnesscontrast.js.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/denoise.js.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/huesaturation.js.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/noise.js.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/sepia.js.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/vibrance.js.map +0 -1
- package/dist/modules/postprocessing/image-adjust-filters/vignette.js.map +0 -1
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.js.map +0 -1
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.js.map +0 -1
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.js.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.js.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.js.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/edgework.js.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.js.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/ink.js.map +0 -1
- package/dist/modules/postprocessing/image-fun-filters/magnify.js.map +0 -1
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.js.map +0 -1
- package/dist/modules/postprocessing/image-warp-filters/swirl.js.map +0 -1
- package/dist/modules/postprocessing/image-warp-filters/warp.js.map +0 -1
- package/dist/modules-webgl1/geometry/geometry.js.map +0 -1
- package/dist/modules-webgl1/lighting/dirlight/dirlight.js.map +0 -1
- package/dist/modules-webgl1/lighting/lights/lights.glsl.js.map +0 -1
- package/dist/modules-webgl1/lighting/lights/lights.js.map +0 -1
- package/dist/modules-webgl1/lighting/pbr/README.md +0 -12
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment.glsl.js.map +0 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex.glsl.js.map +0 -1
- package/dist/modules-webgl1/lighting/pbr/pbr.js.map +0 -1
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.glsl.js.map +0 -1
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js.map +0 -1
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic.glsl.js.map +0 -1
- package/dist/modules-webgl1/math/fp64/fp64-functions.glsl.js.map +0 -1
- package/dist/modules-webgl1/math/fp64/fp64-utils.js.map +0 -1
- package/dist/modules-webgl1/math/fp64/fp64.js.map +0 -1
- package/dist/modules-webgl1/project/README.md +0 -52
- package/dist/modules-webgl1/project/project.js.map +0 -1
- package/dist/types.js.map +0 -1
- /package/src/modules/lighting/gouraud-material/{gouraud-shaders.glsl.ts → gouraud-shaders-glsl.ts} +0 -0
- /package/src/modules/lighting/lights/{lighting-uniforms.glsl.ts → lighting-uniforms-glsl.ts} +0 -0
- /package/src/modules/lighting/pbr-material/{pbr-uniforms.glsl.ts → pbr-uniforms-glsl.ts} +0 -0
- /package/src/modules/lighting/pbr-material/{pbr-vertex.glsl.ts → pbr-vertex-glsl.ts} +0 -0
- /package/src/modules/lighting/phong-material/{phong-shaders.glsl.ts → phong-shaders-glsl.ts} +0 -0
- /package/src/modules-webgl1/lighting/lights/{lights.glsl.ts → lights-glsl.ts} +0 -0
- /package/src/modules-webgl1/lighting/pbr/{pbr-vertex.glsl.ts → pbr-vertex-glsl.ts} +0 -0
- /package/src/modules-webgl1/lighting/phong-lighting/{phong-lighting.glsl.ts → phong-lighting-glsl.ts} +0 -0
- /package/src/modules-webgl1/math/fp64/{fp64-arithmetic.glsl.ts → fp64-arithmetic-glsl.ts} +0 -0
- /package/src/modules-webgl1/math/fp64/{fp64-functions.glsl.ts → fp64-functions-glsl.ts} +0 -0
package/dist/dist.dev.js
CHANGED
|
@@ -10,6 +10,7 @@ var __exports__ = (() => {
|
|
|
10
10
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
14
|
var __export = (target, all) => {
|
|
14
15
|
for (var name in all)
|
|
15
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -23,6 +24,10 @@ var __exports__ = (() => {
|
|
|
23
24
|
return to;
|
|
24
25
|
};
|
|
25
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var __publicField = (obj, key, value) => {
|
|
28
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
26
31
|
|
|
27
32
|
// src/index.ts
|
|
28
33
|
var src_exports = {};
|
|
@@ -133,38 +138,20 @@ var __exports__ = (() => {
|
|
|
133
138
|
function makePropValidator(propType) {
|
|
134
139
|
let type = getTypeOf(propType);
|
|
135
140
|
if (type !== "object") {
|
|
136
|
-
return {
|
|
137
|
-
value: propType,
|
|
138
|
-
...DEFAULT_PROP_VALIDATORS[type],
|
|
139
|
-
type
|
|
140
|
-
};
|
|
141
|
+
return { value: propType, ...DEFAULT_PROP_VALIDATORS[type], type };
|
|
141
142
|
}
|
|
142
143
|
if (typeof propType === "object") {
|
|
143
144
|
if (!propType) {
|
|
144
|
-
return {
|
|
145
|
-
type: "object",
|
|
146
|
-
value: null
|
|
147
|
-
};
|
|
145
|
+
return { type: "object", value: null };
|
|
148
146
|
}
|
|
149
147
|
if (propType.type !== void 0) {
|
|
150
|
-
return {
|
|
151
|
-
...propType,
|
|
152
|
-
...DEFAULT_PROP_VALIDATORS[propType.type],
|
|
153
|
-
type: propType.type
|
|
154
|
-
};
|
|
148
|
+
return { ...propType, ...DEFAULT_PROP_VALIDATORS[propType.type], type: propType.type };
|
|
155
149
|
}
|
|
156
150
|
if (propType.value === void 0) {
|
|
157
|
-
return {
|
|
158
|
-
type: "object",
|
|
159
|
-
value: propType
|
|
160
|
-
};
|
|
151
|
+
return { type: "object", value: propType };
|
|
161
152
|
}
|
|
162
153
|
type = getTypeOf(propType.value);
|
|
163
|
-
return {
|
|
164
|
-
...propType,
|
|
165
|
-
...DEFAULT_PROP_VALIDATORS[type],
|
|
166
|
-
type
|
|
167
|
-
};
|
|
154
|
+
return { ...propType, ...DEFAULT_PROP_VALIDATORS[type], type };
|
|
168
155
|
}
|
|
169
156
|
throw new Error("props");
|
|
170
157
|
}
|
|
@@ -214,10 +201,7 @@ var __exports__ = (() => {
|
|
|
214
201
|
var fragments = [];
|
|
215
202
|
var DECLARATION_INJECT_MARKER = "__LUMA_INJECT_DECLARATIONS__";
|
|
216
203
|
function normalizeInjections(injections) {
|
|
217
|
-
const result = {
|
|
218
|
-
vertex: {},
|
|
219
|
-
fragment: {}
|
|
220
|
-
};
|
|
204
|
+
const result = { vertex: {}, fragment: {} };
|
|
221
205
|
for (const hook in injections) {
|
|
222
206
|
let injection = injections[hook];
|
|
223
207
|
const stage = getHookStage(hook);
|
|
@@ -309,6 +293,14 @@ ${inject[key]}` : inject[key];
|
|
|
309
293
|
// src/lib/shader-module/shader-module-instance.ts
|
|
310
294
|
var index = 1;
|
|
311
295
|
var ShaderModuleInstance = class {
|
|
296
|
+
name;
|
|
297
|
+
vs;
|
|
298
|
+
fs;
|
|
299
|
+
getModuleUniforms;
|
|
300
|
+
dependencies;
|
|
301
|
+
deprecations;
|
|
302
|
+
defines;
|
|
303
|
+
injections;
|
|
312
304
|
uniforms = {};
|
|
313
305
|
uniformTypes = {};
|
|
314
306
|
static instantiateModules(modules) {
|
|
@@ -316,7 +308,10 @@ ${inject[key]}` : inject[key];
|
|
|
316
308
|
if (module instanceof ShaderModuleInstance) {
|
|
317
309
|
return module;
|
|
318
310
|
}
|
|
319
|
-
assert(
|
|
311
|
+
assert(
|
|
312
|
+
typeof module !== "string",
|
|
313
|
+
`Shader module use by name is deprecated. Import shader module '${JSON.stringify(module)}' and use it directly.`
|
|
314
|
+
);
|
|
320
315
|
if (!module.name) {
|
|
321
316
|
console.warn("shader module has no name");
|
|
322
317
|
module.name = `shader-module-${index++}`;
|
|
@@ -351,6 +346,7 @@ ${inject[key]}` : inject[key];
|
|
|
351
346
|
this.uniforms = makePropValidators(uniformPropTypes);
|
|
352
347
|
}
|
|
353
348
|
}
|
|
349
|
+
// Extracts the source code chunk for the specified shader type from the named shader module
|
|
354
350
|
getModuleSource(stage) {
|
|
355
351
|
let moduleSource;
|
|
356
352
|
switch (stage) {
|
|
@@ -380,6 +376,7 @@ ${moduleSource}
|
|
|
380
376
|
getDefines() {
|
|
381
377
|
return this.defines;
|
|
382
378
|
}
|
|
379
|
+
// Warn about deprecated uniforms or functions
|
|
383
380
|
checkDeprecations(shaderSource, log) {
|
|
384
381
|
this.deprecations.forEach((def) => {
|
|
385
382
|
if (def.regex?.test(shaderSource)) {
|
|
@@ -429,21 +426,11 @@ ${moduleSource}
|
|
|
429
426
|
function getShaderDependencies(modules) {
|
|
430
427
|
const moduleMap = {};
|
|
431
428
|
const moduleDepth = {};
|
|
432
|
-
getDependencyGraph({
|
|
433
|
-
modules,
|
|
434
|
-
level: 0,
|
|
435
|
-
moduleMap,
|
|
436
|
-
moduleDepth
|
|
437
|
-
});
|
|
429
|
+
getDependencyGraph({ modules, level: 0, moduleMap, moduleDepth });
|
|
438
430
|
return Object.keys(moduleDepth).sort((a, b) => moduleDepth[b] - moduleDepth[a]).map((name) => moduleMap[name]);
|
|
439
431
|
}
|
|
440
432
|
function getDependencyGraph(options) {
|
|
441
|
-
const {
|
|
442
|
-
modules,
|
|
443
|
-
level,
|
|
444
|
-
moduleMap,
|
|
445
|
-
moduleDepth
|
|
446
|
-
} = options;
|
|
433
|
+
const { modules, level, moduleMap, moduleDepth } = options;
|
|
447
434
|
if (level >= 5) {
|
|
448
435
|
throw new Error("Possible loop in shader dependency graph");
|
|
449
436
|
}
|
|
@@ -455,12 +442,7 @@ ${moduleSource}
|
|
|
455
442
|
}
|
|
456
443
|
for (const module of modules) {
|
|
457
444
|
if (module.dependencies) {
|
|
458
|
-
getDependencyGraph({
|
|
459
|
-
modules: module.dependencies,
|
|
460
|
-
level: level + 1,
|
|
461
|
-
moduleMap,
|
|
462
|
-
moduleDepth
|
|
463
|
-
});
|
|
445
|
+
getDependencyGraph({ modules: module.dependencies, level: level + 1, moduleMap, moduleDepth });
|
|
464
446
|
}
|
|
465
447
|
}
|
|
466
448
|
}
|
|
@@ -567,62 +549,47 @@ ${moduleSource}
|
|
|
567
549
|
}
|
|
568
550
|
|
|
569
551
|
// src/lib/shader-transpiler/transpile-glsl-shader.ts
|
|
570
|
-
function transpileGLSLShader(source,
|
|
552
|
+
function transpileGLSLShader(source, stage) {
|
|
571
553
|
const sourceGLSLVersion = Number(source.match(/^#version[ \t]+(\d+)/m)?.[1] || 100);
|
|
572
554
|
if (sourceGLSLVersion !== 300) {
|
|
573
555
|
throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");
|
|
574
556
|
}
|
|
575
|
-
switch (
|
|
576
|
-
case
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
source = convertShader(source, ES300_FRAGMENT_REPLACEMENTS);
|
|
583
|
-
return source;
|
|
584
|
-
default:
|
|
585
|
-
throw new Error(stage);
|
|
586
|
-
}
|
|
587
|
-
case 100:
|
|
588
|
-
switch (stage) {
|
|
589
|
-
case "vertex":
|
|
590
|
-
source = convertShader(source, ES100_VERTEX_REPLACEMENTS);
|
|
591
|
-
return source;
|
|
592
|
-
case "fragment":
|
|
593
|
-
source = convertShader(source, ES100_FRAGMENT_REPLACEMENTS);
|
|
594
|
-
source = convertFragmentShaderTo100(source);
|
|
595
|
-
return source;
|
|
596
|
-
default:
|
|
597
|
-
throw new Error(stage);
|
|
598
|
-
}
|
|
557
|
+
switch (stage) {
|
|
558
|
+
case "vertex":
|
|
559
|
+
source = convertShader(source, ES300_VERTEX_REPLACEMENTS);
|
|
560
|
+
return source;
|
|
561
|
+
case "fragment":
|
|
562
|
+
source = convertShader(source, ES300_FRAGMENT_REPLACEMENTS);
|
|
563
|
+
return source;
|
|
599
564
|
default:
|
|
600
|
-
throw new Error(
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
var ES300_REPLACEMENTS = [
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
var
|
|
565
|
+
throw new Error(stage);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
var ES300_REPLACEMENTS = [
|
|
569
|
+
// Fix poorly formatted version directive
|
|
570
|
+
[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/, "#version 300 es\n"],
|
|
571
|
+
// The individual `texture...()` functions were replaced with `texture()` overloads
|
|
572
|
+
[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g, "textureLod("],
|
|
573
|
+
[/\btexture(2D|2DProj|Cube)(EXT)?\(/g, "texture("]
|
|
574
|
+
];
|
|
575
|
+
var ES300_VERTEX_REPLACEMENTS = [
|
|
576
|
+
...ES300_REPLACEMENTS,
|
|
577
|
+
// `attribute` keyword replaced with `in`
|
|
578
|
+
[makeVariableTextRegExp("attribute"), "in $1"],
|
|
579
|
+
// `varying` keyword replaced with `out`
|
|
580
|
+
[makeVariableTextRegExp("varying"), "out $1"]
|
|
581
|
+
];
|
|
582
|
+
var ES300_FRAGMENT_REPLACEMENTS = [
|
|
583
|
+
...ES300_REPLACEMENTS,
|
|
584
|
+
// `varying` keyword replaced with `in`
|
|
585
|
+
[makeVariableTextRegExp("varying"), "in $1"]
|
|
586
|
+
];
|
|
611
587
|
function convertShader(source, replacements) {
|
|
612
588
|
for (const [pattern, replacement] of replacements) {
|
|
613
589
|
source = source.replace(pattern, replacement);
|
|
614
590
|
}
|
|
615
591
|
return source;
|
|
616
592
|
}
|
|
617
|
-
function convertFragmentShaderTo100(source) {
|
|
618
|
-
source = convertShader(source, ES100_FRAGMENT_REPLACEMENTS);
|
|
619
|
-
const outputMatch = ES300_FRAGMENT_OUTPUT_REGEX.exec(source);
|
|
620
|
-
if (outputMatch) {
|
|
621
|
-
const outputName = outputMatch[1];
|
|
622
|
-
source = source.replace(ES300_FRAGMENT_OUTPUT_REGEX, "").replace(new RegExp(`\\b${outputName}\\b`, "g"), ES100_FRAGMENT_OUTPUT_NAME);
|
|
623
|
-
}
|
|
624
|
-
return source;
|
|
625
|
-
}
|
|
626
593
|
function makeVariableTextRegExp(qualifier) {
|
|
627
594
|
return new RegExp(`\\b${qualifier}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`, "g");
|
|
628
595
|
}
|
|
@@ -653,10 +620,7 @@ ${moduleSource}
|
|
|
653
620
|
return result;
|
|
654
621
|
}
|
|
655
622
|
function normalizeShaderHooks(hookFunctions) {
|
|
656
|
-
const result = {
|
|
657
|
-
vertex: {},
|
|
658
|
-
fragment: {}
|
|
659
|
-
};
|
|
623
|
+
const result = { vertex: {}, fragment: {} };
|
|
660
624
|
for (const hookFunction of hookFunctions) {
|
|
661
625
|
let opts;
|
|
662
626
|
let hook;
|
|
@@ -670,9 +634,7 @@ ${moduleSource}
|
|
|
670
634
|
hook = hook.trim();
|
|
671
635
|
const [shaderStage, signature] = hook.split(":");
|
|
672
636
|
const name = hook.replace(/\(.+/, "");
|
|
673
|
-
const normalizedHook = Object.assign(opts, {
|
|
674
|
-
signature
|
|
675
|
-
});
|
|
637
|
+
const normalizedHook = Object.assign(opts, { signature });
|
|
676
638
|
switch (shaderStage) {
|
|
677
639
|
case "vs":
|
|
678
640
|
result.vertex[name] = normalizedHook;
|
|
@@ -724,51 +686,30 @@ ${DECLARATION_INJECT_MARKER}
|
|
|
724
686
|
precision highp float;
|
|
725
687
|
`;
|
|
726
688
|
function assembleShaders(options) {
|
|
727
|
-
const {
|
|
728
|
-
vs: vs6,
|
|
729
|
-
fs: fs28
|
|
730
|
-
} = options;
|
|
689
|
+
const { vs: vs6, fs: fs28 } = options;
|
|
731
690
|
const modules = resolveModules(options.modules || []);
|
|
732
691
|
switch (options.platformInfo.shaderLanguage) {
|
|
733
692
|
case "glsl":
|
|
734
693
|
return {
|
|
735
|
-
vs: assembleGLSLShader(options.platformInfo, {
|
|
736
|
-
|
|
737
|
-
source: vs6,
|
|
738
|
-
stage: "vertex",
|
|
739
|
-
modules
|
|
740
|
-
}),
|
|
741
|
-
fs: assembleGLSLShader(options.platformInfo, {
|
|
742
|
-
...options,
|
|
743
|
-
source: fs28,
|
|
744
|
-
stage: "fragment",
|
|
745
|
-
modules
|
|
746
|
-
}),
|
|
694
|
+
vs: assembleGLSLShader(options.platformInfo, { ...options, source: vs6, stage: "vertex", modules }),
|
|
695
|
+
fs: assembleGLSLShader(options.platformInfo, { ...options, source: fs28, stage: "fragment", modules }),
|
|
747
696
|
getUniforms: assembleGetUniforms(modules)
|
|
748
697
|
};
|
|
749
698
|
case "wgsl":
|
|
750
699
|
return {
|
|
751
|
-
vs: assembleWGSLShader(options.platformInfo, {
|
|
752
|
-
|
|
753
|
-
source: vs6,
|
|
754
|
-
stage: "vertex",
|
|
755
|
-
modules
|
|
756
|
-
}),
|
|
757
|
-
fs: assembleWGSLShader(options.platformInfo, {
|
|
758
|
-
...options,
|
|
759
|
-
source: fs28,
|
|
760
|
-
stage: "fragment",
|
|
761
|
-
modules
|
|
762
|
-
}),
|
|
700
|
+
vs: assembleWGSLShader(options.platformInfo, { ...options, source: vs6, stage: "vertex", modules }),
|
|
701
|
+
fs: assembleWGSLShader(options.platformInfo, { ...options, source: fs28, stage: "fragment", modules }),
|
|
763
702
|
getUniforms: assembleGetUniforms(modules)
|
|
764
703
|
};
|
|
765
704
|
}
|
|
766
705
|
}
|
|
767
706
|
function assembleWGSLShader(platformInfo, options) {
|
|
768
707
|
const {
|
|
708
|
+
// id,
|
|
769
709
|
source,
|
|
770
710
|
stage,
|
|
771
711
|
modules,
|
|
712
|
+
// defines = {},
|
|
772
713
|
hookFunctions = [],
|
|
773
714
|
inject = {},
|
|
774
715
|
log
|
|
@@ -781,10 +722,7 @@ precision highp float;
|
|
|
781
722
|
const declInjections = {};
|
|
782
723
|
const mainInjections = {};
|
|
783
724
|
for (const key in inject) {
|
|
784
|
-
const injection = typeof inject[key] === "string" ? {
|
|
785
|
-
injection: inject[key],
|
|
786
|
-
order: 0
|
|
787
|
-
} : inject[key];
|
|
725
|
+
const injection = typeof inject[key] === "string" ? { injection: inject[key], order: 0 } : inject[key];
|
|
788
726
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
789
727
|
if (match) {
|
|
790
728
|
const hash = match[2];
|
|
@@ -862,11 +800,7 @@ precision highp float;
|
|
|
862
800
|
assembledSource = prologue ? `${sourceVersionDirective}
|
|
863
801
|
|
|
864
802
|
// ----- PROLOGUE -------------------------
|
|
865
|
-
${getShaderNameDefine({
|
|
866
|
-
id,
|
|
867
|
-
source,
|
|
868
|
-
stage
|
|
869
|
-
})}
|
|
803
|
+
${getShaderNameDefine({ id, source, stage })}
|
|
870
804
|
${`#define SHADER_TYPE_${stage.toUpperCase()}`}
|
|
871
805
|
${getPlatformShaderDefines(platformInfo)}
|
|
872
806
|
${getVersionDefines(platformInfo)}
|
|
@@ -885,10 +819,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
885
819
|
const declInjections = {};
|
|
886
820
|
const mainInjections = {};
|
|
887
821
|
for (const key in inject) {
|
|
888
|
-
const injection = typeof inject[key] === "string" ? {
|
|
889
|
-
injection: inject[key],
|
|
890
|
-
order: 0
|
|
891
|
-
} : inject[key];
|
|
822
|
+
const injection = typeof inject[key] === "string" ? { injection: inject[key], order: 0 } : inject[key];
|
|
892
823
|
const match = /^(v|f)s:(#)?([\w-]+)$/.exec(key);
|
|
893
824
|
if (match) {
|
|
894
825
|
const hash = match[2];
|
|
@@ -933,7 +864,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
933
864
|
assembledSource += coreSource;
|
|
934
865
|
assembledSource = injectShader(assembledSource, stage, mainInjections);
|
|
935
866
|
if (language === "glsl" && sourceVersion !== targetVersion) {
|
|
936
|
-
assembledSource = transpileGLSLShader(assembledSource,
|
|
867
|
+
assembledSource = transpileGLSLShader(assembledSource, stage);
|
|
937
868
|
}
|
|
938
869
|
return assembledSource.trim();
|
|
939
870
|
}
|
|
@@ -948,11 +879,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
948
879
|
};
|
|
949
880
|
}
|
|
950
881
|
function getShaderNameDefine(options) {
|
|
951
|
-
const {
|
|
952
|
-
id,
|
|
953
|
-
source,
|
|
954
|
-
stage
|
|
955
|
-
} = options;
|
|
882
|
+
const { id, source, stage } = options;
|
|
956
883
|
const injectShaderName = id && source.indexOf("SHADER_NAME") === -1;
|
|
957
884
|
return injectShaderName ? `
|
|
958
885
|
#define SHADER_NAME ${id}_${stage}
|
|
@@ -981,11 +908,7 @@ ${getApplicationDefines(allDefines)}
|
|
|
981
908
|
if (props.fs) {
|
|
982
909
|
fs28 = getShaderSource(props.platformInfo, props.fs);
|
|
983
910
|
}
|
|
984
|
-
return {
|
|
985
|
-
...props,
|
|
986
|
-
vs: vs6,
|
|
987
|
-
fs: fs28
|
|
988
|
-
};
|
|
911
|
+
return { ...props, vs: vs6, fs: fs28 };
|
|
989
912
|
}
|
|
990
913
|
function getShaderSource(platformInfo, shader) {
|
|
991
914
|
if (typeof shader === "string") {
|
|
@@ -1006,45 +929,63 @@ ${getApplicationDefines(allDefines)}
|
|
|
1006
929
|
}
|
|
1007
930
|
|
|
1008
931
|
// src/lib/shader-assembler.ts
|
|
1009
|
-
var
|
|
932
|
+
var _ShaderAssembler = class {
|
|
933
|
+
/** Hook functions */
|
|
1010
934
|
_hookFunctions = [];
|
|
935
|
+
/** Shader modules */
|
|
1011
936
|
_defaultModules = [];
|
|
937
|
+
/**
|
|
938
|
+
* A default shader assembler instance - the natural place to register default modules and hooks
|
|
939
|
+
* @returns
|
|
940
|
+
*/
|
|
1012
941
|
static getDefaultShaderAssembler() {
|
|
1013
|
-
|
|
1014
|
-
return
|
|
942
|
+
_ShaderAssembler.defaultShaderAssembler = _ShaderAssembler.defaultShaderAssembler || new _ShaderAssembler();
|
|
943
|
+
return _ShaderAssembler.defaultShaderAssembler;
|
|
1015
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Add a default module that does not have to be provided with every call to assembleShaders()
|
|
947
|
+
*/
|
|
1016
948
|
addDefaultModule(module) {
|
|
1017
|
-
if (!this._defaultModules.find(
|
|
949
|
+
if (!this._defaultModules.find(
|
|
950
|
+
(m) => m.name === (typeof module === "string" ? module : module.name)
|
|
951
|
+
)) {
|
|
1018
952
|
this._defaultModules.push(module);
|
|
1019
953
|
}
|
|
1020
954
|
}
|
|
955
|
+
/**
|
|
956
|
+
* Remove a default module
|
|
957
|
+
*/
|
|
1021
958
|
removeDefaultModule(module) {
|
|
1022
959
|
const moduleName = typeof module === "string" ? module : module.name;
|
|
1023
960
|
this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);
|
|
1024
961
|
}
|
|
962
|
+
/**
|
|
963
|
+
* Register a shader hook
|
|
964
|
+
* @param hook
|
|
965
|
+
* @param opts
|
|
966
|
+
*/
|
|
1025
967
|
addShaderHook(hook, opts) {
|
|
1026
968
|
if (opts) {
|
|
1027
|
-
hook = Object.assign(opts, {
|
|
1028
|
-
hook
|
|
1029
|
-
});
|
|
969
|
+
hook = Object.assign(opts, { hook });
|
|
1030
970
|
}
|
|
1031
971
|
this._hookFunctions.push(hook);
|
|
1032
972
|
}
|
|
973
|
+
/**
|
|
974
|
+
* Assemble a pair of shaders into a single shader program
|
|
975
|
+
* @param platformInfo
|
|
976
|
+
* @param props
|
|
977
|
+
* @returns
|
|
978
|
+
*/
|
|
1033
979
|
assembleShaders(props) {
|
|
1034
980
|
const modules = this._getModuleList(props.modules);
|
|
1035
981
|
const hookFunctions = this._hookFunctions;
|
|
1036
982
|
const options = selectShaders(props);
|
|
1037
|
-
const assembled = assembleShaders({
|
|
1038
|
-
|
|
1039
|
-
...options,
|
|
1040
|
-
modules,
|
|
1041
|
-
hookFunctions
|
|
1042
|
-
});
|
|
1043
|
-
return {
|
|
1044
|
-
...assembled,
|
|
1045
|
-
modules
|
|
1046
|
-
};
|
|
983
|
+
const assembled = assembleShaders({ platformInfo: props.platformInfo, ...options, modules, hookFunctions });
|
|
984
|
+
return { ...assembled, modules };
|
|
1047
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* Dedupe and combine with default modules
|
|
988
|
+
*/
|
|
1048
989
|
_getModuleList(appModules = []) {
|
|
1049
990
|
const modules = new Array(this._defaultModules.length + appModules.length);
|
|
1050
991
|
const seen = {};
|
|
@@ -1067,6 +1008,9 @@ ${getApplicationDefines(allDefines)}
|
|
|
1067
1008
|
return ShaderModuleInstance.instantiateModules(modules);
|
|
1068
1009
|
}
|
|
1069
1010
|
};
|
|
1011
|
+
var ShaderAssembler = _ShaderAssembler;
|
|
1012
|
+
/** Default ShaderAssembler instance */
|
|
1013
|
+
__publicField(ShaderAssembler, "defaultShaderAssembler");
|
|
1070
1014
|
|
|
1071
1015
|
// src/lib/shader-module/normalize-shader-module.ts
|
|
1072
1016
|
function normalizeShaderModule(module) {
|
|
@@ -1081,7 +1025,6 @@ ${getApplicationDefines(allDefines)}
|
|
|
1081
1025
|
}
|
|
1082
1026
|
|
|
1083
1027
|
// src/lib/glsl-utils/shader-utils.ts
|
|
1084
|
-
var FS100 = glsl`void main() {gl_FragColor = vec4(0);}`;
|
|
1085
1028
|
var FS_GLES = glsl`\
|
|
1086
1029
|
out vec4 transform_output;
|
|
1087
1030
|
void main() {
|
|
@@ -1097,44 +1040,23 @@ ${FS_GLES}`;
|
|
|
1097
1040
|
return null;
|
|
1098
1041
|
}
|
|
1099
1042
|
const name = definition.split(";")[0];
|
|
1100
|
-
return {
|
|
1101
|
-
qualifier,
|
|
1102
|
-
type,
|
|
1103
|
-
name
|
|
1104
|
-
};
|
|
1043
|
+
return { qualifier, type, name };
|
|
1105
1044
|
}
|
|
1106
1045
|
function getPassthroughFS(options) {
|
|
1107
|
-
const {
|
|
1108
|
-
version = 100,
|
|
1109
|
-
input,
|
|
1110
|
-
inputChannels,
|
|
1111
|
-
output
|
|
1112
|
-
} = options || {};
|
|
1046
|
+
const { input, inputChannels, output } = options || {};
|
|
1113
1047
|
if (!input) {
|
|
1114
|
-
|
|
1115
|
-
return FS300;
|
|
1116
|
-
} else if (version > 300) {
|
|
1117
|
-
return `#version ${version}
|
|
1118
|
-
${FS_GLES}`;
|
|
1119
|
-
}
|
|
1120
|
-
return FS100;
|
|
1048
|
+
return FS300;
|
|
1121
1049
|
}
|
|
1122
1050
|
if (!inputChannels) {
|
|
1123
1051
|
throw new Error("inputChannels");
|
|
1124
1052
|
}
|
|
1125
1053
|
const inputType = channelCountToType(inputChannels);
|
|
1126
1054
|
const outputValue = convertToVec4(input, inputChannels);
|
|
1127
|
-
|
|
1128
|
-
return `#version ${version} ${version === 300 ? "es" : ""}
|
|
1055
|
+
return `#version 300 es
|
|
1129
1056
|
in ${inputType} ${input};
|
|
1130
1057
|
out vec4 ${output};
|
|
1131
1058
|
void main() {
|
|
1132
1059
|
${output} = ${outputValue};
|
|
1133
|
-
}`;
|
|
1134
|
-
}
|
|
1135
|
-
return `varying ${inputType} ${input};
|
|
1136
|
-
void main() {
|
|
1137
|
-
gl_FragColor = ${outputValue};
|
|
1138
1060
|
}`;
|
|
1139
1061
|
}
|
|
1140
1062
|
function typeToChannelSuffix(type) {
|
|
@@ -1603,6 +1525,7 @@ void main() {
|
|
|
1603
1525
|
get isStruct() {
|
|
1604
1526
|
return true;
|
|
1605
1527
|
}
|
|
1528
|
+
/// Return the index of the member with the given name, or -1 if not found.
|
|
1606
1529
|
getMemberIndex(name) {
|
|
1607
1530
|
for (let i = 0; i < this.members.length; i++) {
|
|
1608
1531
|
if (this.members[i].name == name)
|
|
@@ -2153,6 +2076,12 @@ void main() {
|
|
|
2153
2076
|
rgba32sint: new TokenType("rgba32sint", TokenClass.keyword, "rgba32sint"),
|
|
2154
2077
|
rgba32float: new TokenType("rgba32float", TokenClass.keyword, "rgba32float"),
|
|
2155
2078
|
static_assert: new TokenType("static_assert", TokenClass.keyword, "static_assert")
|
|
2079
|
+
// WGSL grammar has a few keywords that have different token names than the strings they
|
|
2080
|
+
// represent. Aliasing them here.
|
|
2081
|
+
/*int32: new TokenType("i32", TokenClass.keyword, "i32"),
|
|
2082
|
+
uint32: new TokenType("u32", TokenClass.keyword, "u32"),
|
|
2083
|
+
float32: new TokenType("f32", TokenClass.keyword, "f32"),
|
|
2084
|
+
pointer: new TokenType("ptr", TokenClass.keyword, "ptr"),*/
|
|
2156
2085
|
};
|
|
2157
2086
|
TokenTypes.tokens = {
|
|
2158
2087
|
decimal_float_literal: new TokenType("decimal_float_literal", TokenClass.token, /((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),
|
|
@@ -2209,23 +2138,146 @@ void main() {
|
|
|
2209
2138
|
shift_right_equal: new TokenType("shift_right_equal", TokenClass.token, ">>="),
|
|
2210
2139
|
shift_left_equal: new TokenType("shift_left_equal", TokenClass.token, "<<=")
|
|
2211
2140
|
};
|
|
2212
|
-
TokenTypes.storage_class = [
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2141
|
+
TokenTypes.storage_class = [
|
|
2142
|
+
_a.keywords.function,
|
|
2143
|
+
_a.keywords.private,
|
|
2144
|
+
_a.keywords.workgroup,
|
|
2145
|
+
_a.keywords.uniform,
|
|
2146
|
+
_a.keywords.storage
|
|
2147
|
+
];
|
|
2148
|
+
TokenTypes.access_mode = [
|
|
2149
|
+
_a.keywords.read,
|
|
2150
|
+
_a.keywords.write,
|
|
2151
|
+
_a.keywords.read_write
|
|
2152
|
+
];
|
|
2153
|
+
TokenTypes.sampler_type = [
|
|
2154
|
+
_a.keywords.sampler,
|
|
2155
|
+
_a.keywords.sampler_comparison
|
|
2156
|
+
];
|
|
2157
|
+
TokenTypes.sampled_texture_type = [
|
|
2158
|
+
_a.keywords.texture_1d,
|
|
2159
|
+
_a.keywords.texture_2d,
|
|
2160
|
+
_a.keywords.texture_2d_array,
|
|
2161
|
+
_a.keywords.texture_3d,
|
|
2162
|
+
_a.keywords.texture_cube,
|
|
2163
|
+
_a.keywords.texture_cube_array
|
|
2164
|
+
];
|
|
2165
|
+
TokenTypes.multisampled_texture_type = [
|
|
2166
|
+
_a.keywords.texture_multisampled_2d
|
|
2167
|
+
];
|
|
2168
|
+
TokenTypes.storage_texture_type = [
|
|
2169
|
+
_a.keywords.texture_storage_1d,
|
|
2170
|
+
_a.keywords.texture_storage_2d,
|
|
2171
|
+
_a.keywords.texture_storage_2d_array,
|
|
2172
|
+
_a.keywords.texture_storage_3d
|
|
2173
|
+
];
|
|
2174
|
+
TokenTypes.depth_texture_type = [
|
|
2175
|
+
_a.keywords.texture_depth_2d,
|
|
2176
|
+
_a.keywords.texture_depth_2d_array,
|
|
2177
|
+
_a.keywords.texture_depth_cube,
|
|
2178
|
+
_a.keywords.texture_depth_cube_array,
|
|
2179
|
+
_a.keywords.texture_depth_multisampled_2d
|
|
2180
|
+
];
|
|
2219
2181
|
TokenTypes.texture_external_type = [_a.keywords.texture_external];
|
|
2220
|
-
TokenTypes.any_texture_type = [
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2182
|
+
TokenTypes.any_texture_type = [
|
|
2183
|
+
..._a.sampled_texture_type,
|
|
2184
|
+
..._a.multisampled_texture_type,
|
|
2185
|
+
..._a.storage_texture_type,
|
|
2186
|
+
..._a.depth_texture_type,
|
|
2187
|
+
..._a.texture_external_type
|
|
2188
|
+
];
|
|
2189
|
+
TokenTypes.texel_format = [
|
|
2190
|
+
_a.keywords.r8unorm,
|
|
2191
|
+
_a.keywords.r8snorm,
|
|
2192
|
+
_a.keywords.r8uint,
|
|
2193
|
+
_a.keywords.r8sint,
|
|
2194
|
+
_a.keywords.r16uint,
|
|
2195
|
+
_a.keywords.r16sint,
|
|
2196
|
+
_a.keywords.r16float,
|
|
2197
|
+
_a.keywords.rg8unorm,
|
|
2198
|
+
_a.keywords.rg8snorm,
|
|
2199
|
+
_a.keywords.rg8uint,
|
|
2200
|
+
_a.keywords.rg8sint,
|
|
2201
|
+
_a.keywords.r32uint,
|
|
2202
|
+
_a.keywords.r32sint,
|
|
2203
|
+
_a.keywords.r32float,
|
|
2204
|
+
_a.keywords.rg16uint,
|
|
2205
|
+
_a.keywords.rg16sint,
|
|
2206
|
+
_a.keywords.rg16float,
|
|
2207
|
+
_a.keywords.rgba8unorm,
|
|
2208
|
+
_a.keywords.rgba8unorm_srgb,
|
|
2209
|
+
_a.keywords.rgba8snorm,
|
|
2210
|
+
_a.keywords.rgba8uint,
|
|
2211
|
+
_a.keywords.rgba8sint,
|
|
2212
|
+
_a.keywords.bgra8unorm,
|
|
2213
|
+
_a.keywords.bgra8unorm_srgb,
|
|
2214
|
+
_a.keywords.rgb10a2unorm,
|
|
2215
|
+
_a.keywords.rg11b10float,
|
|
2216
|
+
_a.keywords.rg32uint,
|
|
2217
|
+
_a.keywords.rg32sint,
|
|
2218
|
+
_a.keywords.rg32float,
|
|
2219
|
+
_a.keywords.rgba16uint,
|
|
2220
|
+
_a.keywords.rgba16sint,
|
|
2221
|
+
_a.keywords.rgba16float,
|
|
2222
|
+
_a.keywords.rgba32uint,
|
|
2223
|
+
_a.keywords.rgba32sint,
|
|
2224
|
+
_a.keywords.rgba32float
|
|
2225
|
+
];
|
|
2226
|
+
TokenTypes.const_literal = [
|
|
2227
|
+
_a.tokens.int_literal,
|
|
2228
|
+
_a.tokens.uint_literal,
|
|
2229
|
+
_a.tokens.decimal_float_literal,
|
|
2230
|
+
_a.tokens.hex_float_literal,
|
|
2231
|
+
_a.keywords.true,
|
|
2232
|
+
_a.keywords.false
|
|
2233
|
+
];
|
|
2234
|
+
TokenTypes.literal_or_ident = [
|
|
2235
|
+
_a.tokens.ident,
|
|
2236
|
+
_a.tokens.int_literal,
|
|
2237
|
+
_a.tokens.uint_literal,
|
|
2238
|
+
_a.tokens.decimal_float_literal,
|
|
2239
|
+
_a.tokens.hex_float_literal
|
|
2240
|
+
];
|
|
2241
|
+
TokenTypes.element_count_expression = [
|
|
2242
|
+
_a.tokens.int_literal,
|
|
2243
|
+
_a.tokens.uint_literal,
|
|
2244
|
+
_a.tokens.ident
|
|
2245
|
+
];
|
|
2246
|
+
TokenTypes.template_types = [
|
|
2247
|
+
_a.keywords.vec2,
|
|
2248
|
+
_a.keywords.vec3,
|
|
2249
|
+
_a.keywords.vec4,
|
|
2250
|
+
_a.keywords.mat2x2,
|
|
2251
|
+
_a.keywords.mat2x3,
|
|
2252
|
+
_a.keywords.mat2x4,
|
|
2253
|
+
_a.keywords.mat3x2,
|
|
2254
|
+
_a.keywords.mat3x3,
|
|
2255
|
+
_a.keywords.mat3x4,
|
|
2256
|
+
_a.keywords.mat4x2,
|
|
2257
|
+
_a.keywords.mat4x3,
|
|
2258
|
+
_a.keywords.mat4x4,
|
|
2259
|
+
_a.keywords.atomic,
|
|
2260
|
+
_a.keywords.bitcast,
|
|
2261
|
+
..._a.any_texture_type
|
|
2262
|
+
];
|
|
2226
2263
|
TokenTypes.attribute_name = [_a.tokens.ident, _a.keywords.block];
|
|
2227
|
-
TokenTypes.assignment_operators = [
|
|
2228
|
-
|
|
2264
|
+
TokenTypes.assignment_operators = [
|
|
2265
|
+
_a.tokens.equal,
|
|
2266
|
+
_a.tokens.plus_equal,
|
|
2267
|
+
_a.tokens.minus_equal,
|
|
2268
|
+
_a.tokens.times_equal,
|
|
2269
|
+
_a.tokens.division_equal,
|
|
2270
|
+
_a.tokens.modulo_equal,
|
|
2271
|
+
_a.tokens.and_equal,
|
|
2272
|
+
_a.tokens.or_equal,
|
|
2273
|
+
_a.tokens.xor_equal,
|
|
2274
|
+
_a.tokens.shift_right_equal,
|
|
2275
|
+
_a.tokens.shift_left_equal
|
|
2276
|
+
];
|
|
2277
|
+
TokenTypes.increment_operators = [
|
|
2278
|
+
_a.tokens.plus_plus,
|
|
2279
|
+
_a.tokens.minus_minus
|
|
2280
|
+
];
|
|
2229
2281
|
var Token = class {
|
|
2230
2282
|
constructor(type, lexeme, line) {
|
|
2231
2283
|
this.type = type;
|
|
@@ -2253,6 +2305,7 @@ void main() {
|
|
|
2253
2305
|
this._line = 1;
|
|
2254
2306
|
this._source = source !== null && source !== void 0 ? source : "";
|
|
2255
2307
|
}
|
|
2308
|
+
/// Scan all tokens from the source.
|
|
2256
2309
|
scanTokens() {
|
|
2257
2310
|
while (!this._isAtEnd()) {
|
|
2258
2311
|
this._start = this._current;
|
|
@@ -2262,6 +2315,7 @@ void main() {
|
|
|
2262
2315
|
this._tokens.push(new Token(TokenTypes.eof, "", this._line));
|
|
2263
2316
|
return this._tokens;
|
|
2264
2317
|
}
|
|
2318
|
+
/// Scan a single token from the source.
|
|
2265
2319
|
scanToken() {
|
|
2266
2320
|
let lexeme = this._advance();
|
|
2267
2321
|
if (lexeme == "\n") {
|
|
@@ -2618,7 +2672,11 @@ void main() {
|
|
|
2618
2672
|
let result = null;
|
|
2619
2673
|
if (this._check(TokenTypes.keywords.return))
|
|
2620
2674
|
result = this._return_statement();
|
|
2621
|
-
else if (this._check([
|
|
2675
|
+
else if (this._check([
|
|
2676
|
+
TokenTypes.keywords.var,
|
|
2677
|
+
TokenTypes.keywords.let,
|
|
2678
|
+
TokenTypes.keywords.const
|
|
2679
|
+
]))
|
|
2622
2680
|
result = this._variable_statement();
|
|
2623
2681
|
else if (this._match(TokenTypes.keywords.discard))
|
|
2624
2682
|
result = new Discard();
|
|
@@ -2803,7 +2861,9 @@ void main() {
|
|
|
2803
2861
|
}
|
|
2804
2862
|
_case_selectors() {
|
|
2805
2863
|
var _a2, _b, _c, _d;
|
|
2806
|
-
const selectors = [
|
|
2864
|
+
const selectors = [
|
|
2865
|
+
(_b = (_a2 = this._shift_expression()) === null || _a2 === void 0 ? void 0 : _a2.evaluate(this._context).toString()) !== null && _b !== void 0 ? _b : ""
|
|
2866
|
+
];
|
|
2807
2867
|
while (this._match(TokenTypes.tokens.comma)) {
|
|
2808
2868
|
selectors.push((_d = (_c = this._shift_expression()) === null || _c === void 0 ? void 0 : _c.evaluate(this._context).toString()) !== null && _d !== void 0 ? _d : "");
|
|
2809
2869
|
}
|
|
@@ -2906,7 +2966,12 @@ void main() {
|
|
|
2906
2966
|
}
|
|
2907
2967
|
_relational_expression() {
|
|
2908
2968
|
let expr = this._shift_expression();
|
|
2909
|
-
while (this._match([
|
|
2969
|
+
while (this._match([
|
|
2970
|
+
TokenTypes.tokens.less_than,
|
|
2971
|
+
TokenTypes.tokens.greater_than,
|
|
2972
|
+
TokenTypes.tokens.less_than_equal,
|
|
2973
|
+
TokenTypes.tokens.greater_than_equal
|
|
2974
|
+
])) {
|
|
2910
2975
|
expr = new BinaryOperator(this._previous().toString(), expr, this._shift_expression());
|
|
2911
2976
|
}
|
|
2912
2977
|
return expr;
|
|
@@ -2927,13 +2992,23 @@ void main() {
|
|
|
2927
2992
|
}
|
|
2928
2993
|
_multiplicative_expression() {
|
|
2929
2994
|
let expr = this._unary_expression();
|
|
2930
|
-
while (this._match([
|
|
2995
|
+
while (this._match([
|
|
2996
|
+
TokenTypes.tokens.star,
|
|
2997
|
+
TokenTypes.tokens.forward_slash,
|
|
2998
|
+
TokenTypes.tokens.modulo
|
|
2999
|
+
])) {
|
|
2931
3000
|
expr = new BinaryOperator(this._previous().toString(), expr, this._unary_expression());
|
|
2932
3001
|
}
|
|
2933
3002
|
return expr;
|
|
2934
3003
|
}
|
|
2935
3004
|
_unary_expression() {
|
|
2936
|
-
if (this._match([
|
|
3005
|
+
if (this._match([
|
|
3006
|
+
TokenTypes.tokens.minus,
|
|
3007
|
+
TokenTypes.tokens.bang,
|
|
3008
|
+
TokenTypes.tokens.tilde,
|
|
3009
|
+
TokenTypes.tokens.star,
|
|
3010
|
+
TokenTypes.tokens.and
|
|
3011
|
+
])) {
|
|
2937
3012
|
return new UnaryOperator(this._previous().toString(), this._unary_expression());
|
|
2938
3013
|
}
|
|
2939
3014
|
return this._singular_expression();
|
|
@@ -3187,7 +3262,14 @@ void main() {
|
|
|
3187
3262
|
return aliasNode;
|
|
3188
3263
|
}
|
|
3189
3264
|
_type_decl() {
|
|
3190
|
-
if (this._check([
|
|
3265
|
+
if (this._check([
|
|
3266
|
+
TokenTypes.tokens.ident,
|
|
3267
|
+
...TokenTypes.texel_format,
|
|
3268
|
+
TokenTypes.keywords.bool,
|
|
3269
|
+
TokenTypes.keywords.f32,
|
|
3270
|
+
TokenTypes.keywords.i32,
|
|
3271
|
+
TokenTypes.keywords.u32
|
|
3272
|
+
])) {
|
|
3191
3273
|
const type2 = this._advance();
|
|
3192
3274
|
const typeName = type2.toString();
|
|
3193
3275
|
if (this._context.structs.has(typeName)) {
|
|
@@ -3298,7 +3380,9 @@ void main() {
|
|
|
3298
3380
|
const name = this._consume(TokenTypes.attribute_name, "Expected attribute name");
|
|
3299
3381
|
const attr = new Attribute(name.toString(), null);
|
|
3300
3382
|
if (this._match(TokenTypes.tokens.paren_left)) {
|
|
3301
|
-
attr.value = [
|
|
3383
|
+
attr.value = [
|
|
3384
|
+
this._consume(TokenTypes.literal_or_ident, "Expected attribute value").toString()
|
|
3385
|
+
];
|
|
3302
3386
|
if (this._check(TokenTypes.tokens.comma)) {
|
|
3303
3387
|
this._advance();
|
|
3304
3388
|
do {
|
|
@@ -3921,74 +4005,23 @@ void main() {
|
|
|
3921
4005
|
}
|
|
3922
4006
|
};
|
|
3923
4007
|
WgslReflect._typeInfo = {
|
|
3924
|
-
f16: {
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
},
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
},
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
},
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
},
|
|
3940
|
-
|
|
3941
|
-
align: 4,
|
|
3942
|
-
size: 4
|
|
3943
|
-
},
|
|
3944
|
-
vec2: {
|
|
3945
|
-
align: 8,
|
|
3946
|
-
size: 8
|
|
3947
|
-
},
|
|
3948
|
-
vec3: {
|
|
3949
|
-
align: 16,
|
|
3950
|
-
size: 12
|
|
3951
|
-
},
|
|
3952
|
-
vec4: {
|
|
3953
|
-
align: 16,
|
|
3954
|
-
size: 16
|
|
3955
|
-
},
|
|
3956
|
-
mat2x2: {
|
|
3957
|
-
align: 8,
|
|
3958
|
-
size: 16
|
|
3959
|
-
},
|
|
3960
|
-
mat3x2: {
|
|
3961
|
-
align: 8,
|
|
3962
|
-
size: 24
|
|
3963
|
-
},
|
|
3964
|
-
mat4x2: {
|
|
3965
|
-
align: 8,
|
|
3966
|
-
size: 32
|
|
3967
|
-
},
|
|
3968
|
-
mat2x3: {
|
|
3969
|
-
align: 16,
|
|
3970
|
-
size: 32
|
|
3971
|
-
},
|
|
3972
|
-
mat3x3: {
|
|
3973
|
-
align: 16,
|
|
3974
|
-
size: 48
|
|
3975
|
-
},
|
|
3976
|
-
mat4x3: {
|
|
3977
|
-
align: 16,
|
|
3978
|
-
size: 64
|
|
3979
|
-
},
|
|
3980
|
-
mat2x4: {
|
|
3981
|
-
align: 16,
|
|
3982
|
-
size: 32
|
|
3983
|
-
},
|
|
3984
|
-
mat3x4: {
|
|
3985
|
-
align: 16,
|
|
3986
|
-
size: 48
|
|
3987
|
-
},
|
|
3988
|
-
mat4x4: {
|
|
3989
|
-
align: 16,
|
|
3990
|
-
size: 64
|
|
3991
|
-
}
|
|
4008
|
+
f16: { align: 2, size: 2 },
|
|
4009
|
+
i32: { align: 4, size: 4 },
|
|
4010
|
+
u32: { align: 4, size: 4 },
|
|
4011
|
+
f32: { align: 4, size: 4 },
|
|
4012
|
+
atomic: { align: 4, size: 4 },
|
|
4013
|
+
vec2: { align: 8, size: 8 },
|
|
4014
|
+
vec3: { align: 16, size: 12 },
|
|
4015
|
+
vec4: { align: 16, size: 16 },
|
|
4016
|
+
mat2x2: { align: 8, size: 16 },
|
|
4017
|
+
mat3x2: { align: 8, size: 24 },
|
|
4018
|
+
mat4x2: { align: 8, size: 32 },
|
|
4019
|
+
mat2x3: { align: 16, size: 32 },
|
|
4020
|
+
mat3x3: { align: 16, size: 48 },
|
|
4021
|
+
mat4x3: { align: 16, size: 64 },
|
|
4022
|
+
mat2x4: { align: 16, size: 32 },
|
|
4023
|
+
mat3x4: { align: 16, size: 48 },
|
|
4024
|
+
mat4x4: { align: 16, size: 64 }
|
|
3992
4025
|
};
|
|
3993
4026
|
WgslReflect._textureTypes = TokenTypes.any_texture_type.map((t) => {
|
|
3994
4027
|
return t.name;
|
|
@@ -3999,10 +4032,7 @@ void main() {
|
|
|
3999
4032
|
|
|
4000
4033
|
// src/lib/wgsl/get-shader-layout-wgsl.ts
|
|
4001
4034
|
function getShaderLayoutFromWGSL(source) {
|
|
4002
|
-
const shaderLayout = {
|
|
4003
|
-
attributes: [],
|
|
4004
|
-
bindings: []
|
|
4005
|
-
};
|
|
4035
|
+
const shaderLayout = { attributes: [], bindings: [] };
|
|
4006
4036
|
const parsedWGSL = parseWGSL(source);
|
|
4007
4037
|
for (const uniform of parsedWGSL.uniforms) {
|
|
4008
4038
|
const members = [];
|
|
@@ -4016,6 +4046,7 @@ void main() {
|
|
|
4016
4046
|
type: "uniform",
|
|
4017
4047
|
name: uniform.name,
|
|
4018
4048
|
location: uniform.binding,
|
|
4049
|
+
// @ts-expect-error
|
|
4019
4050
|
group: uniform.group,
|
|
4020
4051
|
members
|
|
4021
4052
|
});
|
|
@@ -4052,9 +4083,7 @@ void main() {
|
|
|
4052
4083
|
if (typeof error === "object" && error?.token) {
|
|
4053
4084
|
message += error.token.line || "";
|
|
4054
4085
|
}
|
|
4055
|
-
throw new Error(message, {
|
|
4056
|
-
cause: error
|
|
4057
|
-
});
|
|
4086
|
+
throw new Error(message, { cause: error });
|
|
4058
4087
|
}
|
|
4059
4088
|
}
|
|
4060
4089
|
|
|
@@ -4410,7 +4439,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
4410
4439
|
return uniforms;
|
|
4411
4440
|
}
|
|
4412
4441
|
|
|
4413
|
-
// src/modules/lighting/lights/lighting-uniforms
|
|
4442
|
+
// src/modules/lighting/lights/lighting-uniforms-glsl.ts
|
|
4414
4443
|
var lightingUniforms = glsl`\
|
|
4415
4444
|
precision highp int;
|
|
4416
4445
|
|
|
@@ -4468,11 +4497,6 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
4468
4497
|
// src/modules/lighting/lights/lighting-uniforms.ts
|
|
4469
4498
|
var MAX_LIGHTS = 5;
|
|
4470
4499
|
var COLOR_FACTOR = 255;
|
|
4471
|
-
var LIGHT_TYPE = function(LIGHT_TYPE2) {
|
|
4472
|
-
LIGHT_TYPE2[LIGHT_TYPE2["POINT"] = 0] = "POINT";
|
|
4473
|
-
LIGHT_TYPE2[LIGHT_TYPE2["DIRECTIONAL"] = 1] = "DIRECTIONAL";
|
|
4474
|
-
return LIGHT_TYPE2;
|
|
4475
|
-
}(LIGHT_TYPE || {});
|
|
4476
4500
|
var lighting = {
|
|
4477
4501
|
name: "lighting",
|
|
4478
4502
|
vs: lightingUniforms,
|
|
@@ -4487,59 +4511,48 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
4487
4511
|
enabled: "i32",
|
|
4488
4512
|
ambientLightColor: "vec3<f32>",
|
|
4489
4513
|
numberOfLights: "i32",
|
|
4514
|
+
// , array: MAX_LIGHTS,
|
|
4490
4515
|
lightType: "i32",
|
|
4516
|
+
// , array: MAX_LIGHTS,
|
|
4491
4517
|
lightColor: "vec3<f32>",
|
|
4518
|
+
// , array: MAX_LIGHTS,
|
|
4492
4519
|
lightPosition: "vec3<f32>",
|
|
4520
|
+
// , array: MAX_LIGHTS,
|
|
4521
|
+
// TODO - could combine direction and attenuation
|
|
4493
4522
|
lightDirection: "vec3<f32>",
|
|
4523
|
+
// , array: MAX_LIGHTS,
|
|
4494
4524
|
lightAttenuation: "vec3<f32>"
|
|
4525
|
+
// , array: MAX_LIGHTS},
|
|
4495
4526
|
},
|
|
4496
4527
|
defaultUniforms: {
|
|
4497
4528
|
enabled: 1,
|
|
4498
4529
|
ambientLightColor: [0.1, 0.1, 0.1],
|
|
4499
4530
|
numberOfLights: 0,
|
|
4500
|
-
lightType:
|
|
4531
|
+
lightType: 0 /* POINT */,
|
|
4501
4532
|
lightColor: [1, 1, 1],
|
|
4502
4533
|
lightPosition: [1, 1, 2],
|
|
4534
|
+
// TODO - could combine direction and attenuation
|
|
4503
4535
|
lightDirection: [1, 1, 1],
|
|
4504
4536
|
lightAttenuation: [1, 1, 1]
|
|
4505
4537
|
}
|
|
4506
4538
|
};
|
|
4507
4539
|
function getUniforms2(props, prevUniforms = {}) {
|
|
4508
|
-
props = props ? {
|
|
4509
|
-
...props
|
|
4510
|
-
} : props;
|
|
4540
|
+
props = props ? { ...props } : props;
|
|
4511
4541
|
if (!props) {
|
|
4512
|
-
return {
|
|
4513
|
-
...lighting.defaultUniforms
|
|
4514
|
-
};
|
|
4542
|
+
return { ...lighting.defaultUniforms };
|
|
4515
4543
|
}
|
|
4516
4544
|
if (props.lights) {
|
|
4517
|
-
props = {
|
|
4518
|
-
...props,
|
|
4519
|
-
...extractLightTypes(props.lights),
|
|
4520
|
-
lights: void 0
|
|
4521
|
-
};
|
|
4545
|
+
props = { ...props, ...extractLightTypes(props.lights), lights: void 0 };
|
|
4522
4546
|
}
|
|
4523
|
-
const {
|
|
4524
|
-
ambientLight,
|
|
4525
|
-
pointLights,
|
|
4526
|
-
directionalLights
|
|
4527
|
-
} = props || {};
|
|
4547
|
+
const { ambientLight, pointLights, directionalLights } = props || {};
|
|
4528
4548
|
const hasLights = ambientLight || pointLights && pointLights.length > 0 || directionalLights && directionalLights.length > 0;
|
|
4529
4549
|
if (!hasLights) {
|
|
4530
|
-
return {
|
|
4531
|
-
...lighting.defaultUniforms,
|
|
4532
|
-
enabled: 0
|
|
4533
|
-
};
|
|
4550
|
+
return { ...lighting.defaultUniforms, enabled: 0 };
|
|
4534
4551
|
}
|
|
4535
4552
|
const uniforms = {
|
|
4536
4553
|
...lighting.defaultUniforms,
|
|
4537
4554
|
...prevUniforms,
|
|
4538
|
-
...getLightSourceUniforms({
|
|
4539
|
-
ambientLight,
|
|
4540
|
-
pointLights,
|
|
4541
|
-
directionalLights
|
|
4542
|
-
})
|
|
4555
|
+
...getLightSourceUniforms({ ambientLight, pointLights, directionalLights })
|
|
4543
4556
|
};
|
|
4544
4557
|
if (props.enabled !== void 0) {
|
|
4545
4558
|
uniforms.enabled = props.enabled ? 1 : 0;
|
|
@@ -4551,18 +4564,24 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
4551
4564
|
pointLights = [],
|
|
4552
4565
|
directionalLights = []
|
|
4553
4566
|
}) {
|
|
4554
|
-
const lightSourceUniforms = {
|
|
4567
|
+
const lightSourceUniforms = {
|
|
4568
|
+
// lightType: new Array(MAX_LIGHTS).fill(0),
|
|
4569
|
+
// lightColor: new Array(MAX_LIGHTS).fill([0, 0, 0]),
|
|
4570
|
+
// lightPosition: new Array(MAX_LIGHTS).fill([0, 0, 0]),
|
|
4571
|
+
// lightDirection: new Array(MAX_LIGHTS).fill([0, 0, 0]),
|
|
4572
|
+
// lightAttenuation: new Array(MAX_LIGHTS).fill([0, 0, 0])
|
|
4573
|
+
};
|
|
4555
4574
|
lightSourceUniforms.ambientLightColor = convertColor(ambientLight);
|
|
4556
4575
|
let currentLight = 0;
|
|
4557
4576
|
for (const pointLight of pointLights) {
|
|
4558
|
-
lightSourceUniforms.lightType =
|
|
4577
|
+
lightSourceUniforms.lightType = 0 /* POINT */;
|
|
4559
4578
|
lightSourceUniforms.lightColor = convertColor(pointLight);
|
|
4560
4579
|
lightSourceUniforms.lightPosition = pointLight.position;
|
|
4561
4580
|
lightSourceUniforms.lightAttenuation = [pointLight.attenuation || 1, 0, 0];
|
|
4562
4581
|
currentLight++;
|
|
4563
4582
|
}
|
|
4564
4583
|
for (const directionalLight of directionalLights) {
|
|
4565
|
-
lightSourceUniforms.lightType =
|
|
4584
|
+
lightSourceUniforms.lightType = 1 /* DIRECTIONAL */;
|
|
4566
4585
|
lightSourceUniforms.lightColor = convertColor(directionalLight);
|
|
4567
4586
|
lightSourceUniforms.lightPosition = directionalLight.position;
|
|
4568
4587
|
lightSourceUniforms.lightDirection = directionalLight.direction;
|
|
@@ -4572,10 +4591,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
4572
4591
|
return lightSourceUniforms;
|
|
4573
4592
|
}
|
|
4574
4593
|
function extractLightTypes(lights2) {
|
|
4575
|
-
const lightSources = {
|
|
4576
|
-
pointLights: [],
|
|
4577
|
-
directionalLights: []
|
|
4578
|
-
};
|
|
4594
|
+
const lightSources = { pointLights: [], directionalLights: [] };
|
|
4579
4595
|
for (const light of lights2 || []) {
|
|
4580
4596
|
switch (light.type) {
|
|
4581
4597
|
case "ambient":
|
|
@@ -4593,10 +4609,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
4593
4609
|
return lightSources;
|
|
4594
4610
|
}
|
|
4595
4611
|
function convertColor(colorDef = {}) {
|
|
4596
|
-
const {
|
|
4597
|
-
color = [0, 0, 0],
|
|
4598
|
-
intensity = 1
|
|
4599
|
-
} = colorDef;
|
|
4612
|
+
const { color = [0, 0, 0], intensity = 1 } = colorDef;
|
|
4600
4613
|
return color.map((component) => component * intensity / COLOR_FACTOR);
|
|
4601
4614
|
}
|
|
4602
4615
|
|
|
@@ -4626,6 +4639,14 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
4626
4639
|
dependencies: [],
|
|
4627
4640
|
vs: VS_GLSL,
|
|
4628
4641
|
fs: FS_GLSL,
|
|
4642
|
+
// vs: {glsl: VS_GLSL, wgsl: VS_WGSL},
|
|
4643
|
+
// fs: {glsl: FS_GLSL, wgsl: FS_WGSL},
|
|
4644
|
+
// fragmentInputs: [
|
|
4645
|
+
// {
|
|
4646
|
+
// name: 'dirlight_vNormal',
|
|
4647
|
+
// type: 'vec3<f32>'
|
|
4648
|
+
// }
|
|
4649
|
+
// ],
|
|
4629
4650
|
uniformTypes: {
|
|
4630
4651
|
lightDirection: "vec3<f32>"
|
|
4631
4652
|
},
|
|
@@ -4642,7 +4663,7 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
4642
4663
|
return uniforms;
|
|
4643
4664
|
}
|
|
4644
4665
|
|
|
4645
|
-
// src/modules/lighting/gouraud-material/gouraud-shaders
|
|
4666
|
+
// src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts
|
|
4646
4667
|
var GOURAUD_VS = glsl`\
|
|
4647
4668
|
uniform materialUniforms {
|
|
4648
4669
|
uniform float ambient;
|
|
@@ -4738,6 +4759,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
4738
4759
|
// src/modules/lighting/gouraud-material/gouraud-material.ts
|
|
4739
4760
|
var gouraudMaterial = {
|
|
4740
4761
|
name: "gouraud-lighting",
|
|
4762
|
+
// Note these are switched between phong and gouraud
|
|
4741
4763
|
vs: GOURAUD_VS,
|
|
4742
4764
|
fs: GOURAUD_FS,
|
|
4743
4765
|
defines: {
|
|
@@ -4757,14 +4779,11 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
4757
4779
|
specularColor: [0.15, 0.15, 0.15]
|
|
4758
4780
|
},
|
|
4759
4781
|
getUniforms(props) {
|
|
4760
|
-
return {
|
|
4761
|
-
...gouraudMaterial.defaultUniforms,
|
|
4762
|
-
...props
|
|
4763
|
-
};
|
|
4782
|
+
return { ...gouraudMaterial.defaultUniforms, ...props };
|
|
4764
4783
|
}
|
|
4765
4784
|
};
|
|
4766
4785
|
|
|
4767
|
-
// src/modules/lighting/phong-material/phong-shaders
|
|
4786
|
+
// src/modules/lighting/phong-material/phong-shaders-glsl.ts
|
|
4768
4787
|
var PHONG_VS = glsl`\
|
|
4769
4788
|
uniform phongMaterialUniforms {
|
|
4770
4789
|
uniform float ambient;
|
|
@@ -4863,6 +4882,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
4863
4882
|
// src/modules/lighting/phong-material/phong-material.ts
|
|
4864
4883
|
var phongMaterial = {
|
|
4865
4884
|
name: "phong-lighting",
|
|
4885
|
+
// Note these are switched between phong and gouraud
|
|
4866
4886
|
vs: PHONG_VS,
|
|
4867
4887
|
fs: PHONG_FS,
|
|
4868
4888
|
defines: {
|
|
@@ -4882,14 +4902,11 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
4882
4902
|
specularColor: [0.15, 0.15, 0.15]
|
|
4883
4903
|
},
|
|
4884
4904
|
getUniforms(props) {
|
|
4885
|
-
return {
|
|
4886
|
-
...phongMaterial.defaultUniforms,
|
|
4887
|
-
...props
|
|
4888
|
-
};
|
|
4905
|
+
return { ...phongMaterial.defaultUniforms, ...props };
|
|
4889
4906
|
}
|
|
4890
4907
|
};
|
|
4891
4908
|
|
|
4892
|
-
// src/modules/lighting/pbr-material/pbr-vertex
|
|
4909
|
+
// src/modules/lighting/pbr-material/pbr-vertex-glsl.ts
|
|
4893
4910
|
var vs2 = glsl`\
|
|
4894
4911
|
uniform projection {
|
|
4895
4912
|
mat4 u_MVPMatrix;
|
|
@@ -4934,7 +4951,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
|
|
|
4934
4951
|
}
|
|
4935
4952
|
`;
|
|
4936
4953
|
|
|
4937
|
-
// src/modules/lighting/pbr-material/pbr-fragment
|
|
4954
|
+
// src/modules/lighting/pbr-material/pbr-fragment-glsl.ts
|
|
4938
4955
|
var fs3 = glsl`\
|
|
4939
4956
|
#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
|
|
4940
4957
|
# error PBR fragment shader: Texture LOD is not available
|
|
@@ -4944,14 +4961,8 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
|
|
|
4944
4961
|
# error PBR fragment shader: Derivatives are not available
|
|
4945
4962
|
#endif
|
|
4946
4963
|
|
|
4947
|
-
//
|
|
4948
|
-
|
|
4949
|
-
// and still take advantage of WebGL 2.0
|
|
4950
|
-
#if (__VERSION__ < 300)
|
|
4951
|
-
#define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)
|
|
4952
|
-
#else
|
|
4953
|
-
#define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)
|
|
4954
|
-
#endif
|
|
4964
|
+
// TODO - remove we only support WebGL2
|
|
4965
|
+
#define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)
|
|
4955
4966
|
|
|
4956
4967
|
precision highp float;
|
|
4957
4968
|
|
|
@@ -5377,57 +5388,52 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
5377
5388
|
PBR_DEBUG: 0
|
|
5378
5389
|
},
|
|
5379
5390
|
uniformTypes: {
|
|
5391
|
+
// Material is unlit
|
|
5380
5392
|
unlit: "i32",
|
|
5393
|
+
// Base color map
|
|
5381
5394
|
baseColorMapEnabled: "i32",
|
|
5382
5395
|
baseColorFactor: "vec4<f32>",
|
|
5383
5396
|
normalMapEnabled: "i32",
|
|
5384
5397
|
normalScale: "f32",
|
|
5398
|
+
// #ifdef HAS_NORMALMAP
|
|
5385
5399
|
emissiveMapEnabled: "i32",
|
|
5386
5400
|
emissiveFactor: "vec3<f32>",
|
|
5401
|
+
// #ifdef HAS_EMISSIVEMAP
|
|
5387
5402
|
metallicRoughnessValues: "vec2<f32>",
|
|
5388
5403
|
metallicRoughnessMapEnabled: "i32",
|
|
5389
5404
|
occlusionMapEnabled: "i32",
|
|
5390
5405
|
occlusionStrength: "f32",
|
|
5406
|
+
// #ifdef HAS_OCCLUSIONMAP
|
|
5391
5407
|
alphaCutoffEnabled: "i32",
|
|
5392
5408
|
alphaCutoff: "f32",
|
|
5409
|
+
// #ifdef ALPHA_CUTOFF
|
|
5410
|
+
// IBL
|
|
5393
5411
|
IBLenabled: "i32",
|
|
5394
5412
|
scaleIBLAmbient: "vec2<f32>",
|
|
5413
|
+
// #ifdef USE_IBL
|
|
5414
|
+
// debugging flags used for shader output of intermediate PBR variables
|
|
5415
|
+
// #ifdef PBR_DEBUG
|
|
5395
5416
|
scaleDiffBaseMR: "vec4<f32>",
|
|
5396
5417
|
scaleFGDSpec: "vec4<f32>"
|
|
5397
5418
|
},
|
|
5398
5419
|
bindings: {
|
|
5399
|
-
baseColorSampler: {
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
},
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
}
|
|
5415
|
-
|
|
5416
|
-
type: "texture",
|
|
5417
|
-
location: 12
|
|
5418
|
-
},
|
|
5419
|
-
diffuseEnvSampler: {
|
|
5420
|
-
type: "texture",
|
|
5421
|
-
location: 13
|
|
5422
|
-
},
|
|
5423
|
-
specularEnvSampler: {
|
|
5424
|
-
type: "texture",
|
|
5425
|
-
location: 14
|
|
5426
|
-
},
|
|
5427
|
-
brdfLUT: {
|
|
5428
|
-
type: "texture",
|
|
5429
|
-
location: 15
|
|
5430
|
-
}
|
|
5420
|
+
baseColorSampler: { type: "texture", location: 8 },
|
|
5421
|
+
// #ifdef HAS_BASECOLORMAP
|
|
5422
|
+
normalSampler: { type: "texture", location: 9 },
|
|
5423
|
+
// #ifdef HAS_NORMALMAP
|
|
5424
|
+
emissiveSampler: { type: "texture", location: 10 },
|
|
5425
|
+
// #ifdef HAS_EMISSIVEMAP
|
|
5426
|
+
metallicRoughnessSampler: { type: "texture", location: 11 },
|
|
5427
|
+
// #ifdef HAS_METALROUGHNESSMAP
|
|
5428
|
+
occlusionSampler: { type: "texture", location: 12 },
|
|
5429
|
+
// #ifdef HAS_OCCLUSIONMAP
|
|
5430
|
+
// IBL Samplers
|
|
5431
|
+
diffuseEnvSampler: { type: "texture", location: 13 },
|
|
5432
|
+
// #ifdef USE_IBL (samplerCube)
|
|
5433
|
+
specularEnvSampler: { type: "texture", location: 14 },
|
|
5434
|
+
// #ifdef USE_IBL (samplerCube)
|
|
5435
|
+
brdfLUT: { type: "texture", location: 15 }
|
|
5436
|
+
// #ifdef USE_IBL
|
|
5431
5437
|
},
|
|
5432
5438
|
dependencies: [lighting]
|
|
5433
5439
|
};
|
|
@@ -5461,23 +5467,11 @@ vec4 brightnessContrast_filterColor(vec4 color, vec2 texSize, vec2 texCoords) {
|
|
|
5461
5467
|
contrast: "f32"
|
|
5462
5468
|
},
|
|
5463
5469
|
uniformPropTypes: {
|
|
5464
|
-
brightness: {
|
|
5465
|
-
|
|
5466
|
-
value: 0,
|
|
5467
|
-
min: -1,
|
|
5468
|
-
max: 1
|
|
5469
|
-
},
|
|
5470
|
-
contrast: {
|
|
5471
|
-
format: "f32",
|
|
5472
|
-
value: 0,
|
|
5473
|
-
min: -1,
|
|
5474
|
-
max: 1
|
|
5475
|
-
}
|
|
5470
|
+
brightness: { format: "f32", value: 0, min: -1, max: 1 },
|
|
5471
|
+
contrast: { format: "f32", value: 0, min: -1, max: 1 }
|
|
5476
5472
|
},
|
|
5477
5473
|
fs: fs4,
|
|
5478
|
-
passes: [{
|
|
5479
|
-
filter: true
|
|
5480
|
-
}]
|
|
5474
|
+
passes: [{ filter: true }]
|
|
5481
5475
|
};
|
|
5482
5476
|
|
|
5483
5477
|
// src/modules/postprocessing/image-adjust-filters/denoise.ts
|
|
@@ -5511,19 +5505,11 @@ vec4 denoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
5511
5505
|
strength: "f32"
|
|
5512
5506
|
},
|
|
5513
5507
|
uniformPropTypes: {
|
|
5514
|
-
strength: {
|
|
5515
|
-
|
|
5516
|
-
value: 0.5,
|
|
5517
|
-
min: 0,
|
|
5518
|
-
max: 1
|
|
5519
|
-
}
|
|
5508
|
+
strength: { format: "f32", value: 0.5, min: 0, max: 1 }
|
|
5509
|
+
// strength: {..., adjust: (strength: number): number => 0.53 + 200 * Math.pow(1 - strength, 4) // TODO - JS preprocessing
|
|
5520
5510
|
},
|
|
5521
5511
|
fs: fs5,
|
|
5522
|
-
passes: [{
|
|
5523
|
-
sampler: true
|
|
5524
|
-
}, {
|
|
5525
|
-
sampler: true
|
|
5526
|
-
}]
|
|
5512
|
+
passes: [{ sampler: true }, { sampler: true }]
|
|
5527
5513
|
};
|
|
5528
5514
|
|
|
5529
5515
|
// src/modules/postprocessing/image-adjust-filters/huesaturation.ts
|
|
@@ -5567,21 +5553,11 @@ vec4 hueSaturation_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
5567
5553
|
saturation: "f32"
|
|
5568
5554
|
},
|
|
5569
5555
|
uniformPropTypes: {
|
|
5570
|
-
hue: {
|
|
5571
|
-
|
|
5572
|
-
min: -1,
|
|
5573
|
-
max: 1
|
|
5574
|
-
},
|
|
5575
|
-
saturation: {
|
|
5576
|
-
value: 0,
|
|
5577
|
-
min: -1,
|
|
5578
|
-
max: 1
|
|
5579
|
-
}
|
|
5556
|
+
hue: { value: 0, min: -1, max: 1 },
|
|
5557
|
+
saturation: { value: 0, min: -1, max: 1 }
|
|
5580
5558
|
},
|
|
5581
5559
|
fs: fs6,
|
|
5582
|
-
passes: [{
|
|
5583
|
-
filter: true
|
|
5584
|
-
}]
|
|
5560
|
+
passes: [{ filter: true }]
|
|
5585
5561
|
};
|
|
5586
5562
|
|
|
5587
5563
|
// src/modules/postprocessing/image-adjust-filters/noise.ts
|
|
@@ -5612,16 +5588,10 @@ vec4 noise_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
5612
5588
|
amount: "f32"
|
|
5613
5589
|
},
|
|
5614
5590
|
uniformPropTypes: {
|
|
5615
|
-
amount: {
|
|
5616
|
-
value: 0.5,
|
|
5617
|
-
min: 0,
|
|
5618
|
-
max: 1
|
|
5619
|
-
}
|
|
5591
|
+
amount: { value: 0.5, min: 0, max: 1 }
|
|
5620
5592
|
},
|
|
5621
5593
|
fs: fs7,
|
|
5622
|
-
passes: [{
|
|
5623
|
-
filter: true
|
|
5624
|
-
}]
|
|
5594
|
+
passes: [{ filter: true }]
|
|
5625
5595
|
};
|
|
5626
5596
|
|
|
5627
5597
|
// src/modules/postprocessing/image-adjust-filters/sepia.ts
|
|
@@ -5653,16 +5623,10 @@ vec4 sepia_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
5653
5623
|
amount: "f32"
|
|
5654
5624
|
},
|
|
5655
5625
|
uniformPropTypes: {
|
|
5656
|
-
amount: {
|
|
5657
|
-
value: 0.5,
|
|
5658
|
-
min: 0,
|
|
5659
|
-
max: 1
|
|
5660
|
-
}
|
|
5626
|
+
amount: { value: 0.5, min: 0, max: 1 }
|
|
5661
5627
|
},
|
|
5662
5628
|
fs: fs8,
|
|
5663
|
-
passes: [{
|
|
5664
|
-
filter: true
|
|
5665
|
-
}]
|
|
5629
|
+
passes: [{ filter: true }]
|
|
5666
5630
|
};
|
|
5667
5631
|
|
|
5668
5632
|
// src/modules/postprocessing/image-adjust-filters/vibrance.ts
|
|
@@ -5686,16 +5650,10 @@ vec4 vibrance_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
5686
5650
|
var vibrance = {
|
|
5687
5651
|
name: "vibrance",
|
|
5688
5652
|
uniformPropTypes: {
|
|
5689
|
-
amount: {
|
|
5690
|
-
value: 0,
|
|
5691
|
-
min: -1,
|
|
5692
|
-
max: 1
|
|
5693
|
-
}
|
|
5653
|
+
amount: { value: 0, min: -1, max: 1 }
|
|
5694
5654
|
},
|
|
5695
5655
|
fs: fs9,
|
|
5696
|
-
passes: [{
|
|
5697
|
-
filter: true
|
|
5698
|
-
}]
|
|
5656
|
+
passes: [{ filter: true }]
|
|
5699
5657
|
};
|
|
5700
5658
|
|
|
5701
5659
|
// src/modules/postprocessing/image-adjust-filters/vignette.ts
|
|
@@ -5723,20 +5681,10 @@ vec4 vignette_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
5723
5681
|
amount: "f32"
|
|
5724
5682
|
},
|
|
5725
5683
|
uniformPropTypes: {
|
|
5726
|
-
radius: {
|
|
5727
|
-
|
|
5728
|
-
min: 0,
|
|
5729
|
-
max: 1
|
|
5730
|
-
},
|
|
5731
|
-
amount: {
|
|
5732
|
-
value: 0.5,
|
|
5733
|
-
min: 0,
|
|
5734
|
-
max: 1
|
|
5735
|
-
}
|
|
5684
|
+
radius: { value: 0.5, min: 0, max: 1 },
|
|
5685
|
+
amount: { value: 0.5, min: 0, max: 1 }
|
|
5736
5686
|
},
|
|
5737
|
-
passes: [{
|
|
5738
|
-
filter: true
|
|
5739
|
-
}]
|
|
5687
|
+
passes: [{ filter: true }]
|
|
5740
5688
|
};
|
|
5741
5689
|
|
|
5742
5690
|
// src/modules/postprocessing/image-blur-filters/tiltshift.ts
|
|
@@ -5795,38 +5743,16 @@ vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
5795
5743
|
invert: "i32"
|
|
5796
5744
|
},
|
|
5797
5745
|
uniformPropTypes: {
|
|
5798
|
-
blurRadius: {
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
}
|
|
5803
|
-
gradientRadius: {
|
|
5804
|
-
value: 200,
|
|
5805
|
-
min: 0,
|
|
5806
|
-
max: 400
|
|
5807
|
-
},
|
|
5808
|
-
start: {
|
|
5809
|
-
value: [0, 0]
|
|
5810
|
-
},
|
|
5811
|
-
end: {
|
|
5812
|
-
value: [1, 1]
|
|
5813
|
-
},
|
|
5814
|
-
invert: {
|
|
5815
|
-
value: false,
|
|
5816
|
-
private: true
|
|
5817
|
-
}
|
|
5746
|
+
blurRadius: { value: 15, min: 0, max: 50 },
|
|
5747
|
+
gradientRadius: { value: 200, min: 0, max: 400 },
|
|
5748
|
+
start: { value: [0, 0] },
|
|
5749
|
+
end: { value: [1, 1] },
|
|
5750
|
+
invert: { value: false, private: true }
|
|
5818
5751
|
},
|
|
5819
|
-
passes: [
|
|
5820
|
-
sampler: true,
|
|
5821
|
-
uniforms: {
|
|
5822
|
-
|
|
5823
|
-
}
|
|
5824
|
-
}, {
|
|
5825
|
-
sampler: true,
|
|
5826
|
-
uniforms: {
|
|
5827
|
-
invert: true
|
|
5828
|
-
}
|
|
5829
|
-
}],
|
|
5752
|
+
passes: [
|
|
5753
|
+
{ sampler: true, uniforms: { invert: false } },
|
|
5754
|
+
{ sampler: true, uniforms: { invert: true } }
|
|
5755
|
+
],
|
|
5830
5756
|
dependencies: [random],
|
|
5831
5757
|
fs: fs11
|
|
5832
5758
|
};
|
|
@@ -5874,29 +5800,15 @@ vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
5874
5800
|
delta: "vec2<f32>"
|
|
5875
5801
|
},
|
|
5876
5802
|
uniformPropTypes: {
|
|
5877
|
-
radius: {
|
|
5878
|
-
|
|
5879
|
-
min: 0,
|
|
5880
|
-
softMax: 100
|
|
5881
|
-
},
|
|
5882
|
-
delta: {
|
|
5883
|
-
value: [1, 0],
|
|
5884
|
-
private: true
|
|
5885
|
-
}
|
|
5803
|
+
radius: { value: 20, min: 0, softMax: 100 },
|
|
5804
|
+
delta: { value: [1, 0], private: true }
|
|
5886
5805
|
},
|
|
5887
5806
|
fs: fs12,
|
|
5888
5807
|
dependencies: [random],
|
|
5889
|
-
passes: [
|
|
5890
|
-
sampler: true,
|
|
5891
|
-
uniforms: {
|
|
5892
|
-
|
|
5893
|
-
}
|
|
5894
|
-
}, {
|
|
5895
|
-
sampler: true,
|
|
5896
|
-
uniforms: {
|
|
5897
|
-
delta: [0, 1]
|
|
5898
|
-
}
|
|
5899
|
-
}]
|
|
5808
|
+
passes: [
|
|
5809
|
+
{ sampler: true, uniforms: { delta: [1, 0] } },
|
|
5810
|
+
{ sampler: true, uniforms: { delta: [0, 1] } }
|
|
5811
|
+
]
|
|
5900
5812
|
};
|
|
5901
5813
|
|
|
5902
5814
|
// src/modules/postprocessing/image-blur-filters/zoomblur.ts
|
|
@@ -5941,20 +5853,12 @@ vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
5941
5853
|
strength: "f32"
|
|
5942
5854
|
},
|
|
5943
5855
|
uniformPropTypes: {
|
|
5944
|
-
center: {
|
|
5945
|
-
|
|
5946
|
-
},
|
|
5947
|
-
strength: {
|
|
5948
|
-
value: 0.3,
|
|
5949
|
-
min: 0,
|
|
5950
|
-
softMax: 1
|
|
5951
|
-
}
|
|
5856
|
+
center: { value: [0.5, 0.5] },
|
|
5857
|
+
strength: { value: 0.3, min: 0, softMax: 1 }
|
|
5952
5858
|
},
|
|
5953
5859
|
fs: fs13,
|
|
5954
5860
|
dependencies: [random],
|
|
5955
|
-
passes: [{
|
|
5956
|
-
sampler: true
|
|
5957
|
-
}]
|
|
5861
|
+
passes: [{ sampler: true }]
|
|
5958
5862
|
};
|
|
5959
5863
|
|
|
5960
5864
|
// src/modules/postprocessing/image-fun-filters/colorhalftone.ts
|
|
@@ -6002,25 +5906,12 @@ vec4 colorHalftone_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
6002
5906
|
size: "f32"
|
|
6003
5907
|
},
|
|
6004
5908
|
uniformPropTypes: {
|
|
6005
|
-
center: {
|
|
6006
|
-
|
|
6007
|
-
}
|
|
6008
|
-
angle: {
|
|
6009
|
-
value: 1.1,
|
|
6010
|
-
softMin: 0,
|
|
6011
|
-
softMax: Math.PI / 2
|
|
6012
|
-
},
|
|
6013
|
-
size: {
|
|
6014
|
-
value: 4,
|
|
6015
|
-
min: 1,
|
|
6016
|
-
softMin: 3,
|
|
6017
|
-
softMax: 20
|
|
6018
|
-
}
|
|
5909
|
+
center: { value: [0.5, 0.5] },
|
|
5910
|
+
angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
|
|
5911
|
+
size: { value: 4, min: 1, softMin: 3, softMax: 20 }
|
|
6019
5912
|
},
|
|
6020
5913
|
fs: fs14,
|
|
6021
|
-
passes: [{
|
|
6022
|
-
filter: true
|
|
6023
|
-
}]
|
|
5914
|
+
passes: [{ filter: true }]
|
|
6024
5915
|
};
|
|
6025
5916
|
|
|
6026
5917
|
// src/modules/postprocessing/image-fun-filters/dotscreen.ts
|
|
@@ -6056,25 +5947,12 @@ vec4 dotScreen_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
|
|
|
6056
5947
|
size: "f32"
|
|
6057
5948
|
},
|
|
6058
5949
|
uniformPropTypes: {
|
|
6059
|
-
center: {
|
|
6060
|
-
|
|
6061
|
-
}
|
|
6062
|
-
angle: {
|
|
6063
|
-
value: 1.1,
|
|
6064
|
-
softMin: 0,
|
|
6065
|
-
softMax: Math.PI / 2
|
|
6066
|
-
},
|
|
6067
|
-
size: {
|
|
6068
|
-
value: 3,
|
|
6069
|
-
min: 1,
|
|
6070
|
-
softMin: 3,
|
|
6071
|
-
softMax: 20
|
|
6072
|
-
}
|
|
5950
|
+
center: { value: [0.5, 0.5] },
|
|
5951
|
+
angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
|
|
5952
|
+
size: { value: 3, min: 1, softMin: 3, softMax: 20 }
|
|
6073
5953
|
},
|
|
6074
5954
|
fs: fs15,
|
|
6075
|
-
passes: [{
|
|
6076
|
-
filter: true
|
|
6077
|
-
}]
|
|
5955
|
+
passes: [{ filter: true }]
|
|
6078
5956
|
};
|
|
6079
5957
|
|
|
6080
5958
|
// src/modules/postprocessing/image-fun-filters/edgework.ts
|
|
@@ -6137,29 +6015,23 @@ vec4 edgeWork_sampleColor2(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
6137
6015
|
var edgeWork = {
|
|
6138
6016
|
name: "edgeWork",
|
|
6139
6017
|
uniformPropTypes: {
|
|
6140
|
-
radius: {
|
|
6141
|
-
|
|
6142
|
-
min: 1,
|
|
6143
|
-
softMax: 50
|
|
6144
|
-
},
|
|
6145
|
-
delta: {
|
|
6146
|
-
value: [1, 0],
|
|
6147
|
-
private: true
|
|
6148
|
-
}
|
|
6018
|
+
radius: { value: 2, min: 1, softMax: 50 },
|
|
6019
|
+
delta: { value: [1, 0], private: true }
|
|
6149
6020
|
},
|
|
6150
6021
|
fs: fs16,
|
|
6151
6022
|
dependencies: [random],
|
|
6152
|
-
passes: [
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6023
|
+
passes: [
|
|
6024
|
+
{
|
|
6025
|
+
// @ts-expect-error
|
|
6026
|
+
sampler: "edgeWork_sampleColor1",
|
|
6027
|
+
uniformPropTypes: { delta: [1, 0] }
|
|
6028
|
+
},
|
|
6029
|
+
{
|
|
6030
|
+
// @ts-expect-error
|
|
6031
|
+
sampler: "edgeWork_sampleColor2",
|
|
6032
|
+
uniformPropTypes: { delta: [0, 1] }
|
|
6161
6033
|
}
|
|
6162
|
-
|
|
6034
|
+
]
|
|
6163
6035
|
};
|
|
6164
6036
|
|
|
6165
6037
|
// src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts
|
|
@@ -6214,21 +6086,11 @@ vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord
|
|
|
6214
6086
|
scale: "f32"
|
|
6215
6087
|
},
|
|
6216
6088
|
uniformPropTypes: {
|
|
6217
|
-
center: {
|
|
6218
|
-
|
|
6219
|
-
hint: "screenspace"
|
|
6220
|
-
},
|
|
6221
|
-
scale: {
|
|
6222
|
-
value: 10,
|
|
6223
|
-
min: 1,
|
|
6224
|
-
softMin: 5,
|
|
6225
|
-
softMax: 50
|
|
6226
|
-
}
|
|
6089
|
+
center: { value: [0.5, 0.5], hint: "screenspace" },
|
|
6090
|
+
scale: { value: 10, min: 1, softMin: 5, softMax: 50 }
|
|
6227
6091
|
},
|
|
6228
6092
|
fs: fs17,
|
|
6229
|
-
passes: [{
|
|
6230
|
-
sampler: true
|
|
6231
|
-
}]
|
|
6093
|
+
passes: [{ sampler: true }]
|
|
6232
6094
|
};
|
|
6233
6095
|
|
|
6234
6096
|
// src/modules/postprocessing/image-fun-filters/ink.ts
|
|
@@ -6267,16 +6129,10 @@ vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
6267
6129
|
strength: "f32"
|
|
6268
6130
|
},
|
|
6269
6131
|
uniformPropTypes: {
|
|
6270
|
-
strength: {
|
|
6271
|
-
value: 0.25,
|
|
6272
|
-
min: 0,
|
|
6273
|
-
softMax: 1
|
|
6274
|
-
}
|
|
6132
|
+
strength: { value: 0.25, min: 0, softMax: 1 }
|
|
6275
6133
|
},
|
|
6276
6134
|
fs: fs18,
|
|
6277
|
-
passes: [{
|
|
6278
|
-
sampler: true
|
|
6279
|
-
}]
|
|
6135
|
+
passes: [{ sampler: true }]
|
|
6280
6136
|
};
|
|
6281
6137
|
|
|
6282
6138
|
// src/modules/postprocessing/image-fun-filters/magnify.ts
|
|
@@ -6312,20 +6168,15 @@ vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
6312
6168
|
borderColor: "vec4<f32>"
|
|
6313
6169
|
},
|
|
6314
6170
|
uniformPropTypes: {
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
},
|
|
6171
|
+
// range 0 to 1
|
|
6172
|
+
screenXY: { value: [0, 0] },
|
|
6318
6173
|
radiusPixels: 200,
|
|
6319
6174
|
zoom: 2,
|
|
6320
6175
|
borderWidthPixels: 0,
|
|
6321
|
-
borderColor: {
|
|
6322
|
-
value: [255, 255, 255, 255]
|
|
6323
|
-
}
|
|
6176
|
+
borderColor: { value: [255, 255, 255, 255] }
|
|
6324
6177
|
},
|
|
6325
6178
|
fs: fs19,
|
|
6326
|
-
passes: [{
|
|
6327
|
-
sampler: true
|
|
6328
|
-
}]
|
|
6179
|
+
passes: [{ sampler: true }]
|
|
6329
6180
|
};
|
|
6330
6181
|
|
|
6331
6182
|
// src/modules/postprocessing/image-warp-filters/warp.ts
|
|
@@ -6386,24 +6237,12 @@ vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
6386
6237
|
strength: "f32"
|
|
6387
6238
|
},
|
|
6388
6239
|
uniformPropTypes: {
|
|
6389
|
-
center: {
|
|
6390
|
-
|
|
6391
|
-
}
|
|
6392
|
-
radius: {
|
|
6393
|
-
value: 200,
|
|
6394
|
-
min: 1,
|
|
6395
|
-
softMax: 600
|
|
6396
|
-
},
|
|
6397
|
-
strength: {
|
|
6398
|
-
value: 0.5,
|
|
6399
|
-
min: -1,
|
|
6400
|
-
max: 1
|
|
6401
|
-
}
|
|
6240
|
+
center: { value: [0.5, 0.5] },
|
|
6241
|
+
radius: { value: 200, min: 1, softMax: 600 },
|
|
6242
|
+
strength: { value: 0.5, min: -1, max: 1 }
|
|
6402
6243
|
},
|
|
6403
6244
|
dependencies: [warp],
|
|
6404
|
-
passes: [{
|
|
6405
|
-
sampler: true
|
|
6406
|
-
}]
|
|
6245
|
+
passes: [{ sampler: true }]
|
|
6407
6246
|
};
|
|
6408
6247
|
|
|
6409
6248
|
// src/modules/postprocessing/image-warp-filters/swirl.ts
|
|
@@ -6447,24 +6286,12 @@ vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
6447
6286
|
angle: "f32"
|
|
6448
6287
|
},
|
|
6449
6288
|
uniformPropTypes: {
|
|
6450
|
-
center: {
|
|
6451
|
-
|
|
6452
|
-
}
|
|
6453
|
-
radius: {
|
|
6454
|
-
value: 200,
|
|
6455
|
-
min: 1,
|
|
6456
|
-
softMax: 600
|
|
6457
|
-
},
|
|
6458
|
-
angle: {
|
|
6459
|
-
value: 3,
|
|
6460
|
-
softMin: -25,
|
|
6461
|
-
softMax: 25
|
|
6462
|
-
}
|
|
6289
|
+
center: { value: [0.5, 0.5] },
|
|
6290
|
+
radius: { value: 200, min: 1, softMax: 600 },
|
|
6291
|
+
angle: { value: 3, softMin: -25, softMax: 25 }
|
|
6463
6292
|
},
|
|
6464
6293
|
dependencies: [warp],
|
|
6465
|
-
passes: [{
|
|
6466
|
-
sampler: true
|
|
6467
|
-
}]
|
|
6294
|
+
passes: [{ sampler: true }]
|
|
6468
6295
|
};
|
|
6469
6296
|
|
|
6470
6297
|
// src/modules/postprocessing/fxaa/fxaa.ts
|
|
@@ -7053,9 +6880,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
7053
6880
|
name: "fxaa",
|
|
7054
6881
|
uniformPropTypes: {},
|
|
7055
6882
|
fs: fs23,
|
|
7056
|
-
passes: [{
|
|
7057
|
-
sampler: true
|
|
7058
|
-
}]
|
|
6883
|
+
passes: [{ sampler: true }]
|
|
7059
6884
|
};
|
|
7060
6885
|
|
|
7061
6886
|
// src/modules-webgl1/math/fp64/fp64-utils.ts
|
|
@@ -7080,7 +6905,7 @@ vec4 fxaa_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
|
|
|
7080
6905
|
return matrixFP64;
|
|
7081
6906
|
}
|
|
7082
6907
|
|
|
7083
|
-
// src/modules-webgl1/math/fp64/fp64-arithmetic
|
|
6908
|
+
// src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts
|
|
7084
6909
|
var fp64arithmeticShader = glsl`\
|
|
7085
6910
|
uniform float ONE;
|
|
7086
6911
|
|
|
@@ -7249,7 +7074,7 @@ vec2 sqrt_fp64(vec2 a) {
|
|
|
7249
7074
|
}
|
|
7250
7075
|
`;
|
|
7251
7076
|
|
|
7252
|
-
// src/modules-webgl1/math/fp64/fp64-functions
|
|
7077
|
+
// src/modules-webgl1/math/fp64/fp64-functions-glsl.ts
|
|
7253
7078
|
var fp64functionShader = glsl`\
|
|
7254
7079
|
const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
|
|
7255
7080
|
const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
|
|
@@ -7924,6 +7749,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
|
|
|
7924
7749
|
|
|
7925
7750
|
// src/modules-webgl1/math/fp64/fp64.ts
|
|
7926
7751
|
var CONST_UNIFORMS = {
|
|
7752
|
+
// Used in LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
7927
7753
|
ONE: 1
|
|
7928
7754
|
};
|
|
7929
7755
|
function getUniforms4() {
|
|
@@ -7941,6 +7767,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
|
|
|
7941
7767
|
name: "fp64",
|
|
7942
7768
|
vs: fp64functionShader,
|
|
7943
7769
|
dependencies: [fp64arithmetic],
|
|
7770
|
+
// Additional Functions
|
|
7944
7771
|
fp64ify,
|
|
7945
7772
|
fp64LowPart,
|
|
7946
7773
|
fp64ifyMatrix4
|
|
@@ -9553,7 +9380,9 @@ vec3 geometry_getNormal() {
|
|
|
9553
9380
|
uniforms.cameraPositionWorld = opts.cameraPositionWorld;
|
|
9554
9381
|
}
|
|
9555
9382
|
if (opts.projectionMatrix !== void 0 || opts.viewMatrix !== void 0) {
|
|
9556
|
-
uniforms.viewProjectionMatrix = new Matrix4(opts.projectionMatrix).multiplyRight(
|
|
9383
|
+
uniforms.viewProjectionMatrix = new Matrix4(opts.projectionMatrix).multiplyRight(
|
|
9384
|
+
opts.viewMatrix
|
|
9385
|
+
);
|
|
9557
9386
|
}
|
|
9558
9387
|
return uniforms;
|
|
9559
9388
|
}
|
|
@@ -9632,7 +9461,7 @@ ${common}`;
|
|
|
9632
9461
|
fs: fs25
|
|
9633
9462
|
};
|
|
9634
9463
|
|
|
9635
|
-
// src/modules-webgl1/lighting/lights/lights
|
|
9464
|
+
// src/modules-webgl1/lighting/lights/lights-glsl.ts
|
|
9636
9465
|
var lightingShader = glsl`\
|
|
9637
9466
|
#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
9638
9467
|
|
|
@@ -9675,10 +9504,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
9675
9504
|
lightSources: {}
|
|
9676
9505
|
};
|
|
9677
9506
|
function convertColor2(colorDef = {}) {
|
|
9678
|
-
const {
|
|
9679
|
-
color = [0, 0, 0],
|
|
9680
|
-
intensity = 1
|
|
9681
|
-
} = colorDef;
|
|
9507
|
+
const { color = [0, 0, 0], intensity = 1 } = colorDef;
|
|
9682
9508
|
return color.map((component) => component * intensity / 255);
|
|
9683
9509
|
}
|
|
9684
9510
|
function getLightSourceUniforms2({
|
|
@@ -9695,7 +9521,11 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
9695
9521
|
pointLights.forEach((pointLight, index2) => {
|
|
9696
9522
|
lightSourceUniforms[`lighting_uPointLight[${index2}].color`] = convertColor2(pointLight);
|
|
9697
9523
|
lightSourceUniforms[`lighting_uPointLight[${index2}].position`] = pointLight.position;
|
|
9698
|
-
lightSourceUniforms[`lighting_uPointLight[${index2}].attenuation`] = pointLight.attenuation || [
|
|
9524
|
+
lightSourceUniforms[`lighting_uPointLight[${index2}].attenuation`] = pointLight.attenuation || [
|
|
9525
|
+
1,
|
|
9526
|
+
0,
|
|
9527
|
+
0
|
|
9528
|
+
];
|
|
9699
9529
|
});
|
|
9700
9530
|
lightSourceUniforms.lighting_uPointLightCount = pointLights.length;
|
|
9701
9531
|
directionalLights.forEach((directionalLight, index2) => {
|
|
@@ -9707,30 +9537,21 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
9707
9537
|
}
|
|
9708
9538
|
function getUniforms6(opts = INITIAL_MODULE_OPTIONS) {
|
|
9709
9539
|
if ("lightSources" in opts) {
|
|
9710
|
-
const {
|
|
9711
|
-
ambientLight,
|
|
9712
|
-
pointLights,
|
|
9713
|
-
directionalLights
|
|
9714
|
-
} = opts.lightSources || {};
|
|
9540
|
+
const { ambientLight, pointLights, directionalLights } = opts.lightSources || {};
|
|
9715
9541
|
const hasLights = ambientLight || pointLights && pointLights.length > 0 || directionalLights && directionalLights.length > 0;
|
|
9716
9542
|
if (!hasLights) {
|
|
9717
|
-
return {
|
|
9718
|
-
lighting_uEnabled: false
|
|
9719
|
-
};
|
|
9543
|
+
return { lighting_uEnabled: false };
|
|
9720
9544
|
}
|
|
9721
|
-
return Object.assign(
|
|
9722
|
-
|
|
9723
|
-
pointLights,
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9545
|
+
return Object.assign(
|
|
9546
|
+
{},
|
|
9547
|
+
getLightSourceUniforms2({ ambientLight, pointLights, directionalLights }),
|
|
9548
|
+
{
|
|
9549
|
+
lighting_uEnabled: true
|
|
9550
|
+
}
|
|
9551
|
+
);
|
|
9728
9552
|
}
|
|
9729
9553
|
if ("lights" in opts) {
|
|
9730
|
-
const lightSources = {
|
|
9731
|
-
pointLights: [],
|
|
9732
|
-
directionalLights: []
|
|
9733
|
-
};
|
|
9554
|
+
const lightSources = { pointLights: [], directionalLights: [] };
|
|
9734
9555
|
for (const light of opts.lights || []) {
|
|
9735
9556
|
switch (light.type) {
|
|
9736
9557
|
case "ambient":
|
|
@@ -9745,9 +9566,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
9745
9566
|
default:
|
|
9746
9567
|
}
|
|
9747
9568
|
}
|
|
9748
|
-
return getUniforms6({
|
|
9749
|
-
lightSources
|
|
9750
|
-
});
|
|
9569
|
+
return getUniforms6({ lightSources });
|
|
9751
9570
|
}
|
|
9752
9571
|
return {};
|
|
9753
9572
|
}
|
|
@@ -9786,12 +9605,13 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
9786
9605
|
`;
|
|
9787
9606
|
var dirlight2 = {
|
|
9788
9607
|
name: "dirlight",
|
|
9608
|
+
// vs // TODO - reuse normal from geometry module
|
|
9789
9609
|
fs: fs26,
|
|
9790
9610
|
getUniforms: getUniforms7,
|
|
9791
9611
|
dependencies: [project]
|
|
9792
9612
|
};
|
|
9793
9613
|
|
|
9794
|
-
// src/modules-webgl1/lighting/phong-lighting/phong-lighting
|
|
9614
|
+
// src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts
|
|
9795
9615
|
var lightingShader2 = glsl`\
|
|
9796
9616
|
|
|
9797
9617
|
uniform float lighting_uAmbient;
|
|
@@ -9871,12 +9691,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
9871
9691
|
// src/modules-webgl1/lighting/phong-lighting/phong-lighting.ts
|
|
9872
9692
|
var INITIAL_MODULE_OPTIONS2 = {};
|
|
9873
9693
|
function getMaterialUniforms(material) {
|
|
9874
|
-
const {
|
|
9875
|
-
ambient = 0.35,
|
|
9876
|
-
diffuse = 0.6,
|
|
9877
|
-
shininess = 32,
|
|
9878
|
-
specularColor = [30, 30, 30]
|
|
9879
|
-
} = material;
|
|
9694
|
+
const { ambient = 0.35, diffuse = 0.6, shininess = 32, specularColor = [30, 30, 30] } = material;
|
|
9880
9695
|
return {
|
|
9881
9696
|
lighting_uAmbient: ambient,
|
|
9882
9697
|
lighting_uDiffuse: diffuse,
|
|
@@ -9888,13 +9703,9 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
9888
9703
|
if (!("material" in opts)) {
|
|
9889
9704
|
return {};
|
|
9890
9705
|
}
|
|
9891
|
-
const {
|
|
9892
|
-
material
|
|
9893
|
-
} = opts;
|
|
9706
|
+
const { material } = opts;
|
|
9894
9707
|
if (!material) {
|
|
9895
|
-
return {
|
|
9896
|
-
lighting_uEnabled: false
|
|
9897
|
-
};
|
|
9708
|
+
return { lighting_uEnabled: false };
|
|
9898
9709
|
}
|
|
9899
9710
|
return getMaterialUniforms(material);
|
|
9900
9711
|
}
|
|
@@ -9917,7 +9728,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
9917
9728
|
getUniforms: getUniforms8
|
|
9918
9729
|
};
|
|
9919
9730
|
|
|
9920
|
-
// src/modules-webgl1/lighting/pbr/pbr-vertex
|
|
9731
|
+
// src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts
|
|
9921
9732
|
var vs5 = glsl`\
|
|
9922
9733
|
uniform mat4 u_MVPMatrix;
|
|
9923
9734
|
uniform mat4 u_ModelMatrix;
|
|
@@ -9958,7 +9769,7 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
|
|
|
9958
9769
|
}
|
|
9959
9770
|
`;
|
|
9960
9771
|
|
|
9961
|
-
// src/modules-webgl1/lighting/pbr/pbr-fragment
|
|
9772
|
+
// src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts
|
|
9962
9773
|
var fs27 = glsl`\
|
|
9963
9774
|
#if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
|
|
9964
9775
|
# error PBR fragment shader: Texture LOD is not available
|
|
@@ -9968,14 +9779,8 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
|
|
|
9968
9779
|
# error PBR fragment shader: Derivatives are not available
|
|
9969
9780
|
#endif
|
|
9970
9781
|
|
|
9971
|
-
//
|
|
9972
|
-
|
|
9973
|
-
// and still take advantage of WebGL 2.0
|
|
9974
|
-
#if (__VERSION__ < 300)
|
|
9975
|
-
#define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL1COND; INCR)
|
|
9976
|
-
#else
|
|
9977
|
-
#define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)
|
|
9978
|
-
#endif
|
|
9782
|
+
// TODO - remove we no longer support WebGL1
|
|
9783
|
+
#define SMART_FOR(INIT, WEBGL1COND, WEBGL2COND, INCR) for (INIT; WEBGL2COND; INCR)
|
|
9979
9784
|
|
|
9980
9785
|
precision highp float;
|
|
9981
9786
|
|