@luma.gl/shadertools 9.1.0-alpha.16 → 9.1.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +277 -344
- package/dist/dist.min.js +215 -314
- package/dist/index.cjs +276 -346
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/lib/shader-module/shader-module.d.ts +24 -14
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module.js +11 -15
- package/dist/lib/shader-module/shader-pass.d.ts +4 -2
- package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
- package/dist/lib/utils/uniform-types.d.ts +11 -0
- package/dist/lib/utils/uniform-types.d.ts.map +1 -0
- package/dist/lib/utils/uniform-types.js +1 -0
- package/dist/modules/engine/picking/picking.d.ts +7 -7
- package/dist/modules/engine/picking/picking.d.ts.map +1 -1
- package/dist/modules/engine/picking/picking.js +2 -2
- package/dist/modules/engine/project/project.d.ts +9 -8
- package/dist/modules/engine/project/project.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +3 -57
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.js +9 -6
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts +1 -1
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +35 -12
- package/dist/modules/lighting/lights/lighting.d.ts +55 -29
- package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting.js +46 -35
- package/dist/modules/lighting/no-material/dirlight.d.ts +3 -3
- package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
- package/dist/modules/lighting/no-material/dirlight.js +1 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js +56 -60
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts +56 -98
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material.js +14 -22
- package/dist/modules/lighting/pbr-material/pbr-projection.d.ts +10 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.js +24 -0
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +8 -16
- package/dist/modules/lighting/phong-material/phong-material.d.ts +5 -59
- package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-material.js +6 -4
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +1 -40
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +8 -87
- package/dist/modules-webgl1/project/project.d.ts +6 -4
- package/dist/modules-webgl1/project/project.d.ts.map +1 -1
- package/dist/passes/postprocessing/fxaa/fxaa.d.ts +1 -1
- package/dist/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
- package/dist/passes/postprocessing/fxaa/fxaa.js +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts +0 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +0 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts +0 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/huesaturation.js +0 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts +3 -0
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-adjust-filters/vibrance.js +3 -0
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts +2 -2
- package/dist/passes/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts +1 -1
- package/dist/passes/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts +1 -1
- package/dist/passes/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts +15 -11
- package/dist/passes/postprocessing/image-fun-filters/edgework.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/edgework.js +24 -12
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +1 -1
- package/dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts +2 -2
- package/dist/passes/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts +1 -1
- package/dist/passes/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +9 -3
- package/src/lib/shader-module/shader-module.ts +31 -20
- package/src/lib/shader-module/shader-pass.ts +7 -4
- package/src/lib/utils/uniform-types.ts +66 -0
- package/src/modules/engine/picking/picking.ts +9 -9
- package/src/modules/engine/project/project.ts +10 -9
- package/src/modules/lighting/gouraud-material/gouraud-material.ts +14 -12
- package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +35 -12
- package/src/modules/lighting/lights/lighting.ts +83 -54
- package/src/modules/lighting/no-material/dirlight.ts +3 -3
- package/src/modules/lighting/pbr-material/pbr-fragment-glsl.ts +56 -60
- package/src/modules/lighting/pbr-material/pbr-material.ts +40 -74
- package/src/modules/lighting/pbr-material/pbr-projection.ts +39 -0
- package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +8 -16
- package/src/modules/lighting/phong-material/phong-material.ts +12 -12
- package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +8 -88
- package/src/modules-webgl1/project/project.ts +8 -7
- package/src/passes/postprocessing/fxaa/fxaa.ts +2 -2
- package/src/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +0 -1
- package/src/passes/postprocessing/image-adjust-filters/huesaturation.ts +0 -1
- package/src/passes/postprocessing/image-adjust-filters/vibrance.ts +3 -0
- package/src/passes/postprocessing/image-blur-filters/tiltshift.ts +2 -2
- package/src/passes/postprocessing/image-blur-filters/triangleblur.ts +1 -1
- package/src/passes/postprocessing/image-blur-filters/zoomblur.ts +1 -1
- package/src/passes/postprocessing/image-fun-filters/colorhalftone.ts +1 -1
- package/src/passes/postprocessing/image-fun-filters/dotscreen.ts +1 -1
- package/src/passes/postprocessing/image-fun-filters/edgework.ts +26 -15
- package/src/passes/postprocessing/image-fun-filters/hexagonalpixelate.ts +1 -1
- package/src/passes/postprocessing/image-fun-filters/magnify.ts +2 -2
- package/src/passes/postprocessing/image-warp-filters/bulgepinch.ts +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts +0 -42
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +0 -1
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +0 -134
- package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +0 -137
package/dist/index.d.ts
CHANGED
|
@@ -33,10 +33,12 @@ export { picking } from "./modules/engine/picking/picking.js";
|
|
|
33
33
|
export type { LightingProps, LightingUniforms } from "./modules/lighting/lights/lighting.js";
|
|
34
34
|
export { lighting } from "./modules/lighting/lights/lighting.js";
|
|
35
35
|
export { dirlight } from "./modules/lighting/no-material/dirlight.js";
|
|
36
|
-
export type {
|
|
36
|
+
export type { GouraudMaterialProps } from "./modules/lighting/gouraud-material/gouraud-material.js";
|
|
37
37
|
export { gouraudMaterial } from "./modules/lighting/gouraud-material/gouraud-material.js";
|
|
38
|
-
export type {
|
|
38
|
+
export type { PhongMaterialProps } from "./modules/lighting/phong-material/phong-material.js";
|
|
39
39
|
export { phongMaterial } from "./modules/lighting/phong-material/phong-material.js";
|
|
40
|
+
export type { PBRMaterialBindings, PBRMaterialProps, PBRMaterialUniforms } from "./modules/lighting/pbr-material/pbr-material.js";
|
|
41
|
+
export type { PBRProjectionProps } from "./modules/lighting/pbr-material/pbr-projection.js";
|
|
40
42
|
export { pbrMaterial } from "./modules/lighting/pbr-material/pbr-material.js";
|
|
41
43
|
export type { BrightnessContrastProps, BrightnessContrastUniforms } from "./passes/postprocessing/image-adjust-filters/brightnesscontrast.js";
|
|
42
44
|
export { brightnessContrast } from "./passes/postprocessing/image-adjust-filters/brightnesscontrast.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,YAAY,EAAC,YAAY,EAAC,+CAA4C;AAItE,YAAY,EAAC,YAAY,EAAC,6CAA0C;AACpE,YAAY,EAAC,UAAU,EAAC,2CAAwC;AAEhE,OAAO,EAAC,sBAAsB,EAAE,uBAAuB,EAAC,6CAA0C;AAClG,OAAO,EAAC,uBAAuB,EAAC,6CAA0C;AAC1E,OAAO,EAAC,2BAA2B,EAAC,0DAAuD;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E,OAAO,EAAC,MAAM,IAAI,OAAO,EAAC,mDAAgD;AAC1E,OAAO,EAAC,QAAQ,IAAI,SAAS,EAAC,uDAAoD;AAClF,OAAO,EACL,eAAe,EACf,aAAa,EACd,mEAAgE;AACjE,OAAO,EAAC,GAAG,EAAC,6CAA0C"}
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,6 @@ export { lighting } from "./modules/lighting/lights/lighting.js";
|
|
|
33
33
|
export { dirlight } from "./modules/lighting/no-material/dirlight.js";
|
|
34
34
|
export { gouraudMaterial } from "./modules/lighting/gouraud-material/gouraud-material.js";
|
|
35
35
|
export { phongMaterial } from "./modules/lighting/phong-material/phong-material.js";
|
|
36
|
-
// export type {PBRMaterialSettings, PBRMaterialUniforms} from './modules/lighting/pbr-material/pbr';
|
|
37
36
|
export { pbrMaterial } from "./modules/lighting/pbr-material/pbr-material.js";
|
|
38
37
|
export { brightnessContrast } from "./passes/postprocessing/image-adjust-filters/brightnesscontrast.js";
|
|
39
38
|
export { denoise } from "./passes/postprocessing/image-adjust-filters/denoise.js";
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Sampler, Texture } from '@luma.gl/core';
|
|
3
|
-
import type { UniformFormat } from "../../types.js";
|
|
1
|
+
import { UniformFormat } from "../../types.js";
|
|
4
2
|
import { PropType, PropValidator } from "../filters/prop-types.js";
|
|
3
|
+
import type { UniformTypes, UniformValue } from "../utils/uniform-types.js";
|
|
5
4
|
import { ShaderInjection } from "../shader-assembly/shader-injections.js";
|
|
6
|
-
|
|
7
|
-
export type UniformValue = number | boolean | Readonly<NumericArray>;
|
|
5
|
+
type Binding = unknown;
|
|
8
6
|
export type UniformInfo = {
|
|
9
7
|
format?: UniformFormat;
|
|
10
8
|
} & PropType;
|
|
9
|
+
type BindingKeys<T> = {
|
|
10
|
+
[K in keyof T]: T[K] extends UniformValue ? never : K;
|
|
11
|
+
}[keyof T];
|
|
12
|
+
type UniformKeys<T> = {
|
|
13
|
+
[K in keyof T]: T[K] extends UniformValue ? K : never;
|
|
14
|
+
}[keyof T];
|
|
15
|
+
export type PickBindings<T> = {
|
|
16
|
+
[K in BindingKeys<Required<T>>]: T[K];
|
|
17
|
+
};
|
|
18
|
+
export type PickUniforms<T> = {
|
|
19
|
+
[K in UniformKeys<Required<T>>]: T[K];
|
|
20
|
+
};
|
|
11
21
|
/**
|
|
12
22
|
* A shader module definition object
|
|
13
23
|
*
|
|
14
24
|
* @note Needs to be initialized with `initializeShaderModules`
|
|
25
|
+
* @note `UniformsT` & `BindingsT` are deduced from `PropsT` by default. If
|
|
26
|
+
* a custom type for `UniformsT` is used, `BindingsT` should be also be provided.
|
|
15
27
|
*/
|
|
16
|
-
export type ShaderModule<PropsT extends Record<string,
|
|
28
|
+
export type ShaderModule<PropsT extends Record<string, any> = Record<string, any>, UniformsT extends Record<string, UniformValue> = PickUniforms<PropsT>, BindingsT extends Record<string, Binding> = PickBindings<PropsT>> = {
|
|
17
29
|
/** Used for type inference not for values */
|
|
18
30
|
props?: PropsT;
|
|
19
31
|
/** Used for type inference, not currently used for values */
|
|
20
32
|
uniforms?: UniformsT;
|
|
33
|
+
/** Used for type inference, not currently used for values */
|
|
34
|
+
bindings?: BindingsT;
|
|
21
35
|
name: string;
|
|
22
36
|
/** WGSL code */
|
|
23
37
|
source?: string;
|
|
@@ -26,18 +40,13 @@ export type ShaderModule<PropsT extends Record<string, unknown> = Record<string,
|
|
|
26
40
|
/** GLSL vertex shader code */
|
|
27
41
|
vs?: string;
|
|
28
42
|
/** Uniform shader types @note: Both order and types MUST match uniform block declarations in shader */
|
|
29
|
-
uniformTypes?:
|
|
43
|
+
uniformTypes?: Required<UniformTypes<UniformsT>>;
|
|
30
44
|
/** Uniform JS prop types */
|
|
31
45
|
propTypes?: Record<keyof UniformsT, UniformInfo>;
|
|
32
46
|
/** Default uniform values */
|
|
33
47
|
defaultUniforms?: Required<UniformsT>;
|
|
34
48
|
/** Function that maps props to uniforms & bindings */
|
|
35
|
-
getUniforms?: (props
|
|
36
|
-
/** uniform buffers, textures, samplers, storage, ... */
|
|
37
|
-
bindings?: Record<keyof BindingsT, {
|
|
38
|
-
location: number;
|
|
39
|
-
type: 'texture' | 'sampler' | 'uniforms';
|
|
40
|
-
}>;
|
|
49
|
+
getUniforms?: (props: Partial<PropsT>, prevUniforms?: UniformsT) => Partial<UniformsT & BindingsT>;
|
|
41
50
|
defines?: Record<string, string | number>;
|
|
42
51
|
/** Injections */
|
|
43
52
|
inject?: Record<string, string | {
|
|
@@ -68,6 +77,7 @@ export type ShaderModuleDeprecation = {
|
|
|
68
77
|
export declare function initializeShaderModules(modules: ShaderModule[]): void;
|
|
69
78
|
export declare function initializeShaderModule(module: ShaderModule): void;
|
|
70
79
|
/** Convert module props to uniforms */
|
|
71
|
-
export declare function getShaderModuleUniforms<ShaderModuleT extends ShaderModule<Record<string, unknown>, Record<string, UniformValue>>>(module: ShaderModuleT, props?: ShaderModuleT['props'], oldUniforms?: ShaderModuleT['uniforms']): Record<string,
|
|
80
|
+
export declare function getShaderModuleUniforms<ShaderModuleT extends ShaderModule<Record<string, unknown>, Record<string, UniformValue>>>(module: ShaderModuleT, props?: ShaderModuleT['props'], oldUniforms?: ShaderModuleT['uniforms']): Record<string, Binding | UniformValue>;
|
|
72
81
|
export declare function checkShaderModuleDeprecations(shaderModule: ShaderModule, shaderSource: string, log: any): void;
|
|
82
|
+
export {};
|
|
73
83
|
//# sourceMappingURL=shader-module.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-module.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-module.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAC,uBAAoB;AAC1C,OAAO,EACL,QAAQ,EACR,aAAa,EAGd,iCAA8B;AAC/B,OAAO,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AAC,MAAM,EAAE,eAAe,CAAC,CAAC;YACxC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;SAC3C,CAAC;KACH,CAAC;CACH,CAAC;AAEF,8DAA8D;AAC9D,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAIF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAErE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CA2CjE;AAED,uCAAuC;AACvC,wBAAgB,uBAAuB,CACrC,aAAa,SAAS,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,EAEzF,MAAM,EAAE,aAAa,EACrB,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,EAC9B,WAAW,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,GACtC,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAAC,CAYxC;AAwBD,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,GAAG,GACP,IAAI,CAUN"}
|
|
@@ -23,24 +23,20 @@ export function initializeShaderModule(module) {
|
|
|
23
23
|
instance.propValidators = makePropValidators(propTypes);
|
|
24
24
|
}
|
|
25
25
|
module.instance = instance;
|
|
26
|
-
|
|
26
|
+
// TODO(ib) - we need to apply the original prop types to the default uniforms
|
|
27
|
+
let defaultProps = {};
|
|
27
28
|
if (propTypes) {
|
|
28
|
-
|
|
29
|
-
(obj: ShaderModule['props'], [key, propType]) => {
|
|
30
|
-
// @ts-expect-error
|
|
31
|
-
const value = propType?.value;
|
|
32
|
-
if (value) {
|
|
29
|
+
defaultProps = Object.entries(propTypes).reduce((obj, [key, propType]) => {
|
|
33
30
|
// @ts-expect-error
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
module.defaultUniforms = {...module.defaultUniforms, ...defaultUniforms} as any;
|
|
31
|
+
const value = propType?.value;
|
|
32
|
+
if (value) {
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
obj[key] = value;
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}, {});
|
|
42
38
|
}
|
|
43
|
-
|
|
39
|
+
module.defaultUniforms = { ...module.defaultUniforms, ...defaultProps };
|
|
44
40
|
}
|
|
45
41
|
/** Convert module props to uniforms */
|
|
46
42
|
export function getShaderModuleUniforms(module, props, oldUniforms) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Binding } from '@luma.gl/core';
|
|
2
|
+
import type { PickBindings, PickUniforms, ShaderModule } from "./shader-module.js";
|
|
3
|
+
import type { UniformValue } from "../utils/uniform-types.js";
|
|
2
4
|
/**
|
|
3
5
|
* A ShaderPass is a ShaderModule that can be run "standalone" (e.g. post processing effects)
|
|
4
6
|
* It adds additional information on how to run the module.
|
|
5
7
|
* A ShaderPass can require one or more sub passes.
|
|
6
8
|
*/
|
|
7
|
-
export type ShaderPass<PropsT extends Record<string,
|
|
9
|
+
export type ShaderPass<PropsT extends Record<string, any> = Record<string, any>, UniformsT extends Record<string, UniformValue> = PickUniforms<PropsT>, BindingsT extends Record<string, Binding> = PickBindings<PropsT>> = ShaderModule<PropsT, UniformsT, BindingsT> & {
|
|
8
10
|
/** A shader pass can run multiple sub passes */
|
|
9
11
|
passes?: ShaderSubPass<UniformsT>[];
|
|
10
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-pass.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-pass.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,2BAAwB;
|
|
1
|
+
{"version":3,"file":"shader-pass.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-pass.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAC,2BAAwB;AAC9E,OAAO,KAAK,EAAC,YAAY,EAAC,kCAA+B;AAEzD;;;;GAIG;AACH,MAAM,MAAM,UAAU,CACpB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxD,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,EACrE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,IAC9D,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG;IAC/C,gDAAgD;IAChD,MAAM,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;CAGrC,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,aAAa,CACvB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,IAC3E;IACF;;;;OAIG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Matrix3, Matrix4, Vector2, Vector3, Vector4, NumberArray2, NumberArray3, NumberArray4, NumberArray6, NumberArray8, NumberArray9, NumberArray12, NumberArray16 } from '@math.gl/core';
|
|
2
|
+
export type UniformValue = Readonly<number | boolean | NumberArray2 | NumberArray3 | NumberArray4 | NumberArray6 | NumberArray8 | NumberArray9 | NumberArray12 | NumberArray16 | Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4>;
|
|
3
|
+
type UniformType<ValueT extends UniformValue> = ValueT extends number | boolean ? 'f32' | 'i32' | 'u32' : ValueT extends Readonly<NumberArray2 | Vector2> ? 'vec2<f32>' | 'vec2<i32>' | 'vec2<u32>' : ValueT extends Readonly<NumberArray3 | Vector3> ? 'vec3<f32>' | 'vec3<i32>' | 'vec3<u32>' : ValueT extends Readonly<NumberArray4 | Vector4> ? 'vec4<f32>' | 'vec4<i32>' | 'vec4<u32>' | 'mat2x2<f32>' : ValueT extends Readonly<NumberArray6> ? 'mat2x3<f32>' | 'mat3x2<f32>' : ValueT extends Readonly<NumberArray8> ? 'mat2x4<f32>' | 'mat4x2<f32>' : ValueT extends Readonly<NumberArray9 | Matrix3> ? 'mat3x3<f32>' : ValueT extends Readonly<NumberArray12> ? 'mat3x4<f32>' | 'mat4x3<f32>' : ValueT extends Readonly<NumberArray16 | Matrix4> ? 'mat4x4<f32>' : never;
|
|
4
|
+
type UniformProps = {
|
|
5
|
+
[name: string]: UniformValue;
|
|
6
|
+
};
|
|
7
|
+
export type UniformTypes<PropsT extends UniformProps> = {
|
|
8
|
+
[name in keyof PropsT]: UniformType<PropsT[name]>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=uniform-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniform-types.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/uniform-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,YAAY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;KACrD,IAAI,IAAI,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { NumberArray3, NumberArray4 } from '@math.gl/core';
|
|
2
2
|
/**
|
|
3
3
|
* Props for the picking module, which depending on mode renders picking colors or highlighted item.
|
|
4
4
|
* When active, renders picking colors, assumed to be rendered to off-screen "picking" buffer.
|
|
@@ -10,9 +10,9 @@ export type PickingProps = {
|
|
|
10
10
|
/** Set to true when picking an attribute value instead of object index */
|
|
11
11
|
isAttribute?: boolean;
|
|
12
12
|
/** Set to a picking color to visually highlight that item, or `null` to explicitly clear **/
|
|
13
|
-
highlightedObjectColor?:
|
|
13
|
+
highlightedObjectColor?: NumberArray3 | null;
|
|
14
14
|
/** Color of visual highlight of "selected" item */
|
|
15
|
-
highlightColor?:
|
|
15
|
+
highlightColor?: NumberArray3 | NumberArray4;
|
|
16
16
|
/** Color range 0-1 or 0-255 */
|
|
17
17
|
useFloatColors?: boolean;
|
|
18
18
|
};
|
|
@@ -34,9 +34,9 @@ export type PickingUniforms = {
|
|
|
34
34
|
/** Do we have a highlighted item? */
|
|
35
35
|
isHighlightActive?: boolean;
|
|
36
36
|
/** Set to a picking color to visually highlight that item */
|
|
37
|
-
highlightedObjectColor?:
|
|
37
|
+
highlightedObjectColor?: NumberArray3;
|
|
38
38
|
/** Color of visual highlight of "selected" item */
|
|
39
|
-
highlightColor?:
|
|
39
|
+
highlightColor?: NumberArray4;
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
42
42
|
* Provides support for color-coding-based picking and highlighting.
|
|
@@ -62,8 +62,8 @@ export declare const picking: {
|
|
|
62
62
|
readonly isAttribute: false;
|
|
63
63
|
readonly isHighlightActive: false;
|
|
64
64
|
readonly useFloatColors: true;
|
|
65
|
-
readonly highlightedObjectColor:
|
|
66
|
-
readonly highlightColor:
|
|
65
|
+
readonly highlightedObjectColor: [0, 0, 0];
|
|
66
|
+
readonly highlightColor: NumberArray4;
|
|
67
67
|
};
|
|
68
68
|
readonly vs: "uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useFloatColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nout vec4 picking_vRGBcolor_Avalid;\n\n// Normalize unsigned byte color to 0-1 range\nvec3 picking_normalizeColor(vec3 color) {\n return picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\n\n// Normalize unsigned byte color to 0-1 range\nvec4 picking_normalizeColor(vec4 color) {\n return picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\n\nbool picking_isColorZero(vec3 color) {\n return dot(color, vec3(1.0)) < 0.00001;\n}\n\nbool picking_isColorValid(vec3 color) {\n return dot(color, vec3(1.0)) > 0.00001;\n}\n\n// Check if this vertex is highlighted \nbool isVertexHighlighted(vec3 vertexColor) {\n vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\n return\n bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\n\n// Set the current picking color\nvoid picking_setPickingColor(vec3 pickingColor) {\n pickingColor = picking_normalizeColor(pickingColor);\n\n if (bool(picking.isActive)) {\n // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable\n picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\n\n if (!bool(picking.isAttribute)) {\n // Stores the picking color so that the fragment shader can render it during picking\n picking_vRGBcolor_Avalid.rgb = pickingColor;\n }\n } else {\n // Do the comparison with selected item color in vertex shader as it should mean fewer compares\n picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n }\n}\n\nvoid picking_setPickingAttribute(float value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.r = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec2 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rg = value;\n }\n}\n\nvoid picking_setPickingAttribute(vec3 value) {\n if (bool(picking.isAttribute)) {\n picking_vRGBcolor_Avalid.rgb = value;\n }\n}\n";
|
|
69
69
|
readonly fs: "uniform pickingUniforms {\n float isActive;\n float isAttribute;\n float isHighlightActive;\n float useFloatColors;\n vec3 highlightedObjectColor;\n vec4 highlightColor;\n} picking;\n\nin vec4 picking_vRGBcolor_Avalid;\n\n/*\n * Returns highlight color if this item is selected.\n */\nvec4 picking_filterHighlightColor(vec4 color) {\n // If we are still picking, we don't highlight\n if (picking.isActive > 0.5) {\n return color;\n }\n\n bool selected = bool(picking_vRGBcolor_Avalid.a);\n\n if (selected) {\n // Blend in highlight color based on its alpha value\n float highLightAlpha = picking.highlightColor.a;\n float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\n float highLightRatio = highLightAlpha / blendedAlpha;\n\n vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\n return vec4(blendedRGB, blendedAlpha);\n } else {\n return color;\n }\n}\n\n/*\n * Returns picking color if picking enabled else unmodified argument.\n */\nvec4 picking_filterPickingColor(vec4 color) {\n if (bool(picking.isActive)) {\n if (picking_vRGBcolor_Avalid.a == 0.0) {\n discard;\n }\n return picking_vRGBcolor_Avalid;\n }\n return color;\n}\n\n/*\n * Returns picking color if picking is enabled if not\n * highlight color if this item is selected, otherwise unmodified argument.\n */\nvec4 picking_filterColor(vec4 color) {\n vec4 highlightColor = picking_filterHighlightColor(color);\n return picking_filterPickingColor(highlightColor);\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picking.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/picking/picking.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"picking.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/picking/picking.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAK9D;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,6FAA6F;IAC7F,sBAAsB,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7C,mDAAmD;IACnD,cAAc,CAAC,EAAE,YAAY,GAAG,YAAY,CAAC;IAC7C,+BAA+B;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+BAA+B;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qCAAqC;IACrC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,6DAA6D;IAC7D,sBAAsB,CAAC,EAAE,YAAY,CAAC;IACtC,mDAAmD;IACnD,cAAc,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAC;AAuIF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO;oBACL,YAAY;uBACT,eAAe;;;;;;;;;;;;;;;;;;;;;CAwB+B,CAAC;AAEjE,iBAAS,WAAW,CAAC,IAAI,GAAE,YAAiB,EAAE,YAAY,CAAC,EAAE,eAAe,GAAG,eAAe,CA+B7F"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// cyan color
|
|
5
|
-
const DEFAULT_HIGHLIGHT_COLOR =
|
|
5
|
+
const DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
6
6
|
const vs = /* glsl */ `\
|
|
7
7
|
uniform pickingUniforms {
|
|
8
8
|
float isActive;
|
|
@@ -158,7 +158,7 @@ export const picking = {
|
|
|
158
158
|
isAttribute: false,
|
|
159
159
|
isHighlightActive: false,
|
|
160
160
|
useFloatColors: true,
|
|
161
|
-
highlightedObjectColor:
|
|
161
|
+
highlightedObjectColor: [0, 0, 0],
|
|
162
162
|
highlightColor: DEFAULT_HIGHLIGHT_COLOR
|
|
163
163
|
},
|
|
164
164
|
vs,
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Matrix4, Vector3 } from '@math.gl/core';
|
|
2
|
+
import type { NumberArray3, NumberArray16 } from '@math.gl/core';
|
|
2
3
|
/**
|
|
3
4
|
* @note Projection uniforms are normally constant across draw calls,
|
|
4
5
|
* at least for each view.
|
|
5
6
|
*/
|
|
6
7
|
export type ProjectionProps = {
|
|
7
|
-
viewMatrix?: Readonly<Matrix4 |
|
|
8
|
-
projectionMatrix?: Readonly<Matrix4 |
|
|
9
|
-
cameraPositionWorld?: Readonly<Vector3 |
|
|
8
|
+
viewMatrix?: Readonly<Matrix4 | NumberArray16>;
|
|
9
|
+
projectionMatrix?: Readonly<Matrix4 | NumberArray16>;
|
|
10
|
+
cameraPositionWorld?: Readonly<Vector3 | NumberArray3>;
|
|
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 ProjectionUniforms = {
|
|
16
|
-
viewMatrix?: Readonly<Matrix4 |
|
|
17
|
-
projectionMatrix?: Readonly<Matrix4 |
|
|
18
|
-
viewProjectionMatrix?: Readonly<Matrix4 |
|
|
19
|
-
cameraPositionWorld?: Readonly<Vector3 |
|
|
17
|
+
viewMatrix?: Readonly<Matrix4 | NumberArray16>;
|
|
18
|
+
projectionMatrix?: Readonly<Matrix4 | NumberArray16>;
|
|
19
|
+
viewProjectionMatrix?: Readonly<Matrix4 | NumberArray16>;
|
|
20
|
+
cameraPositionWorld?: Readonly<Vector3 | NumberArray3>;
|
|
20
21
|
};
|
|
21
22
|
declare function getUniforms(opts?: ProjectionProps, prevUniforms?: ProjectionUniforms): ProjectionUniforms;
|
|
22
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/project/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../../src/modules/engine/project/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAI/D;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,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;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC;IAC/C,gBAAgB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC;IACrD,oBAAoB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC;IACzD,mBAAmB,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC;CACxD,CAAC;AASF,iBAAS,WAAW,CAClB,IAAI,GAAE,eAAwC,EAC9C,YAAY,GAAE,kBAAuB,GACpC,kBAAkB,CAuBpB;AAmFD;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;CAY+C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
1
|
+
import { ShaderModule } from "../../../lib/shader-module/shader-module.js";
|
|
2
|
+
export type GouraudMaterialProps = {
|
|
3
3
|
ambient?: number;
|
|
4
4
|
diffuse?: number;
|
|
5
5
|
/** Specularity exponent */
|
|
@@ -7,59 +7,5 @@ export type GouraudMaterialUniforms = {
|
|
|
7
7
|
specularColor?: [number, number, number];
|
|
8
8
|
};
|
|
9
9
|
/** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */
|
|
10
|
-
export declare const gouraudMaterial:
|
|
11
|
-
readonly props: GouraudMaterialProps;
|
|
12
|
-
readonly uniforms: GouraudMaterialUniforms;
|
|
13
|
-
readonly name: "gouraud-lighting";
|
|
14
|
-
readonly vs: "uniform materialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n";
|
|
15
|
-
readonly fs: "uniform materialUniforms {\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 (lighting.enabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n if (lighting.lightType == 0) {\n PointLight pointLight = lighting_getPointLight(0);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n } else if (lighting.lightType == 1) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n /*\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.pointLightCount) {\n break;\n }\n PointLight pointLight = lighting.pointLight[i];\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n }\n\n for (int i = 0; i < MAX_LIGHTS; i++) {\n if (i >= lighting.directionalLightCount) {\n break;\n }\n DirectionalLight directionalLight = lighting.directionalLight[i];\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n */\n }\n return lightColor;\n}\n\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = vec3(0, 0, 0);\n vec3 surfaceColor = vec3(0, 0, 0);\n\n if (lighting.enabled) {\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n\n switch (lighting.lightType) {\n case 0:\n PointLight pointLight = lighting_getPointLight(0);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n break;\n\n case 1:\n DirectionalLight directionalLight = lighting_getDirectionalLight(0);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n break;\n }\n }\n return lightColor;\n}\n";
|
|
16
|
-
readonly defines: {
|
|
17
|
-
readonly LIGHTING_VERTEX: 1;
|
|
18
|
-
};
|
|
19
|
-
readonly dependencies: [{
|
|
20
|
-
readonly props: import("../lights/lighting").LightingProps;
|
|
21
|
-
readonly uniforms: import("../lights/lighting").LightingUniforms;
|
|
22
|
-
readonly name: "lighting";
|
|
23
|
-
readonly defines: {
|
|
24
|
-
readonly MAX_LIGHTS: 5;
|
|
25
|
-
};
|
|
26
|
-
readonly uniformTypes: {
|
|
27
|
-
readonly enabled: "i32";
|
|
28
|
-
readonly ambientLightColor: "vec3<f32>";
|
|
29
|
-
readonly numberOfLights: "i32";
|
|
30
|
-
readonly lightType: "i32";
|
|
31
|
-
readonly lightColor: "vec3<f32>";
|
|
32
|
-
readonly lightPosition: "vec3<f32>";
|
|
33
|
-
readonly lightDirection: "vec3<f32>";
|
|
34
|
-
readonly lightAttenuation: "vec3<f32>";
|
|
35
|
-
};
|
|
36
|
-
readonly defaultUniforms: {
|
|
37
|
-
readonly enabled: 1;
|
|
38
|
-
readonly ambientLightColor: readonly [0.1, 0.1, 0.1];
|
|
39
|
-
readonly numberOfLights: 0;
|
|
40
|
-
readonly lightType: import("../lights/lighting").LIGHT_TYPE.POINT;
|
|
41
|
-
readonly lightColor: readonly [1, 1, 1];
|
|
42
|
-
readonly lightPosition: readonly [1, 1, 2];
|
|
43
|
-
readonly lightDirection: readonly [1, 1, 1];
|
|
44
|
-
readonly lightAttenuation: readonly [1, 1, 1];
|
|
45
|
-
};
|
|
46
|
-
readonly source: "// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n color: vec3<f32>,\n};\n\nstruct PointLight {\n color: vec3<f32>,\n position: vec3<f32>,\n attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n color: vec3<f32>,\n direction: vec3<f32>,\n};\n\nstruct lightingUniforms {\n enabled: i32,\n poightCount: i32,\n directionalLightCount: i32,\n\n ambientColor: vec3<f32>,\n\n // TODO - support multiple lights by uncommenting arrays below\n lightType: i32,\n lightColor: vec3<f32>,\n lightDirection: vec3<f32>,\n lightPosition: vec3<f32>,\n lightAttenuation: vec3<f32>,\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n};\n\n// Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)\n@binding(1) @group(0) var<uniform> lighting : lightingUniforms;\n\nfn lighting_getPointLight(index: i32) -> PointLight {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nfn lighting_getDirectionalLight(index: i32) -> DirectionalLight {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n";
|
|
47
|
-
readonly vs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int pointLightCount;\n int directionalLightCount;\n\n vec3 ambientColor;\n\n int lightType;\n vec3 lightColor;\n vec3 lightDirection;\n vec3 lightPosition;\n vec3 lightAttenuation;\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
|
|
48
|
-
readonly fs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int pointLightCount;\n int directionalLightCount;\n\n vec3 ambientColor;\n\n int lightType;\n vec3 lightColor;\n vec3 lightDirection;\n vec3 lightPosition;\n vec3 lightAttenuation;\n\n // AmbientLight ambientLight;\n // PointLight pointLight[MAX_LIGHTS];\n // DirectionalLight directionalLight[MAX_LIGHTS];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n return DirectionalLight(lighting.lightColor, lighting.lightDirection);\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
|
|
49
|
-
readonly getUniforms: (props?: import("../lights/lighting").LightingProps, prevUniforms?: Partial<import("../lights/lighting").LightingUniforms>) => import("../lights/lighting").LightingUniforms;
|
|
50
|
-
}];
|
|
51
|
-
readonly uniformTypes: {
|
|
52
|
-
readonly ambient: "f32";
|
|
53
|
-
readonly diffuse: "f32";
|
|
54
|
-
readonly shininess: "f32";
|
|
55
|
-
readonly specularColor: "vec3<f32>";
|
|
56
|
-
};
|
|
57
|
-
readonly defaultUniforms: {
|
|
58
|
-
readonly ambient: 0.35;
|
|
59
|
-
readonly diffuse: 0.6;
|
|
60
|
-
readonly shininess: 32;
|
|
61
|
-
readonly specularColor: [0.15, 0.15, 0.15];
|
|
62
|
-
};
|
|
63
|
-
readonly getUniforms: (props: GouraudMaterialProps) => GouraudMaterialUniforms;
|
|
64
|
-
};
|
|
10
|
+
export declare const gouraudMaterial: ShaderModule<GouraudMaterialProps>;
|
|
65
11
|
//# sourceMappingURL=gouraud-material.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gouraud-material.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/gouraud-material/gouraud-material.ts"],"names":[],"mappings":"
|
|
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;AAItE,MAAM,MAAM,oBAAoB,GAAG;IACjC,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;AAEF,yIAAyI;AACzI,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,oBAAoB,CA+B9D,CAAC"}
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { lighting } from "../lights/lighting.js";
|
|
5
|
-
import {
|
|
5
|
+
import { PHONG_VS, PHONG_FS } from "../phong-material/phong-shaders-glsl.js";
|
|
6
6
|
/** In Gouraud shading, color is calculated for each triangle vertex normal, and then color is interpolated colors across the triangle */
|
|
7
7
|
export const gouraudMaterial = {
|
|
8
8
|
props: {},
|
|
9
|
-
|
|
10
|
-
name: 'gouraud-lighting',
|
|
9
|
+
name: 'gouraudMaterial',
|
|
11
10
|
// Note these are switched between phong and gouraud
|
|
12
|
-
vs:
|
|
13
|
-
fs:
|
|
11
|
+
vs: PHONG_FS.replace('phongMaterial', 'gouraudMaterial'),
|
|
12
|
+
fs: PHONG_VS.replace('phongMaterial', 'gouraudMaterial'),
|
|
14
13
|
defines: {
|
|
15
14
|
LIGHTING_VERTEX: 1
|
|
16
15
|
},
|
|
@@ -28,6 +27,10 @@ export const gouraudMaterial = {
|
|
|
28
27
|
specularColor: [0.15, 0.15, 0.15]
|
|
29
28
|
},
|
|
30
29
|
getUniforms(props) {
|
|
31
|
-
|
|
30
|
+
const uniforms = { ...props };
|
|
31
|
+
if (uniforms.specularColor) {
|
|
32
|
+
uniforms.specularColor = uniforms.specularColor.map(x => x / 255);
|
|
33
|
+
}
|
|
34
|
+
return { ...gouraudMaterial.defaultUniforms, ...uniforms };
|
|
32
35
|
}
|
|
33
36
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const lightingUniformsGLSL = "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int
|
|
1
|
+
export declare const lightingUniformsGLSL = "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform lightingUniforms {\n int enabled;\n int lightType;\n\n int directionalLightCount;\n int pointLightCount;\n\n vec3 ambientColor;\n\n vec3 lightColor0;\n vec3 lightPosition0;\n vec3 lightDirection0;\n vec3 lightAttenuation0;\n\n vec3 lightColor1;\n vec3 lightPosition1;\n vec3 lightDirection1;\n vec3 lightAttenuation1;\n\n vec3 lightColor2;\n vec3 lightPosition2;\n vec3 lightDirection2;\n vec3 lightAttenuation2;\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n switch (index) {\n case 0:\n return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);\n case 1:\n return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);\n case 2:\n default: \n return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);\n }\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n switch (index) {\n case 0:\n return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);\n case 1:\n return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);\n case 2:\n default: \n return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);\n }\n} \n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n// #endif\n";
|
|
2
2
|
//# sourceMappingURL=lighting-uniforms-glsl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lighting-uniforms-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-uniforms-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"lighting-uniforms-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-uniforms-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,g3DA2EhC,CAAC"}
|
|
@@ -22,28 +22,51 @@ struct DirectionalLight {
|
|
|
22
22
|
|
|
23
23
|
uniform lightingUniforms {
|
|
24
24
|
int enabled;
|
|
25
|
-
int
|
|
25
|
+
int lightType;
|
|
26
|
+
|
|
26
27
|
int directionalLightCount;
|
|
28
|
+
int pointLightCount;
|
|
27
29
|
|
|
28
30
|
vec3 ambientColor;
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
vec3
|
|
32
|
-
vec3
|
|
33
|
-
vec3
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
vec3 lightColor0;
|
|
33
|
+
vec3 lightPosition0;
|
|
34
|
+
vec3 lightDirection0;
|
|
35
|
+
vec3 lightAttenuation0;
|
|
36
|
+
|
|
37
|
+
vec3 lightColor1;
|
|
38
|
+
vec3 lightPosition1;
|
|
39
|
+
vec3 lightDirection1;
|
|
40
|
+
vec3 lightAttenuation1;
|
|
41
|
+
|
|
42
|
+
vec3 lightColor2;
|
|
43
|
+
vec3 lightPosition2;
|
|
44
|
+
vec3 lightDirection2;
|
|
45
|
+
vec3 lightAttenuation2;
|
|
39
46
|
} lighting;
|
|
40
47
|
|
|
41
48
|
PointLight lighting_getPointLight(int index) {
|
|
42
|
-
|
|
49
|
+
switch (index) {
|
|
50
|
+
case 0:
|
|
51
|
+
return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);
|
|
52
|
+
case 1:
|
|
53
|
+
return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
|
|
54
|
+
case 2:
|
|
55
|
+
default:
|
|
56
|
+
return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
|
|
57
|
+
}
|
|
43
58
|
}
|
|
44
59
|
|
|
45
60
|
DirectionalLight lighting_getDirectionalLight(int index) {
|
|
46
|
-
|
|
61
|
+
switch (index) {
|
|
62
|
+
case 0:
|
|
63
|
+
return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);
|
|
64
|
+
case 1:
|
|
65
|
+
return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
|
|
66
|
+
case 2:
|
|
67
|
+
default:
|
|
68
|
+
return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
|
|
69
|
+
}
|
|
47
70
|
}
|
|
48
71
|
|
|
49
72
|
float getPointLightAttenuation(PointLight pointLight, float distance) {
|