playcanvas 2.24.0-beta.35 → 2.24.0-beta.36
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/build/playcanvas/src/core/core.js +2 -2
- package/build/playcanvas/src/scene/materials/lit-material-options-builder.js +1 -1
- package/build/playcanvas/src/scene/materials/lit-material.js +1 -0
- package/build/playcanvas/src/scene/materials/standard-material-options-builder.d.ts +0 -19
- package/build/playcanvas/src/scene/materials/standard-material-options-builder.js +7 -14
- package/build/playcanvas/src/scene/materials/standard-material-parameters.d.ts +1 -1
- package/build/playcanvas/src/scene/materials/standard-material-parameters.js +1 -1
- package/build/playcanvas/src/scene/materials/standard-material.d.ts +3 -11
- package/build/playcanvas/src/scene/materials/standard-material.js +8 -32
- package/build/playcanvas.d.ts +3 -30
- package/build/playcanvas.dbg/src/core/core.js +2 -2
- package/build/playcanvas.dbg/src/scene/materials/lit-material-options-builder.js +1 -1
- package/build/playcanvas.dbg/src/scene/materials/lit-material.js +1 -0
- package/build/playcanvas.dbg/src/scene/materials/standard-material-options-builder.js +9 -37
- package/build/playcanvas.dbg/src/scene/materials/standard-material-parameters.js +1 -1
- package/build/playcanvas.dbg/src/scene/materials/standard-material.js +8 -32
- package/build/playcanvas.dbg.js +22 -70
- package/build/playcanvas.dbg.mjs +22 -70
- package/build/playcanvas.js +22 -53
- package/build/playcanvas.min.js +760 -760
- package/build/playcanvas.min.mjs +754 -754
- package/build/playcanvas.mjs +22 -52
- package/build/playcanvas.prf/src/core/core.js +2 -2
- package/build/playcanvas.prf/src/scene/materials/lit-material-options-builder.js +1 -1
- package/build/playcanvas.prf/src/scene/materials/lit-material.js +1 -0
- package/build/playcanvas.prf/src/scene/materials/standard-material-options-builder.js +7 -14
- package/build/playcanvas.prf/src/scene/materials/standard-material-parameters.js +1 -1
- package/build/playcanvas.prf/src/scene/materials/standard-material.js +8 -32
- package/build/playcanvas.prf.js +22 -53
- package/build/playcanvas.prf.mjs +22 -52
- package/package.json +1 -1
|
@@ -67,7 +67,7 @@ class LitMaterialOptionsBuilder {
|
|
|
67
67
|
litOptions.pixelSnap = material.pixelSnap;
|
|
68
68
|
litOptions.ambientSH = material.ambientSH;
|
|
69
69
|
litOptions.occludeSpecular = material.occludeSpecular;
|
|
70
|
-
litOptions.occludeSpecularFloat =
|
|
70
|
+
litOptions.occludeSpecularFloat = true;
|
|
71
71
|
litOptions.useMsdf = false;
|
|
72
72
|
litOptions.msdfTextAttribute = false;
|
|
73
73
|
litOptions.alphaToCoverage = material.alphaToCoverage;
|
|
@@ -51,6 +51,7 @@ class LitMaterial extends Material {
|
|
|
51
51
|
super.updateUniforms(device, scene);
|
|
52
52
|
this.setParameter("material_occludeDirect", this.occludeDirect ? 1 : 0);
|
|
53
53
|
this.setParameter("material_twoSidedLighting", this.twoSidedLighting ? 1 : 0);
|
|
54
|
+
this.setParameter("material_occludeSpecularIntensity", this.occludeSpecularIntensity);
|
|
54
55
|
}
|
|
55
56
|
getShaderVariant(params) {
|
|
56
57
|
options.usedUvs = this.usedUvs.slice();
|
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
export class StandardMaterialOptionsBuilder {
|
|
2
|
-
/**
|
|
3
|
-
* The refraction index for which the shader uses a built-in constant instead of the
|
|
4
|
-
* material_refractionIndex uniform. Shared with StandardMaterial, which needs to invalidate its
|
|
5
|
-
* shaders when refractionIndex moves across this value.
|
|
6
|
-
*
|
|
7
|
-
* @type {number}
|
|
8
|
-
* @ignore
|
|
9
|
-
*/
|
|
10
|
-
static DEFAULT_REFRACTION_INDEX: number;
|
|
11
|
-
/**
|
|
12
|
-
* Compares two material numbers with the tolerance used to decide whether a shader constant can
|
|
13
|
-
* replace a uniform.
|
|
14
|
-
*
|
|
15
|
-
* @param {number} a - The first value.
|
|
16
|
-
* @param {number} b - The second value.
|
|
17
|
-
* @returns {boolean} True when the values are equal within tolerance.
|
|
18
|
-
* @ignore
|
|
19
|
-
*/
|
|
20
|
-
static equalish(a: number, b: number): boolean;
|
|
21
2
|
updateMinRef(options: any, scene: any, stdMat: any, objDefs: any, pass: any, lightList: any, vertexFormat: any, outlinePass?: boolean): void;
|
|
22
3
|
updateRef(options: any, scene: any, cameraShaderParams: any, stdMat: any, objDefs: any, pass: any, lightList: any, vertexFormat: any): void;
|
|
23
4
|
_updateSharedOptions(options: any, scene: any, stdMat: any, objDefs: any, pass: any, cameraShaderParams: any): void;
|
|
@@ -44,10 +44,6 @@ const notBlack = (color) => {
|
|
|
44
44
|
return color.r !== 0 || color.g !== 0 || color.b !== 0;
|
|
45
45
|
};
|
|
46
46
|
class StandardMaterialOptionsBuilder {
|
|
47
|
-
static DEFAULT_REFRACTION_INDEX = 1 / 1.5;
|
|
48
|
-
static equalish(a, b) {
|
|
49
|
-
return Math.abs(a - b) < 1e-4;
|
|
50
|
-
}
|
|
51
47
|
// Minimal options for Depth and Shadow passes, and the outline pass
|
|
52
48
|
updateMinRef(options, scene, stdMat, objDefs, pass, lightList, vertexFormat, outlinePass = false) {
|
|
53
49
|
this._updateSharedOptions(options, scene, stdMat, objDefs, pass);
|
|
@@ -169,20 +165,20 @@ class StandardMaterialOptionsBuilder {
|
|
|
169
165
|
_updateMaterialOptions(options, stdMat, scene) {
|
|
170
166
|
const useSpecular = !!(stdMat.useMetalness || stdMat.specularMap || stdMat.sphereMap || stdMat.cubeMap || stdMat.planarReflectionMap || notBlack(stdMat.specular) || stdMat.specularityFactor > 0 && stdMat.useMetalness || stdMat.enableGGXSpecular || stdMat.clearCoat > 0);
|
|
171
167
|
const useSpecularColor = !stdMat.useMetalness || stdMat.useMetalnessSpecularColor;
|
|
172
|
-
const specularityFactorTint = useSpecular && stdMat.useMetalnessSpecularColor
|
|
168
|
+
const specularityFactorTint = useSpecular && stdMat.useMetalnessSpecularColor;
|
|
173
169
|
const isPackedNormalMap = (texture) => texture ? texture.format === PIXELFORMAT_DXT5 || texture.type === TEXTURETYPE_SWIZZLEGGGR : false;
|
|
174
|
-
const { equalish, DEFAULT_REFRACTION_INDEX } = StandardMaterialOptionsBuilder;
|
|
175
|
-
options.specularityFactorTint = specularityFactorTint;
|
|
176
170
|
options.metalnessTint = stdMat.useMetalness;
|
|
177
171
|
options.glossTint = true;
|
|
172
|
+
options.iorTint = true;
|
|
173
|
+
options.refractionTint = true;
|
|
174
|
+
options.thicknessTint = true;
|
|
175
|
+
options.iridescenceTint = true;
|
|
176
|
+
options.specularityFactorTint = specularityFactorTint;
|
|
178
177
|
options.diffuseEncoding = stdMat.diffuseMap?.encoding;
|
|
179
178
|
options.diffuseDetailEncoding = stdMat.diffuseDetailMap?.encoding;
|
|
180
179
|
options.emissiveEncoding = stdMat.emissiveMap?.encoding;
|
|
181
180
|
options.lightMapEncoding = stdMat.lightMap?.encoding;
|
|
182
181
|
options.packedNormal = isPackedNormalMap(stdMat.normalMap);
|
|
183
|
-
options.refractionTint = !equalish(stdMat.refraction, 1);
|
|
184
|
-
options.refractionIndexTint = !equalish(stdMat.refractionIndex, DEFAULT_REFRACTION_INDEX);
|
|
185
|
-
options.thicknessTint = stdMat.useDynamicRefraction && stdMat.thickness !== 1;
|
|
186
182
|
options.specularEncoding = stdMat.specularMap?.encoding;
|
|
187
183
|
options.sheenEncoding = stdMat.sheenMap?.encoding;
|
|
188
184
|
options.diffuseTransmissionColorEncoding = stdMat.diffuseTransmissionColorMap?.encoding;
|
|
@@ -192,10 +188,7 @@ class StandardMaterialOptionsBuilder {
|
|
|
192
188
|
options.normalDetailPackedNormal = isPackedNormalMap(stdMat.normalDetailMap);
|
|
193
189
|
options.diffuseDetailMode = stdMat.diffuseDetailMode;
|
|
194
190
|
options.aoDetailMode = stdMat.aoDetailMode;
|
|
195
|
-
options.clearCoatGloss = !!stdMat.clearCoatGloss;
|
|
196
191
|
options.clearCoatPackedNormal = isPackedNormalMap(stdMat.clearCoatNormalMap);
|
|
197
|
-
options.iorTint = !equalish(stdMat.refractionIndex, DEFAULT_REFRACTION_INDEX);
|
|
198
|
-
options.iridescenceTint = true;
|
|
199
192
|
options.glossInvert = stdMat.glossInvert;
|
|
200
193
|
options.sheenGlossInvert = stdMat.sheenGlossInvert;
|
|
201
194
|
options.clearCoatGlossInvert = stdMat.clearCoatGlossInvert;
|
|
@@ -204,7 +197,7 @@ class StandardMaterialOptionsBuilder {
|
|
|
204
197
|
options.litOptions.pixelSnap = stdMat.pixelSnap;
|
|
205
198
|
options.litOptions.ambientSH = !!stdMat.ambientSH;
|
|
206
199
|
options.litOptions.occludeSpecular = stdMat.occludeSpecular;
|
|
207
|
-
options.litOptions.occludeSpecularFloat =
|
|
200
|
+
options.litOptions.occludeSpecularFloat = true;
|
|
208
201
|
options.litOptions.useMsdf = !!stdMat.msdfMap;
|
|
209
202
|
options.litOptions.msdfTextAttribute = !!stdMat.msdfTextAttribute;
|
|
210
203
|
options.litOptions.alphaToCoverage = stdMat.alphaToCoverage;
|
|
@@ -75,7 +75,6 @@ export namespace standardMaterialParameterTypes {
|
|
|
75
75
|
let metalnessTint: string;
|
|
76
76
|
let occludeSpecular: string;
|
|
77
77
|
let specularityFactor: string;
|
|
78
|
-
let specularityFactorTint: string;
|
|
79
78
|
let diffuseDetailMode: string;
|
|
80
79
|
let vertexColorGamma: string;
|
|
81
80
|
let specular: string;
|
|
@@ -111,5 +110,6 @@ export namespace standardMaterialRemovedParameters {
|
|
|
111
110
|
let useGamma: string;
|
|
112
111
|
let useGammaTonemap: string;
|
|
113
112
|
let sheenGlossTint: string;
|
|
113
|
+
let specularityFactorTint: string;
|
|
114
114
|
let anisotropy: string;
|
|
115
115
|
}
|
|
@@ -34,7 +34,6 @@ const standardMaterialParameterTypes = {
|
|
|
34
34
|
..._textureParameter("specular"),
|
|
35
35
|
occludeSpecular: "enum:occludeSpecular",
|
|
36
36
|
specularityFactor: "number",
|
|
37
|
-
specularityFactorTint: "boolean",
|
|
38
37
|
..._textureParameter("specularityFactor"),
|
|
39
38
|
useMetalness: "boolean",
|
|
40
39
|
metalness: "number",
|
|
@@ -180,6 +179,7 @@ const standardMaterialRemovedParameters = {
|
|
|
180
179
|
useGamma: "boolean",
|
|
181
180
|
useGammaTonemap: "boolean",
|
|
182
181
|
sheenGlossTint: "boolean",
|
|
182
|
+
specularityFactorTint: "boolean",
|
|
183
183
|
anisotropy: "boolean"
|
|
184
184
|
};
|
|
185
185
|
export {
|
|
@@ -96,10 +96,6 @@ export type UpdateShaderCallback = (options: StandardMaterialOptions) => Standar
|
|
|
96
96
|
* @property {boolean} specularVertexColor Multiply specular by the mesh vertex colors.
|
|
97
97
|
* @property {string} specularVertexColorChannel Vertex color channels to use for specular. Can be
|
|
98
98
|
* "r", "g", "b", "a", "rgb" or any swizzled combination.
|
|
99
|
-
* @property {boolean} specularityFactorTint Force inclusion of the constant `specularityFactor`
|
|
100
|
-
* when compositing with `specularityFactorMap` and/or specularity factor vertex colors. Defaults
|
|
101
|
-
* to `false`. Setting this to `true` is rarely needed - the constant is automatically applied
|
|
102
|
-
* whenever `specularityFactor` differs from 1. Provided as an explicit override.
|
|
103
99
|
* @property {Texture|null} specularityFactorMap The factor of specularity as a texture (default is
|
|
104
100
|
* null).
|
|
105
101
|
* @property {number} specularityFactorMapUv Specularity factor map UV channel. Valid values are 0 to 7.
|
|
@@ -108,8 +104,8 @@ export type UpdateShaderCallback = (options: StandardMaterialOptions) => Standar
|
|
|
108
104
|
* between 0 and 1.
|
|
109
105
|
* @property {number} specularityFactorMapRotation Controls the 2D rotation (in degrees) of the specularity factor map.
|
|
110
106
|
* @property {string} specularityFactorMapChannel The channel used by the specularity factor texture to sample from (default is 'a').
|
|
111
|
-
* @property {boolean} specularityFactorVertexColor Use mesh vertex colors for specularity factor.
|
|
112
|
-
*
|
|
107
|
+
* @property {boolean} specularityFactorVertexColor Use mesh vertex colors for specularity factor.
|
|
108
|
+
* They are multiplied by `specularityFactor`, and by `specularityFactorMap` if set.
|
|
113
109
|
* @property {string} specularityFactorVertexColorChannel Vertex color channels to use for specularity factor. Can be
|
|
114
110
|
* "r", "g", "b", "a", "rgb" or any swizzled combination.
|
|
115
111
|
* @property {boolean} enableGGXSpecular Enables GGX specular. Also enables
|
|
@@ -1302,11 +1298,7 @@ export class StandardMaterial extends Material {
|
|
|
1302
1298
|
set specularityFactorMapUv(arg: number);
|
|
1303
1299
|
get specularityFactorMapUv(): number;
|
|
1304
1300
|
|
|
1305
|
-
/**
|
|
1306
|
-
set specularityFactorTint(arg: boolean);
|
|
1307
|
-
get specularityFactorTint(): boolean;
|
|
1308
|
-
|
|
1309
|
-
/** Use mesh vertex colors for specularity factor. If specularityFactorMap or are specularityFactorTint are set, they'll be multiplied by vertex colors. */
|
|
1301
|
+
/** Use mesh vertex colors for specularity factor. They are multiplied by `specularityFactor`, and by `specularityFactorMap` if set. */
|
|
1310
1302
|
set specularityFactorVertexColor(arg: boolean);
|
|
1311
1303
|
get specularityFactorVertexColor(): boolean;
|
|
1312
1304
|
|
|
@@ -115,10 +115,6 @@ const _propertiesByUniform = new Map(_propertyList.map((property) => [property.u
|
|
|
115
115
|
const isBlack = (color) => {
|
|
116
116
|
return color.r === 0 && color.g === 0 && color.b === 0;
|
|
117
117
|
};
|
|
118
|
-
const dirtyShaderOnZeroOrOne = (oldValue, newValue) => {
|
|
119
|
-
return oldValue === 0 || oldValue === 1 || newValue === 0 || newValue === 1;
|
|
120
|
-
};
|
|
121
|
-
const { equalish, DEFAULT_REFRACTION_INDEX } = StandardMaterialOptionsBuilder;
|
|
122
118
|
class StandardMaterial extends Material {
|
|
123
119
|
_usesViewTextures = true;
|
|
124
120
|
static TEXTURE_PARAMETERS = standardMaterialTextureParameters;
|
|
@@ -237,7 +233,7 @@ class StandardMaterial extends Material {
|
|
|
237
233
|
}
|
|
238
234
|
set specularityFactor(value) {
|
|
239
235
|
if (this._specularityFactor !== value) {
|
|
240
|
-
this._dirtyShader = this._dirtyShader ||
|
|
236
|
+
this._dirtyShader = this._dirtyShader || this._specularityFactor > 0 !== value > 0;
|
|
241
237
|
this._specularityFactor = value;
|
|
242
238
|
this._markPropertyModified(_properties.specularityFactor);
|
|
243
239
|
}
|
|
@@ -247,7 +243,6 @@ class StandardMaterial extends Material {
|
|
|
247
243
|
}
|
|
248
244
|
set sheenGloss(value) {
|
|
249
245
|
if (this._sheenGloss !== value) {
|
|
250
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._sheenGloss, value);
|
|
251
246
|
this._sheenGloss = value;
|
|
252
247
|
this._markPropertyModified(_properties.sheenGloss);
|
|
253
248
|
}
|
|
@@ -257,7 +252,6 @@ class StandardMaterial extends Material {
|
|
|
257
252
|
}
|
|
258
253
|
set gloss(value) {
|
|
259
254
|
if (this._gloss !== value) {
|
|
260
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._gloss, value);
|
|
261
255
|
this._gloss = value;
|
|
262
256
|
this._markPropertyModified(_properties.gloss);
|
|
263
257
|
}
|
|
@@ -267,7 +261,6 @@ class StandardMaterial extends Material {
|
|
|
267
261
|
}
|
|
268
262
|
set aoIntensity(value) {
|
|
269
263
|
if (this._aoIntensity !== value) {
|
|
270
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._aoIntensity, value);
|
|
271
264
|
this._aoIntensity = value;
|
|
272
265
|
this._markPropertyModified(_properties.aoIntensity);
|
|
273
266
|
}
|
|
@@ -286,7 +279,6 @@ class StandardMaterial extends Material {
|
|
|
286
279
|
}
|
|
287
280
|
set parallaxSamples(value) {
|
|
288
281
|
if (this._parallaxSamples !== value) {
|
|
289
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._parallaxSamples, value);
|
|
290
282
|
this._parallaxSamples = value;
|
|
291
283
|
this._markPropertyModified(_properties.parallaxSamples);
|
|
292
284
|
}
|
|
@@ -306,7 +298,6 @@ class StandardMaterial extends Material {
|
|
|
306
298
|
}
|
|
307
299
|
set opacity(value) {
|
|
308
300
|
if (this._opacity !== value) {
|
|
309
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._opacity, value);
|
|
310
301
|
this._opacity = value;
|
|
311
302
|
this._markPropertyModified(_properties.opacity);
|
|
312
303
|
this._markPropertyModified(_properties.alphaDither);
|
|
@@ -317,7 +308,6 @@ class StandardMaterial extends Material {
|
|
|
317
308
|
}
|
|
318
309
|
set alphaFade(value) {
|
|
319
310
|
if (this._alphaFade !== value) {
|
|
320
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._alphaFade, value);
|
|
321
311
|
this._alphaFade = value;
|
|
322
312
|
this._markPropertyModified(_properties.alphaFade);
|
|
323
313
|
}
|
|
@@ -327,7 +317,6 @@ class StandardMaterial extends Material {
|
|
|
327
317
|
}
|
|
328
318
|
set bumpiness(value) {
|
|
329
319
|
if (this._bumpiness !== value) {
|
|
330
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._bumpiness, value);
|
|
331
320
|
this._bumpiness = value;
|
|
332
321
|
this._markPropertyModified(_properties.bumpiness);
|
|
333
322
|
}
|
|
@@ -337,7 +326,6 @@ class StandardMaterial extends Material {
|
|
|
337
326
|
}
|
|
338
327
|
set normalDetailMapBumpiness(value) {
|
|
339
328
|
if (this._normalDetailMapBumpiness !== value) {
|
|
340
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._normalDetailMapBumpiness, value);
|
|
341
329
|
this._normalDetailMapBumpiness = value;
|
|
342
330
|
this._markPropertyModified(_properties.normalDetailMapBumpiness);
|
|
343
331
|
}
|
|
@@ -347,7 +335,6 @@ class StandardMaterial extends Material {
|
|
|
347
335
|
}
|
|
348
336
|
set reflectivity(value) {
|
|
349
337
|
if (this._reflectivity !== value) {
|
|
350
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._reflectivity, value);
|
|
351
338
|
this._reflectivity = value;
|
|
352
339
|
this._markPropertyModified(_properties.reflectivity);
|
|
353
340
|
}
|
|
@@ -357,7 +344,6 @@ class StandardMaterial extends Material {
|
|
|
357
344
|
}
|
|
358
345
|
set occludeSpecularIntensity(value) {
|
|
359
346
|
if (this._occludeSpecularIntensity !== value) {
|
|
360
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._occludeSpecularIntensity, value);
|
|
361
347
|
this._occludeSpecularIntensity = value;
|
|
362
348
|
this._markPropertyModified(_properties.occludeSpecularIntensity);
|
|
363
349
|
}
|
|
@@ -367,7 +353,7 @@ class StandardMaterial extends Material {
|
|
|
367
353
|
}
|
|
368
354
|
set refraction(value) {
|
|
369
355
|
if (this._refraction !== value) {
|
|
370
|
-
this._dirtyShader = this._dirtyShader ||
|
|
356
|
+
this._dirtyShader = this._dirtyShader || this._refraction !== 0 !== (value !== 0);
|
|
371
357
|
this._refraction = value;
|
|
372
358
|
this._markPropertyModified(_properties.refraction);
|
|
373
359
|
}
|
|
@@ -377,7 +363,6 @@ class StandardMaterial extends Material {
|
|
|
377
363
|
}
|
|
378
364
|
set refractionIndex(value) {
|
|
379
365
|
if (this._refractionIndex !== value) {
|
|
380
|
-
this._dirtyShader = this._dirtyShader || equalish(this._refractionIndex, DEFAULT_REFRACTION_INDEX) !== equalish(value, DEFAULT_REFRACTION_INDEX);
|
|
381
366
|
this._refractionIndex = value;
|
|
382
367
|
this._markPropertyModified(_properties.refractionIndex);
|
|
383
368
|
}
|
|
@@ -387,7 +372,7 @@ class StandardMaterial extends Material {
|
|
|
387
372
|
}
|
|
388
373
|
set dispersion(value) {
|
|
389
374
|
if (this._dispersion !== value) {
|
|
390
|
-
this._dirtyShader = this._dirtyShader ||
|
|
375
|
+
this._dirtyShader = this._dirtyShader || this._dispersion > 0 !== value > 0;
|
|
391
376
|
this._dispersion = value;
|
|
392
377
|
this._markPropertyModified(_properties.dispersion);
|
|
393
378
|
}
|
|
@@ -397,7 +382,6 @@ class StandardMaterial extends Material {
|
|
|
397
382
|
}
|
|
398
383
|
set thickness(value) {
|
|
399
384
|
if (this._thickness !== value) {
|
|
400
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._thickness, value);
|
|
401
385
|
this._thickness = value;
|
|
402
386
|
this._markPropertyModified(_properties.thickness);
|
|
403
387
|
}
|
|
@@ -416,7 +400,7 @@ class StandardMaterial extends Material {
|
|
|
416
400
|
}
|
|
417
401
|
set anisotropyIntensity(value) {
|
|
418
402
|
if (this._anisotropyIntensity !== value) {
|
|
419
|
-
this._dirtyShader = this._dirtyShader ||
|
|
403
|
+
this._dirtyShader = this._dirtyShader || this.enableGGXSpecular && !this.anisotropyMap && this._anisotropyIntensity > 0 !== value > 0;
|
|
420
404
|
this._anisotropyIntensity = value;
|
|
421
405
|
this._markPropertyModified(_properties.anisotropyIntensity);
|
|
422
406
|
}
|
|
@@ -426,7 +410,7 @@ class StandardMaterial extends Material {
|
|
|
426
410
|
}
|
|
427
411
|
set clearCoat(value) {
|
|
428
412
|
if (this._clearCoat !== value) {
|
|
429
|
-
this._dirtyShader = this._dirtyShader ||
|
|
413
|
+
this._dirtyShader = this._dirtyShader || this._clearCoat !== 0 !== (value !== 0) || this._clearCoat > 0 !== value > 0;
|
|
430
414
|
this._clearCoat = value;
|
|
431
415
|
this._markPropertyModified(_properties.clearCoat);
|
|
432
416
|
}
|
|
@@ -436,7 +420,6 @@ class StandardMaterial extends Material {
|
|
|
436
420
|
}
|
|
437
421
|
set clearCoatGloss(value) {
|
|
438
422
|
if (this._clearCoatGloss !== value) {
|
|
439
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._clearCoatGloss, value);
|
|
440
423
|
this._clearCoatGloss = value;
|
|
441
424
|
this._markPropertyModified(_properties.clearCoatGloss);
|
|
442
425
|
}
|
|
@@ -446,7 +429,6 @@ class StandardMaterial extends Material {
|
|
|
446
429
|
}
|
|
447
430
|
set clearCoatBumpiness(value) {
|
|
448
431
|
if (this._clearCoatBumpiness !== value) {
|
|
449
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._clearCoatBumpiness, value);
|
|
450
432
|
this._clearCoatBumpiness = value;
|
|
451
433
|
this._markPropertyModified(_properties.clearCoatBumpiness);
|
|
452
434
|
}
|
|
@@ -456,7 +438,7 @@ class StandardMaterial extends Material {
|
|
|
456
438
|
}
|
|
457
439
|
set iridescence(value) {
|
|
458
440
|
if (this._iridescence !== value) {
|
|
459
|
-
this._dirtyShader = this._dirtyShader ||
|
|
441
|
+
this._dirtyShader = this._dirtyShader || this.useIridescence && this._iridescence !== 0 !== (value !== 0);
|
|
460
442
|
this._iridescence = value;
|
|
461
443
|
this._markPropertyModified(_properties.iridescence);
|
|
462
444
|
}
|
|
@@ -466,7 +448,6 @@ class StandardMaterial extends Material {
|
|
|
466
448
|
}
|
|
467
449
|
set iridescenceRefractionIndex(value) {
|
|
468
450
|
if (this._iridescenceRefractionIndex !== value) {
|
|
469
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._iridescenceRefractionIndex, value);
|
|
470
451
|
this._iridescenceRefractionIndex = value;
|
|
471
452
|
this._markPropertyModified(_properties.iridescenceRefractionIndex);
|
|
472
453
|
}
|
|
@@ -476,7 +457,6 @@ class StandardMaterial extends Material {
|
|
|
476
457
|
}
|
|
477
458
|
set iridescenceThicknessMin(value) {
|
|
478
459
|
if (this._iridescenceThicknessMin !== value) {
|
|
479
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._iridescenceThicknessMin, value);
|
|
480
460
|
this._iridescenceThicknessMin = value;
|
|
481
461
|
this._markPropertyModified(_properties.iridescenceThicknessMin);
|
|
482
462
|
}
|
|
@@ -486,7 +466,6 @@ class StandardMaterial extends Material {
|
|
|
486
466
|
}
|
|
487
467
|
set iridescenceThicknessMax(value) {
|
|
488
468
|
if (this._iridescenceThicknessMax !== value) {
|
|
489
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._iridescenceThicknessMax, value);
|
|
490
469
|
this._iridescenceThicknessMax = value;
|
|
491
470
|
this._markPropertyModified(_properties.iridescenceThicknessMax);
|
|
492
471
|
}
|
|
@@ -516,7 +495,6 @@ class StandardMaterial extends Material {
|
|
|
516
495
|
}
|
|
517
496
|
set anisotropyRotation(value) {
|
|
518
497
|
if (this._anisotropyRotation !== value) {
|
|
519
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._anisotropyRotation, value);
|
|
520
498
|
this._anisotropyRotation = value;
|
|
521
499
|
this._markPropertyModified(_properties.anisotropyRotation);
|
|
522
500
|
}
|
|
@@ -526,7 +504,6 @@ class StandardMaterial extends Material {
|
|
|
526
504
|
}
|
|
527
505
|
set attenuationDistance(value) {
|
|
528
506
|
if (this._attenuationDistance !== value) {
|
|
529
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._attenuationDistance, value);
|
|
530
507
|
this._attenuationDistance = value;
|
|
531
508
|
this._markPropertyModified(_properties.attenuationDistance);
|
|
532
509
|
}
|
|
@@ -536,7 +513,6 @@ class StandardMaterial extends Material {
|
|
|
536
513
|
}
|
|
537
514
|
set heightMapFactor(value) {
|
|
538
515
|
if (this._heightMapFactor !== value) {
|
|
539
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._heightMapFactor, value);
|
|
540
516
|
this._heightMapFactor = value;
|
|
541
517
|
this._markPropertyModified(_properties.heightMapFactor);
|
|
542
518
|
}
|
|
@@ -912,7 +888,7 @@ function _defineMaterialProps() {
|
|
|
912
888
|
registerProp("reflectivity", () => 1);
|
|
913
889
|
registerProp("occludeSpecularIntensity", () => 1);
|
|
914
890
|
registerProp("refraction", () => 0);
|
|
915
|
-
registerProp("refractionIndex", () =>
|
|
891
|
+
registerProp("refractionIndex", () => 1 / 1.5);
|
|
916
892
|
registerProp("dispersion", () => 0);
|
|
917
893
|
registerProp("thickness", () => 0);
|
|
918
894
|
registerProp("metalness", () => 1);
|
|
@@ -933,7 +909,6 @@ function _defineMaterialProps() {
|
|
|
933
909
|
registerProp("planarReflectionMatrix", () => new Mat4(), true);
|
|
934
910
|
registerProp("alphaTest", () => 0);
|
|
935
911
|
_defineObject("ambientSH");
|
|
936
|
-
_defineFlag("specularityFactorTint", false);
|
|
937
912
|
_defineFlag("useMetalness", false);
|
|
938
913
|
_defineFlag("useMetalnessSpecularColor", false);
|
|
939
914
|
_defineFlag("useSheen", false);
|
|
@@ -1067,6 +1042,7 @@ _defineRemovedTint("diffuseTint");
|
|
|
1067
1042
|
_defineRemovedTint("emissiveTint");
|
|
1068
1043
|
_defineRemovedTint("ambientTint");
|
|
1069
1044
|
_defineRemovedTint("specularTint");
|
|
1045
|
+
_defineRemovedTint("specularityFactorTint");
|
|
1070
1046
|
_defineDeprecatedAlias("aoVertexColor", "aoMapVertexColor");
|
|
1071
1047
|
_defineDeprecatedAlias("diffuseVertexColor", "diffuseMapVertexColor");
|
|
1072
1048
|
_defineDeprecatedAlias("specularVertexColor", "specularMapVertexColor");
|
package/build/playcanvas.d.ts
CHANGED
|
@@ -35616,25 +35616,6 @@ declare class Material {
|
|
|
35616
35616
|
}
|
|
35617
35617
|
|
|
35618
35618
|
declare class StandardMaterialOptionsBuilder {
|
|
35619
|
-
/**
|
|
35620
|
-
* The refraction index for which the shader uses a built-in constant instead of the
|
|
35621
|
-
* material_refractionIndex uniform. Shared with StandardMaterial, which needs to invalidate its
|
|
35622
|
-
* shaders when refractionIndex moves across this value.
|
|
35623
|
-
*
|
|
35624
|
-
* @type {number}
|
|
35625
|
-
* @ignore
|
|
35626
|
-
*/
|
|
35627
|
-
static DEFAULT_REFRACTION_INDEX: number;
|
|
35628
|
-
/**
|
|
35629
|
-
* Compares two material numbers with the tolerance used to decide whether a shader constant can
|
|
35630
|
-
* replace a uniform.
|
|
35631
|
-
*
|
|
35632
|
-
* @param {number} a - The first value.
|
|
35633
|
-
* @param {number} b - The second value.
|
|
35634
|
-
* @returns {boolean} True when the values are equal within tolerance.
|
|
35635
|
-
* @ignore
|
|
35636
|
-
*/
|
|
35637
|
-
static equalish(a: number, b: number): boolean;
|
|
35638
35619
|
updateMinRef(options: any, scene: any, stdMat: any, objDefs: any, pass: any, lightList: any, vertexFormat: any, outlinePass?: boolean): void;
|
|
35639
35620
|
updateRef(options: any, scene: any, cameraShaderParams: any, stdMat: any, objDefs: any, pass: any, lightList: any, vertexFormat: any): void;
|
|
35640
35621
|
_updateSharedOptions(options: any, scene: any, stdMat: any, objDefs: any, pass: any, cameraShaderParams: any): void;
|
|
@@ -35744,10 +35725,6 @@ type UpdateShaderCallback = (options: StandardMaterialOptions) => StandardMateri
|
|
|
35744
35725
|
* @property {boolean} specularVertexColor Multiply specular by the mesh vertex colors.
|
|
35745
35726
|
* @property {string} specularVertexColorChannel Vertex color channels to use for specular. Can be
|
|
35746
35727
|
* "r", "g", "b", "a", "rgb" or any swizzled combination.
|
|
35747
|
-
* @property {boolean} specularityFactorTint Force inclusion of the constant `specularityFactor`
|
|
35748
|
-
* when compositing with `specularityFactorMap` and/or specularity factor vertex colors. Defaults
|
|
35749
|
-
* to `false`. Setting this to `true` is rarely needed - the constant is automatically applied
|
|
35750
|
-
* whenever `specularityFactor` differs from 1. Provided as an explicit override.
|
|
35751
35728
|
* @property {Texture|null} specularityFactorMap The factor of specularity as a texture (default is
|
|
35752
35729
|
* null).
|
|
35753
35730
|
* @property {number} specularityFactorMapUv Specularity factor map UV channel. Valid values are 0 to 7.
|
|
@@ -35756,8 +35733,8 @@ type UpdateShaderCallback = (options: StandardMaterialOptions) => StandardMateri
|
|
|
35756
35733
|
* between 0 and 1.
|
|
35757
35734
|
* @property {number} specularityFactorMapRotation Controls the 2D rotation (in degrees) of the specularity factor map.
|
|
35758
35735
|
* @property {string} specularityFactorMapChannel The channel used by the specularity factor texture to sample from (default is 'a').
|
|
35759
|
-
* @property {boolean} specularityFactorVertexColor Use mesh vertex colors for specularity factor.
|
|
35760
|
-
*
|
|
35736
|
+
* @property {boolean} specularityFactorVertexColor Use mesh vertex colors for specularity factor.
|
|
35737
|
+
* They are multiplied by `specularityFactor`, and by `specularityFactorMap` if set.
|
|
35761
35738
|
* @property {string} specularityFactorVertexColorChannel Vertex color channels to use for specularity factor. Can be
|
|
35762
35739
|
* "r", "g", "b", "a", "rgb" or any swizzled combination.
|
|
35763
35740
|
* @property {boolean} enableGGXSpecular Enables GGX specular. Also enables
|
|
@@ -36950,11 +36927,7 @@ declare class StandardMaterial extends Material {
|
|
|
36950
36927
|
set specularityFactorMapUv(arg: number);
|
|
36951
36928
|
get specularityFactorMapUv(): number;
|
|
36952
36929
|
|
|
36953
|
-
/**
|
|
36954
|
-
set specularityFactorTint(arg: boolean);
|
|
36955
|
-
get specularityFactorTint(): boolean;
|
|
36956
|
-
|
|
36957
|
-
/** Use mesh vertex colors for specularity factor. If specularityFactorMap or are specularityFactorTint are set, they'll be multiplied by vertex colors. */
|
|
36930
|
+
/** Use mesh vertex colors for specularity factor. They are multiplied by `specularityFactor`, and by `specularityFactorMap` if set. */
|
|
36958
36931
|
set specularityFactorVertexColor(arg: boolean);
|
|
36959
36932
|
get specularityFactorVertexColor(): boolean;
|
|
36960
36933
|
|
|
@@ -67,7 +67,7 @@ class LitMaterialOptionsBuilder {
|
|
|
67
67
|
litOptions.pixelSnap = material.pixelSnap;
|
|
68
68
|
litOptions.ambientSH = material.ambientSH;
|
|
69
69
|
litOptions.occludeSpecular = material.occludeSpecular;
|
|
70
|
-
litOptions.occludeSpecularFloat =
|
|
70
|
+
litOptions.occludeSpecularFloat = true;
|
|
71
71
|
litOptions.useMsdf = false;
|
|
72
72
|
litOptions.msdfTextAttribute = false;
|
|
73
73
|
litOptions.alphaToCoverage = material.alphaToCoverage;
|
|
@@ -59,6 +59,7 @@ class LitMaterial extends Material {
|
|
|
59
59
|
super.updateUniforms(device, scene);
|
|
60
60
|
this.setParameter("material_occludeDirect", this.occludeDirect ? 1 : 0);
|
|
61
61
|
this.setParameter("material_twoSidedLighting", this.twoSidedLighting ? 1 : 0);
|
|
62
|
+
this.setParameter("material_occludeSpecularIntensity", this.occludeSpecularIntensity);
|
|
62
63
|
}
|
|
63
64
|
/** @ignore */
|
|
64
65
|
getShaderVariant(params) {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
1
|
import {
|
|
5
2
|
PIXELFORMAT_DXT5,
|
|
6
3
|
PIXELFORMAT_RGBA8,
|
|
@@ -46,19 +43,7 @@ import { shaderDefsToLightMask } from "../light-mask.js";
|
|
|
46
43
|
const notBlack = (color) => {
|
|
47
44
|
return color.r !== 0 || color.g !== 0 || color.b !== 0;
|
|
48
45
|
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Compares two material numbers with the tolerance used to decide whether a shader constant can
|
|
52
|
-
* replace a uniform.
|
|
53
|
-
*
|
|
54
|
-
* @param {number} a - The first value.
|
|
55
|
-
* @param {number} b - The second value.
|
|
56
|
-
* @returns {boolean} True when the values are equal within tolerance.
|
|
57
|
-
* @ignore
|
|
58
|
-
*/
|
|
59
|
-
static equalish(a, b) {
|
|
60
|
-
return Math.abs(a - b) < 1e-4;
|
|
61
|
-
}
|
|
46
|
+
class StandardMaterialOptionsBuilder {
|
|
62
47
|
// Minimal options for Depth and Shadow passes, and the outline pass
|
|
63
48
|
updateMinRef(options, scene, stdMat, objDefs, pass, lightList, vertexFormat, outlinePass = false) {
|
|
64
49
|
this._updateSharedOptions(options, scene, stdMat, objDefs, pass);
|
|
@@ -180,20 +165,20 @@ const _StandardMaterialOptionsBuilder = class _StandardMaterialOptionsBuilder {
|
|
|
180
165
|
_updateMaterialOptions(options, stdMat, scene) {
|
|
181
166
|
const useSpecular = !!(stdMat.useMetalness || stdMat.specularMap || stdMat.sphereMap || stdMat.cubeMap || stdMat.planarReflectionMap || notBlack(stdMat.specular) || stdMat.specularityFactor > 0 && stdMat.useMetalness || stdMat.enableGGXSpecular || stdMat.clearCoat > 0);
|
|
182
167
|
const useSpecularColor = !stdMat.useMetalness || stdMat.useMetalnessSpecularColor;
|
|
183
|
-
const specularityFactorTint = useSpecular && stdMat.useMetalnessSpecularColor
|
|
168
|
+
const specularityFactorTint = useSpecular && stdMat.useMetalnessSpecularColor;
|
|
184
169
|
const isPackedNormalMap = (texture) => texture ? texture.format === PIXELFORMAT_DXT5 || texture.type === TEXTURETYPE_SWIZZLEGGGR : false;
|
|
185
|
-
const { equalish, DEFAULT_REFRACTION_INDEX } = _StandardMaterialOptionsBuilder;
|
|
186
|
-
options.specularityFactorTint = specularityFactorTint;
|
|
187
170
|
options.metalnessTint = stdMat.useMetalness;
|
|
188
171
|
options.glossTint = true;
|
|
172
|
+
options.iorTint = true;
|
|
173
|
+
options.refractionTint = true;
|
|
174
|
+
options.thicknessTint = true;
|
|
175
|
+
options.iridescenceTint = true;
|
|
176
|
+
options.specularityFactorTint = specularityFactorTint;
|
|
189
177
|
options.diffuseEncoding = stdMat.diffuseMap?.encoding;
|
|
190
178
|
options.diffuseDetailEncoding = stdMat.diffuseDetailMap?.encoding;
|
|
191
179
|
options.emissiveEncoding = stdMat.emissiveMap?.encoding;
|
|
192
180
|
options.lightMapEncoding = stdMat.lightMap?.encoding;
|
|
193
181
|
options.packedNormal = isPackedNormalMap(stdMat.normalMap);
|
|
194
|
-
options.refractionTint = !equalish(stdMat.refraction, 1);
|
|
195
|
-
options.refractionIndexTint = !equalish(stdMat.refractionIndex, DEFAULT_REFRACTION_INDEX);
|
|
196
|
-
options.thicknessTint = stdMat.useDynamicRefraction && stdMat.thickness !== 1;
|
|
197
182
|
options.specularEncoding = stdMat.specularMap?.encoding;
|
|
198
183
|
options.sheenEncoding = stdMat.sheenMap?.encoding;
|
|
199
184
|
options.diffuseTransmissionColorEncoding = stdMat.diffuseTransmissionColorMap?.encoding;
|
|
@@ -203,10 +188,7 @@ const _StandardMaterialOptionsBuilder = class _StandardMaterialOptionsBuilder {
|
|
|
203
188
|
options.normalDetailPackedNormal = isPackedNormalMap(stdMat.normalDetailMap);
|
|
204
189
|
options.diffuseDetailMode = stdMat.diffuseDetailMode;
|
|
205
190
|
options.aoDetailMode = stdMat.aoDetailMode;
|
|
206
|
-
options.clearCoatGloss = !!stdMat.clearCoatGloss;
|
|
207
191
|
options.clearCoatPackedNormal = isPackedNormalMap(stdMat.clearCoatNormalMap);
|
|
208
|
-
options.iorTint = !equalish(stdMat.refractionIndex, DEFAULT_REFRACTION_INDEX);
|
|
209
|
-
options.iridescenceTint = true;
|
|
210
192
|
options.glossInvert = stdMat.glossInvert;
|
|
211
193
|
options.sheenGlossInvert = stdMat.sheenGlossInvert;
|
|
212
194
|
options.clearCoatGlossInvert = stdMat.clearCoatGlossInvert;
|
|
@@ -215,7 +197,7 @@ const _StandardMaterialOptionsBuilder = class _StandardMaterialOptionsBuilder {
|
|
|
215
197
|
options.litOptions.pixelSnap = stdMat.pixelSnap;
|
|
216
198
|
options.litOptions.ambientSH = !!stdMat.ambientSH;
|
|
217
199
|
options.litOptions.occludeSpecular = stdMat.occludeSpecular;
|
|
218
|
-
options.litOptions.occludeSpecularFloat =
|
|
200
|
+
options.litOptions.occludeSpecularFloat = true;
|
|
219
201
|
options.litOptions.useMsdf = !!stdMat.msdfMap;
|
|
220
202
|
options.litOptions.msdfTextAttribute = !!stdMat.msdfTextAttribute;
|
|
221
203
|
options.litOptions.alphaToCoverage = stdMat.alphaToCoverage;
|
|
@@ -332,17 +314,7 @@ const _StandardMaterialOptionsBuilder = class _StandardMaterialOptionsBuilder {
|
|
|
332
314
|
options.litOptions.noShadow = true;
|
|
333
315
|
}
|
|
334
316
|
}
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* The refraction index for which the shader uses a built-in constant instead of the
|
|
338
|
-
* material_refractionIndex uniform. Shared with StandardMaterial, which needs to invalidate its
|
|
339
|
-
* shaders when refractionIndex moves across this value.
|
|
340
|
-
*
|
|
341
|
-
* @type {number}
|
|
342
|
-
* @ignore
|
|
343
|
-
*/
|
|
344
|
-
__publicField(_StandardMaterialOptionsBuilder, "DEFAULT_REFRACTION_INDEX", 1 / 1.5);
|
|
345
|
-
let StandardMaterialOptionsBuilder = _StandardMaterialOptionsBuilder;
|
|
317
|
+
}
|
|
346
318
|
export {
|
|
347
319
|
StandardMaterialOptionsBuilder
|
|
348
320
|
};
|
|
@@ -34,7 +34,6 @@ const standardMaterialParameterTypes = {
|
|
|
34
34
|
..._textureParameter("specular"),
|
|
35
35
|
occludeSpecular: "enum:occludeSpecular",
|
|
36
36
|
specularityFactor: "number",
|
|
37
|
-
specularityFactorTint: "boolean",
|
|
38
37
|
..._textureParameter("specularityFactor"),
|
|
39
38
|
useMetalness: "boolean",
|
|
40
39
|
metalness: "number",
|
|
@@ -180,6 +179,7 @@ const standardMaterialRemovedParameters = {
|
|
|
180
179
|
useGamma: "boolean",
|
|
181
180
|
useGammaTonemap: "boolean",
|
|
182
181
|
sheenGlossTint: "boolean",
|
|
182
|
+
specularityFactorTint: "boolean",
|
|
183
183
|
anisotropy: "boolean"
|
|
184
184
|
};
|
|
185
185
|
export {
|