@luma.gl/shadertools 9.3.0 → 9.3.2

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 (24) hide show
  1. package/dist/dist.dev.js +15 -28
  2. package/dist/dist.min.js +51 -48
  3. package/dist/index.cjs +15 -22
  4. package/dist/index.cjs.map +3 -3
  5. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +0 -1
  6. package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
  7. package/dist/modules/lighting/gouraud-material/gouraud-material.js +6 -11
  8. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -1
  9. package/dist/modules/lighting/phong-material/phong-material.d.ts +0 -1
  10. package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
  11. package/dist/modules/lighting/phong-material/phong-material.js +6 -11
  12. package/dist/modules/lighting/phong-material/phong-material.js.map +1 -1
  13. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +1 -1
  14. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  15. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +1 -1
  16. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts +1 -1
  17. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -1
  18. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +4 -1
  19. package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js.map +1 -1
  20. package/package.json +3 -3
  21. package/src/modules/lighting/gouraud-material/gouraud-material.ts +7 -15
  22. package/src/modules/lighting/phong-material/phong-material.ts +7 -15
  23. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +1 -1
  24. package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +4 -1
@@ -6,7 +6,6 @@ export type GouraudMaterialProps = {
6
6
  /** Specularity exponent */
7
7
  shininess?: number;
8
8
  specularColor?: [number, number, number];
9
- useByteColors?: boolean;
10
9
  };
11
10
  /** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */
12
11
  export declare const gouraudMaterial: ShaderModule<GouraudMaterialProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"gouraud-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-material.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAMtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,yIAAyI;AACzI,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,oBAAoB,CAwC9D,CAAC"}
1
+ {"version":3,"file":"gouraud-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-material.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAMtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAIF,yIAAyI;AACzI,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,oBAAoB,CA+B9D,CAAC"}
@@ -1,10 +1,11 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
+ import { floatColors } from "../../color/float-colors.js";
4
5
  import { lighting } from "../lights/lighting.js";
5
6
  import { PHONG_VS, PHONG_FS } from "../phong-material/phong-shaders-glsl.js";
6
7
  import { PHONG_WGSL } from "../phong-material/phong-shaders-wgsl.js";
7
- import { normalizeByteColor3, resolveUseByteColors } from "../../../lib/color/normalize-byte-colors.js";
8
+ const DEFAULT_SPECULAR_COLOR = [38.25, 38.25, 38.25];
8
9
  /** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */
