@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.
Files changed (170) hide show
  1. package/dist/dist.dev.js +1614 -3716
  2. package/dist/dist.min.js +278 -484
  3. package/dist/index.cjs +366 -804
  4. package/dist/index.cjs.map +4 -4
  5. package/dist/index.d.ts +0 -6
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +0 -10
  8. package/dist/index.js.map +1 -1
  9. package/dist/lib/shader-assembly/assemble-shaders.d.ts +6 -4
  10. package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -1
  11. package/dist/lib/shader-assembly/assemble-shaders.js +14 -9
  12. package/dist/lib/shader-assembly/assemble-shaders.js.map +1 -1
  13. package/dist/lib/shader-assembly/platform-info.d.ts +1 -1
  14. package/dist/lib/shader-assembly/platform-info.d.ts.map +1 -1
  15. package/dist/lib/shader-module/shader-module.d.ts +1 -1
  16. package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
  17. package/dist/lib/wgsl/get-shader-layout-wgsl.d.ts.map +1 -1
  18. package/dist/lib/wgsl/get-shader-layout-wgsl.js +3 -1
  19. package/dist/lib/wgsl/get-shader-layout-wgsl.js.map +1 -1
  20. package/dist/modules/engine/project/project.d.ts.map +1 -1
  21. package/dist/modules/engine/project/project.js +4 -2
  22. package/dist/modules/engine/project/project.js.map +1 -1
  23. package/dist/modules/lighting/gouraud-material/gouraud-material.js +1 -1
  24. package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -1
  25. package/dist/modules/lighting/lights/{lighting-uniforms-glsl.d.ts → lighting-glsl.d.ts} +1 -1
  26. package/dist/modules/lighting/lights/lighting-glsl.d.ts.map +1 -0
  27. package/dist/modules/lighting/lights/{lighting-uniforms-glsl.js → lighting-glsl.js} +1 -1
  28. package/dist/modules/lighting/lights/lighting-glsl.js.map +1 -0
  29. package/dist/modules/lighting/lights/{lighting-uniforms-wgsl.d.ts → lighting-wgsl.d.ts} +1 -1
  30. package/dist/modules/lighting/lights/lighting-wgsl.d.ts.map +1 -0
  31. package/dist/modules/lighting/lights/{lighting-uniforms-wgsl.js → lighting-wgsl.js} +1 -1
  32. package/dist/modules/lighting/lights/lighting-wgsl.js.map +1 -0
  33. package/dist/modules/lighting/lights/lighting.d.ts +1 -3
  34. package/dist/modules/lighting/lights/lighting.d.ts.map +1 -1
  35. package/dist/modules/lighting/lights/lighting.js +4 -4
  36. package/dist/modules/lighting/lights/lighting.js.map +1 -1
  37. package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
  38. package/dist/modules/lighting/no-material/dirlight.js +1 -2
  39. package/dist/modules/lighting/no-material/dirlight.js.map +1 -1
  40. package/dist/modules/lighting/pbr-material/{pbr-fragment-glsl.d.ts → pbr-material-glsl.d.ts} +2 -1
  41. package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -0
  42. package/dist/modules/lighting/pbr-material/{pbr-fragment-glsl.js → pbr-material-glsl.js} +36 -1
  43. package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -0
  44. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +3 -0
  45. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -0
  46. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +487 -0
  47. package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -0
  48. package/dist/modules/lighting/pbr-material/pbr-material.d.ts +11 -4
  49. package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
  50. package/dist/modules/lighting/pbr-material/pbr-material.js +12 -12
  51. package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -1
  52. package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -1
  53. package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -1
  54. package/dist/modules/lighting/phong-material/phong-material.js +1 -1
  55. package/dist/modules/lighting/phong-material/phong-material.js.map +1 -1
  56. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +1 -1
  57. package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -1
  58. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +2 -0
  59. package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -1
  60. package/dist/modules/math/random/random.d.ts +1 -0
  61. package/dist/modules/math/random/random.d.ts.map +1 -1
  62. package/dist/modules/math/random/random.js +7 -0
  63. package/dist/modules/math/random/random.js.map +1 -1
  64. package/package.json +3 -3
  65. package/src/index.ts +0 -17
  66. package/src/lib/shader-assembly/assemble-shaders.ts +12 -11
  67. package/src/lib/shader-assembly/platform-info.ts +1 -1
  68. package/src/lib/shader-module/shader-module.ts +1 -1
  69. package/src/lib/wgsl/get-shader-layout-wgsl.ts +7 -5
  70. package/src/modules/engine/project/project.ts +8 -5
  71. package/src/modules/lighting/gouraud-material/gouraud-material.ts +1 -1
  72. package/src/modules/lighting/lights/lighting.ts +4 -4
  73. package/src/modules/lighting/no-material/dirlight.ts +2 -3
  74. package/src/modules/lighting/pbr-material/{pbr-fragment-glsl.ts → pbr-material-glsl.ts} +36 -1
  75. package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +490 -0
  76. package/src/modules/lighting/pbr-material/pbr-material.ts +12 -12
  77. package/src/modules/lighting/pbr-material/pbr-projection.ts +0 -2
  78. package/src/modules/lighting/phong-material/phong-material.ts +1 -1
  79. package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +2 -0
  80. package/src/modules/math/random/random.ts +8 -0
  81. package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +0 -1
  82. package/dist/modules/lighting/lights/lighting-uniforms-glsl.js.map +0 -1
  83. package/dist/modules/lighting/lights/lighting-uniforms-wgsl.d.ts.map +0 -1
  84. package/dist/modules/lighting/lights/lighting-uniforms-wgsl.js.map +0 -1
  85. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.d.ts.map +0 -1
  86. package/dist/modules/lighting/pbr-material/pbr-fragment-glsl.js.map +0 -1
  87. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts +0 -2
  88. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.d.ts.map +0 -1
  89. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js +0 -67
  90. package/dist/modules/lighting/pbr-material/pbr-uniforms-glsl.js.map +0 -1
  91. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts +0 -2
  92. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.d.ts.map +0 -1
  93. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js +0 -39
  94. package/dist/modules/lighting/pbr-material/pbr-vertex-glsl.js.map +0 -1
  95. package/dist/modules/module-injectors.d.ts +0 -3
  96. package/dist/modules/module-injectors.d.ts.map +0 -1
  97. package/dist/modules/module-injectors.js +0 -31
  98. package/dist/modules/module-injectors.js.map +0 -1
  99. package/dist/modules-webgl1/geometry/geometry.d.ts +0 -9
  100. package/dist/modules-webgl1/geometry/geometry.d.ts.map +0 -1
  101. package/dist/modules-webgl1/geometry/geometry.js +0 -39
  102. package/dist/modules-webgl1/geometry/geometry.js.map +0 -1
  103. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts +0 -10
  104. package/dist/modules-webgl1/lighting/dirlight/dirlight.d.ts.map +0 -1
  105. package/dist/modules-webgl1/lighting/dirlight/dirlight.js +0 -38
  106. package/dist/modules-webgl1/lighting/dirlight/dirlight.js.map +0 -1
  107. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts +0 -2
  108. package/dist/modules-webgl1/lighting/lights/lights-glsl.d.ts.map +0 -1
  109. package/dist/modules-webgl1/lighting/lights/lights-glsl.js +0 -40
  110. package/dist/modules-webgl1/lighting/lights/lights-glsl.js.map +0 -1
  111. package/dist/modules-webgl1/lighting/lights/lights.d.ts +0 -38
  112. package/dist/modules-webgl1/lighting/lights/lights.d.ts.map +0 -1
  113. package/dist/modules-webgl1/lighting/lights/lights.js +0 -93
  114. package/dist/modules-webgl1/lighting/lights/lights.js.map +0 -1
  115. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts +0 -2
  116. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.d.ts.map +0 -1
  117. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js +0 -393
  118. package/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js.map +0 -1
  119. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts +0 -2
  120. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.d.ts.map +0 -1
  121. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js +0 -43
  122. package/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js.map +0 -1
  123. package/dist/modules-webgl1/lighting/pbr/pbr.d.ts +0 -23
  124. package/dist/modules-webgl1/lighting/pbr/pbr.d.ts.map +0 -1
  125. package/dist/modules-webgl1/lighting/pbr/pbr.js +0 -21
  126. package/dist/modules-webgl1/lighting/pbr/pbr.js.map +0 -1
  127. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts +0 -2
  128. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.d.ts.map +0 -1
  129. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js +0 -79
  130. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js.map +0 -1
  131. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.d.ts +0 -45
  132. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.d.ts.map +0 -1
  133. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js +0 -44
  134. package/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js.map +0 -1
  135. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts +0 -2
  136. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.d.ts.map +0 -1
  137. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js +0 -171
  138. package/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js.map +0 -1
  139. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts +0 -2
  140. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.d.ts.map +0 -1
  141. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js +0 -675
  142. package/dist/modules-webgl1/math/fp64/fp64-functions-glsl.js.map +0 -1
  143. package/dist/modules-webgl1/math/fp64/fp64.d.ts +0 -35
  144. package/dist/modules-webgl1/math/fp64/fp64.d.ts.map +0 -1
  145. package/dist/modules-webgl1/math/fp64/fp64.js +0 -38
  146. package/dist/modules-webgl1/math/fp64/fp64.js.map +0 -1
  147. package/dist/modules-webgl1/project/project.d.ts +0 -20
  148. package/dist/modules-webgl1/project/project.d.ts.map +0 -1
  149. package/dist/modules-webgl1/project/project.js +0 -114
  150. package/dist/modules-webgl1/project/project.js.map +0 -1
  151. package/src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts +0 -67
  152. package/src/modules/lighting/pbr-material/pbr-vertex-glsl.ts +0 -39
  153. package/src/modules/module-injectors.ts +0 -32
  154. package/src/modules-webgl1/geometry/geometry.ts +0 -41
  155. package/src/modules-webgl1/lighting/dirlight/dirlight.ts +0 -50
  156. package/src/modules-webgl1/lighting/lights/lights-glsl.ts +0 -40
  157. package/src/modules-webgl1/lighting/lights/lights.ts +0 -143
  158. package/src/modules-webgl1/lighting/pbr/README.md +0 -12
  159. package/src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts +0 -396
  160. package/src/modules-webgl1/lighting/pbr/pbr-vertex-glsl.ts +0 -43
  161. package/src/modules-webgl1/lighting/pbr/pbr.ts +0 -23
  162. package/src/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.ts +0 -79
  163. package/src/modules-webgl1/lighting/phong-lighting/phong-lighting.ts +0 -64
  164. package/src/modules-webgl1/math/fp64/fp64-arithmetic-glsl.ts +0 -171
  165. package/src/modules-webgl1/math/fp64/fp64-functions-glsl.ts +0 -675
  166. package/src/modules-webgl1/math/fp64/fp64.ts +0 -44
  167. package/src/modules-webgl1/project/README.md +0 -52
  168. package/src/modules-webgl1/project/project.ts +0 -135
  169. /package/src/modules/lighting/lights/{lighting-uniforms-glsl.ts → lighting-glsl.ts} +0 -0
  170. /package/src/modules/lighting/lights/{lighting-uniforms-wgsl.ts → lighting-wgsl.ts} +0 -0
