@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,71 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
/** Internal accumulation/copy/dilation shader shared by the engine baker. */
|
|
4
|
+
export const lightmapFilter = {
|
|
5
|
+
name: 'lightmapFilter',
|
|
6
|
+
bindingLayout: [
|
|
7
|
+
{ name: 'lightmapFilter', group: 0 },
|
|
8
|
+
{ name: 'currentTexture', group: 0 },
|
|
9
|
+
{ name: 'previousTexture', group: 0 },
|
|
10
|
+
{ name: 'chartTexture', group: 0 }
|
|
11
|
+
],
|
|
12
|
+
uniformTypes: { weight: 'f32', mode: 'i32' },
|
|
13
|
+
defaultUniforms: { weight: 1, mode: 0 },
|
|
14
|
+
getUniforms: (props) => props,
|
|
15
|
+
source: `
|
|
16
|
+
struct LightmapFilterUniforms {weight: f32, mode: i32};
|
|
17
|
+
@group(0) @binding(auto) var<uniform> lightmapFilter: LightmapFilterUniforms;
|
|
18
|
+
@group(0) @binding(auto) var currentTexture: texture_2d<f32>;
|
|
19
|
+
@group(0) @binding(auto) var previousTexture: texture_2d<f32>;
|
|
20
|
+
@group(0) @binding(auto) var chartTexture: texture_2d<f32>;
|
|
21
|
+
fn lightmapFilter_getColor(coordinates: vec2i) -> vec4f {
|
|
22
|
+
let current = textureLoad(currentTexture, coordinates, 0);
|
|
23
|
+
if (lightmapFilter.mode == 0) {
|
|
24
|
+
let previous = textureLoad(previousTexture, coordinates, 0);
|
|
25
|
+
return vec4f(mix(previous.rgb, current.rgb, lightmapFilter.weight), current.a);
|
|
26
|
+
}
|
|
27
|
+
if (lightmapFilter.mode == 2 || current.a > 0.0) {return current;}
|
|
28
|
+
let chart = textureLoad(chartTexture, coordinates, 0).r;
|
|
29
|
+
if (chart <= 0.0) {return current;}
|
|
30
|
+
let size = vec2i(textureDimensions(currentTexture));
|
|
31
|
+
for (var y = -1; y <= 1; y++) {
|
|
32
|
+
for (var x = -1; x <= 1; x++) {
|
|
33
|
+
let neighbor = coordinates + vec2i(x, y);
|
|
34
|
+
if (all(neighbor >= vec2i(0)) && all(neighbor < size)) {
|
|
35
|
+
let candidate = textureLoad(currentTexture, neighbor, 0);
|
|
36
|
+
if (candidate.a == chart) {return candidate;}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return current;
|
|
41
|
+
}`,
|
|
42
|
+
fs: `
|
|
43
|
+
layout(std140) uniform lightmapFilterUniforms {
|
|
44
|
+
float weight;
|
|
45
|
+
int mode;
|
|
46
|
+
} lightmapFilter;
|
|
47
|
+
uniform sampler2D currentTexture;
|
|
48
|
+
uniform sampler2D previousTexture;
|
|
49
|
+
uniform sampler2D chartTexture;
|
|
50
|
+
vec4 lightmapFilter_getColor(ivec2 coordinates) {
|
|
51
|
+
vec4 current = texelFetch(currentTexture, coordinates, 0);
|
|
52
|
+
if (lightmapFilter.mode == 0) {
|
|
53
|
+
return vec4(mix(texelFetch(previousTexture, coordinates, 0).rgb, current.rgb, lightmapFilter.weight), current.a);
|
|
54
|
+
}
|
|
55
|
+
if (lightmapFilter.mode == 2 || current.a > 0.0) {return current;}
|
|
56
|
+
float chart = texelFetch(chartTexture, coordinates, 0).r;
|
|
57
|
+
ivec2 size = textureSize(currentTexture, 0);
|
|
58
|
+
if (chart <= 0.0) return current;
|
|
59
|
+
for (int y = -1; y <= 1; y++) {
|
|
60
|
+
for (int x = -1; x <= 1; x++) {
|
|
61
|
+
ivec2 neighbor = coordinates + ivec2(x,y);
|
|
62
|
+
if (all(greaterThanEqual(neighbor, ivec2(0))) && all(lessThan(neighbor,size))) {
|
|
63
|
+
vec4 candidate = texelFetch(currentTexture, neighbor, 0);
|
|
64
|
+
if (candidate.a == chart) {return candidate;}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return current;
|
|
69
|
+
}`
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=lightmap-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightmap-filter.js","sourceRoot":"","sources":["../../../../src/modules/lighting/lightmap/lightmap-filter.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,4DAA4D;AAI5D,6EAA6E;AAC7E,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,gBAAgB;IACtB,aAAa,EAAE;QACb,EAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAC;QAClC,EAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAC;QAClC,EAAC,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAC;QACnC,EAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,EAAC;KACjC;IACD,YAAY,EAAE,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAC;IAC1C,eAAe,EAAE,EAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAC;IACrC,WAAW,EAAE,CAAC,KAAuC,EAAE,EAAE,CAAC,KAAK;IAC/D,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BR;IACA,EAAE,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BJ;CACiG,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
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 lightmap_exports = {};
|
|
19
|
+
__export(lightmap_exports, {
|
|
20
|
+
lightmapBake: () => lightmapBake
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(lightmap_exports);
|
|
23
|
+
var import_pbr_material = require("../pbr-material/pbr-material.cjs");
|
|
24
|
+
const lightmapBake = {
|
|
25
|
+
name: "lightmapBake",
|
|
26
|
+
dependencies: [import_pbr_material.pbrMaterial],
|
|
27
|
+
bindingLayout: [{ name: "lightmapBake", group: 0 }],
|
|
28
|
+
uniformTypes: { uvSet: "i32", uvTransform: "mat3x3<f32>", chartId: "f32" },
|
|
29
|
+
defaultUniforms: { uvSet: 1, uvTransform: [1, 0, 0, 0, 1, 0, 0, 0, 1], chartId: 1 },
|
|
30
|
+
getUniforms: (props) => props,
|
|
31
|
+
source: `
|
|
32
|
+
struct LightmapBakeUniforms {uvSet: i32, uvTransform: mat3x3f, chartId: f32};
|
|
33
|
+
@group(0) @binding(auto) var<uniform> lightmapBake: LightmapBakeUniforms;
|
|
34
|
+
|
|
35
|
+
fn lightmap_getIrradiance(position: vec3f, normal: vec3f, directionalVisibility: f32, pointVisibility: vec4f, spotVisibility: vec4f) -> vec3f {
|
|
36
|
+
if (lighting.enabled == 0) {return vec3f(0.0);}
|
|
37
|
+
var irradiance = lighting.ambientColor;
|
|
38
|
+
for (var index = 0; index < lighting.directionalLightCount; index++) {
|
|
39
|
+
let light = lighting_getDirectionalLight(index);
|
|
40
|
+
irradiance += light.color * max(dot(normal, -normalize(light.direction)), 0.0) * select(1.0, directionalVisibility, index == 0);
|
|
41
|
+
}
|
|
42
|
+
for (var index = 0; index < lighting.pointLightCount; index++) {
|
|
43
|
+
let light = lighting_getPointLight(index);
|
|
44
|
+
let offset = light.position - position;
|
|
45
|
+
let visibility = select(1.0, pointVisibility[min(index, 3)], index < 4);
|
|
46
|
+
irradiance += light.color * max(dot(normal, normalize(offset)), 0.0) * visibility / max(getPointLightAttenuation(light, length(offset)), 0.0001);
|
|
47
|
+
}
|
|
48
|
+
for (var index = 0; index < lighting.spotLightCount; index++) {
|
|
49
|
+
let light = lighting_getSpotLight(index);
|
|
50
|
+
irradiance += light.color * max(dot(normal, normalize(light.position - position)), 0.0) * select(1.0, spotVisibility[min(index, 3)], index < 4) / max(getSpotLightAttenuation(light, position), 0.0001);
|
|
51
|
+
}
|
|
52
|
+
return irradiance;
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
vs: `layout(std140) uniform lightmapBakeUniforms {
|
|
56
|
+
int uvSet;
|
|
57
|
+
mat3 uvTransform;
|
|
58
|
+
float chartId;
|
|
59
|
+
} lightmapBake;`,
|
|
60
|
+
fs: `layout(std140) uniform lightmapBakeUniforms {
|
|
61
|
+
int uvSet;
|
|
62
|
+
mat3 uvTransform;
|
|
63
|
+
float chartId;
|
|
64
|
+
} lightmapBake;
|
|
65
|
+
|
|
66
|
+
vec3 lightmap_getIrradiance(vec3 position, vec3 normal, float directionalVisibility, vec4 pointVisibility, vec4 spotVisibility) {
|
|
67
|
+
if (lighting.enabled == 0) {return vec3(0.0);}
|
|
68
|
+
vec3 irradiance = lighting.ambientColor;
|
|
69
|
+
for (int index = 0; index < lighting.directionalLightCount; index++) {
|
|
70
|
+
DirectionalLight light = lighting_getDirectionalLight(index);
|
|
71
|
+
irradiance += light.color * max(dot(normal, -normalize(light.direction)), 0.0) * (index == 0 ? directionalVisibility : 1.0);
|
|
72
|
+
}
|
|
73
|
+
for (int index = 0; index < lighting.pointLightCount; index++) {
|
|
74
|
+
PointLight light = lighting_getPointLight(index);
|
|
75
|
+
vec3 offset = light.position - position;
|
|
76
|
+
irradiance += light.color * max(dot(normal, normalize(offset)), 0.0) * (index < 4 ? pointVisibility[index] : 1.0) / max(getPointLightAttenuation(light, length(offset)), 0.0001);
|
|
77
|
+
}
|
|
78
|
+
for (int index = 0; index < lighting.spotLightCount; index++) {
|
|
79
|
+
SpotLight light = lighting_getSpotLight(index);
|
|
80
|
+
irradiance += light.color * max(dot(normal, normalize(light.position - position)), 0.0) * (index < 4 ? spotVisibility[index] : 1.0) / max(getSpotLightAttenuation(light, position), 0.0001);
|
|
81
|
+
}
|
|
82
|
+
return irradiance;
|
|
83
|
+
}
|
|
84
|
+
`
|
|
85
|
+
};
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
lightmapBake
|
|
89
|
+
});
|