9
10
  export const gouraudMaterial = {
10
11
  props: {},
@@ -17,29 +18,23 @@ export const gouraudMaterial = {
17
18
  defines: {
18
19
  LIGHTING_VERTEX: true
19
20
  },
20
- dependencies: [lighting],
21
+ dependencies: [lighting, floatColors],
21
22
  uniformTypes: {
22
23
  unlit: 'i32',
23
24
  ambient: 'f32',
24
25
  diffuse: 'f32',
25
26
  shininess: 'f32',
26
- specularColor: 'vec3<f32>',
27
- useByteColors: 'i32'
27
+ specularColor: 'vec3<f32>'
28
28
  },
29
29
  defaultUniforms: {
30
30
  unlit: false,
31
31
  ambient: 0.35,
32
32
  diffuse: 0.6,
33
33
  shininess: 32,
34
- specularColor: [0.15, 0.15, 0.15],
35
- useByteColors: true
34
+ specularColor: DEFAULT_SPECULAR_COLOR
36
35
  },
37
36
  getUniforms(props) {
38
- const uniforms = { ...props };
39
- if (uniforms.specularColor) {
40
- uniforms.specularColor = normalizeByteColor3(uniforms.specularColor, resolveUseByteColors(uniforms.useByteColors, true));
41
- }
42
- return { ...gouraudMaterial.defaultUniforms, ...uniforms };
37
+ return { ...gouraudMaterial.defaultUniforms, ...props };
43
38
  }
44
39
  };
45
40
  //# sourceMappingURL=gouraud-material.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gouraud-material.js","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-material.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAC5C,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,gDAA6C;AACxE,OAAO,EAAC,UAAU,EAAC,gDAA6C;AAChE,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,oDAAiD;AAYnG,yIAAyI;AACzI,MAAM,CAAC,MAAM,eAAe,GAAuC;IACjE,KAAK,EAAE,EAA0B;IAEjC,IAAI,EAAE,iBAAiB;IACvB,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IACpD,oDAAoD;IACpD,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,iBAAiB,CAAC;IACxD,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,iBAAiB,CAAC;IACxD,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,eAAe,EAAE,iBAAiB,CAAC;IACjE,OAAO,EAAE;QACP,eAAe,EAAE,IAAI;KACtB;IACD,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,YAAY,EAAE;QACZ,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,WAAW;QAC1B,aAAa,EAAE,KAAK;KACrB;IACD,eAAe,EAAE;QACf,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,GAAG;QACZ,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,aAAa,EAAE,IAAI;KACpB;IAED,WAAW,CAAC,KAA2B;QACrC,MAAM,QAAQ,GAAG,EAAC,GAAG,KAAK,EAAC,CAAC;QAC5B,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;YAC3B,QAAQ,CAAC,aAAa,GAAG,mBAAmB,CAC1C,QAAQ,CAAC,aAAa,EACtB,oBAAoB,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,CACnC,CAAC;QACpB,CAAC;QACD,OAAO,EAAC,GAAG,eAAe,CAAC,eAAe,EAAE,GAAG,QAAQ,EAAC,CAAC;IAC3D,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"gouraud-material.js","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-material.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,OAAO,EAAC,WAAW,EAAC,oCAAiC;AACrD,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAC5C,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,gDAA6C;AACxE,OAAO,EAAC,UAAU,EAAC,gDAA6C;AAWhE,MAAM,sBAAsB,GAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAEnE,yIAAyI;AACzI,MAAM,CAAC,MAAM,eAAe,GAAuC;IACjE,KAAK,EAAE,EAA0B;IAEjC,IAAI,EAAE,iBAAiB;IACvB,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IACpD,oDAAoD;IACpD,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,iBAAiB,CAAC;IACxD,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,iBAAiB,CAAC;IACxD,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,eAAe,EAAE,iBAAiB,CAAC;IACjE,OAAO,EAAE;QACP,eAAe,EAAE,IAAI;KACtB;IACD,YAAY,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;IACrC,YAAY,EAAE;QACZ,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,WAAW;KAC3B;IACD,eAAe,EAAE;QACf,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,GAAG;QACZ,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,sBAAsB;KACtC;IAED,WAAW,CAAC,KAA2B;QACrC,OAAO,EAAC,GAAG,eAAe,CAAC,eAAe,EAAE,GAAG,KAAK,EAAC,CAAC;IACxD,CAAC;CACF,CAAC"}
@@ -7,7 +7,6 @@ export type PhongMaterialProps = {
7
7
  /** Specularity exponent */
8
8
  shininess?: number;
9
9
  specularColor?: NumberArray3;
10
- useByteColors?: boolean;
11
10
  };
12
11
  /** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */
13
12
  export declare const phongMaterial: ShaderModule<PhongMaterialProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"phong-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAMtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,wIAAwI;AACxI,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,kBAAkB,CAsC1D,CAAC"}
1
+ {"version":3,"file":"phong-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,oDAAiD;AAMtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B,CAAC;AAIF,wIAAwI;AACxI,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,kBAAkB,CA6B1D,CAAC"}
@@ -1,16 +1,17 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
+ import { floatColors } from "../../color/float-colors.js";
4
5
  import { lighting } from "../lights/lighting.js";
5
6
  import { PHONG_WGSL } from "./phong-shaders-wgsl.js";
6
7
  import { PHONG_VS, PHONG_FS } from "./phong-shaders-glsl.js";
7
- import { normalizeByteColor3, resolveUseByteColors } from "../../../lib/color/normalize-byte-colors.js";
8
+ const DEFAULT_SPECULAR_COLOR = [38.25, 38.25, 38.25];
8
9
  /** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */
