@luma.gl/shadertools 9.0.0-alpha.21 → 9.0.0-alpha.23

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.
Files changed (54) hide show
  1. package/dist/dist.dev.js +118 -14
  2. package/dist/index.cjs +121 -17
  3. package/dist/index.d.ts +7 -5
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +5 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/lib/shader-assembler/resolve-modules.d.ts +4 -4
  8. package/dist/lib/shader-assembler/resolve-modules.d.ts.map +1 -1
  9. package/dist/lib/shader-assembler/resolve-modules.js +3 -15
  10. package/dist/lib/shader-assembler/resolve-modules.js.map +1 -1
  11. package/dist/lib/shader-generator/generate-shader.d.ts +8 -0
  12. package/dist/lib/shader-generator/generate-shader.d.ts.map +1 -0
  13. package/dist/lib/shader-generator/generate-shader.js +11 -0
  14. package/dist/lib/shader-generator/generate-shader.js.map +1 -0
  15. package/dist/lib/shader-generator/glsl/generate-glsl.d.ts +7 -0
  16. package/dist/lib/shader-generator/glsl/generate-glsl.d.ts.map +1 -0
  17. package/dist/lib/shader-generator/glsl/generate-glsl.js +66 -0
  18. package/dist/lib/shader-generator/glsl/generate-glsl.js.map +1 -0
  19. package/dist/lib/shader-generator/utils/capitalize.d.ts +7 -0
  20. package/dist/lib/shader-generator/utils/capitalize.d.ts.map +1 -0
  21. package/dist/lib/shader-generator/utils/capitalize.js +4 -0
  22. package/dist/lib/shader-generator/utils/capitalize.js.map +1 -0
  23. package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts +7 -0
  24. package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts.map +1 -0
  25. package/dist/lib/shader-generator/wgsl/generate-wgsl.js +16 -0
  26. package/dist/lib/shader-generator/wgsl/generate-wgsl.js.map +1 -0
  27. package/dist/lib/shader-module/shader-module-instance.d.ts +4 -2
  28. package/dist/lib/shader-module/shader-module-instance.d.ts.map +1 -1
  29. package/dist/lib/shader-module/shader-module-instance.js +14 -1
  30. package/dist/lib/shader-module/shader-module-instance.js.map +1 -1
  31. package/dist/lib/shader-module/shader-module.d.ts +7 -6
  32. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  33. package/dist/lib/shader-module/shader-module.js.map +1 -1
  34. package/dist/lib/shader-module/shader-pass.d.ts +9 -3
  35. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  36. package/dist/lib/shader-module/shader-pass.js.map +1 -1
  37. package/dist/types.d.ts +2 -0
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/types.js.map +1 -1
  40. package/dist.min.js +73 -71
  41. package/package.json +3 -3
  42. package/src/index.ts +10 -5
  43. package/src/lib/shader-assembler/resolve-modules.ts +6 -25
  44. package/src/lib/shader-generator/generate-shader.ts +22 -0
  45. package/src/lib/shader-generator/glsl/generate-glsl.ts +92 -0
  46. package/src/lib/shader-generator/utils/capitalize.ts +9 -0
  47. package/src/lib/shader-generator/wgsl/generate-wgsl.ts +29 -0
  48. package/src/lib/shader-module/shader-module-instance.ts +24 -3
  49. package/src/lib/shader-module/shader-module.ts +8 -6
  50. package/src/lib/shader-module/shader-pass.ts +9 -3
  51. package/src/modules/.DS_Store +0 -0
  52. package/src/types.ts +36 -0
  53. package/src/.DS_Store +0 -0
  54. package/src/lib/.DS_Store +0 -0
