@luma.gl/shaders 10.0.0-alpha.10 → 10.0.0-alpha.12
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 +1923 -60
- package/dist/dist.min.js +1499 -148
- package/dist/glsl.cjs.map +1 -1
- package/dist/index.cjs +41 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/lighting/clustered-light-grid/clustered-light-grid.cjs +40 -0
- package/dist/modules/lighting/clustered-light-grid/clustered-light-grid.d.ts +6 -0
- package/dist/modules/lighting/clustered-light-grid/clustered-light-grid.d.ts.map +1 -0
- package/dist/modules/lighting/clustered-light-grid/clustered-light-grid.js +15 -0
- package/dist/modules/lighting/clustered-light-grid/clustered-light-grid.js.map +1 -0
- package/dist/modules/lighting/contact-shadow/contact-shadow.cjs +348 -0
- package/dist/modules/lighting/contact-shadow/contact-shadow.d.ts +188 -0
- package/dist/modules/lighting/contact-shadow/contact-shadow.d.ts.map +1 -0
- package/dist/modules/lighting/contact-shadow/contact-shadow.js +307 -0
- package/dist/modules/lighting/contact-shadow/contact-shadow.js.map +1 -0
- package/dist/modules/lighting/lightmap/lightmap-filter.cjs +93 -0
- package/dist/modules/lighting/lightmap/lightmap-filter.d.ts +35 -0
- package/dist/modules/lighting/lightmap/lightmap-filter.d.ts.map +1 -0
- package/dist/modules/lighting/lightmap/lightmap-filter.js +71 -0
- package/dist/modules/lighting/lightmap/lightmap-filter.js.map +1 -0
- package/dist/modules/lighting/lightmap/lightmap.cjs +89 -0
- package/dist/modules/lighting/lightmap/lightmap.d.ts +405 -0
- package/dist/modules/lighting/lightmap/lightmap.d.ts.map +1 -0
- package/dist/modules/lighting/lightmap/lightmap.js +67 -0
- package/dist/modules/lighting/lightmap/lightmap.js.map +1 -0
- package/dist/modules/lighting/pbr-ambient-occlusion/pbr-ambient-occlusion.cjs +87 -0
- package/dist/modules/lighting/pbr-ambient-occlusion/pbr-ambient-occlusion.d.ts +21 -0
- package/dist/modules/lighting/pbr-ambient-occlusion/pbr-ambient-occlusion.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-ambient-occlusion/pbr-ambient-occlusion.js +61 -0
- package/dist/modules/lighting/pbr-ambient-occlusion/pbr-ambient-occlusion.js.map +1 -0
- package/dist/modules/lighting/pbr-contact-shadow/pbr-contact-shadow.cjs +87 -0
- package/dist/modules/lighting/pbr-contact-shadow/pbr-contact-shadow.d.ts +21 -0
- package/dist/modules/lighting/pbr-contact-shadow/pbr-contact-shadow.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-contact-shadow/pbr-contact-shadow.js +61 -0
- package/dist/modules/lighting/pbr-contact-shadow/pbr-contact-shadow.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.cjs +33 -11
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts +2 -2
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.js +33 -11
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.cjs +33 -11
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +33 -11
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts +3 -3
- package/dist/modules/lighting/pbr-shadow/pbr-shadow.cjs +97 -0
- package/dist/modules/lighting/pbr-shadow/pbr-shadow.d.ts +15 -0
- package/dist/modules/lighting/pbr-shadow/pbr-shadow.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-shadow/pbr-shadow.js +69 -0
- package/dist/modules/lighting/pbr-shadow/pbr-shadow.js.map +1 -0
- package/dist/modules/lighting/pbr-surface/pbr-surface.cjs +114 -0
- package/dist/modules/lighting/pbr-surface/pbr-surface.d.ts +15 -0
- package/dist/modules/lighting/pbr-surface/pbr-surface.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-surface/pbr-surface.js +88 -0
- package/dist/modules/lighting/pbr-surface/pbr-surface.js.map +1 -0
- package/dist/modules/lighting/prefiltered-environment/prefiltered-environment.cjs +379 -0
- package/dist/modules/lighting/prefiltered-environment/prefiltered-environment.d.ts +41 -0
- package/dist/modules/lighting/prefiltered-environment/prefiltered-environment.d.ts.map +1 -0
- package/dist/modules/lighting/prefiltered-environment/prefiltered-environment.js +345 -0
- package/dist/modules/lighting/prefiltered-environment/prefiltered-environment.js.map +1 -0
- package/dist/modules/lighting/shadow/shadow-glsl.cjs +228 -0
- package/dist/modules/lighting/shadow/shadow-glsl.d.ts +3 -0
- package/dist/modules/lighting/shadow/shadow-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/shadow/shadow-glsl.js +204 -0
- package/dist/modules/lighting/shadow/shadow-glsl.js.map +1 -0
- package/dist/modules/lighting/shadow/shadow-types.cjs +15 -0
- package/dist/modules/lighting/shadow/shadow-types.d.ts +63 -0
- package/dist/modules/lighting/shadow/shadow-types.d.ts.map +1 -0
- package/dist/modules/lighting/shadow/shadow-types.js +5 -0
- package/dist/modules/lighting/shadow/shadow-types.js.map +1 -0
- package/dist/modules/lighting/shadow/shadow.cjs +458 -0
- package/dist/modules/lighting/shadow/shadow.d.ts +117 -0
- package/dist/modules/lighting/shadow/shadow.d.ts.map +1 -0
- package/dist/modules/lighting/shadow/shadow.js +450 -0
- package/dist/modules/lighting/shadow/shadow.js.map +1 -0
- package/dist/modules/lighting/unlit-material/unlit-material.cjs +60 -0
- package/dist/modules/lighting/unlit-material/unlit-material.d.ts +9 -0
- package/dist/modules/lighting/unlit-material/unlit-material.d.ts.map +1 -0
- package/dist/modules/lighting/unlit-material/unlit-material.js +40 -0
- package/dist/modules/lighting/unlit-material/unlit-material.js.map +1 -0
- package/dist/types/shader-type-decoder.cjs +12 -2
- package/dist/types/shader-type-decoder.d.ts +7 -7
- package/dist/types/shader-type-decoder.d.ts.map +1 -1
- package/dist/types/shader-type-decoder.js +13 -2
- package/dist/types/shader-type-decoder.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/wgsl.cjs.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +52 -0
- package/src/modules/lighting/clustered-light-grid/clustered-light-grid.ts +17 -0
- package/src/modules/lighting/contact-shadow/contact-shadow.ts +365 -0
- package/src/modules/lighting/lightmap/lightmap-filter.ts +73 -0
- package/src/modules/lighting/lightmap/lightmap.ts +76 -0
- package/src/modules/lighting/pbr-ambient-occlusion/pbr-ambient-occlusion.ts +78 -0
- package/src/modules/lighting/pbr-contact-shadow/pbr-contact-shadow.ts +78 -0
- package/src/modules/lighting/pbr-material/pbr-material-glsl.ts +33 -11
- package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +33 -11
- package/src/modules/lighting/pbr-shadow/pbr-shadow.ts +85 -0
- package/src/modules/lighting/pbr-surface/pbr-surface.ts +103 -0
- package/src/modules/lighting/prefiltered-environment/prefiltered-environment.ts +370 -0
- package/src/modules/lighting/shadow/shadow-glsl.ts +204 -0
- package/src/modules/lighting/shadow/shadow-types.ts +68 -0
- package/src/modules/lighting/shadow/shadow.ts +536 -0
- package/src/modules/lighting/unlit-material/unlit-material.ts +44 -0
- package/src/types/shader-type-decoder.ts +22 -9
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var pbr_shadow_exports = {};
|
|
19
|
+
__export(pbr_shadow_exports, {
|
|
20
|
+
pbrShadow: () => pbrShadow
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(pbr_shadow_exports);
|
|
23
|
+
var import_pbr_material = require("../pbr-material/pbr-material.cjs");
|
|
24
|
+
var import_shadow = require("../shadow/shadow.cjs");
|
|
25
|
+
const pbrShadow = {
|
|
26
|
+
name: "pbrShadow",
|
|
27
|
+
dependencies: [import_pbr_material.pbrMaterial, import_shadow.shadow],
|
|
28
|
+
bindingLayout: [{ name: "pbrShadow", group: 0 }],
|
|
29
|
+
uniformTypes: { viewMatrix: "mat4x4<f32>", enabled: "i32" },
|
|
30
|
+
defaultUniforms: {
|
|
31
|
+
viewMatrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
|
|
32
|
+
enabled: 1
|
|
33
|
+
},
|
|
34
|
+
getUniforms(properties = {}) {
|
|
35
|
+
return {
|
|
36
|
+
...properties.viewMatrix ? { viewMatrix: properties.viewMatrix } : {},
|
|
37
|
+
...properties.enabled === void 0 ? {} : { enabled: Number(properties.enabled) }
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
source: (
|
|
41
|
+
/* wgsl */
|
|
42
|
+
`
|
|
43
|
+
struct PBRShadowUniforms {
|
|
44
|
+
viewMatrix: mat4x4f,
|
|
45
|
+
enabled: i32,
|
|
46
|
+
};
|
|
47
|
+
@group(0) @binding(auto) var<uniform> pbrShadow: PBRShadowUniforms;
|
|
48
|
+
fn pbrShadow_filterColorWithDirectionalContact(vertexColor: vec4f, worldPosition: vec3f, worldNormal: vec3f, contactVisibility: f32) -> vec4f {
|
|
49
|
+
var directionalVisibility = 1.0;
|
|
50
|
+
var pointVisibility = vec4f(1.0);
|
|
51
|
+
var spotVisibility = vec4f(1.0);
|
|
52
|
+
if (pbrShadow.enabled != 0) {
|
|
53
|
+
let normal = normalize(worldNormal);
|
|
54
|
+
let viewDepth = -(pbrShadow.viewMatrix * vec4f(worldPosition, 1.0)).z;
|
|
55
|
+
directionalVisibility = shadow_getDirectionalFactor(worldPosition, normal, viewDepth);
|
|
56
|
+
for (var index = 0; index < 4; index++) {
|
|
57
|
+
pointVisibility[index] = shadow_getPointFactor(index, worldPosition, normal);
|
|
58
|
+
spotVisibility[index] = shadow_getSpotFactor(index, worldPosition, normal);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return pbr_filterColorWithShadows(vertexColor, min(directionalVisibility, contactVisibility), pointVisibility, spotVisibility);
|
|
62
|
+
}
|
|
63
|
+
fn pbrShadow_filterColor(vertexColor: vec4f, worldPosition: vec3f, worldNormal: vec3f) -> vec4f {
|
|
64
|
+
return pbrShadow_filterColorWithDirectionalContact(vertexColor, worldPosition, worldNormal, 1.0);
|
|
65
|
+
}`
|
|
66
|
+
),
|
|
67
|
+
fs: (
|
|
68
|
+
/* glsl */
|
|
69
|
+
`
|
|
70
|
+
layout(std140) uniform pbrShadowUniforms {
|
|
71
|
+
mat4 viewMatrix;
|
|
72
|
+
int enabled;
|
|
73
|
+
} pbrShadow;
|
|
74
|
+
vec4 pbrShadow_filterColorWithDirectionalContact(vec4 vertexColor, vec3 worldPosition, vec3 worldNormal, float contactVisibility) {
|
|
75
|
+
float directionalVisibility = 1.0;
|
|
76
|
+
vec4 pointVisibility = vec4(1.0);
|
|
77
|
+
vec4 spotVisibility = vec4(1.0);
|
|
78
|
+
if (pbrShadow.enabled != 0) {
|
|
79
|
+
vec3 normal = normalize(worldNormal);
|
|
80
|
+
float viewDepth = -(pbrShadow.viewMatrix * vec4(worldPosition, 1.0)).z;
|
|
81
|
+
directionalVisibility = shadow_getDirectionalFactor(worldPosition, normal, viewDepth);
|
|
82
|
+
for (int index = 0; index < 4; index++) {
|
|
83
|
+
pointVisibility[index] = shadow_getPointFactor(index, worldPosition, normal);
|
|
84
|
+
spotVisibility[index] = shadow_getSpotFactor(index, worldPosition, normal);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return pbr_filterColorWithShadows(vertexColor, min(directionalVisibility, contactVisibility), pointVisibility, spotVisibility);
|
|
88
|
+
}
|
|
89
|
+
vec4 pbrShadow_filterColor(vec4 vertexColor, vec3 worldPosition, vec3 worldNormal) {
|
|
90
|
+
return pbrShadow_filterColorWithDirectionalContact(vertexColor, worldPosition, worldNormal, 1.0);
|
|
91
|
+
}`
|
|
92
|
+
)
|
|
93
|
+
};
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
pbrShadow
|
|
97
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NumberArray16 } from '@math.gl/core';
|
|
2
|
+
import type { ShaderModule } from "../../../lib/shader-module/shader-module.js";
|
|
3
|
+
export type PBRShadowProps = {
|
|
4
|
+
/** Receiver camera view matrix, used for directional cascade selection. */
|
|
5
|
+
viewMatrix?: Readonly<NumberArray16>;
|
|
6
|
+
/** Toggle receiving while retaining allocated maps and bindings. Defaults to true. */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type PBRShadowUniforms = {
|
|
10
|
+
viewMatrix: Readonly<NumberArray16>;
|
|
11
|
+
enabled: number;
|
|
12
|
+
};
|
|
13
|
+
/** Applies shadow visibility to matching direct-light slots in the canonical PBR shader. */
|
|
14
|
+
export declare const pbrShadow: ShaderModule<PBRShadowProps, PBRShadowUniforms>;
|
|
15
|
+
//# sourceMappingURL=pbr-shadow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-shadow.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-shadow/pbr-shadow.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAC,YAAY,EAAC,oDAAiD;AAI3E,MAAM,MAAM,cAAc,GAAG;IAC3B,2EAA2E;IAC3E,UAAU,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACrC,sFAAsF;IACtF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,4FAA4F;AAC5F,eAAO,MAAM,SAAS,EAAE,YAAY,CAAC,cAAc,EAAE,iBAAiB,CA+DrE,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
import { pbrMaterial } from "../pbr-material/pbr-material.js";
|
|
4
|
+
import { shadow } from "../shadow/shadow.js";
|
|
5
|
+
/** Applies shadow visibility to matching direct-light slots in the canonical PBR shader. */
|
|
6
|
+
export const pbrShadow = {
|
|
7
|
+
name: 'pbrShadow',
|
|
8
|
+
dependencies: [pbrMaterial, shadow],
|
|
9
|
+
bindingLayout: [{ name: 'pbrShadow', group: 0 }],
|
|
10
|
+
uniformTypes: { viewMatrix: 'mat4x4<f32>', enabled: 'i32' },
|
|
11
|
+
defaultUniforms: {
|
|
12
|
+
viewMatrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
|
|
13
|
+
enabled: 1
|
|
14
|
+
},
|
|
15
|
+
getUniforms(properties = {}) {
|
|
16
|
+
return {
|
|
17
|
+
...(properties.viewMatrix ? { viewMatrix: properties.viewMatrix } : {}),
|
|
18
|
+
...(properties.enabled === undefined ? {} : { enabled: Number(properties.enabled) })
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
source: /* wgsl */ `
|
|
22
|
+
struct PBRShadowUniforms {
|
|
23
|
+
viewMatrix: mat4x4f,
|
|
24
|
+
enabled: i32,
|
|
25
|
+
};
|
|
26
|
+
@group(0) @binding(auto) var<uniform> pbrShadow: PBRShadowUniforms;
|
|
27
|
+
fn pbrShadow_filterColorWithDirectionalContact(vertexColor: vec4f, worldPosition: vec3f, worldNormal: vec3f, contactVisibility: f32) -> vec4f {
|
|
28
|
+
var directionalVisibility = 1.0;
|
|
29
|
+
var pointVisibility = vec4f(1.0);
|
|
30
|
+
var spotVisibility = vec4f(1.0);
|
|
31
|
+
if (pbrShadow.enabled != 0) {
|
|
32
|
+
let normal = normalize(worldNormal);
|
|
33
|
+
let viewDepth = -(pbrShadow.viewMatrix * vec4f(worldPosition, 1.0)).z;
|
|
34
|
+
directionalVisibility = shadow_getDirectionalFactor(worldPosition, normal, viewDepth);
|
|
35
|
+
for (var index = 0; index < 4; index++) {
|
|
36
|
+
pointVisibility[index] = shadow_getPointFactor(index, worldPosition, normal);
|
|
37
|
+
spotVisibility[index] = shadow_getSpotFactor(index, worldPosition, normal);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return pbr_filterColorWithShadows(vertexColor, min(directionalVisibility, contactVisibility), pointVisibility, spotVisibility);
|
|
41
|
+
}
|
|
42
|
+
fn pbrShadow_filterColor(vertexColor: vec4f, worldPosition: vec3f, worldNormal: vec3f) -> vec4f {
|
|
43
|
+
return pbrShadow_filterColorWithDirectionalContact(vertexColor, worldPosition, worldNormal, 1.0);
|
|
44
|
+
}`,
|
|
45
|
+
fs: /* glsl */ `
|
|
46
|
+
layout(std140) uniform pbrShadowUniforms {
|
|
47
|
+
mat4 viewMatrix;
|
|
48
|
+
int enabled;
|
|
49
|
+
} pbrShadow;
|
|
50
|
+
vec4 pbrShadow_filterColorWithDirectionalContact(vec4 vertexColor, vec3 worldPosition, vec3 worldNormal, float contactVisibility) {
|
|
51
|
+
float directionalVisibility = 1.0;
|
|
52
|
+
vec4 pointVisibility = vec4(1.0);
|
|
53
|
+
vec4 spotVisibility = vec4(1.0);
|
|
54
|
+
if (pbrShadow.enabled != 0) {
|
|
55
|
+
vec3 normal = normalize(worldNormal);
|
|
56
|
+
float viewDepth = -(pbrShadow.viewMatrix * vec4(worldPosition, 1.0)).z;
|
|
57
|
+
directionalVisibility = shadow_getDirectionalFactor(worldPosition, normal, viewDepth);
|
|
58
|
+
for (int index = 0; index < 4; index++) {
|
|
59
|
+
pointVisibility[index] = shadow_getPointFactor(index, worldPosition, normal);
|
|
60
|
+
spotVisibility[index] = shadow_getSpotFactor(index, worldPosition, normal);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return pbr_filterColorWithShadows(vertexColor, min(directionalVisibility, contactVisibility), pointVisibility, spotVisibility);
|
|
64
|
+
}
|
|
65
|
+
vec4 pbrShadow_filterColor(vec4 vertexColor, vec3 worldPosition, vec3 worldNormal) {
|
|
66
|
+
return pbrShadow_filterColorWithDirectionalContact(vertexColor, worldPosition, worldNormal, 1.0);
|
|
67
|
+
}`
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=pbr-shadow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-shadow.js","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-shadow/pbr-shadow.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,4DAA4D;AAI5D,OAAO,EAAC,WAAW,EAAC,wCAAqC;AACzD,OAAO,EAAC,MAAM,EAAC,4BAAyB;AAcxC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,SAAS,GAAoD;IACxE,IAAI,EAAE,WAAW;IACjB,YAAY,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC;IACnC,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IAC9C,YAAY,EAAE,EAAC,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAC;IACzD,eAAe,EAAE;QACf,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5D,OAAO,EAAE,CAAC;KACX;IACD,WAAW,CAAC,UAAU,GAAG,EAAE;QACzB,OAAO;YACL,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAAC,UAAU,EAAE,UAAU,CAAC,UAAU,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,GAAG,CAAC,UAAU,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAC,CAAC;SACnF,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;EAuBnB;IAEA,EAAE,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;EAsBf;CACD,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var pbr_surface_exports = {};
|
|
19
|
+
__export(pbr_surface_exports, {
|
|
20
|
+
pbrSurface: () => pbrSurface
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(pbr_surface_exports);
|
|
23
|
+
var import_pbr_material = require("../pbr-material/pbr-material.cjs");
|
|
24
|
+
const pbrSurface = {
|
|
25
|
+
name: "pbrSurface",
|
|
26
|
+
dependencies: [import_pbr_material.pbrMaterial],
|
|
27
|
+
bindingLayout: [{ name: "pbrSurface", group: 0 }],
|
|
28
|
+
uniformTypes: { viewMatrix: "mat4x4<f32>", useMaterialNormals: "i32" },
|
|
29
|
+
defaultUniforms: {
|
|
30
|
+
viewMatrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
|
|
31
|
+
useMaterialNormals: 0
|
|
32
|
+
},
|
|
33
|
+
getUniforms(properties = {}) {
|
|
34
|
+
return {
|
|
35
|
+
...properties.viewMatrix ? { viewMatrix: properties.viewMatrix } : {},
|
|
36
|
+
...properties.useMaterialNormals === void 0 ? {} : { useMaterialNormals: Number(properties.useMaterialNormals) }
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
source: (
|
|
40
|
+
/* wgsl */
|
|
41
|
+
`
|
|
42
|
+
struct PBRSurfaceUniforms {
|
|
43
|
+
viewMatrix: mat4x4f,
|
|
44
|
+
useMaterialNormals: i32,
|
|
45
|
+
};
|
|
46
|
+
@group(0) @binding(auto) var<uniform> pbrSurface: PBRSurfaceUniforms;
|
|
47
|
+
fn pbrSurface_getColor() -> vec4f {
|
|
48
|
+
#ifdef HAS_NORMALS
|
|
49
|
+
var normal = normalize(fragmentInputs.pbr_vNormal);
|
|
50
|
+
#ifdef DOUBLE_SIDED
|
|
51
|
+
if (!pbr_frontFacing) {normal = -normal;}
|
|
52
|
+
#endif
|
|
53
|
+
#else
|
|
54
|
+
var normal = normalize(cross(dpdy(fragmentInputs.pbr_vPosition), dpdx(fragmentInputs.pbr_vPosition)));
|
|
55
|
+
#endif
|
|
56
|
+
#ifdef HAS_NORMALMAP
|
|
57
|
+
if (pbrSurface.useMaterialNormals != 0) {
|
|
58
|
+
let coordinates = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);
|
|
59
|
+
normal = getNormal(getTBN(coordinates), coordinates);
|
|
60
|
+
}
|
|
61
|
+
#else
|
|
62
|
+
#ifdef HAS_BUMPMAP
|
|
63
|
+
if (pbrSurface.useMaterialNormals != 0) {
|
|
64
|
+
let coordinates = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);
|
|
65
|
+
normal = getNormal(getTBN(coordinates), coordinates);
|
|
66
|
+
}
|
|
67
|
+
#endif
|
|
68
|
+
#endif
|
|
69
|
+
let viewNormal = normalize((pbrSurface.viewMatrix * vec4f(normal, 0.0)).xyz);
|
|
70
|
+
return vec4f(viewNormal * 0.5 + vec3f(0.5), 1.0);
|
|
71
|
+
}`
|
|
72
|
+
),
|
|
73
|
+
fs: (
|
|
74
|
+
/* glsl */
|
|
75
|
+
`
|
|
76
|
+
layout(std140) uniform pbrSurfaceUniforms {
|
|
77
|
+
mat4 viewMatrix;
|
|
78
|
+
int useMaterialNormals;
|
|
79
|
+
} pbrSurface;
|
|
80
|
+
vec4 pbrSurface_getColor() {
|
|
81
|
+
#ifdef HAS_NORMALS
|
|
82
|
+
#ifdef HAS_TANGENTS
|
|
83
|
+
vec3 normal = normalize(pbr_vTBN[2]);
|
|
84
|
+
#else
|
|
85
|
+
vec3 normal = normalize(pbr_vNormal);
|
|
86
|
+
#endif
|
|
87
|
+
#ifdef DOUBLE_SIDED
|
|
88
|
+
if (!gl_FrontFacing) normal = -normal;
|
|
89
|
+
#endif
|
|
90
|
+
#else
|
|
91
|
+
vec3 normal = normalize(cross(dFdx(pbr_vPosition), dFdy(pbr_vPosition)));
|
|
92
|
+
#endif
|
|
93
|
+
#ifdef HAS_NORMALMAP
|
|
94
|
+
if (pbrSurface.useMaterialNormals != 0) {
|
|
95
|
+
vec2 coordinates = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);
|
|
96
|
+
normal = getNormal(getTBN(coordinates), coordinates);
|
|
97
|
+
}
|
|
98
|
+
#else
|
|
99
|
+
#ifdef HAS_BUMPMAP
|
|
100
|
+
if (pbrSurface.useMaterialNormals != 0) {
|
|
101
|
+
vec2 coordinates = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);
|
|
102
|
+
normal = getNormal(getTBN(coordinates), coordinates);
|
|
103
|
+
}
|
|
104
|
+
#endif
|
|
105
|
+
#endif
|
|
106
|
+
vec3 viewNormal = normalize((pbrSurface.viewMatrix * vec4(normal, 0.0)).xyz);
|
|
107
|
+
return vec4(viewNormal * 0.5 + 0.5, 1.0);
|
|
108
|
+
}`
|
|
109
|
+
)
|
|
110
|
+
};
|
|
111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
112
|
+
0 && (module.exports = {
|
|
113
|
+
pbrSurface
|
|
114
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NumberArray16 } from '@math.gl/core';
|
|
2
|
+
import type { ShaderModule } from "../../../lib/shader-module/shader-module.js";
|
|
3
|
+
export type PBRSurfaceProps = {
|
|
4
|
+
/** Rigid world-to-view camera transform. Defaults to identity. */
|
|
5
|
+
viewMatrix?: Readonly<NumberArray16>;
|
|
6
|
+
/** Include canonical normal/bump maps instead of geometric normals. Defaults to false. */
|
|
7
|
+
useMaterialNormals?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type PBRSurfaceUniforms = {
|
|
10
|
+
viewMatrix: Readonly<NumberArray16>;
|
|
11
|
+
useMaterialNormals: number;
|
|
12
|
+
};
|
|
13
|
+
/** Encodes view-space PBR normals in RGB; alpha one marks covered surface pixels. */
|
|
14
|
+
export declare const pbrSurface: ShaderModule<PBRSurfaceProps, PBRSurfaceUniforms>;
|
|
15
|
+
//# sourceMappingURL=pbr-surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-surface.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-surface/pbr-surface.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAC,YAAY,EAAC,oDAAiD;AAG3E,MAAM,MAAM,eAAe,GAAG;IAC5B,kEAAkE;IAClE,UAAU,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACrC,0FAA0F;IAC1F,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;IACpC,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,eAAe,EAAE,kBAAkB,CAkFxE,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
import { pbrMaterial } from "../pbr-material/pbr-material.js";
|
|
4
|
+
/** Encodes view-space PBR normals in RGB; alpha one marks covered surface pixels. */
|
|
5
|
+
export const pbrSurface = {
|
|
6
|
+
name: 'pbrSurface',
|
|
7
|
+
dependencies: [pbrMaterial],
|
|
8
|
+
bindingLayout: [{ name: 'pbrSurface', group: 0 }],
|
|
9
|
+
uniformTypes: { viewMatrix: 'mat4x4<f32>', useMaterialNormals: 'i32' },
|
|
10
|
+
defaultUniforms: {
|
|
11
|
+
viewMatrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
|
|
12
|
+
useMaterialNormals: 0
|
|
13
|
+
},
|
|
14
|
+
getUniforms(properties = {}) {
|
|
15
|
+
return {
|
|
16
|
+
...(properties.viewMatrix ? { viewMatrix: properties.viewMatrix } : {}),
|
|
17
|
+
...(properties.useMaterialNormals === undefined
|
|
18
|
+
? {}
|
|
19
|
+
: { useMaterialNormals: Number(properties.useMaterialNormals) })
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
source: /* wgsl */ `
|
|
23
|
+
struct PBRSurfaceUniforms {
|
|
24
|
+
viewMatrix: mat4x4f,
|
|
25
|
+
useMaterialNormals: i32,
|
|
26
|
+
};
|
|
27
|
+
@group(0) @binding(auto) var<uniform> pbrSurface: PBRSurfaceUniforms;
|
|
28
|
+
fn pbrSurface_getColor() -> vec4f {
|
|
29
|
+
#ifdef HAS_NORMALS
|
|
30
|
+
var normal = normalize(fragmentInputs.pbr_vNormal);
|
|
31
|
+
#ifdef DOUBLE_SIDED
|
|
32
|
+
if (!pbr_frontFacing) {normal = -normal;}
|
|
33
|
+
#endif
|
|
34
|
+
#else
|
|
35
|
+
var normal = normalize(cross(dpdy(fragmentInputs.pbr_vPosition), dpdx(fragmentInputs.pbr_vPosition)));
|
|
36
|
+
#endif
|
|
37
|
+
#ifdef HAS_NORMALMAP
|
|
38
|
+
if (pbrSurface.useMaterialNormals != 0) {
|
|
39
|
+
let coordinates = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);
|
|
40
|
+
normal = getNormal(getTBN(coordinates), coordinates);
|
|
41
|
+
}
|
|
42
|
+
#else
|
|
43
|
+
#ifdef HAS_BUMPMAP
|
|
44
|
+
if (pbrSurface.useMaterialNormals != 0) {
|
|
45
|
+
let coordinates = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);
|
|
46
|
+
normal = getNormal(getTBN(coordinates), coordinates);
|
|
47
|
+
}
|
|
48
|
+
#endif
|
|
49
|
+
#endif
|
|
50
|
+
let viewNormal = normalize((pbrSurface.viewMatrix * vec4f(normal, 0.0)).xyz);
|
|
51
|
+
return vec4f(viewNormal * 0.5 + vec3f(0.5), 1.0);
|
|
52
|
+
}`,
|
|
53
|
+
fs: /* glsl */ `
|
|
54
|
+
layout(std140) uniform pbrSurfaceUniforms {
|
|
55
|
+
mat4 viewMatrix;
|
|
56
|
+
int useMaterialNormals;
|
|
57
|
+
} pbrSurface;
|
|
58
|
+
vec4 pbrSurface_getColor() {
|
|
59
|
+
#ifdef HAS_NORMALS
|
|
60
|
+
#ifdef HAS_TANGENTS
|
|
61
|
+
vec3 normal = normalize(pbr_vTBN[2]);
|
|
62
|
+
#else
|
|
63
|
+
vec3 normal = normalize(pbr_vNormal);
|
|
64
|
+
#endif
|
|
65
|
+
#ifdef DOUBLE_SIDED
|
|
66
|
+
if (!gl_FrontFacing) normal = -normal;
|
|
67
|
+
#endif
|
|
68
|
+
#else
|
|
69
|
+
vec3 normal = normalize(cross(dFdx(pbr_vPosition), dFdy(pbr_vPosition)));
|
|
70
|
+
#endif
|
|
71
|
+
#ifdef HAS_NORMALMAP
|
|
72
|
+
if (pbrSurface.useMaterialNormals != 0) {
|
|
73
|
+
vec2 coordinates = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);
|
|
74
|
+
normal = getNormal(getTBN(coordinates), coordinates);
|
|
75
|
+
}
|
|
76
|
+
#else
|
|
77
|
+
#ifdef HAS_BUMPMAP
|
|
78
|
+
if (pbrSurface.useMaterialNormals != 0) {
|
|
79
|
+
vec2 coordinates = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);
|
|
80
|
+
normal = getNormal(getTBN(coordinates), coordinates);
|
|
81
|
+
}
|
|
82
|
+
#endif
|
|
83
|
+
#endif
|
|
84
|
+
vec3 viewNormal = normalize((pbrSurface.viewMatrix * vec4(normal, 0.0)).xyz);
|
|
85
|
+
return vec4(viewNormal * 0.5 + 0.5, 1.0);
|
|
86
|
+
}`
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=pbr-surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-surface.js","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-surface/pbr-surface.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,4DAA4D;AAI5D,OAAO,EAAC,WAAW,EAAC,wCAAqC;AAczD,qFAAqF;AACrF,MAAM,CAAC,MAAM,UAAU,GAAsD;IAC3E,IAAI,EAAE,YAAY;IAClB,YAAY,EAAE,CAAC,WAAW,CAAC;IAC3B,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IAC/C,YAAY,EAAE,EAAC,UAAU,EAAE,aAAa,EAAE,kBAAkB,EAAE,KAAK,EAAC;IACpE,eAAe,EAAE;QACf,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5D,kBAAkB,EAAE,CAAC;KACtB;IACD,WAAW,CAAC,UAAU,GAAG,EAAE;QACzB,OAAO;YACL,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAAC,UAAU,EAAE,UAAU,CAAC,UAAU,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,GAAG,CAAC,UAAU,CAAC,kBAAkB,KAAK,SAAS;gBAC7C,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAC,kBAAkB,EAAE,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAC,CAAC;SACjE,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BnB;IACA,EAAE,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCf;CACD,CAAC"}
|