@@ -0,0 +1,490 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ // Attribution:
6
+ // MIT license, Copyright (c) 2016-2017 Mohamad Moneimne and Contributors
7
+ // This fragment shader defines a reference implementation for Physically Based Shading of
8
+ // a microfacet surface material defined by a glTF model.
9
+
10
+ // TODO - better do the checks outside of shader
11
+
12
+ export const pbrMaterialUniforms = /* wgsl */ `\
13
+ uniform Projection {
14
+ // Projection
15
+ vec3 u_Camera;
16
+ };
17
+
18
+ uniform pbrMaterialUniforms {
19
+ // Material is unlit
20
+ bool unlit;
21
+
22
+ // Base color map
23
+ bool baseColorMapEnabled;
24
+ vec4 baseColorFactor;
25
+
26
+ bool normalMapEnabled;
27
+ float normalScale; // #ifdef HAS_NORMALMAP
28
+
29
+ bool emissiveMapEnabled;
30
+ vec3 emissiveFactor; // #ifdef HAS_EMISSIVEMAP
31
+
32
+ vec2 metallicRoughnessValues;
33
+ bool metallicRoughnessMapEnabled;
34
+
35
+ bool occlusionMapEnabled;
36
+ float occlusionStrength; // #ifdef HAS_OCCLUSIONMAP
37
+
38
+ bool alphaCutoffEnabled;
39
+ float alphaCutoff; // #ifdef ALPHA_CUTOFF
40
+
41
+ // IBL
42
+ bool IBLenabled;
43
+ vec2 scaleIBLAmbient; // #ifdef USE_IBL
44
+
45
+ // debugging flags used for shader output of intermediate PBR variables
46
+ // #ifdef PBR_DEBUG
47
+ vec4 scaleDiffBaseMR;
48
+ vec4 scaleFGDSpec;
49
+ // #endif
50
+ };
51
+
52
+ // Samplers
53
+ #ifdef HAS_BASECOLORMAP
54
+ uniform sampler2D u_BaseColorSampler;
55
+ #endif
56
+ #ifdef HAS_NORMALMAP
57
+ uniform sampler2D u_NormalSampler;
58
+ #endif
59
+ #ifdef HAS_EMISSIVEMAP
60
+ uniform sampler2D u_EmissiveSampler;
61
+ #endif
62
+ #ifdef HAS_METALROUGHNESSMAP
63
+ uniform sampler2D u_MetallicRoughnessSampler;
64
+ #endif
65
+ #ifdef HAS_OCCLUSIONMAP
66
+ uniform sampler2D u_OcclusionSampler;
67
+ #endif
68
+ #ifdef USE_IBL
69
+ uniform samplerCube u_DiffuseEnvSampler;
70
+ uniform samplerCube u_SpecularEnvSampler;
71
+ uniform sampler2D u_brdfLUT;
72
+ #endif
73
+
74
+ `;
75
+
76
+ export const source = /* wgsl */ `\
77
+ struct PBRFragmentInputs {
78
+ pbr_vPosition: vec3f,
79
+ pbr_vUV: vec2f,
80
+ pbr_vTBN: mat3f,
81
+ pbr_vNormal: vec3f
82
+ };
83
+
84
+ var fragmentInputs: PBRFragmentInputs;
85
+
86
+ fn pbr_setPositionNormalTangentUV(position: vec4f, normal: vec4f, tangent: vec4f, uv: vec2f)
87
+ {
88
+ var pos: vec4f = pbrProjection.modelMatrix * position;
89
+ pbr_vPosition = vec3(pos.xyz) / pos.w;
90
+
91
+ #ifdef HAS_NORMALS
92
+ #ifdef HAS_TANGENTS
93
+ let normalW: vec3f = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
94
+ let tangentW: vec3f = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
95
+ let bitangentW: vec3f = cross(normalW, tangentW) * tangent.w;
96
+ fragmentInputs,pbr_vTBN = mat3(tangentW, bitangentW, normalW);
97
+ #else // HAS_TANGENTS != 1
98
+ fragmentInputs.pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
99
+ #endif
100
+ #endif
101
+
102
+ #ifdef HAS_UV
103
+ pbr_vUV = uv;
104
+ #else
105
+ pbr_vUV = vec2(0.,0.);
106
+ #endif
107
+ }
108
+
109
+ struct pbrMaterialUniforms {
110
+ // Material is unlit
111
+ unlit: uint32,
112
+
113
+ // Base color map
114
+ baseColorMapEnabled: uint32,
115
+ baseColorFactor: vec4f,
116
+
117
+ normalMapEnabled : uint32,
118
+ normalScale: f32, // #ifdef HAS_NORMALMAP
119
+
120
+ emissiveMapEnabled: uint32,
121
+ emissiveFactor: vec3f, // #ifdef HAS_EMISSIVEMAP
122
+
123
+ metallicRoughnessValues: vec2f,
124
+ metallicRoughnessMapEnabled: uint32,
125
+
126
+ occlusionMapEnabled: i32,
127
+ occlusionStrength: f32, // #ifdef HAS_OCCLUSIONMAP
128
+
129
+ alphaCutoffEnabled: i32,
130
+ alphaCutoff: f32, // #ifdef ALPHA_CUTOFF
131
+
132
+ // IBL
133
+ IBLenabled: i32,
134
+ scaleIBLAmbient: vec2f, // #ifdef USE_IBL
135
+
136
+ // debugging flags used for shader output of intermediate PBR variables
137
+ // #ifdef PBR_DEBUG
138
+ scaleDiffBaseMR: vec4f,
139
+ scaleFGDSpec: vec4f
140
+ // #endif
141
+ }
142
+
143
+ @binding(2) @group(0) var<uniform> material : pbrMaterialUniforms;
144
+
145
+ // Samplers
146
+ #ifdef HAS_BASECOLORMAP
147
+ uniform sampler2D pbr_baseColorSampler;
148
+ #endif
149
+ #ifdef HAS_NORMALMAP
150
+ uniform sampler2D pbr_normalSampler;
151
+ #endif
152
+ #ifdef HAS_EMISSIVEMAP
153
+ uniform sampler2D pbr_emissiveSampler;
154
+ #endif
155
+ #ifdef HAS_METALROUGHNESSMAP
156
+ uniform sampler2D pbr_metallicRoughnessSampler;
157
+ #endif
158
+ #ifdef HAS_OCCLUSIONMAP
159
+ uniform sampler2D pbr_occlusionSampler;
160
+ #endif
161
+ #ifdef USE_IBL
162
+ uniform samplerCube pbr_diffuseEnvSampler;
163
+ uniform samplerCube pbr_specularEnvSampler;
164
+ uniform sampler2D pbr_brdfLUT;
165
+ #endif
166
+
167
+ // Encapsulate the various inputs used by the various functions in the shading equation
168
+ // We store values in this struct to simplify the integration of alternative implementations
169
+ // of the shading terms, outlined in the Readme.MD Appendix.
170
+ struct PBRInfo {
171
+ NdotL: f32, // cos angle between normal and light direction
172
+ NdotV: f32, // cos angle between normal and view direction
173
+ NdotH: f32, // cos angle between normal and half vector
174
+ LdotH: f32, // cos angle between light direction and half vector
175
+ VdotH: f32, // cos angle between view direction and half vector
176
+ perceptualRoughness: f32, // roughness value, as authored by the model creator (input to shader)
177
+ metalness: f32, // metallic value at the surface
178
+ reflectance0: vec3f, // full reflectance color (normal incidence angle)
179
+ reflectance90: vec3f, // reflectance color at grazing angle
180
+ alphaRoughness: f32, // roughness mapped to a more linear change in the roughness (proposed by [2])
181
+ diffuseColor: vec3f, // color contribution from diffuse lighting
182
+ specularColor: vec3f, // color contribution from specular lighting
183
+ n: vec3f, // normal at surface point
184
+ v: vec3f, // vector from surface point to camera
185
+ };
186
+
187
+ const M_PI = 3.141592653589793;
188
+ const c_MinRoughness = 0.04;
189
+
190
+ fn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f
191
+ {
192
+ #ifdef MANUAL_SRGB
193
+ #ifdef SRGB_FAST_APPROXIMATION
194
+ var linOut: vec3f = pow(srgbIn.xyz,vec3(2.2));
195
+ #else // SRGB_FAST_APPROXIMATION
196
+ var bLess: vec3f = step(vec3(0.04045),srgbIn.xyz);
197
+ var linOut: vec3f = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
198
+ #endif //SRGB_FAST_APPROXIMATION
199
+ return vec4f(linOut,srgbIn.w);;
200
+ #else //MANUAL_SRGB
201
+ return srgbIn;
202
+ #endif //MANUAL_SRGB
203
+ }
204
+
205
+ // Find the normal for this fragment, pulling either from a predefined normal map
206
+ // or from the interpolated mesh normal and tangent attributes.
207
+ fn getNormal() -> vec3f
208
+ {
209
+ // Retrieve the tangent space matrix
210
+ #ifndef HAS_TANGENTS
211
+ var pos_dx: vec3f = dFdx(pbr_vPosition);
212
+ var pos_dy: vec3f = dFdy(pbr_vPosition);
213
+ var tex_dx: vec3f = dFdx(vec3(pbr_vUV, 0.0));
214
+ var tex_dy: vec3f = dFdy(vec3(pbr_vUV, 0.0));
215
+ var t: vec3f = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
216
+
217
+ #ifdef HAS_NORMALS
218
+ var ng: vec3f = normalize(pbr_vNormal);
219
+ #else
220
+ var ng: vec3f = cross(pos_dx, pos_dy);
221
+ #endif
222
+
223
+ t = normalize(t - ng * dot(ng, t));
224
+ var b: vec3f = normalize(cross(ng, t));
225
+ var tbn: mat3f = mat3f(t, b, ng);
226
+ #else // HAS_TANGENTS
227
+ var tbn: mat3f = pbr_vTBN;
228
+ #endif
229
+
230
+ #ifdef HAS_NORMALMAP
231
+ vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
232
+ n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
233
+ #else
234
+ // The tbn matrix is linearly interpolated, so we need to re-normalize
235
+ vec3 n = normalize(tbn[2].xyz);
236
+ #endif
237
+
238
+ return n;
239
+ }
240
+
241
+ // Calculation of the lighting contribution from an optional Image Based Light source.
242
+ // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
243
+ // See our README.md on Environment Maps [3] for additional discussion.
244
+ #ifdef USE_IBL
245
+ fn getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection) -> vec3f
246
+ {
247
+ float mipCount = 9.0; // resolution of 512x512
248
+ float lod = (pbrInfo.perceptualRoughness * mipCount);
249
+ // retrieve a scale and bias to F0. See [1], Figure 3
250
+ vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
251
+ vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
252
+ vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
253
+
254
+ #ifdef USE_TEX_LOD
255
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
256
+ #else
257
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
258
+ #endif
259
+
260
+ vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
261
+ vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
262
+
263
+ // For presentation, this allows us to disable IBL terms
264
+ diffuse *= pbrMaterial.scaleIBLAmbient.x;
265
+ specular *= pbrMaterial.scaleIBLAmbient.y;
266
+
267
+ return diffuse + specular;
268
+ }
269
+ #endif
270
+
271
+ // Basic Lambertian diffuse
272
+ // Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog
273
+ // See also [1], Equation 1
274
+ fn diffuse(pbrInfo: PBRInfo) -> vec3<f32> {
275
+ return pbrInfo.diffuseColor / PI;
276
+ }
277
+
278
+ // The following equation models the Fresnel reflectance term of the spec equation (aka F())
279
+ // Implementation of fresnel from [4], Equation 15
280
+ fn specularReflection(pbrInfo: PBRInfo) -> vec3<f32> {
281
+ return pbrInfo.reflectance0 +
282
+ (pbrInfo.reflectance90 - pbrInfo.reflectance0) *
283
+ pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
284
+ }
285
+
286
+ // This calculates the specular geometric attenuation (aka G()),
287
+ // where rougher material will reflect less light back to the viewer.
288
+ // This implementation is based on [1] Equation 4, and we adopt their modifications to
289
+ // alphaRoughness as input as originally proposed in [2].
290
+ fn geometricOcclusion(pbrInfo: PBRInfo) -> f32 {
291
+ let NdotL: f32 = pbrInfo.NdotL;
292
+ let NdotV: f32 = pbrInfo.NdotV;
293
+ let r: f32 = pbrInfo.alphaRoughness;
294
+
295
+ let attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
296
+ let attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
297
+ return attenuationL * attenuationV;
298
+ }
299
+
300
+ // The following equation(s) model the distribution of microfacet normals across
301
+ // the area being drawn (aka D())
302
+ // Implementation from "Average Irregularity Representation of a Roughened Surface
303
+ // for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz
304
+ // Follows the distribution function recommended in the SIGGRAPH 2013 course notes
305
+ // from EPIC Games [1], Equation 3.
306
+ fn microfacetDistribution(pbrInfo: PBRInfo) -> f32 {
307
+ let roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;
308
+ let f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;
309
+ return roughnessSq / (PI * f * f);
310
+ }
311
+
312
+ fn PBRInfo_setAmbientLight(pbrInfo: ptr<function, PBRInfo>) {
313
+ (*pbrInfo).NdotL = 1.0;
314
+ (*pbrInfo).NdotH = 0.0;
315
+ (*pbrInfo).LdotH = 0.0;
316
+ (*pbrInfo).VdotH = 1.0;
317
+ }
318
+
319
+ fn PBRInfo_setDirectionalLight(pbrInfo: ptr<function, PBRInfo>, lightDirection: vec3<f32>) {
320
+ let n = (*pbrInfo).n;
321
+ let v = (*pbrInfo).v;
322
+ let l = normalize(lightDirection); // Vector from surface point to light
323
+ let h = normalize(l + v); // Half vector between both l and v
324
+
325
+ (*pbrInfo).NdotL = clamp(dot(n, l), 0.001, 1.0);
326
+ (*pbrInfo).NdotH = clamp(dot(n, h), 0.0, 1.0);
327
+ (*pbrInfo).LdotH = clamp(dot(l, h), 0.0, 1.0);
328
+ (*pbrInfo).VdotH = clamp(dot(v, h), 0.0, 1.0);
329
+ }
330
+
331
+ fn PBRInfo_setPointLight(pbrInfo: ptr<function, PBRInfo>, pointLight: PointLight) {
332
+ let light_direction = normalize(pointLight.position - pbr_vPosition);
333
+ PBRInfo_setDirectionalLight(pbrInfo, light_direction);
334
+ }
335
+
336
+ fn calculateFinalColor(pbrInfo: PBRInfo, lightColor: vec3<f32>) -> vec3<f32> {
337
+ // Calculate the shading terms for the microfacet specular shading model
338
+ let F = specularReflection(pbrInfo);
339
+ let G = geometricOcclusion(pbrInfo);
340
+ let D = microfacetDistribution(pbrInfo);
341
+
342
+ // Calculation of analytical lighting contribution
343
+ let diffuseContrib = (1.0 - F) * diffuse(pbrInfo);
344
+ let specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);
345
+ // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
346
+ return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
347
+ }
348
+
349
+ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
350
+ // The albedo may be defined from a base texture or a flat color
351
+ var baseColor: vec4<f32>;
352
+ #ifdef HAS_BASECOLORMAP
353
+ baseColor = SRGBtoLINEAR(textureSample(pbr_baseColorSampler, pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor;
354
+ #else
355
+ baseColor = pbrMaterial.baseColorFactor;
356
+ #endif
357
+
358
+ #ifdef ALPHA_CUTOFF
359
+ if (baseColor.a < pbrMaterial.alphaCutoff) {
360
+ discard;
361
+ }
362
+ #endif
363
+
364
+ var color = vec3<f32>(0.0, 0.0, 0.0);
365
+
366
+ if (pbrMaterial.unlit) {
367
+ color = baseColor.rgb;
368
+ } else {
369
+ // Metallic and Roughness material properties are packed together
370
+ // In glTF, these factors can be specified by fixed scalar values
371
+ // or from a metallic-roughness map
372
+ var perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
373
+ var metallic = pbrMaterial.metallicRoughnessValues.x;
374
+ #ifdef HAS_METALROUGHNESSMAP
375
+ // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
376
+ // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
377
+ let mrSample = textureSample(pbr_metallicRoughnessSampler, pbr_metallicRoughnessSampler, pbr_vUV);
378
+ perceptualRoughness = mrSample.g * perceptualRoughness;
379
+ metallic = mrSample.b * metallic;
380
+ #endif
381
+ perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
382
+ metallic = clamp(metallic, 0.0, 1.0);
383
+ // Roughness is authored as perceptual roughness; as is convention,
384
+ // convert to material roughness by squaring the perceptual roughness [2].
385
+ let alphaRoughness = perceptualRoughness * perceptualRoughness;
386
+
387
+ let f0 = vec3<f32>(0.04);
388
+ var diffuseColor = baseColor.rgb * (vec3<f32>(1.0) - f0);
389
+ diffuseColor *= 1.0 - metallic;
390
+ let specularColor = mix(f0, baseColor.rgb, metallic);
391
+
392
+ // Compute reflectance.
393
+ let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
394
+
395
+ // For typical incident reflectance range (between 4% to 100%) set the grazing
396
+ // reflectance to 100% for typical fresnel effect.
397
+ // For very low reflectance range on highly diffuse objects (below 4%),
398
+ // incrementally reduce grazing reflectance to 0%.
399
+ let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
400
+ let specularEnvironmentR0 = specularColor;
401
+ let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;
402
+
403
+ let n = getNormal(); // normal at surface point
404
+ let v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
405
+
406
+ let NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
407
+ let reflection = -normalize(reflect(v, n));
408
+
409
+ var pbrInfo = PBRInfo(
410
+ 0.0, // NdotL
411
+ NdotV,
412
+ 0.0, // NdotH
413
+ 0.0, // LdotH
414
+ 0.0, // VdotH
415
+ perceptualRoughness,
416
+ metallic,
417
+ specularEnvironmentR0,
418
+ specularEnvironmentR90,
419
+ alphaRoughness,
420
+ diffuseColor,
421
+ specularColor,
422
+ n,
423
+ v
424
+ );
425
+
426
+ #ifdef USE_LIGHTS
427
+ // Apply ambient light
428
+ PBRInfo_setAmbientLight(&pbrInfo);
429
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
430
+
431
+ // Apply directional light
432
+ for (var i = 0; i < lighting.directionalLightCount; i++) {
433
+ if (i < lighting.directionalLightCount) {
434
+ PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);
435
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
436
+ }
437
+ }
438
+
439
+ // Apply point light
440
+ for (var i = 0; i < lighting.pointLightCount; i++) {
441
+ if (i < lighting.pointLightCount) {
442
+ PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i));
443
+ let attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
444
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
445
+ }
446
+ }
447
+ #endif
448
+
449
+ // Calculate lighting contribution from image based lighting source (IBL)
450
+ #ifdef USE_IBL
451
+ if (pbrMaterial.IBLenabled) {
452
+ color += getIBLContribution(pbrInfo, n, reflection);
453
+ }
454
+ #endif
455
+
456
+ // Apply optional PBR terms for additional (optional) shading
457
+ #ifdef HAS_OCCLUSIONMAP
458
+ if (pbrMaterial.occlusionMapEnabled) {
459
+ let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSampler, pbr_vUV).r;
460
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
461
+ }
462
+ #endif
463
+
464
+ #ifdef HAS_EMISSIVEMAP
465
+ if (pbrMaterial.emissiveMapEnabled) {
466
+ let emissive = SRGBtoLINEAR(textureSample(pbr_emissiveSampler, pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
467
+ color += emissive;
468
+ }
469
+ #endif
470
+
471
+ // This section uses mix to override final color for reference app visualization
472
+ // of various parameters in the lighting equation.
473
+ #ifdef PBR_DEBUG
474
+ // TODO: Figure out how to debug multiple lights
475
+
476
+ // color = mix(color, F, pbr_scaleFGDSpec.x);
477
+ // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);
478
+ // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);
479
+ // color = mix(color, specContrib, pbr_scaleFGDSpec.w);
480
+
481
+ // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);
482
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
483
+ color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z);
484
+ color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
485
+ #endif
486
+ }
487
+
488
+ return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), baseColor.a);
489
+ }
490
+ `;
@@ -17,8 +17,8 @@ import type {
17
17
  import {ShaderModule} from '../../../lib/shader-module/shader-module';
18
18
  import {lighting} from '../lights/lighting';
19
19
 
20
- import {vs} from './pbr-vertex-glsl';
21
- import {fs} from './pbr-fragment-glsl';
20
+ import {vs, fs} from './pbr-material-glsl';
21
+ import {source} from './pbr-material-wgsl';
22
22
  import {pbrProjection} from './pbr-projection';
23
23
 
24
24
  /** Non-uniform block bindings for pbr module */
@@ -80,20 +80,20 @@ export const pbrMaterial = {
80
80
 
81
81
  name: 'pbrMaterial',
82
82
  dependencies: [lighting, pbrProjection],
83
+ source,
83
84
  vs,
84
85
  fs,
85
86
 
86
87
  defines: {
87
- LIGHTING_FRAGMENT: 1
88
- // TODO defining these as 0 breaks shader
89
- // HAS_NORMALMAP: 0
90
- // HAS_EMISSIVEMAP: 0,
91
- // HAS_OCCLUSIONMAP: 0,
92
- // HAS_BASECOLORMAP: 0,
93
- // HAS_METALROUGHNESSMAP: 0,
94
- // ALPHA_CUTOFF: 0
95
- // USE_IBL: 0
96
- // PBR_DEBUG: 0
88
+ LIGHTING_FRAGMENT: true,
89
+ HAS_NORMALMAP: false,
90
+ HAS_EMISSIVEMAP: false,
91
+ HAS_OCCLUSIONMAP: false,
92
+ HAS_BASECOLORMAP: false,
93
+ HAS_METALROUGHNESSMAP: false,
94
+ ALPHA_CUTOFF: false,
95
+ USE_IBL: false,
96
+ PBR_DEBUG: false
97
97
  },
98
98
  getUniforms: props => props,
99
99
  uniformTypes: {
@@ -2,8 +2,6 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- /* eslint-disable camelcase */
6
-
7
5
  import type {NumberArray3, NumberArray16} from '@math.gl/core';
8
6
 
9
7
  import {ShaderModule} from '../../../lib/shader-module/shader-module';
@@ -25,7 +25,7 @@ export const phongMaterial: ShaderModule<PhongMaterialProps> = {
25
25
  vs: PHONG_VS,
26
26
  fs: PHONG_FS,
27
27
  defines: {
28
- LIGHTING_FRAGMENT: 1
28
+ LIGHTING_FRAGMENT: true
29
29
  },
30
30
  uniformTypes: {
31
31
  ambient: 'f32',
@@ -12,6 +12,8 @@ uniform phongMaterialUniforms {
12
12
  `;
13
13
 
14
14
  export const PHONG_FS = /* glsl */ `\
15
+ #define MAX_LIGHTS 1
16
+
15
17
  uniform phongMaterialUniforms {
16
18
  uniform float ambient;
17
19
  uniform float diffuse;
@@ -4,6 +4,13 @@
4
4
 
5
5
  import {ShaderModule} from '../../../lib/shader-module/shader-module';
6
6
 
7
+ const source = /* wgsl */ `\
8
+ fn random(scale: vec3f, seed: float) -> f32 {
9
+ /* use the fragment position for a different seed per-pixel */
10
+ return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
11
+ }
12
+ `;
13
+
7
14
  const fs = /* glsl */ `\
8
15
  float random(vec3 scale, float seed) {
9
16
  /* use the fragment position for a different seed per-pixel */
@@ -14,5 +21,6 @@ float random(vec3 scale, float seed) {
14
21
  /** Quick random generator for fragment shaders */
15
22
  export const random = {
16
23
  name: 'random',
24
+ source,
17
25
  fs
18
26
  } as const satisfies ShaderModule<{}, {}>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"lighting-uniforms-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-uniforms-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,g3DA2EhC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"lighting-uniforms-glsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-uniforms-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2E9C,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"lighting-uniforms-wgsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-uniforms-wgsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,gjDAoDhC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"lighting-uniforms-wgsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/lights/lighting-uniforms-wgsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoD9C,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pbr-fragment-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-fragment-glsl.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,EAAE,wwcAkZd,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pbr-fragment-glsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-fragment-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,eAAe;AACf,yEAAyE;AAEzE,0FAA0F;AAC1F,yDAAyD;AAEzD,gDAAgD;AAEhD,MAAM,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkZ5B,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const pbrMaterialUniforms = "uniform Projection {\n // Projection\n vec3 u_Camera;\n};\n\nuniform 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 // 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\n// Samplers\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\n#endif\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\n#endif\n\n";
2
- //# sourceMappingURL=pbr-uniforms-glsl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pbr-uniforms-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,01CA8D/B,CAAC"}
@@ -1,67 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- export const pbrMaterialUniforms = /* glsl */ `\
5
- uniform Projection {
6
- // Projection
7
- vec3 u_Camera;
8
- };
9
-
10
- uniform pbrMaterialUniforms {
11
- // Material is unlit
12
- bool unlit;
13
-
14
- // Base color map
15
- bool baseColorMapEnabled;
16
- vec4 baseColorFactor;
17
-
18
- bool normalMapEnabled;
19
- float normalScale; // #ifdef HAS_NORMALMAP
20
-
21
- bool emissiveMapEnabled;
22
- vec3 emissiveFactor; // #ifdef HAS_EMISSIVEMAP
23
-
24
- vec2 metallicRoughnessValues;
25
- bool metallicRoughnessMapEnabled;
26
-
27
- bool occlusionMapEnabled;
28
- float occlusionStrength; // #ifdef HAS_OCCLUSIONMAP
29
-
30
- bool alphaCutoffEnabled;
31
- float alphaCutoff; // #ifdef ALPHA_CUTOFF
32
-
33
- // IBL
34
- bool IBLenabled;
35
- vec2 scaleIBLAmbient; // #ifdef USE_IBL
36
-
37
- // debugging flags used for shader output of intermediate PBR variables
38
- // #ifdef PBR_DEBUG
39
- vec4 scaleDiffBaseMR;
40
- vec4 scaleFGDSpec;
41
- // #endif
42
- };
43
-
44
- // Samplers
45
- #ifdef HAS_BASECOLORMAP
46
- uniform sampler2D u_BaseColorSampler;
47
- #endif
48
- #ifdef HAS_NORMALMAP
49
- uniform sampler2D u_NormalSampler;
50
- #endif
51
- #ifdef HAS_EMISSIVEMAP
52
- uniform sampler2D u_EmissiveSampler;
53
- #endif
54
- #ifdef HAS_METALROUGHNESSMAP
55
- uniform sampler2D u_MetallicRoughnessSampler;
56
- #endif
57
- #ifdef HAS_OCCLUSIONMAP
58
- uniform sampler2D u_OcclusionSampler;
59
- #endif
60
- #ifdef USE_IBL
61
- uniform samplerCube u_DiffuseEnvSampler;
62
- uniform samplerCube u_SpecularEnvSampler;
63
- uniform sampler2D u_brdfLUT;
64
- #endif
65
-
66
- `;
67
- //# sourceMappingURL=pbr-uniforms-glsl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pbr-uniforms-glsl.js","sourceRoot":"","sources":["../../../../src/modules/lighting/pbr-material/pbr-uniforms-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8D7C,CAAC"}