@luma.gl/shadertools 9.0.16 → 9.0.19

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 (74) hide show
  1. package/dist/dist.dev.js +90 -97
  2. package/dist/dist.min.js +81 -78
  3. package/dist/index.cjs +34 -46
  4. package/dist/index.cjs.map +2 -2
  5. package/dist/lib/shader-module/shader-module.d.ts +22 -13
  6. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  7. package/dist/lib/shader-module/shader-pass.d.ts +4 -2
  8. package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
  9. package/dist/lib/utils/uniform-types.d.ts +49 -0
  10. package/dist/lib/utils/uniform-types.d.ts.map +1 -0
  11. package/dist/lib/utils/uniform-types.js +1 -0
  12. package/dist/modules/engine/picking/picking.d.ts +5 -5
  13. package/dist/modules/engine/picking/picking.d.ts.map +1 -1
  14. package/dist/modules/engine/picking/picking.js +2 -2
  15. package/dist/modules/engine/project/project.d.ts +9 -8
  16. package/dist/modules/engine/project/project.d.ts.map +1 -1
  17. package/dist/modules/lighting/gouraud-material/gouraud-material.js +1 -1
  18. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -1
  19. package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +15 -13
  20. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
  21. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +3 -3
  22. package/dist/modules/lighting/lights/lighting-uniforms.d.ts +15 -14
  23. package/dist/modules/lighting/lights/lighting-uniforms.d.ts.map +1 -1
  24. package/dist/modules/lighting/lights/lighting-uniforms.js +8 -5
  25. package/dist/modules/lighting/no-material/dirlight.d.ts +2 -2
  26. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  27. package/dist/modules/lighting/no-material/dirlight.js +1 -1
  28. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +14 -13
  29. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  30. package/dist/modules/lighting/pbr-material/pbr-material.js +0 -11
  31. package/dist/modules/lighting/phong-material/phong-material.js +1 -1
  32. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  33. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +2 -1
  34. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +2 -2
  35. package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
  36. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +1 -1
  37. package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
  38. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +1 -1
  39. package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
  40. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +1 -1
  41. package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
  42. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +1 -1
  43. package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
  44. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +1 -1
  45. package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
  46. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +2 -2
  47. package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
  48. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +1 -1
  49. package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
  50. package/dist/modules-webgl1/project/project.d.ts +6 -4
  51. package/dist/modules-webgl1/project/project.d.ts.map +1 -1
  52. package/package.json +2 -2
  53. package/src/lib/shader-module/shader-module.ts +24 -12
  54. package/src/lib/shader-module/shader-pass.ts +7 -4
  55. package/src/lib/utils/uniform-types.ts +91 -0
  56. package/src/modules/engine/picking/picking.ts +9 -9
  57. package/src/modules/engine/project/project.ts +10 -9
  58. package/src/modules/lighting/gouraud-material/gouraud-material.ts +1 -1
  59. package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +57 -52
  60. package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +4 -3
  61. package/src/modules/lighting/lights/lighting-uniforms.ts +30 -22
  62. package/src/modules/lighting/no-material/dirlight.ts +3 -3
  63. package/src/modules/lighting/pbr-material/pbr-material.ts +14 -24
  64. package/src/modules/lighting/phong-material/phong-material.ts +1 -1
  65. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +16 -14
  66. package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +2 -2
  67. package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +1 -1
  68. package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +1 -1
  69. package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +1 -1
  70. package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +1 -1
  71. package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +1 -1
  72. package/src/modules/postprocessing/image-fun-filters/magnify.ts +2 -2
  73. package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +1 -1
  74. package/src/modules-webgl1/project/project.ts +8 -7
@@ -5,9 +5,9 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js";
5
5
  */