9
10
  export const phongMaterial = {
10
11
  name: 'phongMaterial',
11
12
  firstBindingSlot: 0,
12
13
  bindingLayout: [{ name: 'phongMaterial', group: 3 }],
13
- dependencies: [lighting],
14
+ dependencies: [lighting, floatColors],
14
15
  // Note these are switched between phong and gouraud
15
16
  source: PHONG_WGSL,
16
17
  vs: PHONG_VS,
@@ -23,23 +24,17 @@ export const phongMaterial = {
23
24
  ambient: 'f32',
24
25
  diffuse: 'f32',
25
26
  shininess: 'f32',
26
- specularColor: 'vec3<f32>',
27
- useByteColors: 'i32'
27
+ specularColor: 'vec3<f32>'
28
28
  },
29
29
  defaultUniforms: {
30
30
  unlit: false,
31
31
  ambient: 0.35,
32
32
  diffuse: 0.6,
33
33
  shininess: 32,
34
- specularColor: [0.15, 0.15, 0.15],
35
- useByteColors: true
34
+ specularColor: DEFAULT_SPECULAR_COLOR
36
35
  },
37
36
  getUniforms(props) {
38
- const uniforms = { ...props };
39
- if (uniforms.specularColor) {
40
- uniforms.specularColor = normalizeByteColor3(uniforms.specularColor, resolveUseByteColors(uniforms.useByteColors, true));
41
- }
42
- return { ...phongMaterial.defaultUniforms, ...uniforms };
37
+ return { ...phongMaterial.defaultUniforms, ...props };
43
38
  }
44
39
  };
45
40
  //# sourceMappingURL=phong-material.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"phong-material.js","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAC5C,OAAO,EAAC,UAAU,EAAC,gCAA6B;AAChD,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,gCAA6B;AACxD,OAAO,EAAC,mBAAmB,EAAE,oBAAoB,EAAC,oDAAiD;AAYnG,wIAAwI;AACxI,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC7D,IAAI,EAAE,eAAe;IACrB,gBAAgB,EAAE,CAAC;IACnB,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IAClD,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,oDAAoD;IACpD,MAAM,EAAE,UAAU;IAClB,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,QAAQ;IACZ,OAAO,EAAE;QACP,iBAAiB,EAAE,IAAI;KACxB;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,WAAW;QAC1B,aAAa,EAAE,KAAK;KACrB;IACD,eAAe,EAAE;QACf,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,GAAG;QACZ,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,aAAa,EAAE,IAAI;KACpB;IACD,WAAW,CAAC,KAA0B;QACpC,MAAM,QAAQ,GAAG,EAAC,GAAG,KAAK,EAAC,CAAC;QAC5B,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;YAC3B,QAAQ,CAAC,aAAa,GAAG,mBAAmB,CAC1C,QAAQ,CAAC,aAAa,EACtB,oBAAoB,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,CACnC,CAAC;QACpB,CAAC;QACD,OAAO,EAAC,GAAG,aAAa,CAAC,eAAe,EAAE,GAAG,QAAQ,EAAC,CAAC;IACzD,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"phong-material.js","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-material.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,OAAO,EAAC,WAAW,EAAC,oCAAiC;AACrD,OAAO,EAAC,QAAQ,EAAC,8BAA2B;AAC5C,OAAO,EAAC,UAAU,EAAC,gCAA6B;AAChD,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,gCAA6B;AAWxD,MAAM,sBAAsB,GAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAEnE,wIAAwI;AACxI,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC7D,IAAI,EAAE,eAAe;IACrB,gBAAgB,EAAE,CAAC;IACnB,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IAClD,YAAY,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;IACrC,oDAAoD;IACpD,MAAM,EAAE,UAAU;IAClB,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,QAAQ;IACZ,OAAO,EAAE;QACP,iBAAiB,EAAE,IAAI;KACxB;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,WAAW;KAC3B;IACD,eAAe,EAAE;QACf,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,GAAG;QACZ,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,sBAAsB;KACtC;IACD,WAAW,CAAC,KAA0B;QACpC,OAAO,EAAC,GAAG,aAAa,CAAC,eAAe,EAAE,GAAG,KAAK,EAAC,CAAC;IACtD,CAAC;CACF,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export declare const PHONG_VS = "layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n";