package/dist/dist.dev.js CHANGED
@@ -27,11 +27,15 @@ var __exports__ = (() => {
27
27
  // src/index.ts
28
28
  var src_exports = {};
29
29
  __export(src_exports, {
30
+ _ShaderModuleInstance: () => ShaderModuleInstance,
31
+ _getDependencyGraph: () => getDependencyGraph,
32
+ _resolveModules: () => resolveModules,
30
33
  _transform: () => transform,
31
34
  _warp: () => warp,
32
35
  assembleShaders: () => assembleShaders,
33
36
  brightnessContrast: () => brightnessContrast,
34
37
  bulgePinch: () => bulgePinch,
38
+ capitalize: () => capitalize,
35
39
  colorHalftone: () => colorHalftone,
36
40
  combineInjects: () => combineInjects,
37
41
  convertToVec4: () => convertToVec4,
@@ -43,6 +47,7 @@ var __exports__ = (() => {
43
47
  fp64: () => fp64,
44
48
  fp64arithmetic: () => fp64arithmetic,
45
49
  fxaa: () => fxaa,
50
+ generateShaderForModule: () => generateShaderForModule,
46
51
  getPassthroughFS: () => getPassthroughFS,
47
52
  getQualifierDetails: () => getQualifierDetails,
48
53
  getShaderInfo: () => getShaderInfo,
@@ -165,6 +170,19 @@ var __exports__ = (() => {
165
170
  // src/lib/shader-module/shader-module-instance.ts
166
171
  var ShaderModuleInstance = class {
167
172
  uniforms = {};
173
+ uniformFormats = {};
174
+ static instantiateModules(modules) {
175
+ return modules.map((module) => {
176
+ if (module instanceof ShaderModuleInstance) {
177
+ return module;
178
+ }
179
+ assert(typeof module !== "string", `Shader module use by name is deprecated. Import shader module '${module}' and use it directly.`);
180
+ assert(module.name, "shader module has no name");
181
+ const moduleObject = new ShaderModuleInstance(module);
182
+ moduleObject.dependencies = ShaderModuleInstance.instantiateModules(module.dependencies || []);
183
+ return moduleObject;
184
+ });
185
+ }
168
186
  constructor(props) {
169
187
  const {
170
188
  name,
@@ -182,7 +200,7 @@ var __exports__ = (() => {
182
200
  this.vs = vs5;
183
201
  this.fs = fs26;
184
202
  this.getModuleUniforms = getUniforms7;
185
- this.dependencies = dependencies;
203
+ this.dependencies = ShaderModuleInstance.instantiateModules(dependencies);
186
204
  this.deprecations = this._parseDeprecationDefinitions(deprecations);
187
205
  this.defines = defines;
188
206
  this.injections = normalizeInjections(inject);
@@ -282,19 +300,8 @@ ${moduleSource}// END MODULE_${this.name}
282
300
 
283
301
  // src/lib/shader-assembler/resolve-modules.ts
284
302
  function resolveModules(modules) {
285
- return getShaderDependencies(instantiateModules(modules));
286
- }
287
- function instantiateModules(modules) {
288
- return modules.map((module) => {
289
- if (module instanceof ShaderModuleInstance) {
290
- return module;
291
- }
292
- assert(typeof module !== "string", `Shader module use by name is deprecated. Import shader module '${module}' and use it directly.`);
293
- assert(module.name, "shader module has no name");
294
- const moduleObject = new ShaderModuleInstance(module);
295
- moduleObject.dependencies = instantiateModules(module.dependencies || []);
296
- return moduleObject;
297
- });
303
+ const instances = ShaderModuleInstance.instantiateModules(modules);
304
+ return getShaderDependencies(instances);
298
305
  }
299
306
  function getShaderDependencies(modules) {
300
307
  const moduleMap = {};
@@ -991,6 +998,103 @@ void main() {
991
998
  }
992
999
  }
993
1000
 
1001
+ // src/lib/shader-generator/utils/capitalize.ts
1002
+ function capitalize(str) {
1003
+ return typeof str === "string" ? str.charAt(0).toUpperCase() + str.slice(1) : str;
1004
+ }
1005
+
1006
+ // src/lib/shader-generator/glsl/generate-glsl.ts
1007
+ function generateGLSLForModule(module, options) {
1008
+ return generateGLSLUniformDeclarations(module, options);
1009
+ }
1010
+ function generateGLSLUniformDeclarations(module, options) {
1011
+ const glsl2 = [];
1012
+ switch (options.uniforms) {
1013
+ case "scoped-interface-blocks":
1014
+ case "unscoped-interface-blocks":
1015
+ glsl2.push(`uniform ${capitalize(module.name)} {`);
1016
+ break;
1017
+ case "uniforms":
1018
+ }
1019
+ for (const [uniformName, uniformFormat] of Object.entries(module.uniformFormats || module.uniforms || {})) {
1020
+ const glslUniformType = getGLSLUniformType(uniformFormat.format);
1021
+ switch (options.uniforms) {
1022
+ case "scoped-interface-blocks":
1023
+ glsl2.push(` ${glslUniformType} ${uniformName};`);
1024
+ break;
1025
+ case "unscoped-interface-blocks":
1026
+ glsl2.push(` ${glslUniformType} ${module.name}_${uniformName};`);
1027
+ break;
1028
+ case "uniforms":
1029
+ glsl2.push(`uniform ${glslUniformType} ${module.name}_${uniformName};`);
1030
+ }
1031
+ }
1032
+ switch (options.uniforms) {
1033
+ case "scoped-interface-blocks":
1034
+ glsl2.push(`} ${module.name};`);
1035
+ break;
1036
+ case "unscoped-interface-blocks":
1037
+ glsl2.push("};");
1038
+ break;
1039
+ case "uniforms":
1040
+ }
1041
+ glsl2.push("");
1042
+ return glsl2.join("\n");
1043
+ }
1044
+ function getGLSLUniformType(uniformFormat) {
1045
+ const UNIFORM_TYPE_TO_GLSL = {
1046
+ "f32": "float",
1047
+ "i32": "int",
1048
+ "u32": "uint",
1049
+ "vec2<f32>": "vec2",
1050
+ "vec3<f32>": "vec3",
1051
+ "vec4<f32>": "vec4",
1052
+ "vec2<i32>": "ivec2",
1053
+ "vec3<i32>": "ivec3",
1054
+ "vec4<i32>": "ivec4",
1055
+ "vec2<u32>": "uvec2",
1056
+ "vec3<u32>": "uvec3",
1057
+ "vec4<u32>": "uvec4",
1058
+ "mat2x2<f32>": "mat2",
1059
+ "mat2x3<f32>": "mat2x3",
1060
+ "mat2x4<f32>": "mat2x4",
1061
+ "mat3x2<f32>": "mat3x2",
1062
+ "mat3x3<f32>": "mat3",
1063
+ "mat3x4<f32>": "mat3x4",
1064
+ "mat4x2<f32>": "mat4x2",
1065
+ "mat4x3<f32>": "mat4x3",
1066
+ "mat4x4<f32>": "mat4"
1067
+ };
1068
+ const glsl2 = UNIFORM_TYPE_TO_GLSL[uniformFormat];
1069
+ return glsl2;
1070
+ }
1071
+
1072
+ // src/lib/shader-generator/wgsl/generate-wgsl.ts
1073
+ function generateWGSLForModule(module, options) {
1074
+ return generateWGSLUniformDeclarations(module, options);
1075
+ }
1076
+ function generateWGSLUniformDeclarations(module, options) {
1077
+ const wgsl = [];
1078
+ wgsl.push(`struct ${capitalize(module.name)} {`);
1079
+ for (const [uniformName, uniformFormat] of Object.entries(module?.uniformFormats || {})) {
1080
+ const wgslUniformType = uniformFormat;
1081
+ wgsl.push(` ${uniformName} : ${wgslUniformType};`);
1082
+ }
1083
+ wgsl.push("};");
1084
+ wgsl.push(`var<uniform> ${module.name} : ${capitalize(module.name)};`);
1085
+ return wgsl.join("\n");
1086
+ }
1087
+
1088
+ // src/lib/shader-generator/generate-shader.ts
1089
+ function generateShaderForModule(module, options) {
1090
+ switch (options.shaderLanguage) {
1091
+ case "glsl":
1092
+ return generateGLSLForModule(module, options);
1093
+ case "wgsl":
1094
+ return generateWGSLForModule(module, options);
1095
+ }
1096
+ }
1097
+
994
1098
  // src/modules/utils/random.ts
995
1099
  var fs = glsl`\
996
1100
  float random(vec3 scale, float seed) {
package/dist/index.cjs CHANGED
@@ -37,11 +37,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
37
37
  // src/index.ts
38
38
  var src_exports = {};
39
39
  __export(src_exports, {
40
+ _ShaderModuleInstance: () => ShaderModuleInstance,
41
+ _getDependencyGraph: () => getDependencyGraph,
42
+ _resolveModules: () => resolveModules,
40
43
  _transform: () => transform,
41
44
  _warp: () => warp,
42
45
  assembleShaders: () => assembleShaders,
43
46
  brightnessContrast: () => brightnessContrast,
44
47
  bulgePinch: () => bulgePinch,
48
+ capitalize: () => capitalize,
45
49
  colorHalftone: () => colorHalftone,
46
50
  combineInjects: () => combineInjects,
47
51
  convertToVec4: () => convertToVec4,
@@ -53,6 +57,7 @@ __export(src_exports, {
53
57
  fp64: () => fp64,
54
58
  fp64arithmetic: () => fp64arithmetic,
55
59
  fxaa: () => fxaa,
60
+ generateShaderForModule: () => generateShaderForModule,
56
61
  getPassthroughFS: () => getPassthroughFS,
57
62
  getQualifierDetails: () => getQualifierDetails,
58
63
  getShaderInfo: () => getShaderInfo,
@@ -159,6 +164,7 @@ function getTypeOf(value) {
159
164
  var ShaderModuleInstance = class {
160
165
  constructor(props) {
161
166
  this.uniforms = {};
167
+ this.uniformFormats = {};
162
168
  const {
163
169
  name,
164
170
  vs: vs5,
@@ -175,7 +181,7 @@ var ShaderModuleInstance = class {
175
181
  this.vs = vs5;
176
182
  this.fs = fs26;
177
183
  this.getModuleUniforms = getUniforms7;
178
- this.dependencies = dependencies;
184
+ this.dependencies = ShaderModuleInstance.instantiateModules(dependencies);
179
185
  this.deprecations = this._parseDeprecationDefinitions(deprecations);
180
186
  this.defines = defines;
181
187
  this.injections = normalizeInjections(inject);
@@ -183,6 +189,21 @@ var ShaderModuleInstance = class {
183
189
  this.uniforms = makePropValidators(uniforms18);
184
190
  }
185
191
  }
192
+ static instantiateModules(modules) {
193
+ return modules.map((module2) => {
194
+ if (module2 instanceof ShaderModuleInstance) {
195
+ return module2;
196
+ }
197
+ assert(
198
+ typeof module2 !== "string",
199
+ `Shader module use by name is deprecated. Import shader module '${module2}' and use it directly.`
200
+ );
201
+ assert(module2.name, "shader module has no name");
202
+ const moduleObject = new ShaderModuleInstance(module2);
203
+ moduleObject.dependencies = ShaderModuleInstance.instantiateModules(module2.dependencies || []);
204
+ return moduleObject;
205
+ });
206
+ }
186
207
  // Extracts the source code chunk for the specified shader type from the named shader module
187
208
  getModuleSource(type) {
188
209
  let moduleSource;
@@ -276,22 +297,8 @@ function normalizeInjections(injections) {
276
297
 
277
298
  // src/lib/shader-assembler/resolve-modules.ts
278
299
  function resolveModules(modules) {
279
- return getShaderDependencies(instantiateModules(modules));
280
- }
281
- function instantiateModules(modules) {
282
- return modules.map((module2) => {
283
- if (module2 instanceof ShaderModuleInstance) {
284
- return module2;
285
- }
286
- assert(
287
- typeof module2 !== "string",
288
- `Shader module use by name is deprecated. Import shader module '${module2}' and use it directly.`
289
- );
290
- assert(module2.name, "shader module has no name");
291
- const moduleObject = new ShaderModuleInstance(module2);
292
- moduleObject.dependencies = instantiateModules(module2.dependencies || []);
293
- return moduleObject;
294
- });
300
+ const instances = ShaderModuleInstance.instantiateModules(modules);
301
+ return getShaderDependencies(instances);
295
302
  }
296
303
  function getShaderDependencies(modules) {
297
304
  const moduleMap = {};
@@ -946,6 +953,103 @@ function convertToVec4(variable, type) {
946
953
  }
947
954
  }
948
955
 
956
+ // src/lib/shader-generator/utils/capitalize.ts
957
+ function capitalize(str) {
958
+ return typeof str === "string" ? str.charAt(0).toUpperCase() + str.slice(1) : str;
959
+ }
960
+
961
+ // src/lib/shader-generator/glsl/generate-glsl.ts
962
+ function generateGLSLForModule(module2, options) {
963
+ return generateGLSLUniformDeclarations(module2, options);
964
+ }
965
+ function generateGLSLUniformDeclarations(module2, options) {
966
+ const glsl2 = [];
967
+ switch (options.uniforms) {
968
+ case "scoped-interface-blocks":
969
+ case "unscoped-interface-blocks":
970
+ glsl2.push(`uniform ${capitalize(module2.name)} {`);
971
+ break;
972
+ case "uniforms":
973
+ }
974
+ for (const [uniformName, uniformFormat] of Object.entries(module2.uniformFormats || module2.uniforms || {})) {
975
+ const glslUniformType = getGLSLUniformType(uniformFormat.format);
976
+ switch (options.uniforms) {
977
+ case "scoped-interface-blocks":
978
+ glsl2.push(` ${glslUniformType} ${uniformName};`);
979
+ break;
980
+ case "unscoped-interface-blocks":
981
+ glsl2.push(` ${glslUniformType} ${module2.name}_${uniformName};`);
982
+ break;
983
+ case "uniforms":
984
+ glsl2.push(`uniform ${glslUniformType} ${module2.name}_${uniformName};`);
985
+ }
986
+ }
987
+ switch (options.uniforms) {
988
+ case "scoped-interface-blocks":
989
+ glsl2.push(`} ${module2.name};`);
990
+ break;
991
+ case "unscoped-interface-blocks":
992
+ glsl2.push("};");
993
+ break;
994
+ case "uniforms":
995
+ }
996
+ glsl2.push("");
997
+ return glsl2.join("\n");
998
+ }
999
+ function getGLSLUniformType(uniformFormat) {
1000
+ const UNIFORM_TYPE_TO_GLSL = {
1001
+ "f32": "float",
1002
+ "i32": "int",
1003
+ "u32": "uint",
1004
+ "vec2<f32>": "vec2",
1005
+ "vec3<f32>": "vec3",
1006
+ "vec4<f32>": "vec4",
1007
+ "vec2<i32>": "ivec2",
1008
+ "vec3<i32>": "ivec3",
1009
+ "vec4<i32>": "ivec4",
1010
+ "vec2<u32>": "uvec2",
1011
+ "vec3<u32>": "uvec3",
1012
+ "vec4<u32>": "uvec4",
1013
+ "mat2x2<f32>": "mat2",
1014
+ "mat2x3<f32>": "mat2x3",
1015
+ "mat2x4<f32>": "mat2x4",
1016
+ "mat3x2<f32>": "mat3x2",
1017
+ "mat3x3<f32>": "mat3",
1018
+ "mat3x4<f32>": "mat3x4",
1019
+ "mat4x2<f32>": "mat4x2",
1020
+ "mat4x3<f32>": "mat4x3",
1021
+ "mat4x4<f32>": "mat4"
1022
+ };
1023
+ const glsl2 = UNIFORM_TYPE_TO_GLSL[uniformFormat];
1024
+ return glsl2;
1025
+ }
1026
+
1027
+ // src/lib/shader-generator/wgsl/generate-wgsl.ts
1028
+ function generateWGSLForModule(module2, options) {
1029
+ return generateWGSLUniformDeclarations(module2, options);
1030
+ }
1031
+ function generateWGSLUniformDeclarations(module2, options) {
1032
+ const wgsl = [];
1033
+ wgsl.push(`struct ${capitalize(module2.name)} {`);
1034
+ for (const [uniformName, uniformFormat] of Object.entries((module2 == null ? void 0 : module2.uniformFormats) || {})) {
1035
+ const wgslUniformType = uniformFormat;
1036
+ wgsl.push(` ${uniformName} : ${wgslUniformType};`);
1037
+ }
1038
+ wgsl.push("};");
1039
+ wgsl.push(`var<uniform> ${module2.name} : ${capitalize(module2.name)};`);
1040
+ return wgsl.join("\n");
1041
+ }
1042
+
1043
+ // src/lib/shader-generator/generate-shader.ts
1044
+ function generateShaderForModule(module2, options) {
1045
+ switch (options.shaderLanguage) {
1046
+ case "glsl":
1047
+ return generateGLSLForModule(module2, options);
1048
+ case "wgsl":
1049
+ return generateWGSLForModule(module2, options);
1050
+ }
1051
+ }
1052
+
949
1053
  // src/modules/utils/random.ts
950
1054
  var fs = glsl`\
951
1055
  float random(vec3 scale, float seed) {
package/dist/index.d.ts CHANGED
@@ -10,6 +10,9 @@ export { getQualifierDetails, getPassthroughFS, typeToChannelSuffix, typeToChann
10
10
  * Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal
11
11
  */
12
12
  export { glsl } from './lib/glsl-utils/highlight';
13
+ export type { ShaderGenerationOptions } from './lib/shader-generator/generate-shader';
14
+ export { generateShaderForModule } from './lib/shader-generator/generate-shader';
15
+ export { capitalize } from './lib/shader-generator/utils/capitalize';
13
16
  export { random } from './modules/utils/random';
14
17
  export { fp32 } from './modules/fp32/fp32';
15
18
  export { fp64, fp64arithmetic } from './modules/fp64/fp64';
@@ -22,8 +25,7 @@ export { pbr } from './modules/pbr/pbr';
22
25
  export { tiltShift } from './modules/image-blur-filters/tiltshift';
23
26
  export { triangleBlur } from './modules/image-blur-filters/triangleblur';
24
27
  export { zoomBlur } from './modules/image-blur-filters/zoomblur';
25
- import type { BrightnessContrastProps } from './modules/image-adjust-filters/brightnesscontrast';
26
- export type { BrightnessContrastProps };
28
+ export type { BrightnessContrastProps } from './modules/image-adjust-filters/brightnesscontrast';
27
29
  export { brightnessContrast } from './modules/image-adjust-filters/brightnesscontrast';
28
30
  export { denoise } from './modules/image-adjust-filters/denoise';
29
31
  export { hueSaturation } from './modules/image-adjust-filters/huesaturation';
@@ -42,7 +44,7 @@ export { swirl } from './modules/image-warp-filters/swirl';
42
44
  export { fxaa } from './modules/fxaa/fxaa';
43
45
  export { warp as _warp } from './modules/image-warp-filters/warp';
44
46
  export { transform as _transform } from './modules/transform/transform';
45
- export declare type ShaderPassProps = {
46
- brightnessContrast?: BrightnessContrastProps;
47
- };
47
+ export { ShaderModuleInstance as _ShaderModuleInstance } from './lib/shader-module/shader-module-instance';
48
+ export { resolveModules as _resolveModules } from './lib/shader-assembler/resolve-modules';
49
+ export { getDependencyGraph as _getDependencyGraph } from './lib/shader-assembler/resolve-modules';
48
50
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AACpE,YAAY,EAAC,UAAU,EAAC,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAC,eAAe,EAAC,MAAM,yCAAyC,CAAC;AAGxE,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAC,qBAAqB,EAAC,MAAM,6CAA6C,CAAC;AAGlF,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACd,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AS,EAAC,MAAM,uCAAuC,CAAC;AAChE,OAAO,EAAC,QAAQ,EAAC,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,+CAA+C,CAAC;AAChF,OAAO,EAAC,GAAG,EAAC,MAAM,iCAAiC,CAAC;AACpD,OAAO,EAAC,OAAO,EAAC,MAAM,qCAAqC,CAAC;AAG5D,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AACnE,OAAO,EAAC,KAAK,EAAC,MAAM,oCAAoC,CAAC;AAGzD,OAAO,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAGzC,OAAO,EAAC,IAAI,IAAI,KAAK,EAAC,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAC,SAAS,IAAI,UAAU,EAAC,MAAM,+BAA+B,CAAC;AAGtE,OAAO,EAAC,oBAAoB,IAAI,qBAAqB,EAAC,MAAM,4CAA4C,CAAC;AACzG,OAAO,EAAC,cAAc,IAAI,eAAe,EAAC,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAC,kBAAkB,IAAI,mBAAmB,EAAC,MAAM,wCAAwC,CAAC"}
package/dist/index.js CHANGED
@@ -4,6 +4,8 @@ export { normalizeShaderModule } from "./lib/shader-module/normalize-shader-modu
4
4
  export { getShaderInfo } from "./lib/glsl-utils/get-shader-info.js";
5
5
  export { getQualifierDetails, getPassthroughFS, typeToChannelSuffix, typeToChannelCount, convertToVec4 } from "./lib/glsl-utils/shader-utils.js";
6
6
  export { glsl } from "./lib/glsl-utils/highlight.js";
7
+ export { generateShaderForModule } from "./lib/shader-generator/generate-shader.js";
8
+ export { capitalize } from "./lib/shader-generator/utils/capitalize.js";
7
9
  export { random } from "./modules/utils/random.js";
8
10
  export { fp32 } from "./modules/fp32/fp32.js";
9
11
  export { fp64, fp64arithmetic } from "./modules/fp64/fp64.js";
@@ -34,4 +36,7 @@ export { swirl } from "./modules/image-warp-filters/swirl.js";
34
36
  export { fxaa } from "./modules/fxaa/fxaa.js";
35
37
  export { warp as _warp } from "./modules/image-warp-filters/warp.js";
36
38
  export { transform as _transform } from "./modules/transform/transform.js";
39
+ export { ShaderModuleInstance as _ShaderModuleInstance } from "./lib/shader-module/shader-module-instance.js";
40
+ export { resolveModules as _resolveModules } from "./lib/shader-assembler/resolve-modules.js";
41
+ export { getDependencyGraph as _getDependencyGraph } from "./lib/shader-assembler/resolve-modules.js";
37
42
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["assembleShaders","combineInjects","normalizeShaderModule","getShaderInfo","getQualifierDetails","getPassthroughFS","typeToChannelSuffix","typeToChannelCount","convertToVec4","glsl","random","fp32","fp64","fp64arithmetic","project","lights","dirlight","picking","gouraudLighting","phongLighting","pbr","tiltShift","triangleBlur","zoomBlur","brightnessContrast","denoise","hueSaturation","noise","sepia","vibrance","vignette","colorHalftone","dotScreen","edgeWork","hexagonalPixelate","ink","magnify","bulgePinch","swirl","fxaa","warp","_warp","transform","_transform"],"sources":["../src/index.ts"],"sourcesContent":["// shadertools exports\n\n// DOCUMENTED APIS\nexport type {ShaderModule} from './lib/shader-module/shader-module';\nexport type {ShaderPass} from './lib/shader-module/shader-pass';\n\nexport {assembleShaders} from './lib/shader-assembler/assemble-shaders';\n\n// HELPERS\nexport {combineInjects} from './lib/shader-assembler/inject-shader';\nexport {normalizeShaderModule} from './lib/shader-module/normalize-shader-module';\n\n// Shader source introspection\nexport {getShaderInfo} from './lib/glsl-utils/get-shader-info';\nexport {\n getQualifierDetails,\n getPassthroughFS,\n typeToChannelSuffix,\n typeToChannelCount,\n convertToVec4\n} from './lib/glsl-utils/shader-utils';\n\n// SHADER HELPERS\n\n/**\n * Marks GLSL shaders for syntax highlighting: glsl`...`\n * Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal\n */\nexport {glsl} from './lib/glsl-utils/highlight';\n\n// SHADER MODULES\n\n// utils\nexport {random} from './modules/utils/random';\n\n// math libraries\nexport {fp32} from './modules/fp32/fp32';\nexport {fp64, fp64arithmetic} from './modules/fp64/fp64';\n\n// projection and lighting\nexport {project} from './modules/project/project';\nexport {lights} from './modules/lights/lights';\nexport {dirlight} from './modules/dirlight/dirlight';\nexport {picking} from './modules/picking/picking';\nexport {gouraudLighting, phongLighting} from './modules/phong-lighting/phong-lighting';\nexport {pbr} from './modules/pbr/pbr';\n\n// glfx BLUR shader modules\nexport {tiltShift} from './modules/image-blur-filters/tiltshift';\nexport {triangleBlur} from './modules/image-blur-filters/triangleblur';\nexport {zoomBlur} from './modules/image-blur-filters/zoomblur';\n\n// glfx image adjustment shader modules\nimport type {BrightnessContrastProps} from './modules/image-adjust-filters/brightnesscontrast';\nexport type {BrightnessContrastProps};\nexport {brightnessContrast} from './modules/image-adjust-filters/brightnesscontrast';\nexport {denoise} from './modules/image-adjust-filters/denoise';\nexport {hueSaturation} from './modules/image-adjust-filters/huesaturation';\nexport {noise} from './modules/image-adjust-filters/noise';\nexport {sepia} from './modules/image-adjust-filters/sepia';\nexport {vibrance} from './modules/image-adjust-filters/vibrance';\nexport {vignette} from './modules/image-adjust-filters/vignette';\n\n// glfx FUN shader modules\nexport {colorHalftone} from './modules/image-fun-filters/colorhalftone';\nexport {dotScreen} from './modules/image-fun-filters/dotscreen';\nexport {edgeWork} from './modules/image-fun-filters/edgework';\nexport {hexagonalPixelate} from './modules/image-fun-filters/hexagonalpixelate';\nexport {ink} from './modules/image-fun-filters/ink';\nexport {magnify} from './modules/image-fun-filters/magnify';\n\n// glfx WARP shader modules\nexport {bulgePinch} from './modules/image-warp-filters/bulgepinch';\nexport {swirl} from './modules/image-warp-filters/swirl';\n\n// Postprocessing\nexport {fxaa} from './modules/fxaa/fxaa';\n\n// experimental\nexport {warp as _warp} from './modules/image-warp-filters/warp';\nexport {transform as _transform} from './modules/transform/transform';\n\nexport type ShaderPassProps = {\n brightnessContrast?: BrightnessContrastProps;\n}"],"mappings":"SAMQA,eAAe;AAAA,SAGfC,cAAc;AAAA,SACdC,qBAAqB;AAAA,SAGrBC,aAAa;AAAA,SAEnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,mBAAmB,EACnBC,kBAAkB,EAClBC,aAAa;AAAA,SASPC,IAAI;AAAA,SAKJC,MAAM;AAAA,SAGNC,IAAI;AAAA,SACJC,IAAI,EAAEC,cAAc;AAAA,SAGpBC,OAAO;AAAA,SACPC,MAAM;AAAA,SACNC,QAAQ;AAAA,SACRC,OAAO;AAAA,SACPC,eAAe,EAAEC,aAAa;AAAA,SAC9BC,GAAG;AAAA,SAGHC,SAAS;AAAA,SACTC,YAAY;AAAA,SACZC,QAAQ;AAAA,SAKRC,kBAAkB;AAAA,SAClBC,OAAO;AAAA,SACPC,aAAa;AAAA,SACbC,KAAK;AAAA,SACLC,KAAK;AAAA,SACLC,QAAQ;AAAA,SACRC,QAAQ;AAAA,SAGRC,aAAa;AAAA,SACbC,SAAS;AAAA,SACTC,QAAQ;AAAA,SACRC,iBAAiB;AAAA,SACjBC,GAAG;AAAA,SACHC,OAAO;AAAA,SAGPC,UAAU;AAAA,SACVC,KAAK;AAAA,SAGLC,IAAI;AAAA,SAGJC,IAAI,IAAIC,KAAK;AAAA,SACbC,SAAS,IAAIC,UAAU"}
1
+ {"version":3,"file":"index.js","names":["assembleShaders","combineInjects","normalizeShaderModule","getShaderInfo","getQualifierDetails","getPassthroughFS","typeToChannelSuffix","typeToChannelCount","convertToVec4","glsl","generateShaderForModule","capitalize","random","fp32","fp64","fp64arithmetic","project","lights","dirlight","picking","gouraudLighting","phongLighting","pbr","tiltShift","triangleBlur","zoomBlur","brightnessContrast","denoise","hueSaturation","noise","sepia","vibrance","vignette","colorHalftone","dotScreen","edgeWork","hexagonalPixelate","ink","magnify","bulgePinch","swirl","fxaa","warp","_warp","transform","_transform","ShaderModuleInstance","_ShaderModuleInstance","resolveModules","_resolveModules","getDependencyGraph","_getDependencyGraph"],"sources":["../src/index.ts"],"sourcesContent":["// shadertools exports\n\n// DOCUMENTED APIS\nexport type {ShaderModule} from './lib/shader-module/shader-module';\nexport type {ShaderPass} from './lib/shader-module/shader-pass';\n\nexport {assembleShaders} from './lib/shader-assembler/assemble-shaders';\n\n// HELPERS\nexport {combineInjects} from './lib/shader-assembler/inject-shader';\nexport {normalizeShaderModule} from './lib/shader-module/normalize-shader-module';\n\n// Shader source introspection\nexport {getShaderInfo} from './lib/glsl-utils/get-shader-info';\nexport {\n getQualifierDetails,\n getPassthroughFS,\n typeToChannelSuffix,\n typeToChannelCount,\n convertToVec4\n} from './lib/glsl-utils/shader-utils';\n\n// SHADER HELPERS\n\n/**\n * Marks GLSL shaders for syntax highlighting: glsl`...`\n * Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal\n */\nexport {glsl} from './lib/glsl-utils/highlight';\n\n// TODO - experimental\nexport type {ShaderGenerationOptions} from './lib/shader-generator/generate-shader';\nexport {generateShaderForModule} from './lib/shader-generator/generate-shader';\nexport {capitalize} from './lib/shader-generator/utils/capitalize';\n\n// SHADER MODULES\n\n// utils\nexport {random} from './modules/utils/random';\n\n// math libraries\nexport {fp32} from './modules/fp32/fp32';\nexport {fp64, fp64arithmetic} from './modules/fp64/fp64';\n\n// projection and lighting\nexport {project} from './modules/project/project';\nexport {lights} from './modules/lights/lights';\nexport {dirlight} from './modules/dirlight/dirlight';\nexport {picking} from './modules/picking/picking';\nexport {gouraudLighting, phongLighting} from './modules/phong-lighting/phong-lighting';\nexport {pbr} from './modules/pbr/pbr';\n\n// glfx BLUR shader modules\nexport {tiltShift} from './modules/image-blur-filters/tiltshift';\nexport {triangleBlur} from './modules/image-blur-filters/triangleblur';\nexport {zoomBlur} from './modules/image-blur-filters/zoomblur';\n\n// glfx image adjustment shader modules\nexport type {BrightnessContrastProps} from './modules/image-adjust-filters/brightnesscontrast';\nexport {brightnessContrast} from './modules/image-adjust-filters/brightnesscontrast';\nexport {denoise} from './modules/image-adjust-filters/denoise';\nexport {hueSaturation} from './modules/image-adjust-filters/huesaturation';\nexport {noise} from './modules/image-adjust-filters/noise';\nexport {sepia} from './modules/image-adjust-filters/sepia';\nexport {vibrance} from './modules/image-adjust-filters/vibrance';\nexport {vignette} from './modules/image-adjust-filters/vignette';\n\n// glfx FUN shader modules\nexport {colorHalftone} from './modules/image-fun-filters/colorhalftone';\nexport {dotScreen} from './modules/image-fun-filters/dotscreen';\nexport {edgeWork} from './modules/image-fun-filters/edgework';\nexport {hexagonalPixelate} from './modules/image-fun-filters/hexagonalpixelate';\nexport {ink} from './modules/image-fun-filters/ink';\nexport {magnify} from './modules/image-fun-filters/magnify';\n\n// glfx WARP shader modules\nexport {bulgePinch} from './modules/image-warp-filters/bulgepinch';\nexport {swirl} from './modules/image-warp-filters/swirl';\n\n// Postprocessing\nexport {fxaa} from './modules/fxaa/fxaa';\n\n// experimental\nexport {warp as _warp} from './modules/image-warp-filters/warp';\nexport {transform as _transform} from './modules/transform/transform';\n\n// TEST EXPORTS\nexport {ShaderModuleInstance as _ShaderModuleInstance} from './lib/shader-module/shader-module-instance';\nexport {resolveModules as _resolveModules} from './lib/shader-assembler/resolve-modules';\nexport {getDependencyGraph as _getDependencyGraph} from './lib/shader-assembler/resolve-modules';"],"mappings":"SAMQA,eAAe;AAAA,SAGfC,cAAc;AAAA,SACdC,qBAAqB;AAAA,SAGrBC,aAAa;AAAA,SAEnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,mBAAmB,EACnBC,kBAAkB,EAClBC,aAAa;AAAA,SASPC,IAAI;AAAA,SAIJC,uBAAuB;AAAA,SACvBC,UAAU;AAAA,SAKVC,MAAM;AAAA,SAGNC,IAAI;AAAA,SACJC,IAAI,EAAEC,cAAc;AAAA,SAGpBC,OAAO;AAAA,SACPC,MAAM;AAAA,SACNC,QAAQ;AAAA,SACRC,OAAO;AAAA,SACPC,eAAe,EAAEC,aAAa;AAAA,SAC9BC,GAAG;AAAA,SAGHC,SAAS;AAAA,SACTC,YAAY;AAAA,SACZC,QAAQ;AAAA,SAIRC,kBAAkB;AAAA,SAClBC,OAAO;AAAA,SACPC,aAAa;AAAA,SACbC,KAAK;AAAA,SACLC,KAAK;AAAA,SACLC,QAAQ;AAAA,SACRC,QAAQ;AAAA,SAGRC,aAAa;AAAA,SACbC,SAAS;AAAA,SACTC,QAAQ;AAAA,SACRC,iBAAiB;AAAA,SACjBC,GAAG;AAAA,SACHC,OAAO;AAAA,SAGPC,UAAU;AAAA,SACVC,KAAK;AAAA,SAGLC,IAAI;AAAA,SAGJC,IAAI,IAAIC,KAAK;AAAA,SACbC,SAAS,IAAIC,UAAU;AAAA,SAGvBC,oBAAoB,IAAIC,qBAAqB;AAAA,SAC7CC,cAAc,IAAIC,eAAe;AAAA,SACjCC,kBAAkB,IAAIC,mBAAmB"}
@@ -13,7 +13,7 @@ export declare function resolveModules(modules: (ShaderModule | ShaderModuleInst
13
13
  * @param modules - Array of modules (inline modules or module names)
14
14
  * @return - Array of modules
15
15
  */
16
- declare function getShaderDependencies(modules: ShaderModule[]): ShaderModuleInstance[];
16
+ declare function getShaderDependencies(modules: ShaderModuleInstance[]): ShaderModuleInstance[];
17
17
  /**
18
18
  * Recursively checks module dependencies to calculate dependency level of each module.
19
19
  *
@@ -23,10 +23,10 @@ declare function getShaderDependencies(modules: ShaderModule[]): ShaderModuleIns
23
23
  * @param options.moduleDepth - Current level
24
24
  * @return - Map of module name to its level
25
25
  */
26
- declare function getDependencyGraph(options: {
27
- modules: ShaderModule[];
26
+ export declare function getDependencyGraph(options: {
27
+ modules: ShaderModuleInstance[];
28
28
  level: number;
29
- moduleMap: Record<string, ShaderModule>;
29
+ moduleMap: Record<string, ShaderModuleInstance>;
30
30
  moduleDepth: Record<string, number>;
31
31
  }): void;
32
32
  export declare const TEST_EXPORTS: {
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-modules.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-assembler/resolve-modules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gCAAgC,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,QAoBA;AAED,eAAO,MAAM,YAAY;;;CAGxB,CAAC"}
@@ -1,19 +1,7 @@
1
- import { assert } from "../utils/assert.js";
2
1
  import { ShaderModuleInstance } from "../shader-module/shader-module-instance.js";
3
2
  export function resolveModules(modules) {
4
- return getShaderDependencies(instantiateModules(modules));
5
- }
6
- function instantiateModules(modules) {
7
- return modules.map(module => {
8
- if (module instanceof ShaderModuleInstance) {
9
- return module;
10
- }
11
- assert(typeof module !== 'string', "Shader module use by name is deprecated. Import shader module '".concat(module, "' and use it directly."));
12
- assert(module.name, 'shader module has no name');
13
- const moduleObject = new ShaderModuleInstance(module);
14
- moduleObject.dependencies = instantiateModules(module.dependencies || []);
15
- return moduleObject;
16
- });
3
+ const instances = ShaderModuleInstance.instantiateModules(modules);
4
+ return getShaderDependencies(instances);
17
5
  }
18
6
  function getShaderDependencies(modules) {
19
7
  const moduleMap = {};
@@ -26,7 +14,7 @@ function getShaderDependencies(modules) {
26
14
  });
27
15
  return Object.keys(moduleDepth).sort((a, b) => moduleDepth[b] - moduleDepth[a]).map(name => moduleMap[name]);
28
16
  }
29
- function getDependencyGraph(options) {
17
+ export function getDependencyGraph(options) {
30
18
  const {
31
19
  modules,
32
20
  level,
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-modules.js","names":["assert","ShaderModuleInstance","resolveModules","modules","getShaderDependencies","instantiateModules","map","module","concat","name","moduleObject","dependencies","moduleMap","moduleDepth","getDependencyGraph","level","Object","keys","sort","a","b","options","Error","undefined","TEST_EXPORTS"],"sources":["../../../src/lib/shader-assembler/resolve-modules.ts"],"sourcesContent":["import {assert} from '../utils/assert';\nimport type {ShaderModule} from '../shader-module/shader-module';\nimport {ShaderModuleInstance} from '../shader-module/shader-module-instance';\n\n// Instantiate shader modules and any dependencies resolve dependencies\nexport function resolveModules(modules: (ShaderModule | ShaderModuleInstance)[]): ShaderModuleInstance[] {\n return getShaderDependencies(instantiateModules(modules));\n}\n\nfunction instantiateModules(modules: (ShaderModule | ShaderModuleInstance)[]): ShaderModuleInstance[] {\n return modules.map((module: ShaderModule | ShaderModuleInstance) => {\n if (module instanceof ShaderModuleInstance) {\n return module;\n }\n\n assert(\n typeof module !== 'string',\n `Shader module use by name is deprecated. Import shader module '${module}' and use it directly.`\n );\n assert(module.name, 'shader module has no name');\n\n const moduleObject = new ShaderModuleInstance(module);\n moduleObject.dependencies = instantiateModules(module.dependencies || []);\n\n return moduleObject;\n });\n}\n\n/**\n * Takes a list of shader module names and returns a new list of\n * shader module names that includes all dependencies, sorted so\n * that modules that are dependencies of other modules come first.\n *\n * If the shader glsl code from the returned modules is concatenated\n * in the reverse order, it is guaranteed that all functions be resolved and\n * that all function and variable definitions come before use.\n *\n * @param modules - Array of modules (inline modules or module names)\n * @return - Array of modules\n */\nfunction getShaderDependencies(modules: ShaderModule[]): ShaderModuleInstance[] {\n const moduleMap: Record<string, ShaderModuleInstance> = {};\n const moduleDepth: Record<string, number> = {};\n getDependencyGraph({modules, level: 0, moduleMap, moduleDepth});\n\n // Return a reverse sort so that dependencies come before the modules that use them\n return Object.keys(moduleDepth)\n .sort((a, b) => moduleDepth[b] - moduleDepth[a])\n .map((name) => moduleMap[name]);\n}\n\n/**\n * Recursively checks module dependencies to calculate dependency level of each module.\n *\n * @param options.modules - Array of modules\n * @param options.level - Current level\n * @param options.moduleMap -\n * @param options.moduleDepth - Current level\n * @return - Map of module name to its level\n */\n// Adds another level of dependencies to the result map\nfunction getDependencyGraph(options: {\n modules: ShaderModule[],\n level: number,\n moduleMap: Record<string, ShaderModule>;\n moduleDepth: Record<string, number>;\n}) {\n const {modules, level, moduleMap, moduleDepth} = options;\n if (level >= 5) {\n throw new Error('Possible loop in shader dependency graph');\n }\n\n // Update level on all current modules\n for (const module of modules) {\n moduleMap[module.name] = module;\n if (moduleDepth[module.name] === undefined || moduleDepth[module.name] < level) {\n moduleDepth[module.name] = level;\n }\n }\n\n // Recurse\n for (const module of modules) {\n if (module.dependencies) {\n getDependencyGraph({modules: module.dependencies, level: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,MAAM;IAAClB,OAAO;IAAEY,KAAK;IAAEH,SAAS;IAAEC;EAAW,CAAC,GAAGQ,OAAO;EACxD,IAAIN,KAAK,IAAI,CAAC,EAAE;IACd,MAAM,IAAIO,KAAK,CAAC,0CAA0C,CAAC;EAC7D;EAGA,KAAK,MAAMf,MAAM,IAAIJ,OAAO,EAAE;IAC5BS,SAAS,CAACL,MAAM,CAACE,IAAI,CAAC,GAAGF,MAAM;IAC/B,IAAIM,WAAW,CAACN,MAAM,CAACE,IAAI,CAAC,KAAKc,SAAS,IAAIV,WAAW,CAACN,MAAM,CAACE,IAAI,CAAC,GAAGM,KAAK,EAAE;MAC9EF,WAAW,CAACN,MAAM,CAACE,IAAI,CAAC,GAAGM,KAAK;IAClC;EACF;EAGA,KAAK,MAAMR,MAAM,IAAIJ,OAAO,EAAE;IAC5B,IAAII,MAAM,CAACI,YAAY,EAAE;MACvBG,kBAAkB,CAAC;QAACX,OAAO,EAAEI,MAAM,CAACI,YAAY;QAAEI,KAAK,EAAEA,KAAK,GAAG,CAAC;QAAEH,SAAS;QAAEC;MAAW,CAAC,CAAC;IAC9F;EACF;AACF;AAEA,OAAO,MAAMW,YAAY,GAAG;EAC1BpB,qBAAqB;EACrBU;AACF,CAAC"}
1
+ {"version":3,"file":"resolve-modules.js","names":["ShaderModuleInstance","resolveModules","modules","instances","instantiateModules","getShaderDependencies","moduleMap","moduleDepth","getDependencyGraph","level","Object","keys","sort","a","b","map","name","options","Error","module","undefined","dependencies","TEST_EXPORTS"],"sources":["../../../src/lib/shader-assembler/resolve-modules.ts"],"sourcesContent":["import type {ShaderModule} from '../shader-module/shader-module';\nimport {ShaderModuleInstance} from '../shader-module/shader-module-instance';\n\n// Instantiate shader modules and any dependencies resolve dependencies\nexport function resolveModules(modules: (ShaderModule | ShaderModuleInstance)[]): ShaderModuleInstance[] {\n const instances = ShaderModuleInstance.instantiateModules(modules);\n return getShaderDependencies(instances);\n}\n\n/**\n * Takes a list of shader module names and returns a new list of\n * shader module names that includes all dependencies, sorted so\n * that modules that are dependencies of other modules come first.\n *\n * If the shader glsl code from the returned modules is concatenated\n * in the reverse order, it is guaranteed that all functions be resolved and\n * that all function and variable definitions come before use.\n *\n * @param modules - Array of modules (inline modules or module names)\n * @return - Array of modules\n */\nfunction getShaderDependencies(modules: ShaderModuleInstance[]): ShaderModuleInstance[] {\n const moduleMap: Record<string, ShaderModuleInstance> = {};\n const moduleDepth: Record<string, number> = {};\n getDependencyGraph({modules, level: 0, moduleMap, moduleDepth});\n\n // Return a reverse sort so that dependencies come before the modules that use them\n return Object.keys(moduleDepth)\n .sort((a, b) => moduleDepth[b] - moduleDepth[a])\n .map((name) => moduleMap[name]);\n}\n\n/**\n * Recursively checks module dependencies to calculate dependency level of each module.\n *\n * @param options.modules - Array of modules\n * @param options.level - Current level\n * @param options.moduleMap -\n * @param options.moduleDepth - Current level\n * @return - Map of module name to its level\n */\n// Adds another level of dependencies to the result map\nexport function getDependencyGraph(options: {\n modules: ShaderModuleInstance[],\n level: number,\n moduleMap: Record<string, ShaderModuleInstance>;\n moduleDepth: Record<string, number>;\n}) {\n const {modules, level, moduleMap, moduleDepth} = options;\n if (level >= 5) {\n throw new Error('Possible loop in shader dependency graph');\n }\n\n // Update level on all current modules\n for (const module of modules) {\n moduleMap[module.name] = module;\n if (moduleDepth[module.name] === undefined || moduleDepth[module.name] < level) {\n moduleDepth[module.name] = level;\n }\n }\n\n // Recurse\n for (const module of modules) {\n if (module.dependencies) {\n getDependencyGraph({modules: module.dependencies, level: level + 1, moduleMap, moduleDepth});\n }\n }\n}\n\nexport const TEST_EXPORTS = {\n getShaderDependencies,\n getDependencyGraph\n};\n"],"mappings":"SACQA,oBAAoB;AAG5B,OAAO,SAASC,cAAcA,CAACC,OAAgD,EAA0B;EACvG,MAAMC,SAAS,GAAGH,oBAAoB,CAACI,kBAAkB,CAACF,OAAO,CAAC;EAClE,OAAOG,qBAAqB,CAACF,SAAS,CAAC;AACzC;AAcA,SAASE,qBAAqBA,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,qBAAqB;EACrBG;AACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ShaderModule } from '../shader-module/shader-module';
2
+ import type { GLSLGenerationOptions } from './glsl/generate-glsl';
3
+ import type { WGSLGenerationOptions } from './wgsl/generate-wgsl';
4
+ /** Options for how to generate shader code from a module */
5
+ export declare type ShaderGenerationOptions = GLSLGenerationOptions | WGSLGenerationOptions;
6
+ /** Generates shader code for a module */
7
+ export declare function generateShaderForModule(module: ShaderModule, options: ShaderGenerationOptions): string;
8
+ //# sourceMappingURL=generate-shader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-shader.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-generator/generate-shader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAC;AAE5D,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAGhE,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAGhE,4DAA4D;AAC5D,oBAAY,uBAAuB,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;AAEpF,yCAAyC;AACzC,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAOtG"}
@@ -0,0 +1,11 @@
1
+ import { generateGLSLForModule } from "./glsl/generate-glsl.js";
2
+ import { generateWGSLForModule } from "./wgsl/generate-wgsl.js";
3
+ export function generateShaderForModule(module, options) {
4
+ switch (options.shaderLanguage) {
5
+ case 'glsl':
6
+ return generateGLSLForModule(module, options);
7
+ case 'wgsl':
8
+ return generateWGSLForModule(module, options);
9
+ }
10
+ }
11
+ //# sourceMappingURL=generate-shader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-shader.js","names":["generateGLSLForModule","generateWGSLForModule","generateShaderForModule","module","options","shaderLanguage"],"sources":["../../../src/lib/shader-generator/generate-shader.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {ShaderModule} from '../shader-module/shader-module';\n\nimport type {GLSLGenerationOptions} from './glsl/generate-glsl';\nimport {generateGLSLForModule} from './glsl/generate-glsl';\n\nimport type {WGSLGenerationOptions} from './wgsl/generate-wgsl';\nimport {generateWGSLForModule} from './wgsl/generate-wgsl';\n\n/** Options for how to generate shader code from a module */\nexport type ShaderGenerationOptions = GLSLGenerationOptions | WGSLGenerationOptions;\n\n/** Generates shader code for a module */\nexport function generateShaderForModule(module: ShaderModule, options: ShaderGenerationOptions): string {\n switch (options.shaderLanguage) {\n case 'glsl':\n return generateGLSLForModule(module, options);\n case 'wgsl':\n return generateWGSLForModule(module, options);\n }\n}\n"],"mappings":"SAKQA,qBAAqB;AAAA,SAGrBC,qBAAqB;AAM7B,OAAO,SAASC,uBAAuBA,CAACC,MAAoB,EAAEC,OAAgC,EAAU;EACtG,QAAQA,OAAO,CAACC,cAAc;IAC5B,KAAK,MAAM;MACT,OAAOL,qBAAqB,CAACG,MAAM,EAAEC,OAAO,CAAC;IAC/C,KAAK,MAAM;MACT,OAAOH,qBAAqB,CAACE,MAAM,EAAEC,OAAO,CAAC;EAAC;AAEpD"}
@@ -0,0 +1,7 @@
1
+ import { ShaderModule } from '../../../lib/shader-module/shader-module';
2
+ export declare type GLSLGenerationOptions = {
3
+ shaderLanguage: 'glsl';
4
+ uniforms: 'scoped-interface-blocks' | 'unscoped-interface-blocks' | 'uniforms';
5
+ };
6
+ export declare function generateGLSLForModule(module: ShaderModule, options: GLSLGenerationOptions): string;
7
+ //# sourceMappingURL=generate-glsl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-glsl.d.ts","sourceRoot":"","sources":["../../../../src/lib/shader-generator/glsl/generate-glsl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,YAAY,EAAC,MAAM,0CAA0C,CAAC;AAGtE,oBAAY,qBAAqB,GAAG;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,yBAAyB,GAAG,2BAA2B,GAAG,UAAU,CAAC;CAChF,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,qBAAqB,UAEzF"}