@luma.gl/shadertools 9.0.16 → 9.0.19
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 +90 -97
- package/dist/dist.min.js +81 -78
- package/dist/index.cjs +34 -46
- package/dist/index.cjs.map +2 -2
- package/dist/lib/shader-module/shader-module.d.ts +22 -13
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -1
- package/dist/lib/shader-module/shader-pass.d.ts +4 -2
- package/dist/lib/shader-module/shader-pass.d.ts.map +1 -1
- package/dist/lib/utils/uniform-types.d.ts +49 -0
- package/dist/lib/utils/uniform-types.d.ts.map +1 -0
- package/dist/lib/utils/uniform-types.js +1 -0
- package/dist/modules/engine/picking/picking.d.ts +5 -5
- package/dist/modules/engine/picking/picking.d.ts.map +1 -1
- package/dist/modules/engine/picking/picking.js +2 -2
- package/dist/modules/engine/project/project.d.ts +9 -8
- package/dist/modules/engine/project/project.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-material.js +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/gouraud-material/gouraud-shaders-glsl.js +15 -13
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting-uniforms-glsl.js +3 -3
- package/dist/modules/lighting/lights/lighting-uniforms.d.ts +15 -14
- package/dist/modules/lighting/lights/lighting-uniforms.d.ts.map +1 -1
- package/dist/modules/lighting/lights/lighting-uniforms.js +8 -5
- package/dist/modules/lighting/no-material/dirlight.d.ts +2 -2
- package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -1
- package/dist/modules/lighting/no-material/dirlight.js +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts +14 -13
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -1
- package/dist/modules/lighting/pbr-material/pbr-material.js +0 -11
- package/dist/modules/lighting/phong-material/phong-material.js +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 -1
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts +2 -2
- package/dist/modules/postprocessing/image-blur-filters/tiltshift.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts +1 -1
- package/dist/modules/postprocessing/image-blur-filters/triangleblur.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts +1 -1
- package/dist/modules/postprocessing/image-blur-filters/zoomblur.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts +1 -1
- package/dist/modules/postprocessing/image-fun-filters/colorhalftone.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts +1 -1
- package/dist/modules/postprocessing/image-fun-filters/dotscreen.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts +1 -1
- package/dist/modules/postprocessing/image-fun-filters/hexagonalpixelate.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts +2 -2
- package/dist/modules/postprocessing/image-fun-filters/magnify.d.ts.map +1 -1
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts +1 -1
- package/dist/modules/postprocessing/image-warp-filters/bulgepinch.d.ts.map +1 -1
- package/dist/modules-webgl1/project/project.d.ts +6 -4
- package/dist/modules-webgl1/project/project.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/lib/shader-module/shader-module.ts +24 -12
- package/src/lib/shader-module/shader-pass.ts +7 -4
- package/src/lib/utils/uniform-types.ts +91 -0
- package/src/modules/engine/picking/picking.ts +9 -9
- package/src/modules/engine/project/project.ts +10 -9
- package/src/modules/lighting/gouraud-material/gouraud-material.ts +1 -1
- package/src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts +57 -52
- package/src/modules/lighting/lights/lighting-uniforms-glsl.ts +4 -3
- package/src/modules/lighting/lights/lighting-uniforms.ts +30 -22
- package/src/modules/lighting/no-material/dirlight.ts +3 -3
- package/src/modules/lighting/pbr-material/pbr-material.ts +14 -24
- package/src/modules/lighting/phong-material/phong-material.ts +1 -1
- package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +16 -14
- package/src/modules/postprocessing/image-blur-filters/tiltshift.ts +2 -2
- package/src/modules/postprocessing/image-blur-filters/triangleblur.ts +1 -1
- package/src/modules/postprocessing/image-blur-filters/zoomblur.ts +1 -1
- package/src/modules/postprocessing/image-fun-filters/colorhalftone.ts +1 -1
- package/src/modules/postprocessing/image-fun-filters/dotscreen.ts +1 -1
- package/src/modules/postprocessing/image-fun-filters/hexagonalpixelate.ts +1 -1
- package/src/modules/postprocessing/image-fun-filters/magnify.ts +2 -2
- package/src/modules/postprocessing/image-warp-filters/bulgepinch.ts +1 -1
- package/src/modules-webgl1/project/project.ts +8 -7
package/dist/dist.dev.js
CHANGED
|
@@ -4909,7 +4909,7 @@ float tan_fp32(float a) {
|
|
|
4909
4909
|
};
|
|
4910
4910
|
|
|
4911
4911
|
// src/modules/engine/picking/picking.ts
|
|
4912
|
-
var DEFAULT_HIGHLIGHT_COLOR =
|
|
4912
|
+
var DEFAULT_HIGHLIGHT_COLOR = [0, 1, 1, 1];
|
|
4913
4913
|
var vs = glsl`\
|
|
4914
4914
|
uniform pickingUniforms {
|
|
4915
4915
|
float isActive;
|
|
@@ -5058,7 +5058,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
5058
5058
|
isAttribute: false,
|
|
5059
5059
|
isHighlightActive: false,
|
|
5060
5060
|
useFloatColors: true,
|
|
5061
|
-
highlightedObjectColor:
|
|
5061
|
+
highlightedObjectColor: [0, 0, 0],
|
|
5062
5062
|
highlightColor: DEFAULT_HIGHLIGHT_COLOR
|
|
5063
5063
|
},
|
|
5064
5064
|
getUniforms
|
|
@@ -5112,15 +5112,16 @@ struct DirectionalLight {
|
|
|
5112
5112
|
|
|
5113
5113
|
uniform lightingUniforms {
|
|
5114
5114
|
int enabled;
|
|
5115
|
-
int
|
|
5115
|
+
int lightType;
|
|
5116
|
+
|
|
5116
5117
|
int directionalLightCount;
|
|
5118
|
+
int pointLightCount;
|
|
5117
5119
|
|
|
5118
5120
|
vec3 ambientColor;
|
|
5119
5121
|
|
|
5120
|
-
int lightType;
|
|
5121
5122
|
vec3 lightColor;
|
|
5122
|
-
vec3 lightDirection;
|
|
5123
5123
|
vec3 lightPosition;
|
|
5124
|
+
vec3 lightDirection;
|
|
5124
5125
|
vec3 lightAttenuation;
|
|
5125
5126
|
|
|
5126
5127
|
// AmbientLight ambientLight;
|
|
@@ -5160,11 +5161,13 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
5160
5161
|
},
|
|
5161
5162
|
uniformTypes: {
|
|
5162
5163
|
enabled: "i32",
|
|
5163
|
-
ambientLightColor: "vec3<f32>",
|
|
5164
|
-
numberOfLights: "i32",
|
|
5165
|
-
// , array: MAX_LIGHTS,
|
|
5166
5164
|
lightType: "i32",
|
|
5167
5165
|
// , array: MAX_LIGHTS,
|
|
5166
|
+
directionalLightCount: "i32",
|
|
5167
|
+
// , array: MAX_LIGHTS,
|
|
5168
|
+
pointLightCount: "i32",
|
|
5169
|
+
// , array: MAX_LIGHTS,
|
|
5170
|
+
ambientLightColor: "vec3<f32>",
|
|
5168
5171
|
lightColor: "vec3<f32>",
|
|
5169
5172
|
// , array: MAX_LIGHTS,
|
|
5170
5173
|
lightPosition: "vec3<f32>",
|
|
@@ -5177,9 +5180,10 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
5177
5180
|
},
|
|
5178
5181
|
defaultUniforms: {
|
|
5179
5182
|
enabled: 1,
|
|
5180
|
-
ambientLightColor: [0.1, 0.1, 0.1],
|
|
5181
|
-
numberOfLights: 0,
|
|
5182
5183
|
lightType: 0 /* POINT */,
|
|
5184
|
+
directionalLightCount: 0,
|
|
5185
|
+
pointLightCount: 0,
|
|
5186
|
+
ambientLightColor: [0.1, 0.1, 0.1],
|
|
5183
5187
|
lightColor: [1, 1, 1],
|
|
5184
5188
|
lightPosition: [1, 1, 2],
|
|
5185
5189
|
// TODO - could combine direction and attenuation
|
|
@@ -5238,7 +5242,8 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
5238
5242
|
lightSourceUniforms.lightDirection = directionalLight.direction;
|
|
5239
5243
|
currentLight++;
|
|
5240
5244
|
}
|
|
5241
|
-
lightSourceUniforms.
|
|
5245
|
+
lightSourceUniforms.directionalLightCount = directionalLights.length;
|
|
5246
|
+
lightSourceUniforms.pointLightCount = pointLights.length;
|
|
5242
5247
|
return lightSourceUniforms;
|
|
5243
5248
|
}
|
|
5244
5249
|
function extractLightTypes(lights2) {
|
|
@@ -5300,7 +5305,7 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
5300
5305
|
lightDirection: "vec3<f32>"
|
|
5301
5306
|
},
|
|
5302
5307
|
defaultUniforms: {
|
|
5303
|
-
lightDirection:
|
|
5308
|
+
lightDirection: [1, 1, 2]
|
|
5304
5309
|
},
|
|
5305
5310
|
getUniforms: getUniforms3
|
|
5306
5311
|
};
|
|
@@ -5314,15 +5319,7 @@ vec4 dirlight_filterColor(vec4 color) {
|
|
|
5314
5319
|
|
|
5315
5320
|
// src/modules/lighting/gouraud-material/gouraud-shaders-glsl.ts
|
|
5316
5321
|
var GOURAUD_VS = glsl`\
|
|
5317
|
-
uniform
|
|
5318
|
-
uniform float ambient;
|
|
5319
|
-
uniform float diffuse;
|
|
5320
|
-
uniform float shininess;
|
|
5321
|
-
uniform vec3 specularColor;
|
|
5322
|
-
} material;
|
|
5323
|
-
`;
|
|
5324
|
-
var GOURAUD_FS = glsl`\
|
|
5325
|
-
uniform materialUniforms {
|
|
5322
|
+
uniform gouraudMaterialUniforms {
|
|
5326
5323
|
uniform float ambient;
|
|
5327
5324
|
uniform float diffuse;
|
|
5328
5325
|
uniform float shininess;
|
|
@@ -5344,39 +5341,41 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
|
|
|
5344
5341
|
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
|
|
5345
5342
|
vec3 lightColor = surfaceColor;
|
|
5346
5343
|
|
|
5347
|
-
if (lighting.enabled) {
|
|
5348
|
-
|
|
5349
|
-
|
|
5344
|
+
if (lighting.enabled == 0) {
|
|
5345
|
+
return lightColor;
|
|
5346
|
+
}
|
|
5350
5347
|
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
5368
|
-
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
5348
|
+
vec3 view_direction = normalize(cameraPosition - position_worldspace);
|
|
5349
|
+
lightColor = material.ambient * surfaceColor * lighting.ambientColor;
|
|
5350
|
+
|
|
5351
|
+
if (lighting.lightType == 0) {
|
|
5352
|
+
PointLight pointLight = lighting_getPointLight(0);
|
|
5353
|
+
vec3 light_position_worldspace = pointLight.position;
|
|
5354
|
+
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
5355
|
+
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
5356
|
+
} else if (lighting.lightType == 1) {
|
|
5357
|
+
DirectionalLight directionalLight = lighting_getDirectionalLight(0);
|
|
5358
|
+
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
5359
|
+
}
|
|
5360
|
+
/*
|
|
5361
|
+
for (int i = 0; i < MAX_LIGHTS; i++) {
|
|
5362
|
+
if (i >= lighting.pointLightCount) {
|
|
5363
|
+
break;
|
|
5369
5364
|
}
|
|
5365
|
+
PointLight pointLight = lighting.pointLight[i];
|
|
5366
|
+
vec3 light_position_worldspace = pointLight.position;
|
|
5367
|
+
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
5368
|
+
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
5369
|
+
}
|
|
5370
5370
|
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
}
|
|
5375
|
-
DirectionalLight directionalLight = lighting.directionalLight[i];
|
|
5376
|
-
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
5371
|
+
for (int i = 0; i < MAX_LIGHTS; i++) {
|
|
5372
|
+
if (i >= lighting.directionalLightCount) {
|
|
5373
|
+
break;
|
|
5377
5374
|
}
|
|
5378
|
-
|
|
5375
|
+
DirectionalLight directionalLight = lighting.directionalLight[i];
|
|
5376
|
+
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
5379
5377
|
}
|
|
5378
|
+
*/
|
|
5380
5379
|
return lightColor;
|
|
5381
5380
|
}
|
|
5382
5381
|
|
|
@@ -5384,30 +5383,41 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
5384
5383
|
vec3 lightColor = vec3(0, 0, 0);
|
|
5385
5384
|
vec3 surfaceColor = vec3(0, 0, 0);
|
|
5386
5385
|
|
|
5387
|
-
if (lighting.enabled) {
|
|
5388
|
-
|
|
5386
|
+
if (lighting.enabled == 0) {
|
|
5387
|
+
return lightColor;
|
|
5388
|
+
}
|
|
5389
5389
|
|
|
5390
|
-
|
|
5391
|
-
case 0:
|
|
5392
|
-
PointLight pointLight = lighting_getPointLight(0);
|
|
5393
|
-
vec3 light_position_worldspace = pointLight.position;
|
|
5394
|
-
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
5395
|
-
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
5396
|
-
break;
|
|
5390
|
+
vec3 view_direction = normalize(cameraPosition - position_worldspace);
|
|
5397
5391
|
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5392
|
+
switch (lighting.lightType) {
|
|
5393
|
+
case 0:
|
|
5394
|
+
PointLight pointLight = lighting_getPointLight(0);
|
|
5395
|
+
vec3 light_position_worldspace = pointLight.position;
|
|
5396
|
+
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
5397
|
+
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
5398
|
+
break;
|
|
5399
|
+
|
|
5400
|
+
case 1:
|
|
5401
|
+
DirectionalLight directionalLight = lighting_getDirectionalLight(0);
|
|
5402
|
+
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
5403
|
+
break;
|
|
5403
5404
|
}
|
|
5405
|
+
|
|
5404
5406
|
return lightColor;
|
|
5405
5407
|
}
|
|
5408
|
+
`;
|
|
5409
|
+
var GOURAUD_FS = glsl`\
|
|
5410
|
+
uniform gouraudMaterialUniforms {
|
|
5411
|
+
uniform float ambient;
|
|
5412
|
+
uniform float diffuse;
|
|
5413
|
+
uniform float shininess;
|
|
5414
|
+
uniform vec3 specularColor;
|
|
5415
|
+
} material;
|
|
5406
5416
|
`;
|
|
5407
5417
|
|
|
5408
5418
|
// src/modules/lighting/gouraud-material/gouraud-material.ts
|
|
5409
5419
|
var gouraudMaterial = {
|
|
5410
|
-
name: "
|
|
5420
|
+
name: "gouraudMaterial",
|
|
5411
5421
|
// Note these are switched between phong and gouraud
|
|
5412
5422
|
vs: GOURAUD_VS,
|
|
5413
5423
|
fs: GOURAUD_FS,
|
|
@@ -5508,21 +5518,23 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
5508
5518
|
vec3 surfaceColor = vec3(0, 0, 0);
|
|
5509
5519
|
|
|
5510
5520
|
if (lighting.enabled == 0) {
|
|
5511
|
-
|
|
5521
|
+
return lightColor;
|
|
5522
|
+
}
|
|
5512
5523
|
|
|
5513
|
-
|
|
5514
|
-
case 0:
|
|
5515
|
-
PointLight pointLight = lighting_getPointLight(0);
|
|
5516
|
-
vec3 light_position_worldspace = pointLight.position;
|
|
5517
|
-
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
5518
|
-
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
5519
|
-
break;
|
|
5524
|
+
vec3 view_direction = normalize(cameraPosition - position_worldspace);
|
|
5520
5525
|
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
+
switch (lighting.lightType) {
|
|
5527
|
+
case 0:
|
|
5528
|
+
PointLight pointLight = lighting_getPointLight(0);
|
|
5529
|
+
vec3 light_position_worldspace = pointLight.position;
|
|
5530
|
+
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
5531
|
+
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);
|
|
5532
|
+
break;
|
|
5533
|
+
|
|
5534
|
+
case 1:
|
|
5535
|
+
DirectionalLight directionalLight = lighting_getDirectionalLight(0);
|
|
5536
|
+
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
5537
|
+
break;
|
|
5526
5538
|
}
|
|
5527
5539
|
return lightColor;
|
|
5528
5540
|
}
|
|
@@ -5530,7 +5542,7 @@ vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspac
|
|
|
5530
5542
|
|
|
5531
5543
|
// src/modules/lighting/phong-material/phong-material.ts
|
|
5532
5544
|
var phongMaterial = {
|
|
5533
|
-
name: "
|
|
5545
|
+
name: "phongMaterial",
|
|
5534
5546
|
// Note these are switched between phong and gouraud
|
|
5535
5547
|
vs: PHONG_VS,
|
|
5536
5548
|
fs: PHONG_FS,
|
|
@@ -6054,25 +6066,6 @@ vec4 pbr_filterColor(vec4 colorUnused)
|
|
|
6054
6066
|
scaleDiffBaseMR: "vec4<f32>",
|
|
6055
6067
|
scaleFGDSpec: "vec4<f32>"
|
|
6056
6068
|
},
|
|
6057
|
-
bindings: {
|
|
6058
|
-
baseColorSampler: { type: "texture", location: 8 },
|
|
6059
|
-
// #ifdef HAS_BASECOLORMAP
|
|
6060
|
-
normalSampler: { type: "texture", location: 9 },
|
|
6061
|
-
// #ifdef HAS_NORMALMAP
|
|
6062
|
-
emissiveSampler: { type: "texture", location: 10 },
|
|
6063
|
-
// #ifdef HAS_EMISSIVEMAP
|
|
6064
|
-
metallicRoughnessSampler: { type: "texture", location: 11 },
|
|
6065
|
-
// #ifdef HAS_METALROUGHNESSMAP
|
|
6066
|
-
occlusionSampler: { type: "texture", location: 12 },
|
|
6067
|
-
// #ifdef HAS_OCCLUSIONMAP
|
|
6068
|
-
// IBL Samplers
|
|
6069
|
-
diffuseEnvSampler: { type: "texture", location: 13 },
|
|
6070
|
-
// #ifdef USE_IBL (samplerCube)
|
|
6071
|
-
specularEnvSampler: { type: "texture", location: 14 },
|
|
6072
|
-
// #ifdef USE_IBL (samplerCube)
|
|
6073
|
-
brdfLUT: { type: "texture", location: 15 }
|
|
6074
|
-
// #ifdef USE_IBL
|
|
6075
|
-
},
|
|
6076
6069
|
dependencies: [lighting]
|
|
6077
6070
|
};
|
|
6078
6071
|
|