@luma.gl/shadertools 9.1.9 → 9.2.0-alpha.2
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 +1614 -3716
- package/dist/dist.min.js +278 -484
- package/dist/index.cjs +366 -804
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +1 -1
- package/dist/lib/shader-assembly/assemble-shaders.d.ts +6 -4
- package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
- package/dist/lib/shader-assembly/assemble-shaders.js +14 -9
- package/dist/lib/shader-assembly/assemble-shaders.js.map +1 -1
- package/dist/lib/shader-assembly/platform-info.d.ts +1 -1
- package/dist/lib/shader-assembly/platform-info.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-module.d.ts +1 -1
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
- package/dist/lib/wgsl/get-shader-layout-wgsl.d.ts.map +1 -1
- package/dist/lib/wgsl/get-shader-layout-wgsl.js +3 -1
- package/dist/lib/wgsl/get-shader-layout-wgsl.js.map +1 -1
- package/dist/modules/engine/project/project.d.ts.map +1 -1
- package/dist/modules/engine/project/project.js +4 -2
- package/dist/modules/engine/project/project.js.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.js +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -1
- package/dist/modules/lighting/lights/{lighting-uniforms-glsl.d.ts → lighting-glsl.d.ts} +1 -1
- package/dist/modules/lighting/lights/lighting-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/lights/{lighting-uniforms-glsl.js → lighting-glsl.js} +1 -1
- package/dist/modules/lighting/lights/lighting-glsl.js.map +1 -0
- package/dist/modules/lighting/lights/{lighting-uniforms-wgsl.d.ts → lighting-wgsl.d.ts} +1 -1
- package/dist/modules/lighting/lights/lighting-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/lights/{lighting-uniforms-wgsl.js → lighting-wgsl.js} +1 -1
- package/dist/modules/lighting/lights/lighting-wgsl.js.map +1 -0
- package/dist/modules/lighting/lights/lighting.d.ts +1 -3
- package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting.js +4 -4
- package/dist/modules/lighting/lights/lighting.js.map +1 -1
- package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
- package/dist/modules/lighting/no-material/dirlight.js +1 -2
- package/dist/modules/lighting/no-material/dirlight.js.map +1 -1
- package/dist/modules/lighting/pbr-material/{pbr-fragment-glsl.d.ts → pbr-material-glsl.d.ts} +2 -1
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/{pbr-fragment-glsl.js → pbr-material-glsl.js} +36 -1
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +3 -0
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +487 -0
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts +11 -4
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material.js +12 -12
- package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -1
- package/dist/modules/lighting/phong-material/phong-material.js +1 -1
- package/dist/modules/lighting/phong-material/phong-material.js.map +1 -1
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +1 -1
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +2 -0
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -1
- package/dist/modules/math/random/random.d.ts +1 -0
- package/dist/modules/math/random/random.d.ts.map +1 -1
- package/dist/modules/math/random/random.js +7 -0
- package/dist/modules/math/random/random.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +0 -17
- package/src/lib/shader-assembly/assemble-shaders.ts +12 -11
- package/src/lib/shader-assembly/platform-info.ts +1 -1
- package/src/lib/shader-module/shader-module.ts +1 -1
- package/src/lib/wgsl/get-shader-layout-wgsl.ts +7 -5
- package/src/modules/engine/project/project.ts +8 -5
- package/src/modules/lighting/gouraud-material/gouraud-material.ts +1 -1
- package/src/modules/lighting/lights/lighting.ts +4 -4
- package/src/modules/lighting/no-material/dirlight.ts +2 -3
- package/src/modules/lighting/pbr-material/{pbr-fragment-glsl.ts → pbr-material-glsl.ts} +36 -1
- package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +490 -0
- package/src/modules/lighting/pbr-material/pbr-material.ts +12 -12
- package/src/modules/lighting/pbr-material/pbr-projection.ts +0 -2
- package/src/modules/lighting/phong-material/phong-material.ts +1 -1
- package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +2 -0
- package/src/modules/math/random/random.ts +8 -0
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +0 -1
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.js.map +0 -1
- package/dist/modules/lighting/lights/lighting-uniforms-wgsl.d.ts.map +0 -1
- package/dist/modules/lighting/lights/lighting-uniforms-wgsl.js.map +0 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +0 -1
- package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js.map +0 -1
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +0 -2
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +0 -1
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +0 -67
- package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js.map +0 -1
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +0 -2
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +0 -1
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +0 -39
- package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js.map +0 -1
- package/dist/modules/module-injectors.d.ts +0 -3
- package/dist/modules/module-injectors.d.ts.map +0 -1
- package/dist/modules/module-injectors.js +0 -31
- package/dist/modules/module-injectors.js.map +0 -1
- package/dist/modules-webgl1/geometry/geometry.d.ts +0 -9
- package/dist/modules-webgl1/geometry/geometry.d.ts.map +0 -1
- package/dist/modules-webgl1/geometry/geometry.js +0 -39
- package/dist/modules-webgl1/geometry/geometry.js.map +0 -1
- package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts +0 -10
- package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts.map +0 -1
- package/dist/modules-webgl1/lighting/dirlight/dirlight.js +0 -38
- package/dist/modules-webgl1/lighting/dirlight/dirlight.js.map +0 -1
- package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +0 -2
- package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +0 -1
- package/dist/modules-webgl1/lighting/lights/lights-glsl.js +0 -40
- package/dist/modules-webgl1/lighting/lights/lights-glsl.js.map +0 -1
- package/dist/modules-webgl1/lighting/lights/lights.d.ts +0 -38
- package/dist/modules-webgl1/lighting/lights/lights.d.ts.map +0 -1
- package/dist/modules-webgl1/lighting/lights/lights.js +0 -93
- package/dist/modules-webgl1/lighting/lights/lights.js.map +0 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +0 -2
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +0 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +0 -393
- package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js.map +0 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +0 -2
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +0 -1
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +0 -43
- package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js.map +0 -1
- package/dist/modules-webgl1/lighting/pbr/pbr.d.ts +0 -23
- package/dist/modules-webgl1/lighting/pbr/pbr.d.ts.map +0 -1
- package/dist/modules-webgl1/lighting/pbr/pbr.js +0 -21
- package/dist/modules-webgl1/lighting/pbr/pbr.js.map +0 -1
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +0 -2
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +0 -1
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +0 -79
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js.map +0 -1
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.d.ts +0 -45
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.d.ts.map +0 -1
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js +0 -44
- package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js.map +0 -1
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +0 -2
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +0 -1
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +0 -171
- package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js.map +0 -1
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +0 -2
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +0 -1
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +0 -675
- package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js.map +0 -1
- package/dist/modules-webgl1/math/fp64/fp64.d.ts +0 -35
- package/dist/modules-webgl1/math/fp64/fp64.d.ts.map +0 -1
- package/dist/modules-webgl1/math/fp64/fp64.js +0 -38
- package/dist/modules-webgl1/math/fp64/fp64.js.map +0 -1
- package/dist/modules-webgl1/project/project.d.ts +0 -20
- package/dist/modules-webgl1/project/project.d.ts.map +0 -1
- package/dist/modules-webgl1/project/project.js +0 -114
- package/dist/modules-webgl1/project/project.js.map +0 -1
- package/src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts +0 -67
- package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +0 -39
- package/src/modules/module-injectors.ts +0 -32
- package/src/modules-webgl1/geometry/geometry.ts +0 -41
- package/src/modules-webgl1/lighting/dirlight/dirlight.ts +0 -50
- package/src/modules-webgl1/lighting/lights/lights-glsl.ts +0 -40
- package/src/modules-webgl1/lighting/lights/lights.ts +0 -143
- package/src/modules-webgl1/lighting/pbr/README.md +0 -12
- package/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts +0 -396
- package/src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts +0 -43
- package/src/modules-webgl1/lighting/pbr/pbr.ts +0 -23
- package/src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts +0 -79
- package/src/modules-webgl1/lighting/phong-lighting/phong-lighting.ts +0 -64
- package/src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts +0 -171
- package/src/modules-webgl1/math/fp64/fp64-functions-glsl.ts +0 -675
- package/src/modules-webgl1/math/fp64/fp64.ts +0 -44
- package/src/modules-webgl1/project/README.md +0 -52
- package/src/modules-webgl1/project/project.ts +0 -135
- /package/src/modules/lighting/lights/{lighting-uniforms-glsl.ts → lighting-glsl.ts} +0 -0
- /package/src/modules/lighting/lights/{lighting-uniforms-wgsl.ts → lighting-wgsl.ts} +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const vs = "out vec3 pbr_vPosition;\nout vec2 pbr_vUV;\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(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\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_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n";
|
|
2
|
-
//# sourceMappingURL=pbr-vertex-glsl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pbr-vertex-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-vertex-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,EAAE,m3BAkCd,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
export const vs = /* glsl */ `\
|
|
5
|
-
out vec3 pbr_vPosition;
|
|
6
|
-
out vec2 pbr_vUV;
|
|
7
|
-
|
|
8
|
-
#ifdef HAS_NORMALS
|
|
9
|
-
# ifdef HAS_TANGENTS
|
|
10
|
-
out mat3 pbr_vTBN;
|
|
11
|
-
# else
|
|
12
|
-
out vec3 pbr_vNormal;
|
|
13
|
-
# endif
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
|
|
17
|
-
{
|
|
18
|
-
vec4 pos = pbrProjection.modelMatrix * position;
|
|
19
|
-
pbr_vPosition = vec3(pos.xyz) / pos.w;
|
|
20
|
-
|
|
21
|
-
#ifdef HAS_NORMALS
|
|
22
|
-
#ifdef HAS_TANGENTS
|
|
23
|
-
vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
|
|
24
|
-
vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
|
|
25
|
-
vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
|
|
26
|
-
pbr_vTBN = mat3(tangentW, bitangentW, normalW);
|
|
27
|
-
#else // HAS_TANGENTS != 1
|
|
28
|
-
pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
|
|
29
|
-
#endif
|
|
30
|
-
#endif
|
|
31
|
-
|
|
32
|
-
#ifdef HAS_UV
|
|
33
|
-
pbr_vUV = uv;
|
|
34
|
-
#else
|
|
35
|
-
pbr_vUV = vec2(0.,0.);
|
|
36
|
-
#endif
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
39
|
-
//# sourceMappingURL=pbr-vertex-glsl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pbr-vertex-glsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-vertex-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC5B,CAAC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const MODULE_INJECTORS_VS = "#ifdef MODULE_LOGDEPTH\n logdepth_adjustPosition(gl_Position);\n#endif\n";
|
|
2
|
-
export declare const MODULE_INJECTORS_FS = "#ifdef MODULE_MATERIAL\n fragColor = material_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_LIGHTING\n fragColor = lighting_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_FOG\n fragColor = fog_filterColor(fragColor);\n#endif\n\n#ifdef MODULE_PICKING\n fragColor = picking_filterHighlightColor(fragColor);\n fragColor = picking_filterPickingColor(fragColor);\n#endif\n\n#ifdef MODULE_LOGDEPTH\n logdepth_setFragDepth();\n#endif\n";
|
|
3
|
-
//# sourceMappingURL=module-injectors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-injectors.d.ts","sourceRoot":"","sources":["../../src/modules/module-injectors.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,8EAI/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,4bAqB/B,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
export const MODULE_INJECTORS_VS = /* glsl */ `\
|
|
5
|
-
#ifdef MODULE_LOGDEPTH
|
|
6
|
-
logdepth_adjustPosition(gl_Position);
|
|
7
|
-
#endif
|
|
8
|
-
`;
|
|
9
|
-
export const MODULE_INJECTORS_FS = /* glsl */ `\
|
|
10
|
-
#ifdef MODULE_MATERIAL
|
|
11
|
-
fragColor = material_filterColor(fragColor);
|
|
12
|
-
#endif
|
|
13
|
-
|
|
14
|
-
#ifdef MODULE_LIGHTING
|
|
15
|
-
fragColor = lighting_filterColor(fragColor);
|
|
16
|
-
#endif
|
|
17
|
-
|
|
18
|
-
#ifdef MODULE_FOG
|
|
19
|
-
fragColor = fog_filterColor(fragColor);
|
|
20
|
-
#endif
|
|
21
|
-
|
|
22
|
-
#ifdef MODULE_PICKING
|
|
23
|
-
fragColor = picking_filterHighlightColor(fragColor);
|
|
24
|
-
fragColor = picking_filterPickingColor(fragColor);
|
|
25
|
-
#endif
|
|
26
|
-
|
|
27
|
-
#ifdef MODULE_LOGDEPTH
|
|
28
|
-
logdepth_setFragDepth();
|
|
29
|
-
#endif
|
|
30
|
-
`;
|
|
31
|
-
//# sourceMappingURL=module-injectors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-injectors.js","sourceRoot":"","sources":["../../src/modules/module-injectors.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;;;;CAI7C,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;CAqB7C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../src/modules-webgl1/geometry/geometry.ts"],"names":[],"mappings":"AAiCA;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAIpB,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// import {ShaderModule} from '../../types';
|
|
2
|
-
// TODO - reuse normal from geometry module
|
|
3
|
-
const vs = /* glsl */ `\
|
|
4
|
-
varying vec4 geometry_vPosition;
|
|
5
|
-
varying vec3 geometry_vNormal;
|
|
6
|
-
|
|
7
|
-
void geometry_setNormal(vec3 normal) {
|
|
8
|
-
geometry_vNormal = normal;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
void geometry_setPosition(vec4 position) {
|
|
12
|
-
geometry_vPosition = position;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
void geometry_setPosition(vec3 position) {
|
|
16
|
-
geometry_vPosition = vec4(position, 1.);
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
const fs = /* glsl */ `\
|
|
20
|
-
varying vec4 geometry_vPosition;
|
|
21
|
-
varying vec3 geometry_vNormal;
|
|
22
|
-
|
|
23
|
-
vec4 geometry_getPosition() {
|
|
24
|
-
return geometry_vPosition;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
vec3 geometry_getNormal() {
|
|
28
|
-
return geometry_vNormal;
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
/**
|
|
32
|
-
* Geometry varyings
|
|
33
|
-
*/
|
|
34
|
-
export const geometry = {
|
|
35
|
-
name: 'geometry',
|
|
36
|
-
vs,
|
|
37
|
-
fs
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=geometry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../../src/modules-webgl1/geometry/geometry.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAE5C,2CAA2C;AAC3C,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;CAerB,CAAC;AAEF,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;CAWrB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,EAAE;IACF,EAAE;CACH,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ShaderModule } from "../../../lib/shader-module/shader-module.js";
|
|
2
|
-
import type { NumericArray } from "../../../types.js";
|
|
3
|
-
export type DirlightOptions = {
|
|
4
|
-
lightDirection?: NumericArray;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Cheap lighting - single directional light, single dot product, one uniform
|
|
8
|
-
*/
|
|
9
|
-
export declare const dirlight: ShaderModule;
|
|
10
|
-
//# sourceMappingURL=dirlight.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dirlight.d.ts","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/dirlight/dirlight.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,oDAAiD;AACtE,OAAO,KAAK,EAAC,YAAY,EAAC,0BAAuB;AAKjD,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,CAAC,EAAE,YAAY,CAAC;CAC/B,CAAC;AA4BF;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,YAMtB,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { project } from "../../project/project.js";
|
|
5
|
-
const DEFAULT_MODULE_OPTIONS = {
|
|
6
|
-
lightDirection: new Float32Array([1, 1, 2])
|
|
7
|
-
};
|
|
8
|
-
function getUniforms(opts = DEFAULT_MODULE_OPTIONS) {
|
|
9
|
-
const uniforms = {};
|
|
10
|
-
if (opts.lightDirection) {
|
|
11
|
-
// @ts-expect-error TODO add types
|
|
12
|
-
uniforms.dirlight_uLightDirection = opts.lightDirection;
|
|
13
|
-
}
|
|
14
|
-
return uniforms;
|
|
15
|
-
}
|
|
16
|
-
const fs = /* glsl */ `\
|
|
17
|
-
uniform vec3 dirlight_uLightDirection;
|
|
18
|
-
|
|
19
|
-
/*
|
|
20
|
-
* Returns color attenuated by angle from light source
|
|
21
|
-
*/
|
|
22
|
-
vec4 dirlight_filterColor(vec4 color) {
|
|
23
|
-
vec3 normal = project_getNormal_World();
|
|
24
|
-
float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
|
|
25
|
-
return vec4(color.rgb * d, color.a);
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
/**
|
|
29
|
-
* Cheap lighting - single directional light, single dot product, one uniform
|
|
30
|
-
*/
|
|
31
|
-
export const dirlight = {
|
|
32
|
-
name: 'dirlight',
|
|
33
|
-
// vs // TODO - reuse normal from geometry module
|
|
34
|
-
fs,
|
|
35
|
-
getUniforms,
|
|
36
|
-
dependencies: [project]
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=dirlight.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dirlight.js","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/dirlight/dirlight.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,OAAO,EAAC,OAAO,EAAC,iCAA8B;AAQ9C,MAAM,sBAAsB,GAA8B;IACxD,cAAc,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAC5C,CAAC;AAEF,SAAS,WAAW,CAAC,OAAwB,sBAAsB;IACjE,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;QACxB,kCAAkC;QAClC,QAAQ,CAAC,wBAAwB,GAAG,IAAI,CAAC,cAAc,CAAC;IAC1D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;CAWrB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAiB;IACpC,IAAI,EAAE,UAAU;IAChB,iDAAiD;IACjD,EAAE;IACF,WAAW;IACX,YAAY,EAAE,CAAC,OAAO,CAAC;CACxB,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const lightingShader = "#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\n\nstruct AmbientLight {\n vec3 color;\n};\n\nstruct PointLight {\n vec3 color;\n vec3 position;\n\n // Constant-Linear-Exponential\n vec3 attenuation;\n};\n\nstruct DirectionalLight {\n vec3 color;\n vec3 direction;\n};\n\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\n\nuniform bool lighting_uEnabled;\n\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\n return pointLight.attenuation.x\n + pointLight.attenuation.y * distance\n + pointLight.attenuation.z * distance * distance;\n}\n\n#endif\n";
|
|
2
|
-
//# sourceMappingURL=lights-glsl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lights-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/lights/lights-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,w2BAmC1B,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
export const lightingShader = /* glsl */ `\
|
|
5
|
-
#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
6
|
-
|
|
7
|
-
struct AmbientLight {
|
|
8
|
-
vec3 color;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
struct PointLight {
|
|
12
|
-
vec3 color;
|
|
13
|
-
vec3 position;
|
|
14
|
-
|
|
15
|
-
// Constant-Linear-Exponential
|
|
16
|
-
vec3 attenuation;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
struct DirectionalLight {
|
|
20
|
-
vec3 color;
|
|
21
|
-
vec3 direction;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
uniform AmbientLight lighting_uAmbientLight;
|
|
25
|
-
uniform PointLight lighting_uPointLight[MAX_LIGHTS];
|
|
26
|
-
uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];
|
|
27
|
-
uniform int lighting_uPointLightCount;
|
|
28
|
-
uniform int lighting_uDirectionalLightCount;
|
|
29
|
-
|
|
30
|
-
uniform bool lighting_uEnabled;
|
|
31
|
-
|
|
32
|
-
float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
33
|
-
return pointLight.attenuation.x
|
|
34
|
-
+ pointLight.attenuation.y * distance
|
|
35
|
-
+ pointLight.attenuation.z * distance * distance;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
#endif
|
|
39
|
-
`;
|
|
40
|
-
//# sourceMappingURL=lights-glsl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lights-glsl.js","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/lights/lights-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCxC,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { NumberArray } from "../../../types.js";
|
|
2
|
-
type LightSources = {
|
|
3
|
-
ambientLight?: {
|
|
4
|
-
color: Readonly<NumberArray>;
|
|
5
|
-
intensity: number;
|
|
6
|
-
};
|
|
7
|
-
pointLights?: {
|
|
8
|
-
color: Readonly<NumberArray>;
|
|
9
|
-
intensity: number;
|
|
10
|
-
position: NumberArray;
|
|
11
|
-
attenuation: number;
|
|
12
|
-
}[];
|
|
13
|
-
directionalLights?: {
|
|
14
|
-
color: Readonly<NumberArray>;
|
|
15
|
-
intensity: number;
|
|
16
|
-
position: NumberArray;
|
|
17
|
-
direction: NumberArray;
|
|
18
|
-
}[];
|
|
19
|
-
};
|
|
20
|
-
export type LightsOptions = {
|
|
21
|
-
lightSources?: LightSources;
|
|
22
|
-
};
|
|
23
|
-
declare function getUniforms(opts?: LightsOptions): Record<string, any>;
|
|
24
|
-
/**
|
|
25
|
-
* An implementation of PBR (Physically-Based Rendering).
|
|
26
|
-
* Physically Based Shading of a microfacet surface defined by a glTF material.
|
|
27
|
-
*/
|
|
28
|
-
export declare const lights: {
|
|
29
|
-
name: string;
|
|
30
|
-
vs: string;
|
|
31
|
-
fs: string;
|
|
32
|
-
getUniforms: typeof getUniforms;
|
|
33
|
-
defines: {
|
|
34
|
-
MAX_LIGHTS: number;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
export {};
|
|
38
|
-
//# sourceMappingURL=lights.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lights.d.ts","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/lights/lights.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,WAAW,EAAC,0BAAuB;AAKhD,KAAK,YAAY,GAAG;IAClB,YAAY,CAAC,EAAE;QACb,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,WAAW,CAAC,EAAE;QACZ,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,WAAW,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;KACrB,EAAE,CAAC;IACJ,iBAAiB,CAAC,EAAE;QAClB,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,WAAW,CAAC;QACtB,SAAS,EAAE,WAAW,CAAC;KACxB,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAgDF,iBAAS,WAAW,CAAC,IAAI,GAAE,aAAsC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAkDtF;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;;;;CAQlB,CAAC"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
// luma.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { lightingShader } from "./lights-glsl.js";
|
|
5
|
-
const INITIAL_MODULE_OPTIONS = {
|
|
6
|
-
lightSources: {}
|
|
7
|
-
};
|
|
8
|
-
// Take color 0-255 and intensity as input and output 0.0-1.0 range
|
|
9
|
-
function convertColor(colorDef = {}) {
|
|
10
|
-
const { color = [0, 0, 0], intensity = 1.0 } = colorDef;
|
|
11
|
-
return color.map(component => (component * intensity) / 255.0);
|
|
12
|
-
}
|
|
13
|
-
function getLightSourceUniforms({ ambientLight, pointLights = [], directionalLights = [] }) {
|
|
14
|
-
const lightSourceUniforms = {};
|
|
15
|
-
if (ambientLight) {
|
|
16
|
-
lightSourceUniforms['lighting_uAmbientLight.color'] = convertColor(ambientLight);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
lightSourceUniforms['lighting_uAmbientLight.color'] = [0, 0, 0];
|
|
20
|
-
}
|
|
21
|
-
pointLights.forEach((pointLight, index) => {
|
|
22
|
-
lightSourceUniforms[`lighting_uPointLight[${index}].color`] = convertColor(pointLight);
|
|
23
|
-
lightSourceUniforms[`lighting_uPointLight[${index}].position`] = pointLight.position;
|
|
24
|
-
lightSourceUniforms[`lighting_uPointLight[${index}].attenuation`] = pointLight.attenuation || [
|
|
25
|
-
1, 0, 0
|
|
26
|
-
];
|
|
27
|
-
});
|
|
28
|
-
lightSourceUniforms.lighting_uPointLightCount = pointLights.length;
|
|
29
|
-
directionalLights.forEach((directionalLight, index) => {
|
|
30
|
-
lightSourceUniforms[`lighting_uDirectionalLight[${index}].color`] =
|
|
31
|
-
convertColor(directionalLight);
|
|
32
|
-
lightSourceUniforms[`lighting_uDirectionalLight[${index}].direction`] =
|
|
33
|
-
directionalLight.direction;
|
|
34
|
-
});
|
|
35
|
-
lightSourceUniforms.lighting_uDirectionalLightCount = directionalLights.length;
|
|
36
|
-
return lightSourceUniforms;
|
|
37
|
-
}
|
|
38
|
-
// eslint-disable-next-line complexity
|
|
39
|
-
function getUniforms(opts = INITIAL_MODULE_OPTIONS) {
|
|
40
|
-
// Specify lights separately
|
|
41
|
-
if ('lightSources' in opts) {
|
|
42
|
-
const { ambientLight, pointLights, directionalLights } = opts.lightSources || {};
|
|
43
|
-
const hasLights = ambientLight ||
|
|
44
|
-
(pointLights && pointLights.length > 0) ||
|
|
45
|
-
(directionalLights && directionalLights.length > 0);
|
|
46
|
-
if (!hasLights) {
|
|
47
|
-
return { lighting_uEnabled: false };
|
|
48
|
-
}
|
|
49
|
-
return Object.assign({}, getLightSourceUniforms({ ambientLight, pointLights, directionalLights }), {
|
|
50
|
-
lighting_uEnabled: true
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
// Support for array of lights. Type of light is detected by type field
|
|
54
|
-
if ('lights' in opts) {
|
|
55
|
-
const lightSources = { pointLights: [], directionalLights: [] };
|
|
56
|
-
// @ts-expect-error
|
|
57
|
-
for (const light of opts.lights || []) {
|
|
58
|
-
switch (light.type) {
|
|
59
|
-
case 'ambient':
|
|
60
|
-
// Note: Only uses last ambient light
|
|
61
|
-
// TODO - add ambient light sources on CPU?
|
|
62
|
-
lightSources.ambientLight = light;
|
|
63
|
-
break;
|
|
64
|
-
case 'directional':
|
|
65
|
-
lightSources.directionalLights?.push(light);
|
|
66
|
-
break;
|
|
67
|
-
case 'point':
|
|
68
|
-
lightSources.pointLights?.push(light);
|
|
69
|
-
break;
|
|
70
|
-
default:
|
|
71
|
-
// eslint-disable-next-line
|
|
72
|
-
// console.warn(light.type);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// Call the `opts.lightSources`` version
|
|
76
|
-
return getUniforms({ lightSources });
|
|
77
|
-
}
|
|
78
|
-
return {};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* An implementation of PBR (Physically-Based Rendering).
|
|
82
|
-
* Physically Based Shading of a microfacet surface defined by a glTF material.
|
|
83
|
-
*/
|
|
84
|
-
export const lights = {
|
|
85
|
-
name: 'lights',
|
|
86
|
-
vs: lightingShader,
|
|
87
|
-
fs: lightingShader,
|
|
88
|
-
getUniforms,
|
|
89
|
-
defines: {
|
|
90
|
-
MAX_LIGHTS: 3
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
//# sourceMappingURL=lights.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lights.js","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/lights/lights.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const fs = "precision highp float;\n\nuniform bool pbr_uUnlit;\n\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\n\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\n\nuniform vec3 u_Camera;\n\n// debugging flags used for shader output of intermediate PBR variables\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\n\nin vec3 pbr_vPosition;\n\nin vec2 pbr_vUV;\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{\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};\n\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\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\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 getNormal()\n{\n // Retrieve the tangent space matrix\n#ifndef HAS_TANGENTS\n vec3 pos_dx = dFdx(pbr_vPosition);\n vec3 pos_dy = dFdy(pbr_vPosition);\n vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\n vec3 tex_dy = dFdy(vec3(pbr_vUV, 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#ifdef HAS_NORMALMAP\n vec3 n = texture(u_NormalSampler, pbr_vUV).rgb;\n n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\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 return n;\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 pbrInputs, vec3 n, vec3 reflection)\n{\n float mipCount = 9.0; // resolution of 512x512\n float lod = (pbrInputs.perceptualRoughness * mipCount);\n // retrieve a scale and bias to F0. See [1], Figure 3\n vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT,\n vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\n vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n\n#ifdef USE_TEX_LOD\n vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\n vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\n\n vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\n vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\n\n // For presentation, this allows us to disable IBL terms\n diffuse *= u_ScaleIBLAmbient.x;\n specular *= u_ScaleIBLAmbient.y;\n\n return diffuse + specular;\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 pbrInputs)\n{\n return pbrInputs.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 pbrInputs)\n{\n return pbrInputs.reflectance0 +\n (pbrInputs.reflectance90 - pbrInputs.reflectance0) *\n pow(clamp(1.0 - pbrInputs.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 pbrInputs)\n{\n float NdotL = pbrInputs.NdotL;\n float NdotV = pbrInputs.NdotV;\n float r = pbrInputs.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 pbrInputs)\n{\n float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\n float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\n return roughnessSq / (M_PI * f * f);\n}\n\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\n pbrInputs.NdotL = 1.0;\n pbrInputs.NdotH = 0.0;\n pbrInputs.LdotH = 0.0;\n pbrInputs.VdotH = 1.0;\n}\n\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\n vec3 n = pbrInputs.n;\n vec3 v = pbrInputs.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 pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\n pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\n pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\n pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\n\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\n vec3 light_direction = normalize(pointLight.position - pbr_vPosition);\n PBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\n\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\n // Calculate the shading terms for the microfacet specular shading model\n vec3 F = specularReflection(pbrInputs);\n float G = geometricOcclusion(pbrInputs);\n float D = microfacetDistribution(pbrInputs);\n\n // Calculation of analytical lighting contribution\n vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\n vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\n // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)\n return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\n\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n // The albedo may be defined from a base texture or a flat color\n#ifdef HAS_BASECOLORMAP\n vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\n vec4 baseColor = u_BaseColorFactor;\n#endif\n\n#ifdef ALPHA_CUTOFF\n if (baseColor.a < u_AlphaCutoff) {\n discard;\n }\n#endif\n\n vec3 color = vec3(0, 0, 0);\n\n if(pbr_uUnlit){\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 = u_MetallicRoughnessValues.y;\n float metallic = u_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(u_MetallicRoughnessSampler, pbr_vUV);\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 // 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 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 // 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\n vec3 n = getNormal(); // normal at surface point\n vec3 v = normalize(u_Camera - pbr_vPosition); // Vector from surface point to camera\n\n float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\n vec3 reflection = -normalize(reflect(v, n));\n\n PBRInfo pbrInputs = 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#ifdef USE_LIGHTS\n // Apply ambient light\n PBRInfo_setAmbientLight(pbrInputs);\n color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\n\n // Apply directional light\n for(int i = 0; i < lighting_uDirectionalLightCount; i++) {\n if (i < lighting_uDirectionalLightCount) {\n PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\n color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n }\n }\n\n // Apply point light\n for(int i = 0; i < lighting_uPointLightCount; i++) {\n if (i < lighting_uPointLightCount) {\n PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\n float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\n color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n }\n }\n#endif\n\n // Calculate lighting contribution from image based lighting source (IBL)\n#ifdef USE_IBL\n color += getIBLContribution(pbrInputs, n, reflection);\n#endif\n\n // Apply optional PBR terms for additional (optional) shading\n#ifdef HAS_OCCLUSIONMAP\n float ao = texture(u_OcclusionSampler, pbr_vUV).r;\n color = mix(color, color * ao, u_OcclusionStrength);\n#endif\n\n#ifdef HAS_EMISSIVEMAP\n vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\n color += emissive;\n#endif\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, u_ScaleFGDSpec.x);\n // color = mix(color, vec3(G), u_ScaleFGDSpec.y);\n // color = mix(color, vec3(D), u_ScaleFGDSpec.z);\n // color = mix(color, specContrib, u_ScaleFGDSpec.w);\n\n // color = mix(color, diffuseContrib, u_ScaleDiffBaseMR.x);\n color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\n color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\n color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n\n }\n\n return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n";
|
|
2
|
-
//# sourceMappingURL=pbr-fragment-glsl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pbr-fragment-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,EAAE,+rbA8Xd,CAAC"}
|