2
- export declare const PHONG_FS = "layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (material.unlit) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.spotLightCount; i++) {\n SpotLight spotLight = lighting_getSpotLight(i);\n vec3 light_position_worldspace = spotLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.directionalLightCount; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n";
2
+ export declare const PHONG_FS = "layout(std140) uniform phongMaterialUniforms {\n uniform bool unlit;\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction);\n float lambertian = dot(light_direction, normal_worldspace);\n float specular = 0.0;\n if (lambertian > 0.0) {\n float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, material.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (material.unlit) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.spotLightCount; i++) {\n SpotLight spotLight = lighting_getSpotLight(i);\n vec3 light_position_worldspace = spotLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);\n }\n\n for (int i = 0; i < lighting.directionalLightCount; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n";
3
3
  //# sourceMappingURL=phong-shaders-glsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"phong-shaders-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,yMAQpB,CAAC;AAEF,eAAO,MAAM,QAAQ,0hFA0DpB,CAAC"}
1
+ {"version":3,"file":"phong-shaders-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ,yMAQpB,CAAC;AAEF,eAAO,MAAM,QAAQ,ijFA0DpB,CAAC"}
@@ -28,7 +28,7 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
28
28
  specular = pow(specular_angle, material.shininess);
29
29
  }
30
30
  lambertian = max(lambertian, 0.0);
31
- return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;
31
+ return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color;
32
32
  }
33
33
 
34
34
  vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
@@ -1,2 +1,2 @@
1
- export declare const PHONG_WGSL = "struct phongMaterialUniforms {\n unlit: u32,\n ambient: f32,\n diffuse: f32,\n shininess: f32,\n specularColor: vec3<f32>,\n};\n\n@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;\n\nfn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {\n let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);\n var lambertian: f32 = dot(light_direction, normal_worldspace);\n var specular: f32 = 0.0;\n if (lambertian > 0.0) {\n let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, phongMaterial.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (lambertian * phongMaterial.diffuse * surfaceColor + specular * phongMaterial.specularColor) * color;\n}\n\nfn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {\n var lightColor: vec3<f32> = surfaceColor;\n\n if (phongMaterial.unlit != 0u) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);\n lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n } \n \n return lightColor;\n}\n\nfn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{\n var lightColor = vec3<f32>(0, 0, 0);\n let surfaceColor = vec3<f32>(0, 0, 0);\n\n if (lighting.enabled != 0) {\n let view_direction = normalize(cameraPosition - position_worldspace);\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n";
1
+ export declare const PHONG_WGSL = "struct phongMaterialUniforms {\n unlit: u32,\n ambient: f32,\n diffuse: f32,\n shininess: f32,\n specularColor: vec3<f32>,\n};\n\n@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;\n\nfn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {\n let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);\n var lambertian: f32 = dot(light_direction, normal_worldspace);\n var specular: f32 = 0.0;\n if (lambertian > 0.0) {\n let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\n specular = pow(specular_angle, phongMaterial.shininess);\n }\n lambertian = max(lambertian, 0.0);\n return (\n lambertian * phongMaterial.diffuse * surfaceColor +\n specular * floatColors_normalize(phongMaterial.specularColor)\n ) * color;\n}\n\nfn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {\n var lightColor: vec3<f32> = surfaceColor;\n\n if (phongMaterial.unlit != 0u) {\n return surfaceColor;\n }\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace);\n lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor;\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n } \n \n return lightColor;\n}\n\nfn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{\n var lightColor = vec3<f32>(0, 0, 0);\n let surfaceColor = vec3<f32>(0, 0, 0);\n\n if (lighting.enabled != 0) {\n let view_direction = normalize(cameraPosition - position_worldspace);\n\n for (var i: i32 = 0; i < lighting.pointLightCount; i++) {\n let pointLight: PointLight = lighting_getPointLight(i);\n let light_position_worldspace: vec3<f32> = pointLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getPointLightAttenuation(\n pointLight,\n distance(light_position_worldspace, position_worldspace)\n );\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n pointLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.spotLightCount; i++) {\n let spotLight: SpotLight = lighting_getSpotLight(i);\n let light_position_worldspace: vec3<f32> = spotLight.position;\n let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);\n let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);\n lightColor += lighting_getLightColor(\n surfaceColor,\n light_direction,\n view_direction,\n normal_worldspace,\n spotLight.color / light_attenuation\n );\n }\n\n for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {\n let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n }\n return lightColor;\n}\n";
2
2
  //# sourceMappingURL=phong-shaders-wgsl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"phong-shaders-wgsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-wgsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,2uJAyHtB,CAAC"}
