@deck.gl/geo-layers 9.4.0-alpha.2 → 9.4.0-beta.3
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 +10452 -10051
- package/dist/geo-cell-layer/GeoCellLayer.d.ts.map +1 -1
- package/dist/geo-cell-layer/GeoCellLayer.js +2 -1
- package/dist/geo-cell-layer/GeoCellLayer.js.map +1 -1
- package/dist/index.cjs +21654 -1900
- package/dist/index.cjs.map +3 -4
- package/dist/mesh-layer/mesh-layer-uniforms.d.ts +1 -0
- package/dist/mesh-layer/mesh-layer-uniforms.d.ts.map +1 -1
- package/dist/mesh-layer/mesh-layer-uniforms.js +8 -0
- package/dist/mesh-layer/mesh-layer-uniforms.js.map +1 -1
- package/dist/mesh-layer/mesh-layer.d.ts.map +1 -1
- package/dist/mesh-layer/mesh-layer.js +15 -6
- package/dist/mesh-layer/mesh-layer.js.map +1 -1
- package/dist/mesh-layer/mesh-layer.wgsl.d.ts +3 -0
- package/dist/mesh-layer/mesh-layer.wgsl.d.ts.map +1 -0
- package/dist/mesh-layer/mesh-layer.wgsl.js +130 -0
- package/dist/mesh-layer/mesh-layer.wgsl.js.map +1 -0
- package/dist/mesh-layer/mesh-pbr-material.d.ts +252 -0
- package/dist/mesh-layer/mesh-pbr-material.d.ts.map +1 -0
- package/dist/mesh-layer/mesh-pbr-material.js +27 -0
- package/dist/mesh-layer/mesh-pbr-material.js.map +1 -0
- package/dist/trips-layer/trips-layer-uniforms.d.ts +1 -0
- package/dist/trips-layer/trips-layer-uniforms.d.ts.map +1 -1
- package/dist/trips-layer/trips-layer-uniforms.js +14 -3
- package/dist/trips-layer/trips-layer-uniforms.js.map +1 -1
- package/dist/trips-layer/trips-layer.d.ts +6 -1
- package/dist/trips-layer/trips-layer.d.ts.map +1 -1
- package/dist/trips-layer/trips-layer.js +57 -24
- package/dist/trips-layer/trips-layer.js.map +1 -1
- package/dist/trips-layer/trips-layer.wgsl.d.ts +11 -0
- package/dist/trips-layer/trips-layer.wgsl.d.ts.map +1 -0
- package/dist/trips-layer/trips-layer.wgsl.js +48 -0
- package/dist/trips-layer/trips-layer.wgsl.js.map +1 -0
- package/dist.min.js +1415 -149
- package/dist.webgl-only/a5-layer/a5-layer.js +30 -0
- package/dist.webgl-only/a5-layer/a5-layer.js.map +1 -0
- package/dist.webgl-only/geo-cell-layer/GeoCellLayer.js +57 -0
- package/dist.webgl-only/geo-cell-layer/GeoCellLayer.js.map +1 -0
- package/dist.webgl-only/geohash-layer/geohash-layer.js +24 -0
- package/dist.webgl-only/geohash-layer/geohash-layer.js.map +1 -0
- package/dist.webgl-only/geohash-layer/geohash-utils.js +54 -0
- package/dist.webgl-only/geohash-layer/geohash-utils.js.map +1 -0
- package/dist.webgl-only/great-circle-layer/great-circle-layer.js +17 -0
- package/dist.webgl-only/great-circle-layer/great-circle-layer.js.map +1 -0
- package/dist.webgl-only/h3-layers/h3-cluster-layer.js +52 -0
- package/dist.webgl-only/h3-layers/h3-cluster-layer.js.map +1 -0
- package/dist.webgl-only/h3-layers/h3-hexagon-layer.js +209 -0
- package/dist.webgl-only/h3-layers/h3-hexagon-layer.js.map +1 -0
- package/dist.webgl-only/h3-layers/h3-utils.js +60 -0
- package/dist.webgl-only/h3-layers/h3-utils.js.map +1 -0
- package/dist.webgl-only/index.cjs +23004 -0
- package/dist.webgl-only/index.cjs.map +6 -0
- package/dist.webgl-only/index.js +22 -0
- package/dist.webgl-only/index.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-fragment.glsl.js +34 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-fragment.glsl.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-uniforms.js +19 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-vertex.glsl.js +64 -0
- package/dist.webgl-only/mesh-layer/mesh-layer-vertex.glsl.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-layer.js +149 -0
- package/dist.webgl-only/mesh-layer/mesh-layer.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-layer.wgsl.js +5 -0
- package/dist.webgl-only/mesh-layer/mesh-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/mesh-layer/mesh-pbr-material.js +27 -0
- package/dist.webgl-only/mesh-layer/mesh-pbr-material.js.map +1 -0
- package/dist.webgl-only/mvt-layer/coordinate-transform.js +45 -0
- package/dist.webgl-only/mvt-layer/coordinate-transform.js.map +1 -0
- package/dist.webgl-only/mvt-layer/find-index-binary.js +100 -0
- package/dist.webgl-only/mvt-layer/find-index-binary.js.map +1 -0
- package/dist.webgl-only/mvt-layer/mvt-layer.js +315 -0
- package/dist.webgl-only/mvt-layer/mvt-layer.js.map +1 -0
- package/dist.webgl-only/quadkey-layer/quadkey-layer.js +27 -0
- package/dist.webgl-only/quadkey-layer/quadkey-layer.js.map +1 -0
- package/dist.webgl-only/quadkey-layer/quadkey-utils.js +30 -0
- package/dist.webgl-only/quadkey-layer/quadkey-utils.js.map +1 -0
- package/dist.webgl-only/s2-layer/s2-geometry.js +127 -0
- package/dist.webgl-only/s2-layer/s2-geometry.js.map +1 -0
- package/dist.webgl-only/s2-layer/s2-layer.js +24 -0
- package/dist.webgl-only/s2-layer/s2-layer.js.map +1 -0
- package/dist.webgl-only/s2-layer/s2-utils.js +91 -0
- package/dist.webgl-only/s2-layer/s2-utils.js.map +1 -0
- package/dist.webgl-only/terrain-layer/terrain-layer.js +260 -0
- package/dist.webgl-only/terrain-layer/terrain-layer.js.map +1 -0
- package/dist.webgl-only/tile-3d-layer/tile-3d-layer.js +343 -0
- package/dist.webgl-only/tile-3d-layer/tile-3d-layer.js.map +1 -0
- package/dist.webgl-only/tile-layer/tile-layer.js +233 -0
- package/dist.webgl-only/tile-layer/tile-layer.js.map +1 -0
- package/dist.webgl-only/tileset-2d/index.js +7 -0
- package/dist.webgl-only/tileset-2d/index.js.map +1 -0
- package/dist.webgl-only/tileset-2d/memoize.js +45 -0
- package/dist.webgl-only/tileset-2d/memoize.js.map +1 -0
- package/dist.webgl-only/tileset-2d/tile-2d-header.js +141 -0
- package/dist.webgl-only/tileset-2d/tile-2d-header.js.map +1 -0
- package/dist.webgl-only/tileset-2d/tile-2d-traversal.js +208 -0
- package/dist.webgl-only/tileset-2d/tile-2d-traversal.js.map +1 -0
- package/dist.webgl-only/tileset-2d/tileset-2d.js +557 -0
- package/dist.webgl-only/tileset-2d/tileset-2d.js.map +1 -0
- package/dist.webgl-only/tileset-2d/types.js +5 -0
- package/dist.webgl-only/tileset-2d/types.js.map +1 -0
- package/dist.webgl-only/tileset-2d/utils.js +246 -0
- package/dist.webgl-only/tileset-2d/utils.js.map +1 -0
- package/dist.webgl-only/trips-layer/trips-layer-uniforms.js +23 -0
- package/dist.webgl-only/trips-layer/trips-layer-uniforms.js.map +1 -0
- package/dist.webgl-only/trips-layer/trips-layer.js +97 -0
- package/dist.webgl-only/trips-layer/trips-layer.js.map +1 -0
- package/dist.webgl-only/trips-layer/trips-layer.wgsl.js +3 -0
- package/dist.webgl-only/trips-layer/trips-layer.wgsl.js.map +1 -0
- package/dist.webgl-only/wms-layer/utils.js +17 -0
- package/dist.webgl-only/wms-layer/utils.js.map +1 -0
- package/dist.webgl-only/wms-layer/wms-layer.js +198 -0
- package/dist.webgl-only/wms-layer/wms-layer.js.map +1 -0
- package/package.json +12 -7
- package/src/geo-cell-layer/GeoCellLayer.ts +2 -0
- package/src/mesh-layer/mesh-layer-uniforms.ts +9 -0
- package/src/mesh-layer/mesh-layer.ts +15 -6
- package/src/mesh-layer/mesh-layer.wgsl.ts +130 -0
- package/src/mesh-layer/mesh-pbr-material.ts +39 -0
- package/src/trips-layer/trips-layer-uniforms.ts +15 -3
- package/src/trips-layer/trips-layer.ts +84 -38
- package/src/trips-layer/trips-layer.wgsl.ts +63 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import type { PBRMaterialProps, PBRMaterialUniforms, ShaderModule } from '@luma.gl/shadertools';
|
|
2
|
+
export declare const meshPbrMaterial: {
|
|
3
|
+
readonly source: string;
|
|
4
|
+
readonly props: PBRMaterialProps;
|
|
5
|
+
readonly uniforms: PBRMaterialUniforms;
|
|
6
|
+
readonly defaultUniforms: Required<PBRMaterialUniforms>;
|
|
7
|
+
readonly name: "pbrMaterial";
|
|
8
|
+
readonly firstBindingSlot: 0;
|
|
9
|
+
readonly bindingLayout: readonly [{
|
|
10
|
+
readonly name: "pbrMaterial";
|
|
11
|
+
readonly group: 3;
|
|
12
|
+
}, {
|
|
13
|
+
readonly name: "pbr_baseColorSampler";
|
|
14
|
+
readonly group: 3;
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "pbr_normalSampler";
|
|
17
|
+
readonly group: 3;
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "pbr_emissiveSampler";
|
|
20
|
+
readonly group: 3;
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "pbr_metallicRoughnessSampler";
|
|
23
|
+
readonly group: 3;
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "pbr_occlusionSampler";
|
|
26
|
+
readonly group: 3;
|
|
27
|
+
}, {
|
|
28
|
+
readonly name: "pbr_specularColorSampler";
|
|
29
|
+
readonly group: 3;
|
|
30
|
+
}, {
|
|
31
|
+
readonly name: "pbr_specularIntensitySampler";
|
|
32
|
+
readonly group: 3;
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "pbr_transmissionSampler";
|
|
35
|
+
readonly group: 3;
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "pbr_thicknessSampler";
|
|
38
|
+
readonly group: 3;
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "pbr_clearcoatSampler";
|
|
41
|
+
readonly group: 3;
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "pbr_clearcoatRoughnessSampler";
|
|
44
|
+
readonly group: 3;
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "pbr_clearcoatNormalSampler";
|
|
47
|
+
readonly group: 3;
|
|
48
|
+
}, {
|
|
49
|
+
readonly name: "pbr_sheenColorSampler";
|
|
50
|
+
readonly group: 3;
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "pbr_sheenRoughnessSampler";
|
|
53
|
+
readonly group: 3;
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "pbr_iridescenceSampler";
|
|
56
|
+
readonly group: 3;
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "pbr_iridescenceThicknessSampler";
|
|
59
|
+
readonly group: 3;
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "pbr_anisotropySampler";
|
|
62
|
+
readonly group: 3;
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "pbr_bumpSampler";
|
|
65
|
+
readonly group: 3;
|
|
66
|
+
}, {
|
|
67
|
+
readonly name: "pbr_diffuseTransmissionSampler";
|
|
68
|
+
readonly group: 3;
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "pbr_diffuseTransmissionColorSampler";
|
|
71
|
+
readonly group: 3;
|
|
72
|
+
}, {
|
|
73
|
+
readonly name: "pbr_multiscatterColorSampler";
|
|
74
|
+
readonly group: 3;
|
|
75
|
+
}];
|
|
76
|
+
readonly dependencies: [{
|
|
77
|
+
readonly props: import("@luma.gl/shadertools").LightingProps;
|
|
78
|
+
readonly uniforms: import("@luma.gl/shadertools").LightingUniforms;
|
|
79
|
+
readonly name: "lighting";
|
|
80
|
+
readonly defines: {};
|
|
81
|
+
readonly uniformTypes: {
|
|
82
|
+
readonly enabled: "i32";
|
|
83
|
+
readonly directionalLightCount: "i32";
|
|
84
|
+
readonly pointLightCount: "i32";
|
|
85
|
+
readonly spotLightCount: "i32";
|
|
86
|
+
readonly ambientColor: "vec3<f32>";
|
|
87
|
+
readonly lights: readonly [{
|
|
88
|
+
readonly color: "vec3<f32>";
|
|
89
|
+
readonly position: "vec3<f32>";
|
|
90
|
+
readonly direction: "vec3<f32>";
|
|
91
|
+
readonly attenuation: "vec3<f32>";
|
|
92
|
+
readonly coneCos: "vec2<f32>";
|
|
93
|
+
}, 5];
|
|
94
|
+
};
|
|
95
|
+
readonly defaultUniforms: import("@luma.gl/shadertools").LightingUniforms;
|
|
96
|
+
readonly bindingLayout: readonly [{
|
|
97
|
+
readonly name: "lighting";
|
|
98
|
+
readonly group: 2;
|
|
99
|
+
}];
|
|
100
|
+
readonly firstBindingSlot: 0;
|
|
101
|
+
readonly source: "// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nconst MAX_LIGHTS: i32 = 5;\n\nstruct AmbientLight {\n color: vec3<f32>,\n};\n\nstruct PointLight {\n color: vec3<f32>,\n position: vec3<f32>,\n attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct DirectionalLight {\n color: vec3<f32>,\n direction: vec3<f32>,\n};\n\nstruct UniformLight {\n color: vec3<f32>,\n position: vec3<f32>,\n direction: vec3<f32>,\n attenuation: vec3<f32>,\n coneCos: vec2<f32>,\n};\n\nstruct lightingUniforms {\n enabled: i32,\n directionalLightCount: i32,\n pointLightCount: i32,\n spotLightCount: i32,\n ambientColor: vec3<f32>,\n lights: array<UniformLight, 5>,\n};\n\n@group(2) @binding(auto) var<uniform> lighting : lightingUniforms;\n\nfn lighting_getPointLight(index: i32) -> PointLight {\n let light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nfn lighting_getSpotLight(index: i32) -> SpotLight {\n let light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nfn lighting_getDirectionalLight(index: i32) -> DirectionalLight {\n let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {\n let lightDirection = normalize(positionWorldspace - spotLight.position);\n let coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), lightDirection)\n );\n let distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n";
|
|
102
|
+
readonly vs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nstruct UniformLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nlayout(std140) uniform lightingUniforms {\n int enabled;\n int directionalLightCount;\n int pointLightCount;\n int spotLightCount;\n vec3 ambientColor;\n UniformLight lights[5];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n UniformLight light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nSpotLight lighting_getSpotLight(int index) {\n UniformLight light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n UniformLight light =\n lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfloat getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {\n vec3 light_direction = normalize(positionWorldspace - spotLight.position);\n float coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), light_direction)\n );\n float distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n\n// #endif\n";
|
|
103
|
+
readonly fs: "precision highp int;\n\n// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential\n};\n\nstruct SpotLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nstruct UniformLight {\n vec3 color;\n vec3 position;\n vec3 direction;\n vec3 attenuation;\n vec2 coneCos;\n};\n\nlayout(std140) uniform lightingUniforms {\n int enabled;\n int directionalLightCount;\n int pointLightCount;\n int spotLightCount;\n vec3 ambientColor;\n UniformLight lights[5];\n} lighting;\n\nPointLight lighting_getPointLight(int index) {\n UniformLight light = lighting.lights[index];\n return PointLight(light.color, light.position, light.attenuation);\n}\n\nSpotLight lighting_getSpotLight(int index) {\n UniformLight light = lighting.lights[lighting.pointLightCount + index];\n return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);\n}\n\nDirectionalLight lighting_getDirectionalLight(int index) {\n UniformLight light =\n lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];\n return DirectionalLight(light.color, light.direction);\n}\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\nfloat getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {\n vec3 light_direction = normalize(positionWorldspace - spotLight.position);\n float coneFactor = smoothstep(\n spotLight.coneCos.y,\n spotLight.coneCos.x,\n dot(normalize(spotLight.direction), light_direction)\n );\n float distanceAttenuation = getPointLightAttenuation(\n PointLight(spotLight.color, spotLight.position, spotLight.attenuation),\n distance(spotLight.position, positionWorldspace)\n );\n return distanceAttenuation / max(coneFactor, 0.0001);\n}\n\n// #endif\n";
|
|
104
|
+
readonly getUniforms: (props?: import("@luma.gl/shadertools").LightingProps, _prevUniforms?: Partial<import("@luma.gl/shadertools").LightingUniforms>) => import("@luma.gl/shadertools").LightingUniforms;
|
|
105
|
+
}, {
|
|
106
|
+
readonly name: "ibl";
|
|
107
|
+
readonly firstBindingSlot: 32;
|
|
108
|
+
readonly bindingLayout: readonly [{
|
|
109
|
+
readonly name: "pbr_diffuseEnvSampler";
|
|
110
|
+
readonly group: 2;
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "pbr_specularEnvSampler";
|
|
113
|
+
readonly group: 2;
|
|
114
|
+
}, {
|
|
115
|
+
readonly name: "pbr_brdfLUT";
|
|
116
|
+
readonly group: 2;
|
|
117
|
+
}];
|
|
118
|
+
readonly source: "#ifdef USE_IBL\n@group(2) @binding(auto) var pbr_diffuseEnvSampler: texture_cube<f32>;\n@group(2) @binding(auto) var pbr_diffuseEnvSamplerSampler: sampler;\n@group(2) @binding(auto) var pbr_specularEnvSampler: texture_cube<f32>;\n@group(2) @binding(auto) var pbr_specularEnvSamplerSampler: sampler;\n@group(2) @binding(auto) var pbr_brdfLUT: texture_2d<f32>;\n@group(2) @binding(auto) var pbr_brdfLUTSampler: sampler;\n#endif\n";
|
|
119
|
+
readonly vs: "#ifdef USE_IBL\nuniform samplerCube pbr_diffuseEnvSampler;\nuniform samplerCube pbr_specularEnvSampler;\nuniform sampler2D pbr_brdfLUT;\n#endif\n";
|
|
120
|
+
readonly fs: "#ifdef USE_IBL\nuniform samplerCube pbr_diffuseEnvSampler;\nuniform samplerCube pbr_specularEnvSampler;\nuniform sampler2D pbr_brdfLUT;\n#endif\n";
|
|
121
|
+
}, ShaderModule<import("@luma.gl/shadertools").PBRProjectionProps>];
|
|
122
|
+
readonly vs: "out vec3 pbr_vPosition;\nout vec2 pbr_vUV0;\nout vec2 pbr_vUV1;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nout mat3 pbr_vTBN;\n# else\nout vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(\n vec4 position,\n vec4 normal,\n vec4 tangent,\n vec2 uv0,\n vec2 uv1\n)\n{\n vec4 pos = pbrProjection.modelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else // HAS_TANGENTS != 1\n pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV0 = uv0;\n#else\n pbr_vUV0 = vec2(0.,0.);\n#endif\n\n pbr_vUV1 = uv1;\n}\n";
|
|
123
|
+
readonly fs: "precision highp float;\n\nlayout(std140) uniform pbrMaterialUniforms {\n // Material is unlit\n bool unlit;\n\n // Base color map\n bool baseColorMapEnabled;\n vec4 baseColorFactor;\n\n bool normalMapEnabled; \n float normalScale; // #ifdef HAS_NORMALMAP\n\n bool emissiveMapEnabled;\n vec3 emissiveFactor; // #ifdef HAS_EMISSIVEMAP\n\n vec2 metallicRoughnessValues;\n bool metallicRoughnessMapEnabled;\n\n bool occlusionMapEnabled;\n float occlusionStrength; // #ifdef HAS_OCCLUSIONMAP\n \n bool alphaCutoffEnabled;\n float alphaCutoff; // #ifdef ALPHA_CUTOFF\n\n vec3 specularColorFactor;\n float specularIntensityFactor;\n bool specularColorMapEnabled;\n bool specularIntensityMapEnabled;\n\n float ior;\n\n float transmissionFactor;\n bool transmissionMapEnabled;\n\n float thicknessFactor;\n float attenuationDistance;\n vec3 attenuationColor;\n\n float clearcoatFactor;\n float clearcoatRoughnessFactor;\n bool clearcoatMapEnabled;\n bool clearcoatRoughnessMapEnabled;\n\n vec3 sheenColorFactor;\n float sheenRoughnessFactor;\n bool sheenColorMapEnabled;\n bool sheenRoughnessMapEnabled;\n\n float iridescenceFactor;\n float iridescenceIor;\n vec2 iridescenceThicknessRange;\n bool iridescenceMapEnabled;\n\n float anisotropyStrength;\n float anisotropyRotation;\n vec2 anisotropyDirection;\n bool anisotropyMapEnabled;\n\n float emissiveStrength;\n float dispersion;\n \n // IBL\n bool IBLenabled;\n vec2 scaleIBLAmbient; // #ifdef USE_IBL\n \n // debugging flags used for shader output of intermediate PBR variables\n // #ifdef PBR_DEBUG\n vec4 scaleDiffBaseMR;\n vec4 scaleFGDSpec;\n // #endif\n\n int baseColorUVSet;\n mat3 baseColorUVTransform;\n int metallicRoughnessUVSet;\n mat3 metallicRoughnessUVTransform;\n int normalUVSet;\n mat3 normalUVTransform;\n int occlusionUVSet;\n mat3 occlusionUVTransform;\n int emissiveUVSet;\n mat3 emissiveUVTransform;\n int specularColorUVSet;\n mat3 specularColorUVTransform;\n int specularIntensityUVSet;\n mat3 specularIntensityUVTransform;\n int transmissionUVSet;\n mat3 transmissionUVTransform;\n int thicknessUVSet;\n mat3 thicknessUVTransform;\n int clearcoatUVSet;\n mat3 clearcoatUVTransform;\n int clearcoatRoughnessUVSet;\n mat3 clearcoatRoughnessUVTransform;\n int clearcoatNormalUVSet;\n mat3 clearcoatNormalUVTransform;\n int sheenColorUVSet;\n mat3 sheenColorUVTransform;\n int sheenRoughnessUVSet;\n mat3 sheenRoughnessUVTransform;\n int iridescenceUVSet;\n mat3 iridescenceUVTransform;\n int iridescenceThicknessUVSet;\n mat3 iridescenceThicknessUVTransform;\n int anisotropyUVSet;\n mat3 anisotropyUVTransform;\n\n float bumpFactor;\n bool bumpMapEnabled;\n float diffuseTransmissionFactor;\n bool diffuseTransmissionMapEnabled;\n vec3 diffuseTransmissionColorFactor;\n bool diffuseTransmissionColorMapEnabled;\n vec3 multiscatterColorFactor;\n bool multiscatterColorMapEnabled;\n float scatterAnisotropy;\n\n int bumpUVSet;\n mat3 bumpUVTransform;\n int diffuseTransmissionUVSet;\n mat3 diffuseTransmissionUVTransform;\n int diffuseTransmissionColorUVSet;\n mat3 diffuseTransmissionColorUVTransform;\n int multiscatterColorUVSet;\n mat3 multiscatterColorUVTransform;\n} pbrMaterial;\n\n// Samplers\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D pbr_baseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D pbr_normalSampler;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D pbr_emissiveSampler;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D pbr_metallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D pbr_occlusionSampler;\n#endif\n#ifdef HAS_SPECULARCOLORMAP\nuniform sampler2D pbr_specularColorSampler;\n#endif\n#ifdef HAS_SPECULARINTENSITYMAP\nuniform sampler2D pbr_specularIntensitySampler;\n#endif\n#ifdef HAS_TRANSMISSIONMAP\nuniform sampler2D pbr_transmissionSampler;\n#endif\n#ifdef HAS_THICKNESSMAP\nuniform sampler2D pbr_thicknessSampler;\n#endif\n#ifdef HAS_CLEARCOATMAP\nuniform sampler2D pbr_clearcoatSampler;\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSMAP\nuniform sampler2D pbr_clearcoatRoughnessSampler;\n#endif\n#ifdef HAS_CLEARCOATNORMALMAP\nuniform sampler2D pbr_clearcoatNormalSampler;\n#endif\n#ifdef HAS_SHEENCOLORMAP\nuniform sampler2D pbr_sheenColorSampler;\n#endif\n#ifdef HAS_SHEENROUGHNESSMAP\nuniform sampler2D pbr_sheenRoughnessSampler;\n#endif\n#ifdef HAS_IRIDESCENCEMAP\nuniform sampler2D pbr_iridescenceSampler;\n#endif\n#ifdef HAS_IRIDESCENCETHICKNESSMAP\nuniform sampler2D pbr_iridescenceThicknessSampler;\n#endif\n#ifdef HAS_ANISOTROPYMAP\nuniform sampler2D pbr_anisotropySampler;\n#endif\n#ifdef HAS_BUMPMAP\nuniform sampler2D pbr_bumpSampler;\n#endif\n#ifdef HAS_DIFFUSETRANSMISSIONMAP\nuniform sampler2D pbr_diffuseTransmissionSampler;\n#endif\n#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP\nuniform sampler2D pbr_diffuseTransmissionColorSampler;\n#endif\n#ifdef HAS_MULTISCATTERCOLORMAP\nuniform sampler2D pbr_multiscatterColorSampler;\n#endif\n// Inputs from vertex shader\n\nin vec3 pbr_vPosition;\nin vec2 pbr_vUV0;\nin vec2 pbr_vUV1;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nin mat3 pbr_vTBN;\n#else\nin vec3 pbr_vNormal;\n#endif\n#endif\n\n// Encapsulate the various inputs used by the various functions in the shading equation\n// We store values in this struct to simplify the integration of alternative implementations\n// of the shading terms, outlined in the Readme.MD Appendix.\nstruct PBRInfo {\n float NdotL; // cos angle between normal and light direction\n float NdotV; // cos angle between normal and view direction\n float NdotH; // cos angle between normal and half vector\n float LdotH; // cos angle between light direction and half vector\n float VdotH; // cos angle between view direction and half vector\n float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)\n float metalness; // metallic value at the surface\n vec3 reflectance0; // full reflectance color (normal incidence angle)\n vec3 reflectance90; // reflectance color at grazing angle\n float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])\n vec3 diffuseColor; // color contribution from diffuse lighting\n vec3 specularColor; // color contribution from specular lighting\n vec3 n; // normal at surface point\n vec3 v; // vector from surface point to camera\n vec3 l; // direction from the surface toward the current light\n vec3 h; // half vector between the current light and camera\n};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\n\n// Widen sub-pixel specular lobes using the screen-space normal footprint.\n// This is geometric specular antialiasing: the normal variance is converted\n// into an additional squared perceptual roughness before evaluating BRDFs.\nfloat widenSpecularRoughness(float perceptualRoughness, vec3 normal)\n{\n vec3 normalDerivativeX = dFdx(normal);\n vec3 normalDerivativeY = dFdy(normal);\n float normalVariance =\n dot(normalDerivativeX, normalDerivativeX) +\n dot(normalDerivativeY, normalDerivativeY);\n float kernelRoughnessSquared = min(2.0 * normalVariance, 1.0);\n return clamp(\n sqrt(perceptualRoughness * perceptualRoughness + kernelRoughnessSquared),\n c_MinRoughness,\n 1.0\n );\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor);\n\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\n vec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else // SRGB_FAST_APPROXIMATION\n vec3 bLess = step(vec3(0.04045),srgbIn.xyz);\n vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif //SRGB_FAST_APPROXIMATION\n return vec4(linOut,srgbIn.w);;\n#else //MANUAL_SRGB\n return srgbIn;\n#endif //MANUAL_SRGB\n}\n\nvec2 getMaterialUV(int uvSet, mat3 uvTransform)\n{\n vec2 baseUV = uvSet == 1 ? pbr_vUV1 : pbr_vUV0;\n return (uvTransform * vec3(baseUV, 1.0)).xy;\n}\n\n// Build the tangent basis from interpolated attributes or screen-space derivatives.\nmat3 getTBN(vec2 uv)\n{\n#ifndef HAS_TANGENTS\n vec3 pos_dx = dFdx(pbr_vPosition);\n vec3 pos_dy = dFdy(pbr_vPosition);\n vec3 tex_dx = dFdx(vec3(uv, 0.0));\n vec3 tex_dy = dFdy(vec3(uv, 0.0));\n vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n\n#ifdef HAS_NORMALS\n vec3 ng = normalize(pbr_vNormal);\n#else\n vec3 ng = cross(pos_dx, pos_dy);\n#endif\n\n t = normalize(t - ng * dot(ng, t));\n vec3 b = normalize(cross(ng, t));\n mat3 tbn = mat3(t, b, ng);\n#else // HAS_TANGENTS\n mat3 tbn = pbr_vTBN;\n#endif\n\n return tbn;\n}\n\n// Find the normal for this fragment, pulling either from a predefined normal map\n// or from the interpolated mesh normal and tangent attributes.\nvec3 getMappedNormal(sampler2D normalSampler, mat3 tbn, float normalScale, vec2 uv)\n{\n vec3 n = texture(normalSampler, uv).rgb;\n return normalize(tbn * ((2.0 * n - 1.0) * vec3(normalScale, normalScale, 1.0)));\n}\n\nvec3 getNormal(mat3 tbn, vec2 uv)\n{\n#ifdef HAS_NORMALMAP\n vec3 n = getMappedNormal(pbr_normalSampler, tbn, pbrMaterial.normalScale, uv);\n#else\n // The tbn matrix is linearly interpolated, so we need to re-normalize\n vec3 n = normalize(tbn[2].xyz);\n#endif\n\n#ifdef HAS_BUMPMAP\n vec2 bumpUV = getMaterialUV(pbrMaterial.bumpUVSet, pbrMaterial.bumpUVTransform);\n vec2 bumpTexelSize = 1.0 / vec2(textureSize(pbr_bumpSampler, 0));\n float bumpHeight = texture(pbr_bumpSampler, bumpUV).r;\n vec2 bumpGradient = vec2(\n texture(pbr_bumpSampler, bumpUV + vec2(bumpTexelSize.x, 0.0)).r - bumpHeight,\n texture(pbr_bumpSampler, bumpUV + vec2(0.0, bumpTexelSize.y)).r - bumpHeight\n );\n n = normalize(n - pbrMaterial.bumpFactor *\n (tbn[0] * bumpGradient.x + tbn[1] * bumpGradient.y));\n#endif\n\n return n;\n}\n\nvec3 getClearcoatNormal(mat3 tbn, vec3 baseNormal, vec2 uv)\n{\n#ifdef HAS_CLEARCOATNORMALMAP\n return getMappedNormal(pbr_clearcoatNormalSampler, tbn, 1.0, uv);\n#else\n return baseNormal;\n#endif\n}\n\n// Calculation of the lighting contribution from an optional Image Based Light source.\n// Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].\n// See our README.md on Environment Maps [3] for additional discussion.\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)\n{\n#ifdef USE_SCENE_ENVIRONMENT\n float maximumMipLevel = max(pbrScene.environmentMipCount - 1.0, 0.0);\n float rotationSine = sin(pbrScene.environmentRotation);\n float rotationCosine = cos(pbrScene.environmentRotation);\n mat2 environmentRotation = mat2(rotationCosine, rotationSine, -rotationSine, rotationCosine);\n vec3 environmentNormal = vec3(environmentRotation * n.xz, n.y).xzy;\n vec3 environmentReflection = vec3(environmentRotation * reflection.xz, reflection.y).xzy;\n#else\n float maximumMipLevel = 9.0;\n vec3 environmentNormal = n;\n vec3 environmentReflection = reflection;\n#endif\n float lod = pbrInfo.perceptualRoughness * maximumMipLevel;\n // retrieve a scale and bias to F0. See [1], Figure 3\n vec4 brdfSample = texture(pbr_brdfLUT,\n vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness));\n vec4 diffuseSample = texture(pbr_diffuseEnvSampler, environmentNormal);\n\n#ifdef USE_TEX_LOD\n vec4 specularSample = textureLod(pbr_specularEnvSampler, environmentReflection, lod);\n#else\n vec4 specularSample = texture(pbr_specularEnvSampler, environmentReflection);\n#endif\n\n#ifdef USE_SCENE_ENVIRONMENT\n vec3 brdf = brdfSample.rgb;\n vec3 diffuseLight = diffuseSample.rgb;\n vec3 specularLight = specularSample.rgb;\n#else\n vec3 brdf = SRGBtoLINEAR(brdfSample).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(diffuseSample).rgb;\n vec3 specularLight = SRGBtoLINEAR(specularSample).rgb;\n#endif\n\n vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;\n vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);\n\n // For presentation, this allows us to disable IBL terms\n diffuse *= pbrMaterial.scaleIBLAmbient.x;\n specular *= pbrMaterial.scaleIBLAmbient.y;\n\n#ifdef USE_SCENE_ENVIRONMENT\n return (diffuse + specular) * max(pbrScene.environmentIntensity, 0.0);\n#else\n return diffuse + specular;\n#endif\n}\n#endif\n\n// Basic Lambertian diffuse\n// Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog\n// See also [1], Equation 1\nvec3 diffuse(PBRInfo pbrInfo)\n{\n return pbrInfo.diffuseColor / M_PI;\n}\n\n// The following equation models the Fresnel reflectance term of the spec equation (aka F())\n// Implementation of fresnel from [4], Equation 15\nvec3 specularReflection(PBRInfo pbrInfo)\n{\n return pbrInfo.reflectance0 +\n (pbrInfo.reflectance90 - pbrInfo.reflectance0) *\n pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);\n}\n\n// This calculates the specular geometric attenuation (aka G()),\n// where rougher material will reflect less light back to the viewer.\n// This implementation is based on [1] Equation 4, and we adopt their modifications to\n// alphaRoughness as input as originally proposed in [2].\nfloat geometricOcclusion(PBRInfo pbrInfo)\n{\n float NdotL = pbrInfo.NdotL;\n float NdotV = pbrInfo.NdotV;\n float r = pbrInfo.alphaRoughness;\n\n float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\n float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\n return attenuationL * attenuationV;\n}\n\n// The following equation(s) model the distribution of microfacet normals across\n// the area being drawn (aka D())\n// Implementation from \"Average Irregularity Representation of a Roughened Surface\n// for Ray Reflection\" by T. S. Trowbridge, and K. P. Reitz\n// Follows the distribution function recommended in the SIGGRAPH 2013 course notes\n// from EPIC Games [1], Equation 3.\nfloat microfacetDistribution(PBRInfo pbrInfo)\n{\n float roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;\n float f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nfloat maxComponent(vec3 value)\n{\n return max(max(value.r, value.g), value.b);\n}\n\nfloat getDielectricF0(float ior)\n{\n float clampedIor = max(ior, 1.0);\n float ratio = (clampedIor - 1.0) / (clampedIor + 1.0);\n return ratio * ratio;\n}\n\nvec2 normalizeDirection(vec2 direction)\n{\n float directionLength = length(direction);\n return directionLength > 0.0001 ? direction / directionLength : vec2(1.0, 0.0);\n}\n\nvec2 rotateDirection(vec2 direction, float rotation)\n{\n float s = sin(rotation);\n float c = cos(rotation);\n return vec2(direction.x * c - direction.y * s, direction.x * s + direction.y * c);\n}\n\nvec3 encodeLinearSRGB(vec3 linearColor)\n{\n vec3 positiveColor = max(linearColor, vec3(0.0));\n return mix(\n positiveColor * 12.92,\n 1.055 * pow(positiveColor, vec3(1.0 / 2.4)) - 0.055,\n greaterThan(positiveColor, vec3(0.0031308))\n );\n}\n\nvec3 toneMapKhronosPBRNeutral(vec3 color)\n{\n const float startCompression = 0.76;\n float darkestChannel = min(color.r, min(color.g, color.b));\n float offset = darkestChannel < 0.08\n ? darkestChannel - 6.25 * darkestChannel * darkestChannel\n : 0.04;\n color -= vec3(offset);\n\n float peak = maxComponent(color);\n if (peak < startCompression) {\n return color;\n }\n\n float compressionRange = 1.0 - startCompression;\n float compressedPeak = 1.0 - compressionRange * compressionRange /\n (peak + compressionRange - startCompression);\n color *= compressedPeak / max(peak, 0.0001);\n float desaturation = 1.0 - 1.0 / (0.15 * (peak - compressedPeak) + 1.0);\n return mix(color, vec3(compressedPeak), desaturation);\n}\n\nvec3 applySceneColorManagement(vec3 sceneColor)\n{\n#ifdef USE_SCENE_COLOR_MANAGEMENT\n vec3 color = max(sceneColor, vec3(0.0)) * max(pbrScene.exposure, 0.0);\n if (pbrScene.toneMapMode == 1) {\n color /= vec3(1.0) + color;\n } else if (pbrScene.toneMapMode == 2) {\n color = toneMapKhronosPBRNeutral(color);\n } else if (pbrScene.toneMapMode == 3) {\n color = clamp(\n (color * (2.51 * color + 0.03)) / (color * (2.43 * color + 0.59) + 0.14),\n vec3(0.0),\n vec3(1.0)\n );\n }\n return pbrScene.outputEncoding == 0 ? color : encodeLinearSRGB(color);\n#else\n return pow(max(sceneColor, vec3(0.0)), vec3(1.0 / 2.2));\n#endif\n}\n\nfloat dielectricSchlick(float reflectance, float cosine)\n{\n return reflectance + (1.0 - reflectance) * pow(clamp(1.0 - cosine, 0.0, 1.0), 5.0);\n}\n\nvec3 evaluateIridescenceSensitivity(float opticalPathDifference, vec3 phaseShift)\n{\n float phase = 2.0 * M_PI * opticalPathDifference * 1.0e-9;\n vec3 sensitivity = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);\n vec3 position = vec3(1.6810e6, 1.7953e6, 2.2084e6);\n vec3 variance = vec3(4.3278e9, 9.3046e9, 6.6121e9);\n vec3 xyz = sensitivity * sqrt(2.0 * M_PI * variance) *\n cos(position * phase + phaseShift) * exp(-phase * phase * variance);\n xyz.x += 9.7470e-14 * sqrt(2.0 * M_PI * 4.5282e9) *\n cos(2.2399e6 * phase + phaseShift.x) * exp(-4.5282e9 * phase * phase);\n xyz /= 1.0685e-7;\n return mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n ) * xyz;\n}\n\nvec3 getIridescenceTint(float iridescence, float thickness, float NdotV, vec3 baseReflectance)\n{\n if (iridescence <= 0.0 || thickness <= 0.0) {\n return baseReflectance;\n }\n\n float filmIor = max(pbrMaterial.iridescenceIor, 1.0);\n float sineSquared = (1.0 - NdotV * NdotV) / (filmIor * filmIor);\n float cosineSquared = 1.0 - sineSquared;\n if (cosineSquared <= 0.0) {\n return mix(baseReflectance, vec3(1.0), iridescence);\n }\n float filmCosine = sqrt(cosineSquared);\n float firstInterfaceReflectance = dielectricSchlick(getDielectricF0(filmIor), NdotV);\n float transmittedEnergy = 1.0 - firstInterfaceReflectance;\n\n vec3 baseIor = (vec3(1.0) + sqrt(clamp(baseReflectance, vec3(0.0), vec3(0.9999)))) /\n (vec3(1.0) - sqrt(clamp(baseReflectance, vec3(0.0), vec3(0.9999))));\n vec3 secondInterfaceF0 = (baseIor - vec3(filmIor)) / (baseIor + vec3(filmIor));\n secondInterfaceF0 *= secondInterfaceF0;\n vec3 secondInterfaceReflectance = secondInterfaceF0 +\n (vec3(1.0) - secondInterfaceF0) * pow(1.0 - filmCosine, 5.0);\n vec3 phaseShift = vec3(M_PI);\n phaseShift += mix(vec3(0.0), vec3(M_PI), lessThan(baseIor, vec3(filmIor)));\n float opticalPathDifference = 2.0 * filmIor * thickness * filmCosine;\n vec3 combinedReflectance = clamp(\n firstInterfaceReflectance * secondInterfaceReflectance,\n vec3(0.00001),\n vec3(0.9999)\n );\n vec3 recurringAmplitude = sqrt(combinedReflectance);\n vec3 interfaceResponse = transmittedEnergy * transmittedEnergy * secondInterfaceReflectance /\n (vec3(1.0) - combinedReflectance);\n vec3 reflectedSpectrum = vec3(firstInterfaceReflectance) + interfaceResponse;\n vec3 harmonicAmplitude = interfaceResponse - vec3(transmittedEnergy);\n for (int harmonic = 1; harmonic <= 2; harmonic++) {\n harmonicAmplitude *= recurringAmplitude;\n reflectedSpectrum += harmonicAmplitude * 2.0 * evaluateIridescenceSensitivity(\n float(harmonic) * opticalPathDifference,\n float(harmonic) * phaseShift\n );\n }\n return mix(baseReflectance, clamp(reflectedSpectrum, vec3(0.0), vec3(1.0)), iridescence);\n}\n\nvec3 getVolumeAttenuation(float thickness)\n{\n if (thickness <= 0.0) {\n return vec3(1.0);\n }\n\n vec3 attenuationCoefficient =\n -log(max(pbrMaterial.attenuationColor, vec3(0.0001))) /\n max(pbrMaterial.attenuationDistance, 0.0001);\n return exp(-attenuationCoefficient * thickness);\n}\n\n// KHR_materials_volume_scatter is an active draft. This evaluates a local,\n// thickness-aware single-scattering approximation rather than random walk.\nvec3 getDiffuseTransmissionAttenuation(\n PBRInfo pbrInfo,\n vec3 multiscatterColor,\n float thickness\n)\n{\n vec3 volumeAttenuation = getVolumeAttenuation(thickness);\n float scatteringStrength = maxComponent(multiscatterColor);\n if (thickness <= 0.0 || scatteringStrength <= 0.0001) {\n return volumeAttenuation;\n }\n\n float anisotropy = clamp(pbrMaterial.scatterAnisotropy, -0.95, 0.95);\n float scatteringCosine = clamp(dot(-pbrInfo.v, pbrInfo.l), -1.0, 1.0);\n float phaseDenominator = max(\n 1.0 + anisotropy * anisotropy - 2.0 * anisotropy * scatteringCosine,\n 0.0001\n );\n float phaseWeight = clamp(\n (1.0 - anisotropy * anisotropy) / pow(phaseDenominator, 1.5),\n 0.0,\n 4.0\n );\n float scatteringDepth = thickness / max(pbrMaterial.attenuationDistance, 0.0001);\n float scatteringProbability = 1.0 - exp(-scatteringDepth);\n vec3 scatteringColor = clamp(multiscatterColor, vec3(0.0), vec3(1.0));\n return mix(\n volumeAttenuation,\n volumeAttenuation * mix(vec3(1.0), scatteringColor * phaseWeight, scatteringColor),\n scatteringProbability\n );\n}\n\nvec3 calculateDiffuseTransmissionLight(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 diffuseTransmissionColor,\n float diffuseTransmission,\n vec3 multiscatterColor,\n float thickness\n)\n{\n float oppositeHemisphere = max(dot(-pbrInfo.n, pbrInfo.l), 0.0);\n if (oppositeHemisphere <= 0.0 || diffuseTransmission <= 0.0) {\n return vec3(0.0);\n }\n\n vec3 nonReflectedEnergy = vec3(1.0) - clamp(pbrInfo.reflectance0, vec3(0.0), vec3(1.0));\n vec3 attenuatedColor = getDiffuseTransmissionAttenuation(\n pbrInfo,\n multiscatterColor,\n thickness\n );\n return lightColor * diffuseTransmissionColor * nonReflectedEnergy *\n attenuatedColor * (diffuseTransmission * oppositeHemisphere / M_PI);\n}\n\n#ifdef USE_IBL\nvec3 calculateDiffuseTransmissionIBL(\n PBRInfo pbrInfo,\n vec3 diffuseTransmissionColor,\n float diffuseTransmission,\n vec3 multiscatterColor,\n float thickness\n)\n{\n if (diffuseTransmission <= 0.0) {\n return vec3(0.0);\n }\n\n#ifdef USE_SCENE_ENVIRONMENT\n float rotationSine = sin(pbrScene.environmentRotation);\n float rotationCosine = cos(pbrScene.environmentRotation);\n mat2 environmentRotation = mat2(rotationCosine, rotationSine, -rotationSine, rotationCosine);\n vec3 oppositeNormal = vec3(environmentRotation * -pbrInfo.n.xz, -pbrInfo.n.y).xzy;\n vec3 environmentColor = texture(pbr_diffuseEnvSampler, oppositeNormal).rgb *\n max(pbrScene.environmentIntensity, 0.0);\n#else\n vec3 environmentColor = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, -pbrInfo.n)).rgb;\n#endif\n vec3 nonReflectedEnergy = vec3(1.0) - clamp(pbrInfo.reflectance0, vec3(0.0), vec3(1.0));\n return environmentColor * diffuseTransmissionColor * nonReflectedEnergy *\n getDiffuseTransmissionAttenuation(pbrInfo, multiscatterColor, thickness) *\n diffuseTransmission * pbrMaterial.scaleIBLAmbient.x;\n}\n#endif\n\n#ifdef USE_TRANSMISSION_FRAMEBUFFER\nvec3 sampleTransmittedSceneColor(\n vec3 position,\n vec3 normal,\n vec3 viewDirection,\n float thickness,\n float perceptualRoughness,\n float indexOfRefraction\n)\n{\n vec3 refractionDirection = refract(\n -viewDirection,\n normal,\n 1.0 / max(indexOfRefraction, 1.0)\n );\n vec3 refractedPosition = position + refractionDirection * thickness;\n vec4 clipPosition = pbrScene.projectionMatrix *\n pbrScene.viewMatrix * vec4(refractedPosition, 1.0);\n vec2 textureCoordinate = clipPosition.xy / max(clipPosition.w, 0.0001) * 0.5 + 0.5;\n textureCoordinate = clamp(textureCoordinate, vec2(0.001), vec2(0.999));\n\n vec2 blurRadius = perceptualRoughness * perceptualRoughness * 8.0 /\n max(pbrScene.framebufferSize, vec2(1.0));\n vec3 sceneColor = texture(pbr_transmissionFramebufferSampler, textureCoordinate).rgb * 0.4;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate + vec2(blurRadius.x, 0.0)\n ).rgb * 0.15;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate - vec2(blurRadius.x, 0.0)\n ).rgb * 0.15;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate + vec2(0.0, blurRadius.y)\n ).rgb * 0.15;\n sceneColor += texture(\n pbr_transmissionFramebufferSampler,\n textureCoordinate - vec2(0.0, blurRadius.y)\n ).rgb * 0.15;\n return max(sceneColor, vec3(0.0));\n}\n\nvec3 getTransmittedSceneColor(\n vec3 position,\n vec3 normal,\n vec3 viewDirection,\n float thickness,\n float perceptualRoughness\n)\n{\n if (pbrMaterial.dispersion <= 0.0) {\n return sampleTransmittedSceneColor(\n position,\n normal,\n viewDirection,\n thickness,\n perceptualRoughness,\n pbrMaterial.ior\n );\n }\n\n float halfSpread = (max(pbrMaterial.ior, 1.0) - 1.0) * 0.025 * pbrMaterial.dispersion;\n vec3 indicesOfRefraction = max(\n vec3(pbrMaterial.ior - halfSpread, pbrMaterial.ior, pbrMaterial.ior + halfSpread),\n vec3(1.0)\n );\n return vec3(\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.r\n ).r,\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.g\n ).g,\n sampleTransmittedSceneColor(\n position, normal, viewDirection, thickness, perceptualRoughness, indicesOfRefraction.b\n ).b\n );\n}\n#endif\n\nPBRInfo createClearcoatPBRInfo(PBRInfo basePBRInfo, vec3 clearcoatNormal, float clearcoatRoughness)\n{\n float perceptualRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n float NdotV = clamp(abs(dot(clearcoatNormal, basePBRInfo.v)), 0.001, 1.0);\n\n return PBRInfo(\n basePBRInfo.NdotL,\n NdotV,\n basePBRInfo.NdotH,\n basePBRInfo.LdotH,\n basePBRInfo.VdotH,\n perceptualRoughness,\n 0.0,\n vec3(0.04),\n vec3(1.0),\n alphaRoughness,\n vec3(0.0),\n vec3(0.04),\n clearcoatNormal,\n basePBRInfo.v,\n basePBRInfo.l,\n basePBRInfo.h\n );\n}\n\nvec3 calculateClearcoatContribution(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 clearcoatNormal,\n float clearcoatFactor,\n float clearcoatRoughness\n) {\n if (clearcoatFactor <= 0.0) {\n return vec3(0.0);\n }\n\n PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);\n return calculateFinalColor(clearcoatPBRInfo, lightColor) * clearcoatFactor;\n}\n\n#ifdef USE_IBL\nvec3 calculateClearcoatIBLContribution(\n PBRInfo pbrInfo,\n vec3 clearcoatNormal,\n vec3 reflection,\n float clearcoatFactor,\n float clearcoatRoughness\n) {\n if (clearcoatFactor <= 0.0) {\n return vec3(0.0);\n }\n\n PBRInfo clearcoatPBRInfo = createClearcoatPBRInfo(pbrInfo, clearcoatNormal, clearcoatRoughness);\n return getIBLContribution(clearcoatPBRInfo, clearcoatNormal, reflection) * clearcoatFactor;\n}\n#endif\n\nvec3 calculateSheenContribution(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 sheenColor,\n float sheenRoughness\n) {\n if (maxComponent(sheenColor) <= 0.0) {\n return vec3(0.0);\n }\n\n float alpha = max(sheenRoughness * sheenRoughness, 0.0001);\n float inverseAlpha = 1.0 / alpha;\n float sineSquared = max(1.0 - pbrInfo.NdotH * pbrInfo.NdotH, 0.0);\n float distribution = (2.0 + inverseAlpha) * pow(sineSquared, inverseAlpha * 0.5) /\n (2.0 * M_PI);\n float visibility = 1.0 / max(\n 4.0 * (pbrInfo.NdotL + pbrInfo.NdotV - pbrInfo.NdotL * pbrInfo.NdotV),\n 0.0001\n );\n return pbrInfo.NdotL * lightColor * sheenColor * distribution * visibility *\n (1.0 - pbrInfo.metalness);\n}\n\nvec3 calculateAnisotropicLightColor(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 anisotropyTangent,\n float anisotropyStrength\n) {\n if (anisotropyStrength <= 0.0) {\n return calculateFinalColor(pbrInfo, lightColor);\n }\n\n vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n float tangentRoughness = mix(\n pbrInfo.alphaRoughness,\n 1.0,\n anisotropyStrength * anisotropyStrength\n );\n float bitangentRoughness = clamp(pbrInfo.alphaRoughness, 0.001, 1.0);\n float roughnessProduct = tangentRoughness * bitangentRoughness;\n vec3 distributionVector = vec3(\n bitangentRoughness * dot(anisotropyTangent, pbrInfo.h),\n tangentRoughness * dot(anisotropyBitangent, pbrInfo.h),\n roughnessProduct * pbrInfo.NdotH\n );\n float distributionFactor = roughnessProduct /\n max(dot(distributionVector, distributionVector), 0.000001);\n float distribution = roughnessProduct * distributionFactor * distributionFactor / M_PI;\n float viewMask = pbrInfo.NdotL * length(vec3(\n tangentRoughness * dot(anisotropyTangent, pbrInfo.v),\n bitangentRoughness * dot(anisotropyBitangent, pbrInfo.v),\n pbrInfo.NdotV\n ));\n float lightMask = pbrInfo.NdotV * length(vec3(\n tangentRoughness * dot(anisotropyTangent, pbrInfo.l),\n bitangentRoughness * dot(anisotropyBitangent, pbrInfo.l),\n pbrInfo.NdotL\n ));\n float visibility = clamp(0.5 / max(viewMask + lightMask, 0.000001), 0.0, 1.0);\n vec3 fresnel = specularReflection(pbrInfo);\n vec3 diffuseContribution = (vec3(1.0) - fresnel) * diffuse(pbrInfo);\n return pbrInfo.NdotL * lightColor *\n (diffuseContribution + fresnel * distribution * visibility);\n}\n\nvec3 getAnisotropicReflection(PBRInfo pbrInfo, vec3 anisotropyTangent, float anisotropyStrength)\n{\n if (anisotropyStrength <= 0.0) {\n return -normalize(reflect(pbrInfo.v, pbrInfo.n));\n }\n vec3 anisotropyBitangent = normalize(cross(pbrInfo.n, anisotropyTangent));\n vec3 anisotropicNormal = normalize(cross(anisotropyBitangent, pbrInfo.v));\n anisotropicNormal = normalize(cross(anisotropicNormal, anisotropyBitangent));\n float bend = anisotropyStrength * (1.0 - pbrInfo.perceptualRoughness);\n return -normalize(reflect(pbrInfo.v, normalize(mix(pbrInfo.n, anisotropicNormal, bend))));\n}\n\nvec3 calculateMaterialLightColor(\n PBRInfo pbrInfo,\n vec3 lightColor,\n vec3 clearcoatNormal,\n float clearcoatFactor,\n float clearcoatRoughness,\n vec3 sheenColor,\n float sheenRoughness,\n vec3 anisotropyTangent,\n float anisotropyStrength\n) {\n vec3 color = calculateAnisotropicLightColor(\n pbrInfo,\n lightColor,\n anisotropyTangent,\n anisotropyStrength\n );\n color += calculateClearcoatContribution(\n pbrInfo,\n lightColor,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness\n );\n color += calculateSheenContribution(pbrInfo, lightColor, sheenColor, sheenRoughness);\n return color;\n}\n\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) {\n pbrInfo.NdotL = 1.0;\n pbrInfo.NdotH = 0.0;\n pbrInfo.LdotH = 0.0;\n pbrInfo.VdotH = 1.0;\n pbrInfo.l = pbrInfo.n;\n pbrInfo.h = pbrInfo.n;\n}\n\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) {\n vec3 n = pbrInfo.n;\n vec3 v = pbrInfo.v;\n vec3 l = normalize(lightDirection); // Vector from surface point to light\n vec3 h = normalize(l+v); // Half vector between both l and v\n\n pbrInfo.NdotL = clamp(dot(n, l), 0.001, 1.0);\n pbrInfo.NdotH = clamp(dot(n, h), 0.0, 1.0);\n pbrInfo.LdotH = clamp(dot(l, h), 0.0, 1.0);\n pbrInfo.VdotH = clamp(dot(v, h), 0.0, 1.0);\n pbrInfo.l = l;\n pbrInfo.h = h;\n}\n\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) {\n vec3 light_direction = normalize(pointLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInfo, light_direction);\n}\n\nvoid PBRInfo_setSpotLight(inout PBRInfo pbrInfo, SpotLight spotLight) {\n vec3 light_direction = normalize(spotLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInfo, light_direction);\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) {\n // Calculate the shading terms for the microfacet specular shading model\n vec3 F = specularReflection(pbrInfo);\n float G = geometricOcclusion(pbrInfo);\n float D = microfacetDistribution(pbrInfo);\n\n // Calculation of analytical lighting contribution\n vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInfo);\n vec3 specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);\n // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)\n return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nvec4 pbr_filterColor(vec4 vertexColor)\n{\n vec2 baseColorUV = getMaterialUV(pbrMaterial.baseColorUVSet, pbrMaterial.baseColorUVTransform);\n vec2 metallicRoughnessUV = getMaterialUV(\n pbrMaterial.metallicRoughnessUVSet,\n pbrMaterial.metallicRoughnessUVTransform\n );\n vec2 normalUV = getMaterialUV(pbrMaterial.normalUVSet, pbrMaterial.normalUVTransform);\n vec2 occlusionUV = getMaterialUV(pbrMaterial.occlusionUVSet, pbrMaterial.occlusionUVTransform);\n vec2 emissiveUV = getMaterialUV(pbrMaterial.emissiveUVSet, pbrMaterial.emissiveUVTransform);\n vec2 specularColorUV = getMaterialUV(\n pbrMaterial.specularColorUVSet,\n pbrMaterial.specularColorUVTransform\n );\n vec2 specularIntensityUV = getMaterialUV(\n pbrMaterial.specularIntensityUVSet,\n pbrMaterial.specularIntensityUVTransform\n );\n vec2 transmissionUV = getMaterialUV(\n pbrMaterial.transmissionUVSet,\n pbrMaterial.transmissionUVTransform\n );\n vec2 thicknessUV = getMaterialUV(pbrMaterial.thicknessUVSet, pbrMaterial.thicknessUVTransform);\n vec2 clearcoatUV = getMaterialUV(pbrMaterial.clearcoatUVSet, pbrMaterial.clearcoatUVTransform);\n vec2 clearcoatRoughnessUV = getMaterialUV(\n pbrMaterial.clearcoatRoughnessUVSet,\n pbrMaterial.clearcoatRoughnessUVTransform\n );\n vec2 clearcoatNormalUV = getMaterialUV(\n pbrMaterial.clearcoatNormalUVSet,\n pbrMaterial.clearcoatNormalUVTransform\n );\n vec2 sheenColorUV = getMaterialUV(\n pbrMaterial.sheenColorUVSet,\n pbrMaterial.sheenColorUVTransform\n );\n vec2 sheenRoughnessUV = getMaterialUV(\n pbrMaterial.sheenRoughnessUVSet,\n pbrMaterial.sheenRoughnessUVTransform\n );\n vec2 iridescenceUV = getMaterialUV(\n pbrMaterial.iridescenceUVSet,\n pbrMaterial.iridescenceUVTransform\n );\n vec2 iridescenceThicknessUV = getMaterialUV(\n pbrMaterial.iridescenceThicknessUVSet,\n pbrMaterial.iridescenceThicknessUVTransform\n );\n vec2 anisotropyUV = getMaterialUV(\n pbrMaterial.anisotropyUVSet,\n pbrMaterial.anisotropyUVTransform\n );\n vec2 diffuseTransmissionUV = getMaterialUV(\n pbrMaterial.diffuseTransmissionUVSet,\n pbrMaterial.diffuseTransmissionUVTransform\n );\n vec2 diffuseTransmissionColorUV = getMaterialUV(\n pbrMaterial.diffuseTransmissionColorUVSet,\n pbrMaterial.diffuseTransmissionColorUVTransform\n );\n vec2 multiscatterColorUV = getMaterialUV(\n pbrMaterial.multiscatterColorUVSet,\n pbrMaterial.multiscatterColorUVTransform\n );\n\n // The albedo may be defined from a base texture or a flat color\n#ifdef HAS_BASECOLORMAP\n vec4 baseColor =\n SRGBtoLINEAR(texture(pbr_baseColorSampler, baseColorUV)) *\n pbrMaterial.baseColorFactor * vertexColor;\n#else\n vec4 baseColor = pbrMaterial.baseColorFactor * vertexColor;\n#endif\n\n#ifdef ALPHA_CUTOFF\n if (baseColor.a < pbrMaterial.alphaCutoff) {\n discard;\n }\n#endif\n\n vec3 color = vec3(0, 0, 0);\n\n float transmission = 0.0;\n\n if(pbrMaterial.unlit){\n color.rgb = baseColor.rgb;\n }\n else{\n // Metallic and Roughness material properties are packed together\n // In glTF, these factors can be specified by fixed scalar values\n // or from a metallic-roughness map\n float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;\n float metallic = pbrMaterial.metallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\n // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.\n // This layout intentionally reserves the 'r' channel for (optional) occlusion map data\n vec4 mrSample = texture(pbr_metallicRoughnessSampler, metallicRoughnessUV);\n perceptualRoughness = mrSample.g * perceptualRoughness;\n metallic = mrSample.b * metallic;\n#endif\n perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\n metallic = clamp(metallic, 0.0, 1.0);\n mat3 tbn = getTBN(normalUV);\n vec3 n = getNormal(tbn, normalUV); // normal at surface point\n perceptualRoughness = widenSpecularRoughness(perceptualRoughness, n);\n vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera\n float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n#ifdef USE_MATERIAL_EXTENSIONS\n bool useExtendedPBR =\n pbrMaterial.specularColorMapEnabled ||\n pbrMaterial.specularIntensityMapEnabled ||\n abs(pbrMaterial.specularIntensityFactor - 1.0) > 0.0001 ||\n maxComponent(abs(pbrMaterial.specularColorFactor - vec3(1.0))) > 0.0001 ||\n abs(pbrMaterial.ior - 1.5) > 0.0001 ||\n pbrMaterial.dispersion > 0.0001 ||\n pbrMaterial.transmissionMapEnabled ||\n pbrMaterial.transmissionFactor > 0.0001 ||\n pbrMaterial.diffuseTransmissionMapEnabled ||\n pbrMaterial.diffuseTransmissionColorMapEnabled ||\n pbrMaterial.diffuseTransmissionFactor > 0.0001 ||\n pbrMaterial.multiscatterColorMapEnabled ||\n maxComponent(pbrMaterial.multiscatterColorFactor) > 0.0001 ||\n pbrMaterial.clearcoatMapEnabled ||\n pbrMaterial.clearcoatRoughnessMapEnabled ||\n pbrMaterial.clearcoatFactor > 0.0001 ||\n pbrMaterial.clearcoatRoughnessFactor > 0.0001 ||\n pbrMaterial.sheenColorMapEnabled ||\n pbrMaterial.sheenRoughnessMapEnabled ||\n maxComponent(pbrMaterial.sheenColorFactor) > 0.0001 ||\n pbrMaterial.sheenRoughnessFactor > 0.0001 ||\n pbrMaterial.iridescenceMapEnabled ||\n pbrMaterial.iridescenceFactor > 0.0001 ||\n abs(pbrMaterial.iridescenceIor - 1.3) > 0.0001 ||\n abs(pbrMaterial.iridescenceThicknessRange.x - 100.0) > 0.0001 ||\n abs(pbrMaterial.iridescenceThicknessRange.y - 400.0) > 0.0001 ||\n pbrMaterial.anisotropyMapEnabled ||\n pbrMaterial.anisotropyStrength > 0.0001 ||\n abs(pbrMaterial.anisotropyRotation) > 0.0001 ||\n length(pbrMaterial.anisotropyDirection - vec2(1.0, 0.0)) > 0.0001;\n#else\n bool useExtendedPBR = false;\n#endif\n\n if (!useExtendedPBR) {\n // Keep the baseline metallic-roughness implementation byte-for-byte equivalent in behavior.\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n vec3 f0 = vec3(0.04);\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\n diffuseColor *= 1.0 - metallic;\n vec3 specularColor = mix(f0, baseColor.rgb, metallic);\n\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInfo = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v,\n n,\n n\n );\n\n#ifdef USE_LIGHTS\n PBRInfo_setAmbientLight(pbrInfo);\n color += calculateFinalColor(pbrInfo, lighting.ambientColor);\n\n for(int i = 0; i < lighting.directionalLightCount; i++) {\n if (i < lighting.directionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);\n color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);\n }\n }\n\n for(int i = 0; i < lighting.pointLightCount; i++) {\n if (i < lighting.pointLightCount) {\n PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));\n float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));\n color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);\n }\n }\n\n for(int i = 0; i < lighting.spotLightCount; i++) {\n if (i < lighting.spotLightCount) {\n PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i));\n float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition);\n color += calculateFinalColor(pbrInfo, lighting_getSpotLight(i).color / attenuation);\n }\n }\n#endif\n\n#ifdef USE_IBL\n if (pbrMaterial.IBLenabled) {\n color += getIBLContribution(pbrInfo, n, reflection);\n }\n#endif\n\n#ifdef HAS_OCCLUSIONMAP\n if (pbrMaterial.occlusionMapEnabled) {\n float ao = texture(pbr_occlusionSampler, occlusionUV).r;\n color = mix(color, color * ao, pbrMaterial.occlusionStrength);\n }\n#endif\n\n vec3 emissive = pbrMaterial.emissiveFactor;\n#ifdef HAS_EMISSIVEMAP\n if (pbrMaterial.emissiveMapEnabled) {\n emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, emissiveUV)).rgb;\n }\n#endif\n color += emissive * pbrMaterial.emissiveStrength;\n\n#ifdef PBR_DEBUG\n color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);\n#endif\n\n return vec4(applySceneColorManagement(color), baseColor.a);\n }\n\n float specularIntensity = pbrMaterial.specularIntensityFactor;\n#ifdef HAS_SPECULARINTENSITYMAP\n if (pbrMaterial.specularIntensityMapEnabled) {\n specularIntensity *= texture(pbr_specularIntensitySampler, specularIntensityUV).a;\n }\n#endif\n\n vec3 specularFactor = pbrMaterial.specularColorFactor;\n#ifdef HAS_SPECULARCOLORMAP\n if (pbrMaterial.specularColorMapEnabled) {\n specularFactor *= SRGBtoLINEAR(texture(pbr_specularColorSampler, specularColorUV)).rgb;\n }\n#endif\n\n transmission = pbrMaterial.transmissionFactor;\n#ifdef HAS_TRANSMISSIONMAP\n if (pbrMaterial.transmissionMapEnabled) {\n transmission *= texture(pbr_transmissionSampler, transmissionUV).r;\n }\n#endif\n transmission = clamp(transmission * (1.0 - metallic), 0.0, 1.0);\n float thickness = max(pbrMaterial.thicknessFactor, 0.0);\n#ifdef HAS_THICKNESSMAP\n thickness *= texture(pbr_thicknessSampler, thicknessUV).g;\n#endif\n\n float diffuseTransmission = clamp(pbrMaterial.diffuseTransmissionFactor, 0.0, 1.0);\n#ifdef HAS_DIFFUSETRANSMISSIONMAP\n if (pbrMaterial.diffuseTransmissionMapEnabled) {\n diffuseTransmission *= texture(pbr_diffuseTransmissionSampler, diffuseTransmissionUV).a;\n }\n#endif\n diffuseTransmission *= (1.0 - metallic) * (1.0 - transmission);\n vec3 diffuseTransmissionColor = pbrMaterial.diffuseTransmissionColorFactor;\n#ifdef HAS_DIFFUSETRANSMISSIONCOLORMAP\n if (pbrMaterial.diffuseTransmissionColorMapEnabled) {\n diffuseTransmissionColor *= SRGBtoLINEAR(\n texture(pbr_diffuseTransmissionColorSampler, diffuseTransmissionColorUV)\n ).rgb;\n }\n#endif\n vec3 multiscatterColor = pbrMaterial.multiscatterColorFactor;\n#ifdef HAS_MULTISCATTERCOLORMAP\n if (pbrMaterial.multiscatterColorMapEnabled) {\n multiscatterColor *= SRGBtoLINEAR(\n texture(pbr_multiscatterColorSampler, multiscatterColorUV)\n ).rgb;\n }\n#endif\n\n float clearcoatFactor = pbrMaterial.clearcoatFactor;\n float clearcoatRoughness = pbrMaterial.clearcoatRoughnessFactor;\n#ifdef HAS_CLEARCOATMAP\n if (pbrMaterial.clearcoatMapEnabled) {\n clearcoatFactor *= texture(pbr_clearcoatSampler, clearcoatUV).r;\n }\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSMAP\n if (pbrMaterial.clearcoatRoughnessMapEnabled) {\n clearcoatRoughness *= texture(pbr_clearcoatRoughnessSampler, clearcoatRoughnessUV).g;\n }\n#endif\n clearcoatFactor = clamp(clearcoatFactor, 0.0, 1.0);\n clearcoatRoughness = clamp(clearcoatRoughness, c_MinRoughness, 1.0);\n vec3 clearcoatNormal = getClearcoatNormal(getTBN(clearcoatNormalUV), n, clearcoatNormalUV);\n clearcoatRoughness = widenSpecularRoughness(clearcoatRoughness, clearcoatNormal);\n\n vec3 sheenColor = pbrMaterial.sheenColorFactor;\n float sheenRoughness = pbrMaterial.sheenRoughnessFactor;\n#ifdef HAS_SHEENCOLORMAP\n if (pbrMaterial.sheenColorMapEnabled) {\n sheenColor *= SRGBtoLINEAR(texture(pbr_sheenColorSampler, sheenColorUV)).rgb;\n }\n#endif\n#ifdef HAS_SHEENROUGHNESSMAP\n if (pbrMaterial.sheenRoughnessMapEnabled) {\n sheenRoughness *= texture(pbr_sheenRoughnessSampler, sheenRoughnessUV).a;\n }\n#endif\n sheenRoughness = clamp(sheenRoughness, c_MinRoughness, 1.0);\n\n float iridescence = pbrMaterial.iridescenceFactor;\n#ifdef HAS_IRIDESCENCEMAP\n if (pbrMaterial.iridescenceMapEnabled) {\n iridescence *= texture(pbr_iridescenceSampler, iridescenceUV).r;\n }\n#endif\n iridescence = clamp(iridescence, 0.0, 1.0);\n float iridescenceThickness = mix(\n pbrMaterial.iridescenceThicknessRange.x,\n pbrMaterial.iridescenceThicknessRange.y,\n 0.5\n );\n#ifdef HAS_IRIDESCENCETHICKNESSMAP\n iridescenceThickness = mix(\n pbrMaterial.iridescenceThicknessRange.x,\n pbrMaterial.iridescenceThicknessRange.y,\n texture(pbr_iridescenceThicknessSampler, iridescenceThicknessUV).g\n );\n#endif\n\n float anisotropyStrength = clamp(pbrMaterial.anisotropyStrength, 0.0, 1.0);\n vec2 anisotropyDirection = normalizeDirection(pbrMaterial.anisotropyDirection);\n#ifdef HAS_ANISOTROPYMAP\n if (pbrMaterial.anisotropyMapEnabled) {\n vec3 anisotropySample = texture(pbr_anisotropySampler, anisotropyUV).rgb;\n anisotropyStrength *= anisotropySample.b;\n vec2 mappedDirection = anisotropySample.rg * 2.0 - 1.0;\n if (length(mappedDirection) > 0.0001) {\n anisotropyDirection = normalize(mappedDirection);\n }\n }\n#endif\n anisotropyDirection = rotateDirection(anisotropyDirection, pbrMaterial.anisotropyRotation);\n vec3 anisotropyTangent = normalize(tbn[0] * anisotropyDirection.x + tbn[1] * anisotropyDirection.y);\n if (length(anisotropyTangent) < 0.0001) {\n anisotropyTangent = normalize(tbn[0]);\n }\n // Roughness is authored as perceptual roughness; as is convention,\n // convert to material roughness by squaring the perceptual roughness [2].\n float alphaRoughness = perceptualRoughness * perceptualRoughness;\n\n float dielectricF0 = getDielectricF0(pbrMaterial.ior);\n vec3 dielectricSpecularF0 = min(\n vec3(dielectricF0) * specularFactor * specularIntensity,\n vec3(1.0)\n );\n dielectricSpecularF0 = getIridescenceTint(\n iridescence,\n iridescenceThickness,\n NdotV,\n dielectricSpecularF0\n );\n vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - dielectricSpecularF0);\n diffuseColor *= (1.0 - metallic) * (1.0 - transmission) * (1.0 - diffuseTransmission);\n vec3 specularColor = mix(dielectricSpecularF0, baseColor.rgb, metallic);\n\n float clearcoatViewFresnel = dielectricSchlick(\n 0.04,\n clamp(abs(dot(clearcoatNormal, v)), 0.0, 1.0)\n );\n float sheenDirectionalAlbedo = maxComponent(sheenColor) *\n (0.157 + 0.343 * (1.0 - NdotV)) * (1.0 - sheenRoughness * 0.5);\n float baseLayerEnergy = (1.0 - clearcoatFactor * clearcoatViewFresnel) *\n (1.0 - clamp(sheenDirectionalAlbedo, 0.0, 1.0));\n diffuseColor *= baseLayerEnergy;\n specularColor *= baseLayerEnergy;\n\n // Compute reflectance.\n float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\n\n // For typical incident reflectance range (between 4% to 100%) set the grazing\n // reflectance to 100% for typical fresnel effect.\n // For very low reflectance range on highly diffuse objects (below 4%),\n // incrementally reduce grazing reflecance to 0%.\n float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\n vec3 specularEnvironmentR0 = specularColor.rgb;\n vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInfo = PBRInfo(\n 0.0, // NdotL\n NdotV,\n 0.0, // NdotH\n 0.0, // LdotH\n 0.0, // VdotH\n perceptualRoughness,\n metallic,\n specularEnvironmentR0,\n specularEnvironmentR90,\n alphaRoughness,\n diffuseColor,\n specularColor,\n n,\n v,\n n,\n n\n );\n\n\n#ifdef USE_LIGHTS\n // Apply ambient light\n PBRInfo_setAmbientLight(pbrInfo);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting.ambientColor,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n\n // Apply directional light\n for(int i = 0; i < lighting.directionalLightCount; i++) {\n if (i < lighting.directionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getDirectionalLight(i).color,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getDirectionalLight(i).color,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\n );\n }\n }\n\n // Apply point light\n for(int i = 0; i < lighting.pointLightCount; i++) {\n if (i < lighting.pointLightCount) {\n PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));\n float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getPointLight(i).color / attenuation,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getPointLight(i).color / attenuation,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\n );\n }\n }\n\n for(int i = 0; i < lighting.spotLightCount; i++) {\n if (i < lighting.spotLightCount) {\n PBRInfo_setSpotLight(pbrInfo, lighting_getSpotLight(i));\n float attenuation = getSpotLightAttenuation(lighting_getSpotLight(i), pbr_vPosition);\n color += calculateMaterialLightColor(\n pbrInfo,\n lighting_getSpotLight(i).color / attenuation,\n clearcoatNormal,\n clearcoatFactor,\n clearcoatRoughness,\n sheenColor,\n sheenRoughness,\n anisotropyTangent,\n anisotropyStrength\n );\n color += calculateDiffuseTransmissionLight(\n pbrInfo,\n lighting_getSpotLight(i).color / attenuation,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\n );\n }\n }\n#endif\n\n // Calculate lighting contribution from image based lighting source (IBL)\n#ifdef USE_IBL\n if (pbrMaterial.IBLenabled) {\n color += getIBLContribution(\n pbrInfo,\n n,\n getAnisotropicReflection(pbrInfo, anisotropyTangent, anisotropyStrength)\n );\n color += calculateClearcoatIBLContribution(\n pbrInfo,\n clearcoatNormal,\n -normalize(reflect(v, clearcoatNormal)),\n clearcoatFactor,\n clearcoatRoughness\n );\n color += calculateDiffuseTransmissionIBL(\n pbrInfo,\n diffuseTransmissionColor,\n diffuseTransmission,\n multiscatterColor,\n thickness\n );\n color += sheenColor * pbrMaterial.scaleIBLAmbient.x * (1.0 - sheenRoughness) * 0.25;\n }\n#endif\n\n // Apply optional PBR terms for additional (optional) shading\n#ifdef HAS_OCCLUSIONMAP\n if (pbrMaterial.occlusionMapEnabled) {\n float ao = texture(pbr_occlusionSampler, occlusionUV).r;\n color = mix(color, color * ao, pbrMaterial.occlusionStrength);\n }\n#endif\n\n vec3 emissive = pbrMaterial.emissiveFactor;\n#ifdef HAS_EMISSIVEMAP\n if (pbrMaterial.emissiveMapEnabled) {\n emissive *= SRGBtoLINEAR(texture(pbr_emissiveSampler, emissiveUV)).rgb;\n }\n#endif\n color += emissive * pbrMaterial.emissiveStrength;\n\n if (transmission > 0.0) {\n#ifdef USE_TRANSMISSION_FRAMEBUFFER\n float dielectricFresnel = getDielectricF0(pbrMaterial.ior);\n float transmissionFresnel = dielectricFresnel +\n (1.0 - dielectricFresnel) * pow(1.0 - NdotV, 5.0);\n vec3 transmittedColor = getTransmittedSceneColor(\n pbr_vPosition,\n n,\n v,\n thickness,\n perceptualRoughness\n );\n color += transmittedColor * getVolumeAttenuation(thickness) *\n transmission * (1.0 - transmissionFresnel);\n#else\n color = mix(color, color * getVolumeAttenuation(thickness), transmission);\n#endif\n }\n\n // This section uses mix to override final color for reference app visualization\n // of various parameters in the lighting equation.\n#ifdef PBR_DEBUG\n // TODO: Figure out how to debug multiple lights\n\n // color = mix(color, F, pbr_scaleFGDSpec.x);\n // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);\n // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);\n // color = mix(color, specContrib, pbr_scaleFGDSpec.w);\n\n // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);\n color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);\n#endif\n\n }\n\n#ifdef USE_TRANSMISSION_FRAMEBUFFER\n float alpha = clamp(baseColor.a, 0.0, 1.0);\n#else\n float alpha = clamp(baseColor.a * (1.0 - transmission), 0.0, 1.0);\n#endif\n return vec4(applySceneColorManagement(color), alpha);\n}\n";
|
|
124
|
+
readonly defines: {
|
|
125
|
+
readonly LIGHTING_FRAGMENT: true;
|
|
126
|
+
readonly HAS_NORMALMAP: false;
|
|
127
|
+
readonly HAS_EMISSIVEMAP: false;
|
|
128
|
+
readonly HAS_OCCLUSIONMAP: false;
|
|
129
|
+
readonly HAS_BASECOLORMAP: false;
|
|
130
|
+
readonly HAS_METALROUGHNESSMAP: false;
|
|
131
|
+
readonly HAS_SPECULARCOLORMAP: false;
|
|
132
|
+
readonly HAS_SPECULARINTENSITYMAP: false;
|
|
133
|
+
readonly HAS_TRANSMISSIONMAP: false;
|
|
134
|
+
readonly HAS_THICKNESSMAP: false;
|
|
135
|
+
readonly HAS_CLEARCOATMAP: false;
|
|
136
|
+
readonly HAS_CLEARCOATROUGHNESSMAP: false;
|
|
137
|
+
readonly HAS_CLEARCOATNORMALMAP: false;
|
|
138
|
+
readonly HAS_SHEENCOLORMAP: false;
|
|
139
|
+
readonly HAS_SHEENROUGHNESSMAP: false;
|
|
140
|
+
readonly HAS_IRIDESCENCEMAP: false;
|
|
141
|
+
readonly HAS_IRIDESCENCETHICKNESSMAP: false;
|
|
142
|
+
readonly HAS_ANISOTROPYMAP: false;
|
|
143
|
+
readonly HAS_BUMPMAP: false;
|
|
144
|
+
readonly HAS_DIFFUSETRANSMISSIONMAP: false;
|
|
145
|
+
readonly HAS_DIFFUSETRANSMISSIONCOLORMAP: false;
|
|
146
|
+
readonly HAS_MULTISCATTERCOLORMAP: false;
|
|
147
|
+
readonly USE_MATERIAL_EXTENSIONS: false;
|
|
148
|
+
readonly ALPHA_CUTOFF: false;
|
|
149
|
+
readonly USE_IBL: false;
|
|
150
|
+
readonly PBR_DEBUG: false;
|
|
151
|
+
};
|
|
152
|
+
readonly getUniforms: (props: Partial<PBRMaterialProps>) => Partial<PBRMaterialProps>;
|
|
153
|
+
readonly uniformTypes: {
|
|
154
|
+
readonly unlit: "i32";
|
|
155
|
+
readonly baseColorMapEnabled: "i32";
|
|
156
|
+
readonly baseColorFactor: "vec4<f32>";
|
|
157
|
+
readonly normalMapEnabled: "i32";
|
|
158
|
+
readonly normalScale: "f32";
|
|
159
|
+
readonly emissiveMapEnabled: "i32";
|
|
160
|
+
readonly emissiveFactor: "vec3<f32>";
|
|
161
|
+
readonly metallicRoughnessValues: "vec2<f32>";
|
|
162
|
+
readonly metallicRoughnessMapEnabled: "i32";
|
|
163
|
+
readonly occlusionMapEnabled: "i32";
|
|
164
|
+
readonly occlusionStrength: "f32";
|
|
165
|
+
readonly alphaCutoffEnabled: "i32";
|
|
166
|
+
readonly alphaCutoff: "f32";
|
|
167
|
+
readonly specularColorFactor: "vec3<f32>";
|
|
168
|
+
readonly specularIntensityFactor: "f32";
|
|
169
|
+
readonly specularColorMapEnabled: "i32";
|
|
170
|
+
readonly specularIntensityMapEnabled: "i32";
|
|
171
|
+
readonly ior: "f32";
|
|
172
|
+
readonly transmissionFactor: "f32";
|
|
173
|
+
readonly transmissionMapEnabled: "i32";
|
|
174
|
+
readonly thicknessFactor: "f32";
|
|
175
|
+
readonly attenuationDistance: "f32";
|
|
176
|
+
readonly attenuationColor: "vec3<f32>";
|
|
177
|
+
readonly clearcoatFactor: "f32";
|
|
178
|
+
readonly clearcoatRoughnessFactor: "f32";
|
|
179
|
+
readonly clearcoatMapEnabled: "i32";
|
|
180
|
+
readonly clearcoatRoughnessMapEnabled: "i32";
|
|
181
|
+
readonly sheenColorFactor: "vec3<f32>";
|
|
182
|
+
readonly sheenRoughnessFactor: "f32";
|
|
183
|
+
readonly sheenColorMapEnabled: "i32";
|
|
184
|
+
readonly sheenRoughnessMapEnabled: "i32";
|
|
185
|
+
readonly iridescenceFactor: "f32";
|
|
186
|
+
readonly iridescenceIor: "f32";
|
|
187
|
+
readonly iridescenceThicknessRange: "vec2<f32>";
|
|
188
|
+
readonly iridescenceMapEnabled: "i32";
|
|
189
|
+
readonly anisotropyStrength: "f32";
|
|
190
|
+
readonly anisotropyRotation: "f32";
|
|
191
|
+
readonly anisotropyDirection: "vec2<f32>";
|
|
192
|
+
readonly anisotropyMapEnabled: "i32";
|
|
193
|
+
readonly emissiveStrength: "f32";
|
|
194
|
+
readonly dispersion: "f32";
|
|
195
|
+
readonly IBLenabled: "i32";
|
|
196
|
+
readonly scaleIBLAmbient: "vec2<f32>";
|
|
197
|
+
readonly scaleDiffBaseMR: "vec4<f32>";
|
|
198
|
+
readonly scaleFGDSpec: "vec4<f32>";
|
|
199
|
+
readonly baseColorUVSet: "i32";
|
|
200
|
+
readonly baseColorUVTransform: "mat3x3<f32>";
|
|
201
|
+
readonly metallicRoughnessUVSet: "i32";
|
|
202
|
+
readonly metallicRoughnessUVTransform: "mat3x3<f32>";
|
|
203
|
+
readonly normalUVSet: "i32";
|
|
204
|
+
readonly normalUVTransform: "mat3x3<f32>";
|
|
205
|
+
readonly occlusionUVSet: "i32";
|
|
206
|
+
readonly occlusionUVTransform: "mat3x3<f32>";
|
|
207
|
+
readonly emissiveUVSet: "i32";
|
|
208
|
+
readonly emissiveUVTransform: "mat3x3<f32>";
|
|
209
|
+
readonly specularColorUVSet: "i32";
|
|
210
|
+
readonly specularColorUVTransform: "mat3x3<f32>";
|
|
211
|
+
readonly specularIntensityUVSet: "i32";
|
|
212
|
+
readonly specularIntensityUVTransform: "mat3x3<f32>";
|
|
213
|
+
readonly transmissionUVSet: "i32";
|
|
214
|
+
readonly transmissionUVTransform: "mat3x3<f32>";
|
|
215
|
+
readonly thicknessUVSet: "i32";
|
|
216
|
+
readonly thicknessUVTransform: "mat3x3<f32>";
|
|
217
|
+
readonly clearcoatUVSet: "i32";
|
|
218
|
+
readonly clearcoatUVTransform: "mat3x3<f32>";
|
|
219
|
+
readonly clearcoatRoughnessUVSet: "i32";
|
|
220
|
+
readonly clearcoatRoughnessUVTransform: "mat3x3<f32>";
|
|
221
|
+
readonly clearcoatNormalUVSet: "i32";
|
|
222
|
+
readonly clearcoatNormalUVTransform: "mat3x3<f32>";
|
|
223
|
+
readonly sheenColorUVSet: "i32";
|
|
224
|
+
readonly sheenColorUVTransform: "mat3x3<f32>";
|
|
225
|
+
readonly sheenRoughnessUVSet: "i32";
|
|
226
|
+
readonly sheenRoughnessUVTransform: "mat3x3<f32>";
|
|
227
|
+
readonly iridescenceUVSet: "i32";
|
|
228
|
+
readonly iridescenceUVTransform: "mat3x3<f32>";
|
|
229
|
+
readonly iridescenceThicknessUVSet: "i32";
|
|
230
|
+
readonly iridescenceThicknessUVTransform: "mat3x3<f32>";
|
|
231
|
+
readonly anisotropyUVSet: "i32";
|
|
232
|
+
readonly anisotropyUVTransform: "mat3x3<f32>";
|
|
233
|
+
readonly bumpFactor: "f32";
|
|
234
|
+
readonly bumpMapEnabled: "i32";
|
|
235
|
+
readonly diffuseTransmissionFactor: "f32";
|
|
236
|
+
readonly diffuseTransmissionMapEnabled: "i32";
|
|
237
|
+
readonly diffuseTransmissionColorFactor: "vec3<f32>";
|
|
238
|
+
readonly diffuseTransmissionColorMapEnabled: "i32";
|
|
239
|
+
readonly multiscatterColorFactor: "vec3<f32>";
|
|
240
|
+
readonly multiscatterColorMapEnabled: "i32";
|
|
241
|
+
readonly scatterAnisotropy: "f32";
|
|
242
|
+
readonly bumpUVSet: "i32";
|
|
243
|
+
readonly bumpUVTransform: "mat3x3<f32>";
|
|
244
|
+
readonly diffuseTransmissionUVSet: "i32";
|
|
245
|
+
readonly diffuseTransmissionUVTransform: "mat3x3<f32>";
|
|
246
|
+
readonly diffuseTransmissionColorUVSet: "i32";
|
|
247
|
+
readonly diffuseTransmissionColorUVTransform: "mat3x3<f32>";
|
|
248
|
+
readonly multiscatterColorUVSet: "i32";
|
|
249
|
+
readonly multiscatterColorUVTransform: "mat3x3<f32>";
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
//# sourceMappingURL=mesh-pbr-material.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh-pbr-material.d.ts","sourceRoot":"","sources":["../../src/mesh-layer/mesh-pbr-material.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACb,MAAM,sBAAsB,CAAC;AAwB9B,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAIk3d,CAAC,6DAA2D,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAD92d,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { pbrMaterial } from '@luma.gl/shadertools';
|
|
5
|
+
// The stock PBR module still uses the pre-indexed UV field name in one helper and owns a
|
|
6
|
+
// separate camera uniform. Align it with the current PBR input struct and deck.gl's project
|
|
7
|
+
// module until these compatibility fixes can be made in luma.gl itself.
|
|
8
|
+
const source = pbrMaterial.source
|
|
9
|
+
.replace(/fn pbr_setPositionNormalTangentUV\([\s\S]*?\n}\n/, `fn pbr_setPositionNormalTangentUV(position: vec4f, normal: vec4f, tangent: vec4f, uv: vec2f)
|
|
10
|
+
{
|
|
11
|
+
fragmentInputs.pbr_vPosition = position.xyz;
|
|
12
|
+
fragmentInputs.pbr_vNormal = normal.xyz;
|
|
13
|
+
fragmentInputs.pbr_vTBN = mat3x3f(
|
|
14
|
+
vec3f(1.0, 0.0, 0.0),
|
|
15
|
+
vec3f(0.0, 1.0, 0.0),
|
|
16
|
+
vec3f(0.0, 0.0, 1.0)
|
|
17
|
+
);
|
|
18
|
+
fragmentInputs.pbr_vUV0 = uv;
|
|
19
|
+
fragmentInputs.pbr_vUV1 = uv;
|
|
20
|
+
}
|
|
21
|
+
`)
|
|
22
|
+
.replace(/pbrProjection\.camera/g, 'project.cameraPosition');
|
|
23
|
+
export const meshPbrMaterial = {
|
|
24
|
+
...pbrMaterial,
|
|
25
|
+
source
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=mesh-pbr-material.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh-pbr-material.js","sourceRoot":"","sources":["../../src/mesh-layer/mesh-pbr-material.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AASjD,yFAAyF;AACzF,4FAA4F;AAC5F,wEAAwE;AACxE,MAAM,MAAM,GAAI,WAAW,CAAC,MAAiB;KAC1C,OAAO,CACN,kDAAkD,EAClD;;;;;;;;;;;;CAYH,CACE;KACA,OAAO,CAAC,wBAAwB,EAAE,wBAAwB,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,WAAW;IACd,MAAM;CACqF,CAAC"}
|
|
@@ -5,6 +5,7 @@ export type TripsProps = {
|
|
|
5
5
|
};
|
|
6
6
|
export declare const tripsUniforms: {
|
|
7
7
|
readonly name: "trips";
|
|
8
|
+
readonly source: "struct TripsUniforms {\n fadeTrail: f32,\n trailLength: f32,\n currentTime: f32,\n};\n\n@group(0) @binding(auto)\nvar<uniform> trips: TripsUniforms;\n";
|
|
8
9
|
readonly vs: "layout(std140) uniform tripsUniforms {\n bool fadeTrail;\n float trailLength;\n float currentTime;\n} trips;\n";
|
|
9
10
|
readonly fs: "layout(std140) uniform tripsUniforms {\n bool fadeTrail;\n float trailLength;\n float currentTime;\n} trips;\n";
|
|
10
11
|
readonly uniformTypes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trips-layer-uniforms.d.ts","sourceRoot":"","sources":["../../src/trips-layer/trips-layer-uniforms.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"trips-layer-uniforms.d.ts","sourceRoot":"","sources":["../../src/trips-layer/trips-layer-uniforms.ts"],"names":[],"mappings":"AAyBA,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;CAUmB,CAAC"}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
// deck.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
const
|
|
4
|
+
const uniformBlockWGSL = /* wgsl */ `\
|
|
5
|
+
struct TripsUniforms {
|
|
6
|
+
fadeTrail: f32,
|
|
7
|
+
trailLength: f32,
|
|
8
|
+
currentTime: f32,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
@group(0) @binding(auto)
|
|
12
|
+
var<uniform> trips: TripsUniforms;
|
|
13
|
+
`;
|
|
14
|
+
const uniformBlockGLSL = `\
|
|
5
15
|
layout(std140) uniform tripsUniforms {
|
|
6
16
|
bool fadeTrail;
|
|
7
17
|
float trailLength;
|
|
@@ -10,8 +20,9 @@ layout(std140) uniform tripsUniforms {
|
|
|
10
20
|
`;
|
|
11
21
|
export const tripsUniforms = {
|
|
12
22
|
name: 'trips',
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
source: uniformBlockWGSL,
|
|
24
|
+
vs: uniformBlockGLSL,
|
|
25
|
+
fs: uniformBlockGLSL,
|
|
15
26
|
uniformTypes: {
|
|
16
27
|
fadeTrail: 'f32',
|
|
17
28
|
trailLength: 'f32',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trips-layer-uniforms.js","sourceRoot":"","sources":["../../src/trips-layer/trips-layer-uniforms.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,
|
|
1
|
+
{"version":3,"file":"trips-layer-uniforms.js","sourceRoot":"","sources":["../../src/trips-layer/trips-layer-uniforms.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,gBAAgB,GAAG,UAAU,CAAC;;;;;;;;;CASnC,CAAC;AAEF,MAAM,gBAAgB,GAAG;;;;;;CAMxB,CAAC;AAQF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,gBAAgB;IACxB,EAAE,EAAE,gBAAgB;IACpB,EAAE,EAAE,gBAAgB;IACpB,YAAY,EAAE;QACZ,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,KAAK;QAClB,WAAW,EAAE,KAAK;KACnB;CAC0C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NumericArray } from '@math.gl/core';
|
|
2
|
-
import { AccessorFunction, DefaultProps } from '@deck.gl/core';
|
|
2
|
+
import type { AccessorFunction, Attribute, DefaultProps } from '@deck.gl/core';
|
|
3
3
|
import { PathLayer, PathLayerProps } from '@deck.gl/layers';
|
|
4
4
|
/** All properties supported by TripsLayer. */
|
|
5
5
|
export type TripsLayerProps<DataT = unknown> = _TripsLayerProps<DataT> & PathLayerProps<DataT>;
|
|
@@ -31,6 +31,11 @@ export default class TripsLayer<DataT = any, ExtraProps extends {} = {}> extends
|
|
|
31
31
|
static defaultProps: DefaultProps<TripsLayerProps<unknown>>;
|
|
32
32
|
getShaders(): any;
|
|
33
33
|
initializeState(): void;
|
|
34
|
+
/** Materialize timestamps in the same per-path instance layout as the path tessellator. */
|
|
35
|
+
protected calculateWebGPUTimestamps(attribute: Attribute, { data, props }: {
|
|
36
|
+
data: TripsLayerProps<DataT>['data'];
|
|
37
|
+
props: TripsLayerProps<DataT>;
|
|
38
|
+
}): void;
|
|
34
39
|
draw(params: any): void;
|
|
35
40
|
}
|
|
36
41
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trips-layer.d.ts","sourceRoot":"","sources":["../../src/trips-layer/trips-layer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"trips-layer.d.ts","sourceRoot":"","sources":["../../src/trips-layer/trips-layer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAC,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAC,SAAS,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAqC1D,8CAA8C;AAC9C,MAAM,MAAM,eAAe,CAAC,KAAK,GAAG,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;AAE/F,sCAAsC;AACtC,KAAK,gBAAgB,CAAC,KAAK,GAAG,OAAO,IAAI;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;CACvD,CAAC;AAEF,0DAA0D;AAC1D,MAAM,CAAC,OAAO,OAAO,UAAU,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,SAAS,EAAE,GAAG,EAAE,CAAE,SAAQ,SAAS,CACxF,KAAK,EACL,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CAC/C;IACC,MAAM,CAAC,SAAS,SAAgB;IAChC,MAAM,CAAC,YAAY,yCAAgB;IAEnC,UAAU;IAQV,eAAe;IAgCf,2FAA2F;IAC3F,SAAS,CAAC,yBAAyB,CACjC,SAAS,EAAE,SAAS,EACpB,EAAC,IAAI,EAAE,KAAK,EAAC,EAAE;QAAC,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;QAAC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,CAAA;KAAC,GACnF,IAAI;IA2BP,IAAI,CAAC,MAAM,KAAA;CAQZ"}
|
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
// deck.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { createIterable } from '@deck.gl/core';
|
|
4
5
|
import { PathLayer } from '@deck.gl/layers';
|
|
5
6
|
import { tripsUniforms } from "./trips-layer-uniforms.js";
|
|
7
|
+
import { packTripTimestamps, tripsShaderInjectionsWGSL } from "./trips-layer.wgsl.js";
|
|
6
8
|
const defaultProps = {
|
|
7
9
|
fadeTrail: true,
|
|
8
10
|
trailLength: { type: 'number', value: 120, min: 0 },
|
|
9
11
|
currentTime: { type: 'number', value: 0, min: 0 },
|
|
10
12
|
getTimestamps: { type: 'accessor', value: (d) => d.timestamps }
|
|
11
13
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getShaders() {
|
|
15
|
-
const shaders = super.getShaders();
|
|
16
|
-
shaders.inject = {
|
|
17
|
-
'vs:#decl': `\
|
|
14
|
+
const tripsShaderInjectionsGLSL = {
|
|
15
|
+
'vs:#decl': `\
|
|
18
16
|
in float instanceTimestamps;
|
|
19
17
|
in float instanceNextTimestamps;
|
|
20
18
|
out float vTime;
|
|
21
19
|
`,
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// Timestamp of the vertex
|
|
21
|
+
'vs:#main-end': `\
|
|
24
22
|
vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength;
|
|
25
23
|
`,
|
|
26
|
-
|
|
24
|
+
'fs:#decl': `\
|
|
27
25
|
in float vTime;
|
|
28
26
|
`,
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
// Drop segments only after PathLayer evaluates analytic-coverage derivatives, then
|
|
28
|
+
// fade the color (currentTime - 100%, end of trail - 0%).
|
|
29
|
+
'fs:DECKGL_FILTER_COLOR': `\
|
|
31
30
|
if(vTime > trips.currentTime || (trips.fadeTrail && (vTime < trips.currentTime - trips.trailLength))) {
|
|
32
31
|
discard;
|
|
33
32
|
}
|
|
34
|
-
`,
|
|
35
|
-
// Fade the color (currentTime - 100%, end of trail - 0%)
|
|
36
|
-
'fs:DECKGL_FILTER_COLOR': `\
|
|
37
33
|
if(trips.fadeTrail) {
|
|
38
34
|
color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength;
|
|
39
35
|
}
|
|
40
36
|
`
|
|
41
|
-
|
|
37
|
+
};
|
|
38
|
+
/** Render animated paths that represent vehicle trips. */
|
|
39
|
+
class TripsLayer extends PathLayer {
|
|
40
|
+
getShaders() {
|
|
41
|
+
const shaders = super.getShaders();
|
|
42
|
+
shaders.inject =
|
|
43
|
+
this.context.device.type === 'webgpu' ? tripsShaderInjectionsWGSL : tripsShaderInjectionsGLSL;
|
|
42
44
|
shaders.modules = [...shaders.modules, tripsUniforms];
|
|
43
45
|
return shaders;
|
|
44
46
|
}
|
|
@@ -46,20 +48,51 @@ if(trips.fadeTrail) {
|
|
|
46
48
|
super.initializeState();
|
|
47
49
|
const attributeManager = this.getAttributeManager();
|
|
48
50
|
attributeManager.addInstanced({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
accessor: 'getTimestamps',
|
|
52
|
-
shaderAttributes: {
|
|
51
|
+
...(this.context.device.type === 'webgpu'
|
|
52
|
+
? {
|
|
53
53
|
instanceTimestamps: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
size: 2,
|
|
55
|
+
accessor: 'getTimestamps',
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
57
|
+
update: this.calculateWebGPUTimestamps,
|
|
58
|
+
bufferGroup: 'path-instance-data'
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
: {
|
|
62
|
+
timestamps: {
|
|
63
|
+
size: 1,
|
|
64
|
+
accessor: 'getTimestamps',
|
|
65
|
+
shaderAttributes: {
|
|
66
|
+
instanceTimestamps: {
|
|
67
|
+
vertexOffset: 0
|
|
68
|
+
},
|
|
69
|
+
instanceNextTimestamps: {
|
|
70
|
+
vertexOffset: 1
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
})
|
|
61
75
|
});
|
|
62
76
|
}
|
|
77
|
+
/** Materialize timestamps in the same per-path instance layout as the path tessellator. */
|
|
78
|
+
calculateWebGPUTimestamps(attribute, { data, props }) {
|
|
79
|
+
const { pathTesselator } = this.state;
|
|
80
|
+
const { instanceCount, vertexStarts } = pathTesselator;
|
|
81
|
+
const packedTimestamps = new Float32Array(instanceCount * 2);
|
|
82
|
+
const { iterable, objectInfo } = createIterable(data);
|
|
83
|
+
for (const object of iterable) {
|
|
84
|
+
objectInfo.index++;
|
|
85
|
+
const vertexStart = vertexStarts[objectInfo.index];
|
|
86
|
+
const vertexEnd = vertexStarts[objectInfo.index + 1] ?? instanceCount;
|
|
87
|
+
if (vertexEnd <= vertexStart) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const timestamps = props.getTimestamps?.(object, objectInfo) ?? [];
|
|
91
|
+
packedTimestamps.set(packTripTimestamps(timestamps, vertexEnd - vertexStart, props._pathType === 'loop'), vertexStart * 2);
|
|
92
|
+
}
|
|
93
|
+
attribute.startIndices = vertexStarts;
|
|
94
|
+
attribute.value = packedTimestamps;
|
|
95
|
+
}
|
|
63
96
|
draw(params) {
|
|
64
97
|
const { fadeTrail, trailLength, currentTime } = this.props;
|
|
65
98
|
const tripsProps = { fadeTrail, trailLength, currentTime };
|