6
6
  export type TiltShiftProps = {
7
7
  /** The x,y coordinate of the start of the line segment. */
8
- start?: number[];
8
+ start?: [number, number];
9
9
  /** The xm y coordinate of the end of the line segment. */
10
- end?: number[];
10
+ end?: [number, number];
11
11
  /** The maximum radius of the pyramid blur. */
12
12
  blurRadius?: number;
13
13
  /** The distance from the line at which the maximum blur radius is reached. */
@@ -1 +1 @@
1
- {"version":3,"file":"tiltshift.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-blur-filters/tiltshift.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAiDlE;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,EAAE,UAAU,CAAC,cAAc,EAAE,cAAc,CAsBhE,CAAC"}
1
+ {"version":3,"file":"tiltshift.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-blur-filters/tiltshift.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAiDlE;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,2DAA2D;IAC3D,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,EAAE,UAAU,CAAC,cAAc,EAAE,cAAc,CAsBhE,CAAC"}
@@ -9,7 +9,7 @@ export type TriangleBlurProps = {
9
9
  /** The radius of the pyramid convolved with the image. */
10
10
  radius?: number;
11
11
  /** @deprecated internal property */
12
- delta?: number[];
12
+ delta?: [number, number];
13
13
  };
14
14
  /**
15
15
  * @filter Triangle Blur
@@ -1 +1 @@
1
- {"version":3,"file":"triangleblur.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-blur-filters/triangleblur.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAwClE;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,UAAU,CAAC,iBAAiB,EAAE,iBAAiB,CAgBzE,CAAC"}
1
+ {"version":3,"file":"triangleblur.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-blur-filters/triangleblur.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAwClE;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,UAAU,CAAC,iBAAiB,EAAE,iBAAiB,CAgBzE,CAAC"}
@@ -4,7 +4,7 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js";
4
4
  */
5
5
  export type ZoomBlurProps = {
6
6
  /** - The x, y coordinate of the blur origin. */
7
- center?: number[];
7
+ center?: [number, number];
8
8
  /** - The strength of the blur. Values in the range 0 to 1 are usually sufficient, where 0 doesn't change the image and 1 creates a highly blurred image. */
9
9
  strength?: number;
10
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"zoomblur.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-blur-filters/zoomblur.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAsClE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,4JAA4J;IAC5J,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,UAAU,CAAC,aAAa,EAAE,aAAa,CAa7D,CAAC"}
1
+ {"version":3,"file":"zoomblur.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-blur-filters/zoomblur.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAsClE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,gDAAgD;IAChD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,4JAA4J;IAC5J,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,UAAU,CAAC,aAAa,EAAE,aAAa,CAa7D,CAAC"}
@@ -7,7 +7,7 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js";
7
7
  */
8
8
  export type ColorHalftoneProps = {
9
9
  /** The x,y coordinate of the pattern origin. */
10
- center?: number[];
10
+ center?: [number, number];
11
11
  /** The rotation of the pattern in radians. */
12
12
  angle?: number;
13
13
  /** The diameter of a dot in pixels. */
@@ -1 +1 @@
1
- {"version":3,"file":"colorhalftone.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/colorhalftone.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAyClE;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,UAAU,CAAC,kBAAkB,EAAE,kBAAkB,CAc5E,CAAC"}
1
+ {"version":3,"file":"colorhalftone.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/colorhalftone.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAyClE;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gDAAgD;IAChD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,UAAU,CAAC,kBAAkB,EAAE,kBAAkB,CAc5E,CAAC"}
@@ -6,7 +6,7 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js";
6
6
  */
7
7
  export type DotScreenProps = {
8
8
  /** The x, y coordinate of the pattern origin. */
9
- center?: number[];
9
+ center?: [number, number];
10
10
  /** The rotation of the pattern in radians. */
11
11
  angle?: number;
12
12
  /** The diameter of a dot in pixels. */
@@ -1 +1 @@
1
- {"version":3,"file":"dotscreen.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/dotscreen.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AA4BlE;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,UAAU,CAAC,cAAc,EAAE,cAAc,CAchE,CAAC"}
1
+ {"version":3,"file":"dotscreen.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/dotscreen.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AA4BlE;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,iDAAiD;IACjD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,UAAU,CAAC,cAAc,EAAE,cAAc,CAchE,CAAC"}
@@ -6,7 +6,7 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js";
6
6
  */
7
7
  export type HexagonalPixelateProps = {
8
8
  /** The [x, y] coordinates of the pattern center. */
9
- center?: number[];
9
+ center?: [number, number];
10
10
  /** The width of an individual tile, in pixels. */
11
11
  scale?: number;
12
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"hexagonalpixelate.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAgDlE;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAAU,CAAC,sBAAsB,EAAE,sBAAsB,CAYxF,CAAC"}
1
+ {"version":3,"file":"hexagonalpixelate.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAgDlE;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,oDAAoD;IACpD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAAU,CAAC,sBAAsB,EAAE,sBAAsB,CAYxF,CAAC"}
@@ -4,7 +4,7 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js";
4
4
  */
5
5
  export type MagnifyProps = {
6
6
  /** x, y position in screen coords, both x and y is normalized and in range `[0, 1]`. `[0, 0]` is the up left corner, `[1, 1]` is the bottom right corner. Default value is `[0, 0]`. */
7
- screenXY?: number[];
7
+ screenXY?: [number, number];
8
8
  /** effect radius in pixels. Default value is `100`. */
9
9
  radiusPixels?: number;
10
10
  /** magnify level. Default value is `2`. */
@@ -12,7 +12,7 @@ export type MagnifyProps = {
12
12
  /** border width of the effect circle, will not show border if value <= 0.0. Default value is `0`. */
13
13
  borderWidthPixels?: number;
14
14
  /** border color of the effect circle. Default value is `[255, 255, 255, 255]`. */
15
- borderColor?: number[];
15
+ borderColor?: [number, number, number, number];
16
16
  };
17
17
  /**
18
18
  * Magnify - display a circle with magnify effect applied to surrounding the pixels given position
@@ -1 +1 @@
1
- {"version":3,"file":"magnify.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/magnify.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AA0BlE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,wLAAwL;IACxL,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qGAAqG;IACrG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,UAAU,CAAC,YAAY,EAAE,YAAY,CAmB1D,CAAC"}
1
+ {"version":3,"file":"magnify.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-fun-filters/magnify.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AA0BlE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,wLAAwL;IACxL,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,uDAAuD;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qGAAqG;IACrG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kFAAkF;IAClF,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,UAAU,CAAC,YAAY,EAAE,YAAY,CAmB1D,CAAC"}
@@ -2,7 +2,7 @@ import { ShaderPass } from "../../../lib/shader-module/shader-pass.js";
2
2
  /** Bulges or pinches the image in a circle. */
3
3
  export type BulgePinchProps = {
4
4
  /** The [x, y] coordinates of the center of the circle of effect. */
5
- center?: number[];
5
+ center?: [number, number];
6
6
  /** The radius of the circle of effect. */
7
7
  radius?: number;
8
8
  /** strength -1 to 1 (-1 is strong pinch, 0 is no effect, 1 is strong bulge) */
@@ -1 +1 @@
1
- {"version":3,"file":"bulgepinch.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-warp-filters/bulgepinch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAkClE,+CAA+C;AAC/C,MAAM,MAAM,eAAe,GAAG;IAC5B,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,UAAU,CAAC,eAAe,EAAE,eAAe,CAenE,CAAC"}
1
+ {"version":3,"file":"bulgepinch.d.ts","sourceRoot":"","sources":["../../../../src/modules/postprocessing/image-warp-filters/bulgepinch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,kDAA+C;AAkClE,+CAA+C;AAC/C,MAAM,MAAM,eAAe,GAAG;IAC5B,oEAAoE;IACpE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,UAAU,CAAC,eAAe,EAAE,eAAe,CAenE,CAAC"}
@@ -1,9 +1,11 @@
1
+ import { Vector3, Matrix4 } from '@math.gl/core';
1
2
  import { ShaderModule } from "../../lib/shader-module/shader-module.js";
3
+ import type { NumberArray3, NumberArray16 } from "../../lib/utils/uniform-types.js";
2
4
  type ProjectionProps = {
3
- modelMatrix?: readonly number[];
4
- viewMatrix?: readonly number[];
5
- projectionMatrix?: readonly number[];
6
- cameraPositionWorld?: readonly number[];
5
+ modelMatrix?: Readonly<Matrix4 | NumberArray16>;
6
+ viewMatrix?: Readonly<Matrix4 | NumberArray16>;
7
+ projectionMatrix?: Readonly<Matrix4 | NumberArray16>;
8
+ cameraPositionWorld?: Readonly<Vector3 | NumberArray3>;
7
9
  };
8
10
  /**
9
11
  * Projects coordinates
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/modules-webgl1/project/project.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,YAAY,EAAC,iDAA8C;AAEnE,KAAK,eAAe,GAAG;IACrB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAiHF;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,YAAY,CAAC,eAAe,EAAE,eAAe,CAKlE,CAAC"}
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/modules-webgl1/project/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAC,YAAY,EAAC,iDAA8C;AACnE,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,yCAAsC;AAE/E,KAAK,eAAe,GAAG;IACrB,WAAW,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC;IAChD,UAAU,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC;IAC/C,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC;IACrD,mBAAmB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC;CACxD,CAAC;AAiHF;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,YAAY,CAAC,eAAe,EAAE,eAAe,CAKlE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/shadertools",
3
- "version": "9.0.16",
3
+ "version": "9.0.19",
4
4
  "description": "Shader module system for luma.gl",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -53,5 +53,5 @@
53
53
  "@math.gl/types": "^4.0.0",
54
54
  "wgsl_reflect": "^1.0.1"
55
55
  },
56
- "gitHead": "b1f2597d6efc8aa223ddb3bf6b1530510f17ea40"
56
+ "gitHead": "5e1ede7bdaf2c9ccdbd167804601537e93dc4225"
57
57
  }
@@ -2,47 +2,59 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {NumberArray} from '@math.gl/types';
6
5
  import {UniformFormat} from '../../types';
7
6
  import {PropType} from '../filters/prop-types';
8
- import {Sampler, Texture} from '@luma.gl/core';
7
+ import type {UniformTypes, UniformValue} from '../utils/uniform-types';
9
8
 
10
- export type UniformValue = number | boolean | Readonly<NumberArray>; // Float32Array> | Readonly<Int32Array> | Readonly<Uint32Array> | Readonly<number[]>;
9
+ // To avoid dependency on core module, do not import `Binding` type.
10
+ // The ShaderModule is not concerned with the type of `Binding`,
11
+ // it is the repsonsibility of `splitUniformsAndBindings` in
12
+ // ShaderInputs to type the result of `getUniforms()`
13
+ type Binding = unknown; // import type {Binding} from '@luma.gl/core';
11
14
 
12
15
  export type UniformInfo = {
13
16
  format?: UniformFormat;
14
17
  } & PropType;
15
18
 
19
+ // Helper types
20
+ type BindingKeys<T> = {[K in keyof T]: T[K] extends UniformValue ? never : K}[keyof T];
21
+ type UniformKeys<T> = {[K in keyof T]: T[K] extends UniformValue ? K : never}[keyof T];
22
+ export type PickBindings<T> = {[K in BindingKeys<Required<T>>]: T[K]};
23
+ export type PickUniforms<T> = {[K in UniformKeys<Required<T>>]: T[K]};
24
+
16
25
  /**
17
26
  * A shader module definition object
18
- * @note Can be viewed as the ShaderModuleProps for a ShaderModuleInstance
27
+ * @note `UniformsT` & `BindingsT` are deduced from `PropsT` by default. If
28
+ * a custom type for `UniformsT` is used, `BindingsT` should be also be provided.
19
29
  */
20
30
  export type ShaderModule<
21
- PropsT extends Record<string, unknown> = Record<string, unknown>,
22
- UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>,
23
- BindingsT extends Record<string, Buffer | Texture | Sampler> = {}
31
+ PropsT extends Record<string, any> = Record<string, any>,
32
+ UniformsT extends Record<string, UniformValue> = PickUniforms<PropsT>,
33
+ BindingsT extends Record<string, Binding> = PickBindings<PropsT>
24
34
  > = {
25
35
  /** Used for type inference not for values */
26
36
  props?: Required<PropsT>;
27
37
  /** Used for type inference, not currently used for values */
28
38
  uniforms?: UniformsT;
39
+ /** Used for type inference, not currently used for values */
40
+ bindings?: BindingsT;
29
41
 
30
42
  name: string;
31
43
  fs?: string;
32
44
  vs?: string;
33
45
 
34
46
  /** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */
35
- uniformTypes?: Record<keyof UniformsT, UniformFormat>;
47
+ uniformTypes?: Required<UniformTypes<UniformsT>>; // Record<keyof UniformsT, UniformFormat>;
36
48
  /** Uniform JS prop types */
37
49
  uniformPropTypes?: Record<keyof UniformsT, UniformInfo>;
38
50
  /** Default uniform values */
39
51
  defaultUniforms?: Required<UniformsT>; // Record<keyof UniformsT, UniformValue>;
40
52
 
41
53
  /** Function that maps props to uniforms & bindings */
42
- getUniforms?: (props?: any, oldProps?: any) => Record<string, UniformValue>;
43
-
44
- /** uniform buffers, textures, samplers, storage, ... */
45
- bindings?: Record<keyof BindingsT, {location: number; type: 'texture' | 'sampler' | 'uniforms'}>;
54
+ getUniforms?: (
55
+ props?: Partial<PropsT>,
56
+ prevUniforms?: UniformsT
57
+ ) => Partial<UniformsT & BindingsT>;
46
58
 
47
59
  defines?: Record<string, string | number>;
48
60
  /** Injections */
@@ -2,16 +2,19 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {ShaderModule, UniformValue} from './shader-module';
5
+ import type {Binding} from '@luma.gl/core';
6
+ import type {PickBindings, PickUniforms, ShaderModule} from './shader-module';
7
+ import type {UniformValue} from '../utils/uniform-types';
6
8
 
7
9
  /**
8
10
  * A shaderpass is a shader module with additional information
9
11
  * on how to run
10
12
  */
11
13
  export type ShaderPass<
12
- PropsT extends Record<string, unknown> = Record<string, unknown>,
13
- UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>
14
- > = ShaderModule<PropsT, UniformsT> & {
14
+ PropsT extends Record<string, any> = Record<string, any>,
15
+ UniformsT extends Record<string, UniformValue> = PickUniforms<PropsT>,
16
+ BindingsT extends Record<string, Binding> = PickBindings<PropsT>
17
+ > = ShaderModule<PropsT, UniformsT, BindingsT> & {
15
18
  passes: ShaderPassData[];
16
19
  };
17
20
 
@@ -0,0 +1,91 @@
1
+ import type {Matrix3, Matrix4, Vector2, Vector3, Vector4} from '@math.gl/core';
2
+
3
+ export type NumberArray2 = [number, number];
4
+ export type NumberArray3 = [number, number, number];
5
+ export type NumberArray4 = [number, number, number, number];
6
+ export type NumberArray6 = [number, number, number, number, number, number];
7
+ export type NumberArray8 = [number, number, number, number, number, number, number, number];
8
+ export type NumberArray9 = [number, number, number, number, number, number, number, number, number];
9
+ export type NumberArray12 = [
10
+ number,
11
+ number,
12
+ number,
13
+ number,
14
+ number,
15
+ number,
16
+ number,
17
+ number,
18
+ number,
19
+ number,
20
+ number,
21
+ number
22
+ ];
23
+ export type NumberArray16 = [
24
+ number,
25
+ number,
26
+ number,
27
+ number,
28
+ number,
29
+ number,
30
+ number,
31
+ number,
32
+ number,
33
+ number,
34
+ number,
35
+ number,
36
+ number,
37
+ number,
38
+ number,
39
+ number
40
+ ];
41
+
42
+ /*
43
+ * Allowed types to be used for uniform values
44
+ *
45
+ * Only allow types whose length we can type-check (not `TypedArray`)
46
+ */
47
+ export type UniformValue = Readonly<
48
+ | number
49
+ | boolean
50
+ | NumberArray2
51
+ | NumberArray3
52
+ | NumberArray4
53
+ | NumberArray6
54
+ | NumberArray8
55
+ | NumberArray9
56
+ | NumberArray12
57
+ | NumberArray16
58
+ | Vector2
59
+ | Vector3
60
+ | Vector4
61
+ | Matrix3
62
+ | Matrix4
63
+ >;
64
+
65
+ type UniformType<ValueT extends UniformValue> = ValueT extends number | boolean
66
+ ? 'f32' | 'i32' | 'u32'
67
+ : ValueT extends Readonly<NumberArray2 | Vector2>
68
+ ? 'vec2<f32>' | 'vec2<i32>' | 'vec2<u32>'
69
+ : ValueT extends Readonly<NumberArray3 | Vector3>
70
+ ? 'vec3<f32>' | 'vec3<i32>' | 'vec3<u32>'
71
+ : ValueT extends Readonly<NumberArray4 | Vector4>
72
+ ? 'vec4<f32>' | 'vec4<i32>' | 'vec4<u32>' | 'mat2x2<f32>'
73
+ : ValueT extends Readonly<NumberArray6>
74
+ ? 'mat2x3<f32>' | 'mat3x2<f32>'
75
+ : ValueT extends Readonly<NumberArray8>
76
+ ? 'mat2x4<f32>' | 'mat4x2<f32>'
77
+ : ValueT extends Readonly<NumberArray9 | Matrix3>
78
+ ? 'mat3x3<f32>'
79
+ : ValueT extends Readonly<NumberArray12>
80
+ ? 'mat3x4<f32>' | 'mat4x3<f32>'
81
+ : ValueT extends Readonly<NumberArray16 | Matrix4>
82
+ ? 'mat4x4<f32>'
83
+ : never;
84
+
85
+ type UniformProps = {
86
+ [name: string]: UniformValue;
87
+ };
88
+
89
+ export type UniformTypes<PropsT extends UniformProps> = {
90
+ [name in keyof PropsT]: UniformType<PropsT[name]>;
91
+ };
@@ -2,12 +2,12 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {NumberArray} from '../../../types';
6
5
  import {glsl} from '../../../lib/glsl-utils/highlight';
7
6
  import {ShaderModule} from '../../../lib/shader-module/shader-module';
7
+ import type {NumberArray3, NumberArray4} from '../../../lib/utils/uniform-types';
8
8
 
9
9
  // cyan color
10
- const DEFAULT_HIGHLIGHT_COLOR = new Float32Array([0, 1, 1, 1]);
10
+ const DEFAULT_HIGHLIGHT_COLOR: NumberArray4 = [0, 1, 1, 1];
11
11
 
12
12
  /**
13
13
  * Props for the picking module, which depending on mode renders picking colors or highlighted item.
@@ -20,9 +20,9 @@ export type PickingProps = {
20
20
  /** Set to true when picking an attribute value instead of object index */
21
21
  isAttribute?: boolean;
22
22
  /** Set to a picking color to visually highlight that item, or `null` to explicitly clear **/
23
- highlightedObjectColor?: NumberArray | null;
23
+ highlightedObjectColor?: NumberArray3 | null;
24
24
  /** Color of visual highlight of "selected" item */
25
- highlightColor?: NumberArray;
25
+ highlightColor?: NumberArray3 | NumberArray4;
26
26
  /** Color range 0-1 or 0-255 */
27
27
  useFloatColors?: boolean;
28
28
  };
@@ -45,9 +45,9 @@ export type PickingUniforms = {
45
45
  /** Do we have a highlighted item? */
46
46
  isHighlightActive?: boolean;
47
47
  /** Set to a picking color to visually highlight that item */
48
- highlightedObjectColor?: NumberArray;
48
+ highlightedObjectColor?: NumberArray3;
49
49
  /** Color of visual highlight of "selected" item */
50
- highlightColor?: NumberArray;
50
+ highlightColor?: NumberArray4;
51
51
  };
52
52
 
53
53
  const vs = glsl`\
@@ -207,7 +207,7 @@ export const picking: ShaderModule<PickingProps, PickingUniforms> = {
207
207
  isAttribute: false,
208
208
  isHighlightActive: false,
209
209
  useFloatColors: true,
210
- highlightedObjectColor: new Float32Array([0, 0, 0]),
210
+ highlightedObjectColor: [0, 0, 0],
211
211
  highlightColor: DEFAULT_HIGHLIGHT_COLOR
212
212
  },
213
213
  getUniforms
@@ -222,7 +222,7 @@ function getUniforms(opts: PickingProps = {}, prevUniforms?: PickingUniforms): P
222
222
  uniforms.isHighlightActive = false;
223
223
  } else {
224
224
  uniforms.isHighlightActive = true;
225
- const highlightedObjectColor = opts.highlightedObjectColor.slice(0, 3);
225
+ const highlightedObjectColor = opts.highlightedObjectColor.slice(0, 3) as NumberArray3;
226
226
  uniforms.highlightedObjectColor = highlightedObjectColor;
227
227
  }
228
228
 
@@ -231,7 +231,7 @@ function getUniforms(opts: PickingProps = {}, prevUniforms?: PickingUniforms): P
231
231
  if (!Number.isFinite(color[3])) {
232
232
  color[3] = 1;
233
233
  }
234
- uniforms.highlightColor = color;
234
+ uniforms.highlightColor = color as NumberArray4;
235
235
  }
236
236
 
237
237
  if (opts.isActive !== undefined) {
@@ -2,20 +2,21 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {NumericArray as NumberArray, Matrix4, Vector3} from '@math.gl/core';
5
+ import {Matrix4, Vector3} from '@math.gl/core';
6
6
  import {ShaderModule} from '../../../lib/shader-module/shader-module';
7
7
  import {glsl} from '../../../lib/glsl-utils/highlight';
8
+ import type {NumberArray3, NumberArray16} from '../../../lib/utils/uniform-types';
8
9
 
9
- const IDENTITY_MATRIX: Readonly<NumberArray> = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
10
+ const IDENTITY_MATRIX: Readonly<NumberArray16> = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
10
11
 
11
12
  /**
12
13
  * @note Projection uniforms are normally constant across draw calls,
13
14
  * at least for each view.
14
15
  */
15
16
  export type ProjectionProps = {
16
- viewMatrix?: Readonly<Matrix4 | NumberArray>;
17
- projectionMatrix?: Readonly<Matrix4 | NumberArray>;
18
- cameraPositionWorld?: Readonly<Vector3 | NumberArray>;
17
+ viewMatrix?: Readonly<Matrix4 | NumberArray16>;
18
+ projectionMatrix?: Readonly<Matrix4 | NumberArray16>;
19
+ cameraPositionWorld?: Readonly<Vector3 | NumberArray3>;
19
20
  };
20
21
 
21
22
  /**
@@ -23,10 +24,10 @@ export type ProjectionProps = {
23
24
  * at least for each view.
24
25
  */
25
26
  export type ProjectionUniforms = {
26
- viewMatrix?: Readonly<Matrix4 | NumberArray>;
27
- projectionMatrix?: Readonly<Matrix4 | NumberArray>;
28
- viewProjectionMatrix?: Readonly<Matrix4 | NumberArray>;
29
- cameraPositionWorld?: Readonly<Vector3 | NumberArray>;
27
+ viewMatrix?: Readonly<Matrix4 | NumberArray16>;
28
+ projectionMatrix?: Readonly<Matrix4 | NumberArray16>;
29
+ viewProjectionMatrix?: Readonly<Matrix4 | NumberArray16>;
30
+ cameraPositionWorld?: Readonly<Vector3 | NumberArray3>;
30
31
  };
31
32
 
32
33
  const DEFAULT_MODULE_OPTIONS: Required<ProjectionUniforms> = {
@@ -18,7 +18,7 @@ export type GouraudMaterialUniforms = {
18
18
 
19
19
  /** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */
20
20
  export const gouraudMaterial: ShaderModule<GouraudMaterialProps, GouraudMaterialUniforms> = {
21
- name: 'gouraud-lighting',
21
+ name: 'gouraudMaterial',
22
22
  // Note these are switched between phong and gouraud
23
23
  vs: GOURAUD_VS,
24
24
  fs: GOURAUD_FS,
@@ -5,16 +5,7 @@
5
5
  import {glsl} from '../../../lib/glsl-utils/highlight';
6
6
 
7
7
  export const GOURAUD_VS = glsl`\
8
- uniform materialUniforms {
9
- uniform float ambient;
10
- uniform float diffuse;
11
- uniform float shininess;
12
- uniform vec3 specularColor;
13
- } material;
14
- `;
15
-
16
- export const GOURAUD_FS = glsl`\
17
- uniform materialUniforms {
8
+ uniform gouraudMaterialUniforms {
18
9
  uniform float ambient;
19
10
  uniform float diffuse;
20
11
  uniform float shininess;
@@ -36,39 +27,41 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
36
27
  vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
37
28
  vec3 lightColor = surfaceColor;
38
29
 
39
- if (lighting.enabled) {
40
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
41
- lightColor = material.ambient * surfaceColor * lighting.ambientColor;
30
+ if (lighting.enabled == 0) {
31
+ return lightColor;
32
+ }
42
33
 
43
- if (lighting.lightType == 0) {
44
- PointLight pointLight = lighting_getPointLight(0);
45
- vec3 light_position_worldspace = pointLight.position;
46
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
47
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
48
- } else if (lighting.lightType == 1) {
49
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
50
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
51
- }
52
- /*
53
- for (int i = 0; i < MAX_LIGHTS; i++) {
54
- if (i >= lighting.pointLightCount) {
55
- break;
56
- }
57
- PointLight pointLight = lighting.pointLight[i];
58
- vec3 light_position_worldspace = pointLight.position;
59
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
60
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
34
+ vec3 view_direction = normalize(cameraPosition - position_worldspace);
35
+ lightColor = material.ambient * surfaceColor * lighting.ambientColor;
36
+
37
+ if (lighting.lightType == 0) {
38
+ PointLight pointLight = lighting_getPointLight(0);
39
+ vec3 light_position_worldspace = pointLight.position;
40
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
41
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
42
+ } else if (lighting.lightType == 1) {
43
+ DirectionalLight directionalLight = lighting_getDirectionalLight(0);
44
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
45
+ }
46
+ /*
47
+ for (int i = 0; i < MAX_LIGHTS; i++) {
48
+ if (i >= lighting.pointLightCount) {
49
+ break;
61
50
  }
51
+ PointLight pointLight = lighting.pointLight[i];
52
+ vec3 light_position_worldspace = pointLight.position;
53
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
54
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
55
+ }
62
56
 
63
- for (int i = 0; i < MAX_LIGHTS; i++) {
64
- if (i >= lighting.directionalLightCount) {
65
- break;
66
- }
67
- DirectionalLight directionalLight = lighting.directionalLight[i];
68
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
57
+ for (int i = 0; i < MAX_LIGHTS; i++) {
58
+ if (i >= lighting.directionalLightCount) {
59
+ break;
69
60
  }
70
- */
61
+ DirectionalLight directionalLight = lighting.directionalLight[i];
62
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
71
63
  }
64
+ */
72
65
  return lightColor;
73
66
  }
74
67
 
@@ -76,27 +69,39 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
76
69
  vec3 lightColor = vec3(0, 0, 0);
77
70
  vec3 surfaceColor = vec3(0, 0, 0);
78
71
 
79
- if (lighting.enabled) {
80
- vec3 view_direction = normalize(cameraPosition - position_worldspace);
72
+ if (lighting.enabled == 0) {
73
+ return lightColor;
74
+ }
81
75
 
82
- switch (lighting.lightType) {
83
- case 0:
84
- PointLight pointLight = lighting_getPointLight(0);
85
- vec3 light_position_worldspace = pointLight.position;
86
- vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
87
- lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
88
- break;
76
+ vec3 view_direction = normalize(cameraPosition - position_worldspace);
89
77
 
90
- case 1:
91
- DirectionalLight directionalLight = lighting_getDirectionalLight(0);
92
- lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
93
- break;
94
- }
78
+ switch (lighting.lightType) {
79
+ case 0:
80
+ PointLight pointLight = lighting_getPointLight(0);
81
+ vec3 light_position_worldspace = pointLight.position;
82
+ vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
83
+ lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
84
+ break;
85
+
86
+ case 1:
87
+ DirectionalLight directionalLight = lighting_getDirectionalLight(0);
88
+ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
89
+ break;
95
90
  }
91
+
96
92
  return lightColor;
97
93
  }
98
94
  `;
99
95
 
96
+ export const GOURAUD_FS = glsl`\
97
+ uniform gouraudMaterialUniforms {
98
+ uniform float ambient;
99
+ uniform float diffuse;
100
+ uniform float shininess;
101
+ uniform vec3 specularColor;
102
+ } material;
103
+ `;
104
+
100
105
  // TODO - handle multiple lights
101
106
  /**
102
107
  for (int i = 0; i < MAX_LIGHTS; i++) {