1
+ {"version":3,"file":"phong-shaders-wgsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-wgsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,ixJA4HtB,CAAC"}
@@ -21,7 +21,10 @@ fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, v
21
21
  specular = pow(specular_angle, phongMaterial.shininess);
22
22
  }
23
23
  lambertian = max(lambertian, 0.0);
24
- return (lambertian * phongMaterial.diffuse * surfaceColor + specular * phongMaterial.specularColor) * color;
24
+ return (
25
+ lambertian * phongMaterial.diffuse * surfaceColor +
26
+ specular * floatColors_normalize(phongMaterial.specularColor)
27
+ ) * color;
25
28
  }
26
29
 
27
30
  fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {
@@ -1 +1 @@
1
- {"version":3,"file":"phong-shaders-wgsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-wgsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHpC,CAAC"}
1
+ {"version":3,"file":"phong-shaders-wgsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/phong-material/phong-shaders-wgsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4HpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/shadertools",
3
- "version": "9.3.0",
3
+ "version": "9.3.2",
4
4
  "description": "Shader module system for luma.gl",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,11 +46,11 @@
46
46
  "prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
47
47
  },
48
48
  "peerDependencies": {
49
- "@luma.gl/core": "9.3.0-alpha.6"
49
+ "@luma.gl/core": "~9.3.0"
50
50
  },
51
51
  "dependencies": {
52
52
  "@math.gl/core": "^4.1.0",
53
53
  "@math.gl/types": "^4.1.0"
54
54
  },
55
- "gitHead": "c5e44faacd07b315a8622b5927e724f15a3d40ae"
55
+ "gitHead": "8f60fca63dc43702af5b16d0381fd97d7ace7dc9"
56
56
  }
@@ -4,10 +4,10 @@
4
4
 
5
5
  import {NumberArray3} from '@math.gl/types';
6
6
  import {ShaderModule} from '../../../lib/shader-module/shader-module';
7
+ import {floatColors} from '../../color/float-colors';
7
8
  import {lighting} from '../lights/lighting';
8
9
  import {PHONG_VS, PHONG_FS} from '../phong-material/phong-shaders-glsl';
9
10
  import {PHONG_WGSL} from '../phong-material/phong-shaders-wgsl';
10
- import {normalizeByteColor3, resolveUseByteColors} from '../../../lib/color/normalize-byte-colors';
11
11
 
