@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 @@
|
|
|
1
|
+
{"version":3,"file":"lightmap.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lightmap/lightmap.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAC,YAAY,EAAC,oDAAiD;AAG3E,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wHAAwH;AACxH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAMF,OAAO,CAAC,oBAAoB,CAAC;;;;CAuDkC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
import { pbrMaterial } from "../pbr-material/pbr-material.js";
|
|
4
|
+
/** Texture-space rasterization controls. Chart IDs are positive integers exactly representable in the target format. */
|
|
5
|
+
export const lightmapBake = {
|
|
6
|
+
name: 'lightmapBake',
|
|
7
|
+
dependencies: [pbrMaterial],
|
|
8
|
+
bindingLayout: [{ name: 'lightmapBake', group: 0 }],
|
|
9
|
+
uniformTypes: { uvSet: 'i32', uvTransform: 'mat3x3<f32>', chartId: 'f32' },
|
|
10
|
+
defaultUniforms: { uvSet: 1, uvTransform: [1, 0, 0, 0, 1, 0, 0, 0, 1], chartId: 1 },
|
|
11
|
+
getUniforms: (props) => props,
|
|
12
|
+
source: `
|
|
13
|
+
struct LightmapBakeUniforms {uvSet: i32, uvTransform: mat3x3f, chartId: f32};
|
|
14
|
+
@group(0) @binding(auto) var<uniform> lightmapBake: LightmapBakeUniforms;
|
|
15
|
+
|
|
16
|
+
fn lightmap_getIrradiance(position: vec3f, normal: vec3f, directionalVisibility: f32, pointVisibility: vec4f, spotVisibility: vec4f) -> vec3f {
|
|
17
|
+
if (lighting.enabled == 0) {return vec3f(0.0);}
|
|
18
|
+
var irradiance = lighting.ambientColor;
|
|
19
|
+
for (var index = 0; index < lighting.directionalLightCount; index++) {
|
|
20
|
+
let light = lighting_getDirectionalLight(index);
|
|
21
|
+
irradiance += light.color * max(dot(normal, -normalize(light.direction)), 0.0) * select(1.0, directionalVisibility, index == 0);
|
|
22
|
+
}
|
|
23
|
+
for (var index = 0; index < lighting.pointLightCount; index++) {
|
|
24
|
+
let light = lighting_getPointLight(index);
|
|
25
|
+
let offset = light.position - position;
|
|
26
|
+
let visibility = select(1.0, pointVisibility[min(index, 3)], index < 4);
|
|
27
|
+
irradiance += light.color * max(dot(normal, normalize(offset)), 0.0) * visibility / max(getPointLightAttenuation(light, length(offset)), 0.0001);
|
|
28
|
+
}
|
|
29
|
+
for (var index = 0; index < lighting.spotLightCount; index++) {
|
|
30
|
+
let light = lighting_getSpotLight(index);
|
|
31
|
+
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);
|
|
32
|
+
}
|
|
33
|
+
return irradiance;
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
vs: `layout(std140) uniform lightmapBakeUniforms {
|
|
37
|
+
int uvSet;
|
|
38
|
+
mat3 uvTransform;
|
|
39
|
+
float chartId;
|
|
40
|
+
} lightmapBake;`,
|
|
41
|
+
fs: `layout(std140) uniform lightmapBakeUniforms {
|
|
42
|
+
int uvSet;
|
|
43
|
+
mat3 uvTransform;
|
|
44
|
+
float chartId;
|
|
45
|
+
} lightmapBake;
|
|
46
|
+
|
|
47
|
+
vec3 lightmap_getIrradiance(vec3 position, vec3 normal, float directionalVisibility, vec4 pointVisibility, vec4 spotVisibility) {
|
|
48
|
+
if (lighting.enabled == 0) {return vec3(0.0);}
|
|
49
|
+
vec3 irradiance = lighting.ambientColor;
|
|
50
|
+
for (int index = 0; index < lighting.directionalLightCount; index++) {
|
|
51
|
+
DirectionalLight light = lighting_getDirectionalLight(index);
|
|
52
|
+
irradiance += light.color * max(dot(normal, -normalize(light.direction)), 0.0) * (index == 0 ? directionalVisibility : 1.0);
|
|
53
|
+
}
|
|
54
|
+
for (int index = 0; index < lighting.pointLightCount; index++) {
|
|
55
|
+
PointLight light = lighting_getPointLight(index);
|
|
56
|
+
vec3 offset = light.position - position;
|
|
57
|
+
irradiance += light.color * max(dot(normal, normalize(offset)), 0.0) * (index < 4 ? pointVisibility[index] : 1.0) / max(getPointLightAttenuation(light, length(offset)), 0.0001);
|
|
58
|
+
}
|
|
59
|
+
for (int index = 0; index < lighting.spotLightCount; index++) {
|
|
60
|
+
SpotLight light = lighting_getSpotLight(index);
|
|
61
|
+
irradiance += light.color * max(dot(normal, normalize(light.position - position)), 0.0) * (index < 4 ? spotVisibility[index] : 1.0) / max(getSpotLightAttenuation(light, position), 0.0001);
|
|
62
|
+
}
|
|
63
|
+
return irradiance;
|
|
64
|
+
}
|
|
65
|
+
`
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=lightmap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightmap.js","sourceRoot":"","sources":["../../../../src/modules/lighting/lightmap/lightmap.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,4DAA4D;AAI5D,OAAO,EAAC,WAAW,EAAC,wCAAqC;AAQzD,wHAAwH;AACxH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,cAAc;IACpB,YAAY,EAAE,CAAC,WAAW,CAAC;IAC3B,aAAa,EAAE,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC;IACjD,YAAY,EAAE,EAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAC;IACxE,eAAe,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAC;IACjF,WAAW,EAAE,CAAC,KAAoC,EAAE,EAAE,CAAC,KAAK;IAC5D,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;CAuBT;IACC,EAAE,EAAE;;;;gBAIU;IACd,EAAE,EAAE;;;;;;;;;;;;;;;;;;;;;;;;CAwBL;CACqF,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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_ambient_occlusion_exports = {};
|
|
19
|
+
__export(pbr_ambient_occlusion_exports, {
|
|
20
|
+
pbrAmbientOcclusion: () => pbrAmbientOcclusion
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(pbr_ambient_occlusion_exports);
|
|
23
|
+
var import_pbr_material = require("../pbr-material/pbr-material.cjs");
|
|
24
|
+
const pbrAmbientOcclusion = {
|
|
25
|
+
name: "pbrAmbientOcclusion",
|
|
26
|
+
dependencies: [import_pbr_material.pbrMaterial],
|
|
27
|
+
bindingLayout: [
|
|
28
|
+
{ name: "pbrAmbientOcclusion", group: 0 },
|
|
29
|
+
{ name: "ambientOcclusionTexture", group: 2 }
|
|
30
|
+
],
|
|
31
|
+
uniformTypes: { viewport: "vec4<f32>", strength: "f32", enabled: "i32" },
|
|
32
|
+
defaultUniforms: { viewport: [0, 0, 1, 1], strength: 1, enabled: 1 },
|
|
33
|
+
getUniforms(properties = {}) {
|
|
34
|
+
return {
|
|
35
|
+
...properties.viewport ? { viewport: properties.viewport } : {},
|
|
36
|
+
...properties.strength === void 0 ? {} : { strength: properties.strength },
|
|
37
|
+
...properties.enabled === void 0 ? {} : { enabled: Number(properties.enabled) },
|
|
38
|
+
...properties.ambientOcclusionTexture ? { ambientOcclusionTexture: properties.ambientOcclusionTexture } : {}
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
source: (
|
|
42
|
+
/* wgsl */
|
|
43
|
+
`
|
|
44
|
+
struct PBRAmbientOcclusionUniforms {
|
|
45
|
+
viewport: vec4f,
|
|
46
|
+
strength: f32,
|
|
47
|
+
enabled: i32,
|
|
48
|
+
};
|
|
49
|
+
@group(0) @binding(auto) var<uniform> pbrAmbientOcclusion: PBRAmbientOcclusionUniforms;
|
|
50
|
+
@group(2) @binding(auto) var ambientOcclusionTexture: texture_2d<f32>;
|
|
51
|
+
@group(2) @binding(auto) var ambientOcclusionTextureSampler: sampler;
|
|
52
|
+
fn pbrAmbientOcclusion_getFactor(pixelPosition:vec2f)->f32 {
|
|
53
|
+
if(pbrAmbientOcclusion.enabled==0){return 1.0;}
|
|
54
|
+
let coordinates=(pixelPosition-pbrAmbientOcclusion.viewport.xy)/pbrAmbientOcclusion.viewport.zw;
|
|
55
|
+
if(any(coordinates<vec2f(0.0))||any(coordinates>vec2f(1.0))){return 1.0;}
|
|
56
|
+
let visibility=textureSampleLevel(ambientOcclusionTexture,ambientOcclusionTextureSampler,coordinates,0.0).r;
|
|
57
|
+
return mix(1.0,clamp(visibility,0.0,1.0),clamp(pbrAmbientOcclusion.strength,0.0,1.0));
|
|
58
|
+
}
|
|
59
|
+
fn pbrAmbientOcclusion_setFactor(pixelPosition:vec2f) {
|
|
60
|
+
pbr_ambientVisibility = pbrAmbientOcclusion_getFactor(pixelPosition);
|
|
61
|
+
}`
|
|
62
|
+
),
|
|
63
|
+
fs: (
|
|
64
|
+
/* glsl */
|
|
65
|
+
`
|
|
66
|
+
layout(std140) uniform pbrAmbientOcclusionUniforms {
|
|
67
|
+
vec4 viewport;
|
|
68
|
+
float strength;
|
|
69
|
+
int enabled;
|
|
70
|
+
} pbrAmbientOcclusion;
|
|
71
|
+
uniform sampler2D ambientOcclusionTexture;
|
|
72
|
+
float pbrAmbientOcclusion_getFactor(vec2 pixelPosition) {
|
|
73
|
+
if(pbrAmbientOcclusion.enabled==0)return 1.0;
|
|
74
|
+
vec2 coordinates=(pixelPosition-pbrAmbientOcclusion.viewport.xy)/pbrAmbientOcclusion.viewport.zw;
|
|
75
|
+
if(any(lessThan(coordinates,vec2(0.0)))||any(greaterThan(coordinates,vec2(1.0))))return 1.0;
|
|
76
|
+
float visibility=texture(ambientOcclusionTexture,coordinates).r;
|
|
77
|
+
return mix(1.0,clamp(visibility,0.0,1.0),clamp(pbrAmbientOcclusion.strength,0.0,1.0));
|
|
78
|
+
}
|
|
79
|
+
void pbrAmbientOcclusion_setFactor(vec2 pixelPosition) {
|
|
80
|
+
pbr_ambientVisibility = pbrAmbientOcclusion_getFactor(pixelPosition);
|
|
81
|
+
}`
|
|
82
|
+
)
|
|
83
|
+
};
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
pbrAmbientOcclusion
|
|
87
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { NumberArray4 } from '@math.gl/core';
|
|
2
|
+
import type { ShaderModule } from "../../../lib/shader-module/shader-module.js";
|
|
3
|
+
export type PBRAmbientOcclusionProps<TextureT = unknown> = {
|
|
4
|
+
ambientOcclusionTexture?: TextureT;
|
|
5
|
+
/** Origin and dimensions of the receiver viewport, in physical pixels. */
|
|
6
|
+
viewport?: Readonly<NumberArray4>;
|
|
7
|
+
strength?: number;
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type AmbientUniforms = {
|
|
11
|
+
viewport: Readonly<NumberArray4>;
|
|
12
|
+
strength: number;
|
|
13
|
+
enabled: number;
|
|
14
|
+
};
|
|
15
|
+
type AmbientBindings<TextureT = unknown> = {
|
|
16
|
+
ambientOcclusionTexture?: TextureT;
|
|
17
|
+
};
|
|
18
|
+
/** Sets ambient visibility for the canonical PBR material; direct lighting and emission remain independent. */
|
|
19
|
+
export declare const pbrAmbientOcclusion: ShaderModule<PBRAmbientOcclusionProps, AmbientUniforms, AmbientBindings>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=pbr-ambient-occlusion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-ambient-occlusion.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-ambient-occlusion/pbr-ambient-occlusion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAC,YAAY,EAAC,oDAAiD;AAG3E,MAAM,MAAM,wBAAwB,CAAC,QAAQ,GAAG,OAAO,IAAI;IACzD,uBAAuB,CAAC,EAAE,QAAQ,CAAC;IACnC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AACF,KAAK,eAAe,GAAG;IAAC,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC;AAC7F,KAAK,eAAe,CAAC,QAAQ,GAAG,OAAO,IAAI;IAAC,uBAAuB,CAAC,EAAE,QAAQ,CAAA;CAAC,CAAC;AAEhF,+GAA+G;AAC/G,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAC5C,wBAAwB,EACxB,eAAe,EACf,eAAe,CAwDhB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
import { pbrMaterial } from "../pbr-material/pbr-material.js";
|
|
4
|
+
/** Sets ambient visibility for the canonical PBR material; direct lighting and emission remain independent. */
|
|
5
|
+
export const pbrAmbientOcclusion = {
|
|
6
|
+
name: 'pbrAmbientOcclusion',
|
|
7
|
+
dependencies: [pbrMaterial],
|
|
8
|
+
bindingLayout: [
|
|
9
|
+
{ name: 'pbrAmbientOcclusion', group: 0 },
|
|
10
|
+
{ name: 'ambientOcclusionTexture', group: 2 }
|
|
11
|
+
],
|
|
12
|
+
uniformTypes: { viewport: 'vec4<f32>', strength: 'f32', enabled: 'i32' },
|
|
13
|
+
defaultUniforms: { viewport: [0, 0, 1, 1], strength: 1, enabled: 1 },
|
|
14
|
+
getUniforms(properties = {}) {
|
|
15
|
+
return {
|
|
16
|
+
...(properties.viewport ? { viewport: properties.viewport } : {}),
|
|
17
|
+
...(properties.strength === undefined ? {} : { strength: properties.strength }),
|
|
18
|
+
...(properties.enabled === undefined ? {} : { enabled: Number(properties.enabled) }),
|
|
19
|
+
...(properties.ambientOcclusionTexture
|
|
20
|
+
? { ambientOcclusionTexture: properties.ambientOcclusionTexture }
|
|
21
|
+
: {})
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
source: /* wgsl */ `
|
|
25
|
+
struct PBRAmbientOcclusionUniforms {
|
|
26
|
+
viewport: vec4f,
|
|
27
|
+
strength: f32,
|
|
28
|
+
enabled: i32,
|
|
29
|
+
};
|
|
30
|
+
@group(0) @binding(auto) var<uniform> pbrAmbientOcclusion: PBRAmbientOcclusionUniforms;
|
|
31
|
+
@group(2) @binding(auto) var ambientOcclusionTexture: texture_2d<f32>;
|
|
32
|
+
@group(2) @binding(auto) var ambientOcclusionTextureSampler: sampler;
|
|
33
|
+
fn pbrAmbientOcclusion_getFactor(pixelPosition:vec2f)->f32 {
|
|
34
|
+
if(pbrAmbientOcclusion.enabled==0){return 1.0;}
|
|
35
|
+
let coordinates=(pixelPosition-pbrAmbientOcclusion.viewport.xy)/pbrAmbientOcclusion.viewport.zw;
|
|
36
|
+
if(any(coordinates<vec2f(0.0))||any(coordinates>vec2f(1.0))){return 1.0;}
|
|
37
|
+
let visibility=textureSampleLevel(ambientOcclusionTexture,ambientOcclusionTextureSampler,coordinates,0.0).r;
|
|
38
|
+
return mix(1.0,clamp(visibility,0.0,1.0),clamp(pbrAmbientOcclusion.strength,0.0,1.0));
|
|
39
|
+
}
|
|
40
|
+
fn pbrAmbientOcclusion_setFactor(pixelPosition:vec2f) {
|
|
41
|
+
pbr_ambientVisibility = pbrAmbientOcclusion_getFactor(pixelPosition);
|
|
42
|
+
}`,
|
|
43
|
+
fs: /* glsl */ `
|
|
44
|
+
layout(std140) uniform pbrAmbientOcclusionUniforms {
|
|
45
|
+
vec4 viewport;
|
|
46
|
+
float strength;
|
|
47
|
+
int enabled;
|
|
48
|
+
} pbrAmbientOcclusion;
|
|
49
|
+
uniform sampler2D ambientOcclusionTexture;
|
|
50
|
+
float pbrAmbientOcclusion_getFactor(vec2 pixelPosition) {
|
|
51
|
+
if(pbrAmbientOcclusion.enabled==0)return 1.0;
|
|
52
|
+
vec2 coordinates=(pixelPosition-pbrAmbientOcclusion.viewport.xy)/pbrAmbientOcclusion.viewport.zw;
|
|
53
|
+
if(any(lessThan(coordinates,vec2(0.0)))||any(greaterThan(coordinates,vec2(1.0))))return 1.0;
|
|
54
|
+
float visibility=texture(ambientOcclusionTexture,coordinates).r;
|
|
55
|
+
return mix(1.0,clamp(visibility,0.0,1.0),clamp(pbrAmbientOcclusion.strength,0.0,1.0));
|
|
56
|
+
}
|
|
57
|
+
void pbrAmbientOcclusion_setFactor(vec2 pixelPosition) {
|
|
58
|
+
pbr_ambientVisibility = pbrAmbientOcclusion_getFactor(pixelPosition);
|
|
59
|
+
}`
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=pbr-ambient-occlusion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-ambient-occlusion.js","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-ambient-occlusion/pbr-ambient-occlusion.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,4DAA4D;AAI5D,OAAO,EAAC,WAAW,EAAC,wCAAqC;AAYzD,+GAA+G;AAC/G,MAAM,CAAC,MAAM,mBAAmB,GAI5B;IACF,IAAI,EAAE,qBAAqB;IAC3B,YAAY,EAAE,CAAC,WAAW,CAAC;IAC3B,aAAa,EAAE;QACb,EAAC,IAAI,EAAE,qBAAqB,EAAE,KAAK,EAAE,CAAC,EAAC;QACvC,EAAC,IAAI,EAAE,yBAAyB,EAAE,KAAK,EAAE,CAAC,EAAC;KAC5C;IACD,YAAY,EAAE,EAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC;IACtE,eAAe,EAAE,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAC;IAClE,WAAW,CAAC,UAAU,GAAG,EAAE;QACzB,OAAO;YACL,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/D,GAAG,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAC,CAAC;YAC7E,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;YAClF,GAAG,CAAC,UAAU,CAAC,uBAAuB;gBACpC,CAAC,CAAC,EAAC,uBAAuB,EAAE,UAAU,CAAC,uBAAuB,EAAC;gBAC/D,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;EAkBnB;IACA,EAAE,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;EAgBf;CACD,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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_contact_shadow_exports = {};
|
|
19
|
+
__export(pbr_contact_shadow_exports, {
|
|
20
|
+
pbrContactShadow: () => pbrContactShadow
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(pbr_contact_shadow_exports);
|
|
23
|
+
var import_pbr_material = require("../pbr-material/pbr-material.cjs");
|
|
24
|
+
const pbrContactShadow = {
|
|
25
|
+
name: "pbrContactShadow",
|
|
26
|
+
dependencies: [import_pbr_material.pbrMaterial],
|
|
27
|
+
bindingLayout: [
|
|
28
|
+
{ name: "pbrContactShadow", group: 0 },
|
|
29
|
+
{ name: "contactShadowTexture", group: 2 }
|
|
30
|
+
],
|
|
31
|
+
uniformTypes: { viewport: "vec4<f32>", strength: "f32", enabled: "i32" },
|
|
32
|
+
defaultUniforms: { viewport: [0, 0, 1, 1], strength: 1, enabled: 1 },
|
|
33
|
+
getUniforms(properties = {}) {
|
|
34
|
+
return {
|
|
35
|
+
...properties.viewport ? { viewport: properties.viewport } : {},
|
|
36
|
+
...properties.strength === void 0 ? {} : { strength: properties.strength },
|
|
37
|
+
...properties.enabled === void 0 ? {} : { enabled: Number(properties.enabled) },
|
|
38
|
+
...properties.contactShadowTexture ? { contactShadowTexture: properties.contactShadowTexture } : {}
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
source: (
|
|
42
|
+
/* wgsl */
|
|
43
|
+
`
|
|
44
|
+
struct PBRContactShadowUniforms {
|
|
45
|
+
viewport: vec4f,
|
|
46
|
+
strength: f32,
|
|
47
|
+
enabled: i32,
|
|
48
|
+
};
|
|
49
|
+
@group(0) @binding(auto) var<uniform> pbrContactShadow: PBRContactShadowUniforms;
|
|
50
|
+
@group(2) @binding(auto) var contactShadowTexture: texture_2d<f32>;
|
|
51
|
+
@group(2) @binding(auto) var contactShadowTextureSampler: sampler;
|
|
52
|
+
fn pbrContactShadow_getFactor(pixelPosition:vec2f)->f32 {
|
|
53
|
+
if(pbrContactShadow.enabled==0){return 1.0;}
|
|
54
|
+
let coordinates=(pixelPosition-pbrContactShadow.viewport.xy)/pbrContactShadow.viewport.zw;
|
|
55
|
+
if(any(coordinates<vec2f(0.0))||any(coordinates>vec2f(1.0))){return 1.0;}
|
|
56
|
+
let visibility=textureSampleLevel(contactShadowTexture,contactShadowTextureSampler,coordinates,0.0).r;
|
|
57
|
+
return mix(1.0,clamp(visibility,0.0,1.0),clamp(pbrContactShadow.strength,0.0,1.0));
|
|
58
|
+
}
|
|
59
|
+
fn pbrContactShadow_filterColor(vertexColor:vec4f,pixelPosition:vec2f)->vec4f {
|
|
60
|
+
return pbr_filterColorWithShadows(vertexColor,pbrContactShadow_getFactor(pixelPosition),vec4f(1.0),vec4f(1.0));
|
|
61
|
+
}`
|
|
62
|
+
),
|
|
63
|
+
fs: (
|
|
64
|
+
/* glsl */
|
|
65
|
+
`
|
|
66
|
+
layout(std140) uniform pbrContactShadowUniforms {
|
|
67
|
+
vec4 viewport;
|
|
68
|
+
float strength;
|
|
69
|
+
int enabled;
|
|
70
|
+
} pbrContactShadow;
|
|
71
|
+
uniform sampler2D contactShadowTexture;
|
|
72
|
+
float pbrContactShadow_getFactor(vec2 pixelPosition) {
|
|
73
|
+
if(pbrContactShadow.enabled==0)return 1.0;
|
|
74
|
+
vec2 coordinates=(pixelPosition-pbrContactShadow.viewport.xy)/pbrContactShadow.viewport.zw;
|
|
75
|
+
if(any(lessThan(coordinates,vec2(0.0)))||any(greaterThan(coordinates,vec2(1.0))))return 1.0;
|
|
76
|
+
float visibility=texture(contactShadowTexture,coordinates).r;
|
|
77
|
+
return mix(1.0,clamp(visibility,0.0,1.0),clamp(pbrContactShadow.strength,0.0,1.0));
|
|
78
|
+
}
|
|
79
|
+
vec4 pbrContactShadow_filterColor(vec4 vertexColor,vec2 pixelPosition) {
|
|
80
|
+
return pbr_filterColorWithShadows(vertexColor,pbrContactShadow_getFactor(pixelPosition),vec4(1.0),vec4(1.0));
|
|
81
|
+
}`
|
|
82
|
+
)
|
|
83
|
+
};
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
pbrContactShadow
|
|
87
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { NumberArray4 } from '@math.gl/core';
|
|
2
|
+
import type { ShaderModule } from "../../../lib/shader-module/shader-module.js";
|
|
3
|
+
export type PBRContactShadowProps<TextureT = unknown> = {
|
|
4
|
+
contactShadowTexture?: TextureT;
|
|
5
|
+
/** Origin and dimensions of the receiver viewport, in physical pixels. */
|
|
6
|
+
viewport?: Readonly<NumberArray4>;
|
|
7
|
+
strength?: number;
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type ContactUniforms = {
|
|
11
|
+
viewport: Readonly<NumberArray4>;
|
|
12
|
+
strength: number;
|
|
13
|
+
enabled: number;
|
|
14
|
+
};
|
|
15
|
+
type ContactBindings<TextureT = unknown> = {
|
|
16
|
+
contactShadowTexture?: TextureT;
|
|
17
|
+
};
|
|
18
|
+
/** Applies a screen-space visibility mask to the first directional light only. */
|
|
19
|
+
export declare const pbrContactShadow: ShaderModule<PBRContactShadowProps, ContactUniforms, ContactBindings>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=pbr-contact-shadow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-contact-shadow.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-contact-shadow/pbr-contact-shadow.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAC,YAAY,EAAC,oDAAiD;AAG3E,MAAM,MAAM,qBAAqB,CAAC,QAAQ,GAAG,OAAO,IAAI;IACtD,oBAAoB,CAAC,EAAE,QAAQ,CAAC;IAChC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AACF,KAAK,eAAe,GAAG;IAAC,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC;AAC7F,KAAK,eAAe,CAAC,QAAQ,GAAG,OAAO,IAAI;IAAC,oBAAoB,CAAC,EAAE,QAAQ,CAAA;CAAC,CAAC;AAE7E,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,EAAE,YAAY,CACzC,qBAAqB,EACrB,eAAe,EACf,eAAe,CAwDhB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
import { pbrMaterial } from "../pbr-material/pbr-material.js";
|
|
4
|
+
/** Applies a screen-space visibility mask to the first directional light only. */
|
|
5
|
+
export const pbrContactShadow = {
|
|
6
|
+
name: 'pbrContactShadow',
|
|
7
|
+
dependencies: [pbrMaterial],
|
|
8
|
+
bindingLayout: [
|
|
9
|
+
{ name: 'pbrContactShadow', group: 0 },
|
|
10
|
+
{ name: 'contactShadowTexture', group: 2 }
|
|
11
|
+
],
|
|
12
|
+
uniformTypes: { viewport: 'vec4<f32>', strength: 'f32', enabled: 'i32' },
|
|
13
|
+
defaultUniforms: { viewport: [0, 0, 1, 1], strength: 1, enabled: 1 },
|
|
14
|
+
getUniforms(properties = {}) {
|
|
15
|
+
return {
|
|
16
|
+
...(properties.viewport ? { viewport: properties.viewport } : {}),
|
|
17
|
+
...(properties.strength === undefined ? {} : { strength: properties.strength }),
|
|
18
|
+
...(properties.enabled === undefined ? {} : { enabled: Number(properties.enabled) }),
|
|
19
|
+
...(properties.contactShadowTexture
|
|
20
|
+
? { contactShadowTexture: properties.contactShadowTexture }
|
|
21
|
+
: {})
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
source: /* wgsl */ `
|
|
25
|
+
struct PBRContactShadowUniforms {
|
|
26
|
+
viewport: vec4f,
|
|
27
|
+
strength: f32,
|
|
28
|
+
enabled: i32,
|
|
29
|
+
};
|
|
30
|
+
@group(0) @binding(auto) var<uniform> pbrContactShadow: PBRContactShadowUniforms;
|
|
31
|
+
@group(2) @binding(auto) var contactShadowTexture: texture_2d<f32>;
|
|
32
|
+
@group(2) @binding(auto) var contactShadowTextureSampler: sampler;
|
|
33
|
+
fn pbrContactShadow_getFactor(pixelPosition:vec2f)->f32 {
|
|
34
|
+
if(pbrContactShadow.enabled==0){return 1.0;}
|
|
35
|
+
let coordinates=(pixelPosition-pbrContactShadow.viewport.xy)/pbrContactShadow.viewport.zw;
|
|
36
|
+
if(any(coordinates<vec2f(0.0))||any(coordinates>vec2f(1.0))){return 1.0;}
|
|
37
|
+
let visibility=textureSampleLevel(contactShadowTexture,contactShadowTextureSampler,coordinates,0.0).r;
|
|
38
|
+
return mix(1.0,clamp(visibility,0.0,1.0),clamp(pbrContactShadow.strength,0.0,1.0));
|
|
39
|
+
}
|
|
40
|
+
fn pbrContactShadow_filterColor(vertexColor:vec4f,pixelPosition:vec2f)->vec4f {
|
|
41
|
+
return pbr_filterColorWithShadows(vertexColor,pbrContactShadow_getFactor(pixelPosition),vec4f(1.0),vec4f(1.0));
|
|
42
|
+
}`,
|
|
43
|
+
fs: /* glsl */ `
|
|
44
|
+
layout(std140) uniform pbrContactShadowUniforms {
|
|
45
|
+
vec4 viewport;
|
|
46
|
+
float strength;
|
|
47
|
+
int enabled;
|
|
48
|
+
} pbrContactShadow;
|
|
49
|
+
uniform sampler2D contactShadowTexture;
|
|
50
|
+
float pbrContactShadow_getFactor(vec2 pixelPosition) {
|
|
51
|
+
if(pbrContactShadow.enabled==0)return 1.0;
|
|
52
|
+
vec2 coordinates=(pixelPosition-pbrContactShadow.viewport.xy)/pbrContactShadow.viewport.zw;
|
|
53
|
+
if(any(lessThan(coordinates,vec2(0.0)))||any(greaterThan(coordinates,vec2(1.0))))return 1.0;
|
|
54
|
+
float visibility=texture(contactShadowTexture,coordinates).r;
|
|
55
|
+
return mix(1.0,clamp(visibility,0.0,1.0),clamp(pbrContactShadow.strength,0.0,1.0));
|
|
56
|
+
}
|
|
57
|
+
vec4 pbrContactShadow_filterColor(vec4 vertexColor,vec2 pixelPosition) {
|
|
58
|
+
return pbr_filterColorWithShadows(vertexColor,pbrContactShadow_getFactor(pixelPosition),vec4(1.0),vec4(1.0));
|
|
59
|
+
}`
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=pbr-contact-shadow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pbr-contact-shadow.js","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-contact-shadow/pbr-contact-shadow.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,4DAA4D;AAI5D,OAAO,EAAC,WAAW,EAAC,wCAAqC;AAYzD,kFAAkF;AAClF,MAAM,CAAC,MAAM,gBAAgB,GAIzB;IACF,IAAI,EAAE,kBAAkB;IACxB,YAAY,EAAE,CAAC,WAAW,CAAC;IAC3B,aAAa,EAAE;QACb,EAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAC;QACpC,EAAC,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC,EAAC;KACzC;IACD,YAAY,EAAE,EAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC;IACtE,eAAe,EAAE,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAC;IAClE,WAAW,CAAC,UAAU,GAAG,EAAE;QACzB,OAAO;YACL,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/D,GAAG,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAC,CAAC;YAC7E,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;YAClF,GAAG,CAAC,UAAU,CAAC,oBAAoB;gBACjC,CAAC,CAAC,EAAC,oBAAoB,EAAE,UAAU,CAAC,oBAAoB,EAAC;gBACzD,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;EAkBnB;IACA,EAAE,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;EAgBf;CACD,CAAC"}
|
|
@@ -53,7 +53,7 @@ void pbr_setPositionNormalTangentUV(
|
|
|
53
53
|
vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
|
|
54
54
|
pbr_vTBN = mat3(tangentW, bitangentW, normalW);
|
|
55
55
|
#else // HAS_TANGENTS != 1
|
|
56
|
-
pbr_vNormal = normalize(vec3(pbrProjection.
|
|
56
|
+
pbr_vNormal = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
|
|
57
57
|
#endif
|
|
58
58
|
#endif
|
|
59
59
|
|
|
@@ -1060,7 +1060,9 @@ vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) {
|
|
|
1060
1060
|
}
|
|
1061
1061
|
|
|
1062
1062
|
// Visibility for the first four spotlights; environment and other lights are unaffected.
|
|
1063
|
-
|
|
1063
|
+
float pbr_ambientVisibility = 1.0;
|
|
1064
|
+
|
|
1065
|
+
vec4 pbr_filterColorWithShadows(vec4 vertexColor, float directionalVisibility, vec4 pointVisibility, vec4 spotVisibility)
|
|
1064
1066
|
{
|
|
1065
1067
|
vec2 baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform);
|
|
1066
1068
|
vec2 metallicRoughnessUV = getMaterialUV(
|
|
@@ -1156,7 +1158,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1156
1158
|
color.rgb = baseColor.rgb;
|
|
1157
1159
|
#ifdef HAS_LIGHTMAP
|
|
1158
1160
|
if (pbrMaterial.lightmapMapEnabled) {
|
|
1159
|
-
color *= lightmapIrradiance / M_PI;
|
|
1161
|
+
color *= lightmapIrradiance / M_PI * pbr_ambientVisibility;
|
|
1160
1162
|
#ifdef HAS_OCCLUSIONMAP
|
|
1161
1163
|
if (pbrMaterial.occlusionMapEnabled) {
|
|
1162
1164
|
float ao = texture(pbr_occlusionSampler, occlusionUV).r;
|
|
@@ -1258,12 +1260,12 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1258
1260
|
|
|
1259
1261
|
#ifdef USE_LIGHTS
|
|
1260
1262
|
PBRInfo_setAmbientLight(pbrInfo);
|
|
1261
|
-
color += calculateFinalColor(pbrInfo, lighting.ambientColor);
|
|
1263
|
+
color += calculateFinalColor(pbrInfo, lighting.ambientColor * pbr_ambientVisibility);
|
|
1262
1264
|
|
|
1263
1265
|
for(int i = 0; i < lighting.directionalLightCount; i++) {
|
|
1264
1266
|
if (i < lighting.directionalLightCount) {
|
|
1265
1267
|
PBRInfo_setDirectionalLight(pbrInfo, -lighting_getDirectionalLight(i).direction);
|
|
1266
|
-
color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
|
|
1268
|
+
color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color * (i == 0 ? clamp(directionalVisibility, 0.0, 1.0) : 1.0));
|
|
1267
1269
|
}
|
|
1268
1270
|
}
|
|
1269
1271
|
|
|
@@ -1271,7 +1273,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1271
1273
|
if (i < lighting.pointLightCount) {
|
|
1272
1274
|
PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
|
|
1273
1275
|
float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
|
|
1274
|
-
color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
|
|
1276
|
+
color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color * (i < 4 ? clamp(pointVisibility[min(i, 3)], 0.0, 1.0) : 1.0) / attenuation);
|
|
1275
1277
|
}
|
|
1276
1278
|
}
|
|
1277
1279
|
|
|
@@ -1297,6 +1299,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1297
1299
|
}
|
|
1298
1300
|
#endif
|
|
1299
1301
|
|
|
1302
|
+
vec3 indirectBaseColor = color;
|
|
1300
1303
|
#ifdef USE_IBL
|
|
1301
1304
|
if (pbrMaterial.IBLenabled) {
|
|
1302
1305
|
color += getIBLContribution(pbrInfo, n, reflection);
|
|
@@ -1305,6 +1308,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1305
1308
|
|
|
1306
1309
|
// The pinned KHR_lightmap draft explicitly defines c_diff = (1 - metallic) * baseColor.
|
|
1307
1310
|
color += baseColor.rgb * (1.0 - metallic) * lightmapIrradiance / M_PI;
|
|
1311
|
+
color = indirectBaseColor + (color - indirectBaseColor) * pbr_ambientVisibility;
|
|
1308
1312
|
|
|
1309
1313
|
#ifdef HAS_OCCLUSIONMAP
|
|
1310
1314
|
if (pbrMaterial.occlusionMapEnabled) {
|
|
@@ -1537,7 +1541,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1537
1541
|
PBRInfo_setAmbientLight(pbrInfo);
|
|
1538
1542
|
color += calculateMaterialLightColor(
|
|
1539
1543
|
pbrInfo,
|
|
1540
|
-
lighting.ambientColor,
|
|
1544
|
+
lighting.ambientColor * pbr_ambientVisibility,
|
|
1541
1545
|
clearcoatNormal,
|
|
1542
1546
|
clearcoatFactor,
|
|
1543
1547
|
clearcoatRoughness,
|
|
@@ -1553,7 +1557,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1553
1557
|
PBRInfo_setDirectionalLight(pbrInfo, -lighting_getDirectionalLight(i).direction);
|
|
1554
1558
|
color += calculateMaterialLightColor(
|
|
1555
1559
|
pbrInfo,
|
|
1556
|
-
lighting_getDirectionalLight(i).color,
|
|
1560
|
+
lighting_getDirectionalLight(i).color * (i == 0 ? clamp(directionalVisibility, 0.0, 1.0) : 1.0),
|
|
1557
1561
|
clearcoatNormal,
|
|
1558
1562
|
clearcoatFactor,
|
|
1559
1563
|
clearcoatRoughness,
|
|
@@ -1564,7 +1568,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1564
1568
|
);
|
|
1565
1569
|
color += calculateDiffuseTransmissionLight(
|
|
1566
1570
|
pbrInfo,
|
|
1567
|
-
lighting_getDirectionalLight(i).color,
|
|
1571
|
+
lighting_getDirectionalLight(i).color * (i == 0 ? clamp(directionalVisibility, 0.0, 1.0) : 1.0),
|
|
1568
1572
|
diffuseTransmissionColor,
|
|
1569
1573
|
diffuseTransmission,
|
|
1570
1574
|
multiscatterColor,
|
|
@@ -1580,7 +1584,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1580
1584
|
float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
|
|
1581
1585
|
color += calculateMaterialLightColor(
|
|
1582
1586
|
pbrInfo,
|
|
1583
|
-
lighting_getPointLight(i).color / attenuation,
|
|
1587
|
+
lighting_getPointLight(i).color * (i < 4 ? clamp(pointVisibility[min(i, 3)], 0.0, 1.0) : 1.0) / attenuation,
|
|
1584
1588
|
clearcoatNormal,
|
|
1585
1589
|
clearcoatFactor,
|
|
1586
1590
|
clearcoatRoughness,
|
|
@@ -1591,7 +1595,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1591
1595
|
);
|
|
1592
1596
|
color += calculateDiffuseTransmissionLight(
|
|
1593
1597
|
pbrInfo,
|
|
1594
|
-
lighting_getPointLight(i).color / attenuation,
|
|
1598
|
+
lighting_getPointLight(i).color * (i < 4 ? clamp(pointVisibility[min(i, 3)], 0.0, 1.0) : 1.0) / attenuation,
|
|
1595
1599
|
diffuseTransmissionColor,
|
|
1596
1600
|
diffuseTransmission,
|
|
1597
1601
|
multiscatterColor,
|
|
@@ -1660,6 +1664,7 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1660
1664
|
}
|
|
1661
1665
|
#endif
|
|
1662
1666
|
|
|
1667
|
+
vec3 indirectBaseColor = color;
|
|
1663
1668
|
// Calculate lighting contribution from image based lighting source (IBL)
|
|
1664
1669
|
#ifdef USE_IBL
|
|
1665
1670
|
if (pbrMaterial.IBLenabled) {
|
|
@@ -1694,6 +1699,8 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1694
1699
|
(1.0 - diffuseTransmission) * baseLayerEnergy * lightmapIrradiance / M_PI;
|
|
1695
1700
|
#endif
|
|
1696
1701
|
|
|
1702
|
+
color = indirectBaseColor + (color - indirectBaseColor) * pbr_ambientVisibility;
|
|
1703
|
+
|
|
1697
1704
|
// Apply optional PBR terms for additional (optional) shading
|
|
1698
1705
|
#ifdef HAS_OCCLUSIONMAP
|
|
1699
1706
|
if (pbrMaterial.occlusionMapEnabled) {
|
|
@@ -1755,6 +1762,21 @@ vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility)
|
|
|
1755
1762
|
return vec4(applySceneColorManagement(color), alpha);
|
|
1756
1763
|
}
|
|
1757
1764
|
|
|
1765
|
+
// Depth-only passes use the same base-color alpha, vertex color and UV transform.
|
|
1766
|
+
void pbr_discardMaskedFragment(vec4 vertexColor) {
|
|
1767
|
+
#ifdef ALPHA_CUTOFF
|
|
1768
|
+
float alpha = pbrMaterial.baseColorFactor.a * vertexColor.a;
|
|
1769
|
+
#ifdef HAS_BASECOLORMAP
|
|
1770
|
+
alpha *= texture(pbr_baseColorSampler, getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform)).a;
|
|
1771
|
+
#endif
|
|
1772
|
+
if (alpha < pbrMaterial.alphaCutoff) {discard;}
|
|
1773
|
+
#endif
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
vec4 pbr_filterColorWithSpotShadows(vec4 vertexColor, vec4 spotVisibility) {
|
|
1777
|
+
return pbr_filterColorWithShadows(vertexColor, 1.0, vec4(1.0), spotVisibility);
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1758
1780
|
vec4 pbr_filterColor(vec4 vertexColor) {
|
|
1759
1781
|
return pbr_filterColorWithSpotShadows(vertexColor, vec4(1.0));
|
|
1760
1782
|
}
|