12
12
  export type GouraudMaterialProps = {
13
13
  unlit?: boolean;
@@ -16,9 +16,10 @@ export type GouraudMaterialProps = {
16
16
  /** Specularity exponent */
17
17
  shininess?: number;
18
18
  specularColor?: [number, number, number];
19
- useByteColors?: boolean;
20
19
  };
21
20
 
21
+ const DEFAULT_SPECULAR_COLOR: NumberArray3 = [38.25, 38.25, 38.25];
22
+
22
23
  /** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */
23
24
  export const gouraudMaterial: ShaderModule<GouraudMaterialProps> = {
24
25
  props: {} as GouraudMaterialProps,
@@ -32,32 +33,23 @@ export const gouraudMaterial: ShaderModule<GouraudMaterialProps> = {
32
33
  defines: {
33
34
  LIGHTING_VERTEX: true
34
35
  },
35
- dependencies: [lighting],
36
+ dependencies: [lighting, floatColors],
36
37
  uniformTypes: {
37
38
  unlit: 'i32',
38
39
  ambient: 'f32',
39
40
  diffuse: 'f32',
40
41
  shininess: 'f32',
41
- specularColor: 'vec3<f32>',
42
- useByteColors: 'i32'
42
+ specularColor: 'vec3<f32>'
43
43
  },
44
44
  defaultUniforms: {
45
45
  unlit: false,
46
46
  ambient: 0.35,
47
47
  diffuse: 0.6,
48
48
  shininess: 32,
49
- specularColor: [0.15, 0.15, 0.15],
50
- useByteColors: true
49
+ specularColor: DEFAULT_SPECULAR_COLOR
51
50
  },
52
51
 
53
52
  getUniforms(props: GouraudMaterialProps) {
54
- const uniforms = {...props};
55
- if (uniforms.specularColor) {
56
- uniforms.specularColor = normalizeByteColor3(
57
- uniforms.specularColor,
58
- resolveUseByteColors(uniforms.useByteColors, true)
59
- ) as NumberArray3;
60
- }
61
- return {...gouraudMaterial.defaultUniforms, ...uniforms};
53
+ return {...gouraudMaterial.defaultUniforms, ...props};
62
54
  }
63
55
  };
@@ -4,10 +4,10 @@
4
4
 
5
5
  import {NumberArray3} from '@math.gl/types';
6
6
  import {ShaderModule} from '../../../lib/shader-module/shader-module';
7
+ import {floatColors} from '../../color/float-colors';
7
8
  import {lighting} from '../lights/lighting';
8
9
  import {PHONG_WGSL} from './phong-shaders-wgsl';
9
10
  import {PHONG_VS, PHONG_FS} from './phong-shaders-glsl';
10
- import {normalizeByteColor3, resolveUseByteColors} from '../../../lib/color/normalize-byte-colors';
11
11
 
12
12
  export type PhongMaterialProps = {
13
13
  unlit?: boolean;
@@ -16,15 +16,16 @@ export type PhongMaterialProps = {
16
16
  /** Specularity exponent */
17
17
  shininess?: number;
18
18
  specularColor?: NumberArray3;
19
- useByteColors?: boolean;
20
19
  };
21
20
 
21
+ const DEFAULT_SPECULAR_COLOR: NumberArray3 = [38.25, 38.25, 38.25];
22
+
22
23
  /** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */
23
24
  export const phongMaterial: ShaderModule<PhongMaterialProps> = {
24
25
  name: 'phongMaterial',
25
26
  firstBindingSlot: 0,
26
27
  bindingLayout: [{name: 'phongMaterial', group: 3}],
27
- dependencies: [lighting],
28
+ dependencies: [lighting, floatColors],
28
29
  // Note these are switched between phong and gouraud
29
30
  source: PHONG_WGSL,
30
31
  vs: PHONG_VS,
@@ -37,25 +38,16 @@ export const phongMaterial: ShaderModule<PhongMaterialProps> = {
37
38
  ambient: 'f32',
38
39
  diffuse: 'f32',
39
40
  shininess: 'f32',
40
- specularColor: 'vec3<f32>',
41
- useByteColors: 'i32'
41
+ specularColor: 'vec3<f32>'
42
42
  },
43
43
  defaultUniforms: {
44
44
  unlit: false,
45
45
  ambient: 0.35,
46
46
  diffuse: 0.6,
47
47
  shininess: 32,
48
- specularColor: [0.15, 0.15, 0.15],
49
- useByteColors: true
48
+ specularColor: DEFAULT_SPECULAR_COLOR
50
49
  },
51
50
  getUniforms(props?: PhongMaterialProps) {
52
- const uniforms = {...props};
53
- if (uniforms.specularColor) {
54
- uniforms.specularColor = normalizeByteColor3(
55
- uniforms.specularColor,
56
- resolveUseByteColors(uniforms.useByteColors, true)
57
- ) as NumberArray3;
58
- }
59
- return {...phongMaterial.defaultUniforms, ...uniforms};
51
+ return {...phongMaterial.defaultUniforms, ...props};
60
52
  }
61
53
  };
@@ -30,7 +30,7 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
30
30
  specular = pow(specular_angle, material.shininess);
31
31
  }
32
32
  lambertian = max(lambertian, 0.0);
33
- return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;
33
+ return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color;
34
34
  }
35
35
 
36
36
  vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
@@ -22,7 +22,10 @@ fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, v
22
22
  specular = pow(specular_angle, phongMaterial.shininess);
23
23
  }
24
24
  lambertian = max(lambertian, 0.0);
25
- return (lambertian * phongMaterial.diffuse * surfaceColor + specular * phongMaterial.specularColor) * color;
25
+ return (
26
+ lambertian * phongMaterial.diffuse * surfaceColor +
27
+ specular * floatColors_normalize(phongMaterial.specularColor)
28
+ ) * color;
26
29
  }
27
30
 
28
31
  fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {