|
@@ -40,6 +40,7 @@ import "../../Shaders/pbr.fragment";
|
|
import "../../Shaders/pbr.vertex";
|
|
import "../../Shaders/pbr.vertex";
|
|
|
|
|
|
import { EffectFallbacks } from '../effectFallbacks';
|
|
import { EffectFallbacks } from '../effectFallbacks';
|
|
|
|
+import { IMaterialDetailMapDefines, DetailMapConfiguration } from '../material.detailMapConfiguration';
|
|
|
|
|
|
const onCreatedEffectParameters = { effect: null as unknown as Effect, subMesh: null as unknown as Nullable<SubMesh> };
|
|
const onCreatedEffectParameters = { effect: null as unknown as Effect, subMesh: null as unknown as Nullable<SubMesh> };
|
|
|
|
|
|
@@ -53,7 +54,8 @@ export class PBRMaterialDefines extends MaterialDefines
|
|
IMaterialAnisotropicDefines,
|
|
IMaterialAnisotropicDefines,
|
|
IMaterialBRDFDefines,
|
|
IMaterialBRDFDefines,
|
|
IMaterialSheenDefines,
|
|
IMaterialSheenDefines,
|
|
- IMaterialSubSurfaceDefines {
|
|
|
|
|
|
+ IMaterialSubSurfaceDefines,
|
|
|
|
+ IMaterialDetailMapDefines {
|
|
public PBR = true;
|
|
public PBR = true;
|
|
|
|
|
|
public NUM_SAMPLES = "0";
|
|
public NUM_SAMPLES = "0";
|
|
@@ -69,6 +71,10 @@ export class PBRMaterialDefines extends MaterialDefines
|
|
public ALBEDODIRECTUV = 0;
|
|
public ALBEDODIRECTUV = 0;
|
|
public VERTEXCOLOR = false;
|
|
public VERTEXCOLOR = false;
|
|
|
|
|
|
|
|
+ public DETAIL = false;
|
|
|
|
+ public DETAILDIRECTUV = 0;
|
|
|
|
+ public DETAIL_NORMALBLENDMETHOD = 0;
|
|
|
|
+
|
|
public AMBIENT = false;
|
|
public AMBIENT = false;
|
|
public AMBIENTDIRECTUV = 0;
|
|
public AMBIENTDIRECTUV = 0;
|
|
public AMBIENTINGRAYSCALE = false;
|
|
public AMBIENTINGRAYSCALE = false;
|
|
@@ -792,6 +798,11 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
*/
|
|
*/
|
|
public readonly subSurface = new PBRSubSurfaceConfiguration(this._markAllSubMeshesAsTexturesDirty.bind(this));
|
|
public readonly subSurface = new PBRSubSurfaceConfiguration(this._markAllSubMeshesAsTexturesDirty.bind(this));
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Defines the detail map parameters for the material.
|
|
|
|
+ */
|
|
|
|
+ public readonly detailMap = new DetailMapConfiguration(this._markAllSubMeshesAsTexturesDirty.bind(this));
|
|
|
|
+
|
|
protected _rebuildInParallel = false;
|
|
protected _rebuildInParallel = false;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1015,7 +1026,8 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
if (!this.subSurface.isReadyForSubMesh(defines, scene) ||
|
|
if (!this.subSurface.isReadyForSubMesh(defines, scene) ||
|
|
!this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap) ||
|
|
!this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap) ||
|
|
!this.sheen.isReadyForSubMesh(defines, scene) ||
|
|
!this.sheen.isReadyForSubMesh(defines, scene) ||
|
|
- !this.anisotropy.isReadyForSubMesh(defines, scene)) {
|
|
|
|
|
|
+ !this.anisotropy.isReadyForSubMesh(defines, scene) ||
|
|
|
|
+ !this.detailMap.isReadyForSubMesh(defines, scene)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1235,6 +1247,9 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
|
|
|
|
var uniformBuffers = ["Material", "Scene"];
|
|
var uniformBuffers = ["Material", "Scene"];
|
|
|
|
|
|
|
|
+ DetailMapConfiguration.AddUniforms(uniforms);
|
|
|
|
+ DetailMapConfiguration.AddSamplers(samplers);
|
|
|
|
+
|
|
PBRSubSurfaceConfiguration.AddUniforms(uniforms);
|
|
PBRSubSurfaceConfiguration.AddUniforms(uniforms);
|
|
PBRSubSurfaceConfiguration.AddSamplers(samplers);
|
|
PBRSubSurfaceConfiguration.AddSamplers(samplers);
|
|
|
|
|
|
@@ -1563,6 +1578,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
}
|
|
}
|
|
|
|
|
|
// External config
|
|
// External config
|
|
|
|
+ this.detailMap.prepareDefines(defines, scene);
|
|
this.subSurface.prepareDefines(defines, scene);
|
|
this.subSurface.prepareDefines(defines, scene);
|
|
this.clearCoat.prepareDefines(defines, scene);
|
|
this.clearCoat.prepareDefines(defines, scene);
|
|
this.anisotropy.prepareDefines(defines, mesh, scene);
|
|
this.anisotropy.prepareDefines(defines, mesh, scene);
|
|
@@ -1653,6 +1669,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
PBRAnisotropicConfiguration.PrepareUniformBuffer(ubo);
|
|
PBRAnisotropicConfiguration.PrepareUniformBuffer(ubo);
|
|
PBRSheenConfiguration.PrepareUniformBuffer(ubo);
|
|
PBRSheenConfiguration.PrepareUniformBuffer(ubo);
|
|
PBRSubSurfaceConfiguration.PrepareUniformBuffer(ubo);
|
|
PBRSubSurfaceConfiguration.PrepareUniformBuffer(ubo);
|
|
|
|
+ DetailMapConfiguration.PrepareUniformBuffer(ubo);
|
|
|
|
|
|
ubo.create();
|
|
ubo.create();
|
|
}
|
|
}
|
|
@@ -1957,6 +1974,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.detailMap.bindForSubMesh(ubo, scene, this.isFrozen);
|
|
this.subSurface.bindForSubMesh(ubo, scene, engine, this.isFrozen, defines.LODBASEDMICROSFURACE, this.realTimeFiltering);
|
|
this.subSurface.bindForSubMesh(ubo, scene, engine, this.isFrozen, defines.LODBASEDMICROSFURACE, this.realTimeFiltering);
|
|
this.clearCoat.bindForSubMesh(ubo, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
|
|
this.clearCoat.bindForSubMesh(ubo, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
|
|
this.anisotropy.bindForSubMesh(ubo, scene, this.isFrozen);
|
|
this.anisotropy.bindForSubMesh(ubo, scene, this.isFrozen);
|
|
@@ -2053,6 +2071,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
results.push(this._lightmapTexture);
|
|
results.push(this._lightmapTexture);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.detailMap.getAnimatables(results);
|
|
this.subSurface.getAnimatables(results);
|
|
this.subSurface.getAnimatables(results);
|
|
this.clearCoat.getAnimatables(results);
|
|
this.clearCoat.getAnimatables(results);
|
|
this.sheen.getAnimatables(results);
|
|
this.sheen.getAnimatables(results);
|
|
@@ -2124,6 +2143,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
activeTextures.push(this._lightmapTexture);
|
|
activeTextures.push(this._lightmapTexture);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.detailMap.getActiveTextures(activeTextures);
|
|
this.subSurface.getActiveTextures(activeTextures);
|
|
this.subSurface.getActiveTextures(activeTextures);
|
|
this.clearCoat.getActiveTextures(activeTextures);
|
|
this.clearCoat.getActiveTextures(activeTextures);
|
|
this.sheen.getActiveTextures(activeTextures);
|
|
this.sheen.getActiveTextures(activeTextures);
|
|
@@ -2182,7 +2202,8 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- return this.subSurface.hasTexture(texture) ||
|
|
|
|
|
|
+ return this.detailMap.hasTexture(texture) ||
|
|
|
|
+ this.subSurface.hasTexture(texture) ||
|
|
this.clearCoat.hasTexture(texture) ||
|
|
this.clearCoat.hasTexture(texture) ||
|
|
this.sheen.hasTexture(texture) ||
|
|
this.sheen.hasTexture(texture) ||
|
|
this.anisotropy.hasTexture(texture);
|
|
this.anisotropy.hasTexture(texture);
|
|
@@ -2212,6 +2233,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
|
|
this._microSurfaceTexture?.dispose();
|
|
this._microSurfaceTexture?.dispose();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.detailMap.dispose(forceDisposeTextures);
|
|
this.subSurface.dispose(forceDisposeTextures);
|
|
this.subSurface.dispose(forceDisposeTextures);
|
|
this.clearCoat.dispose(forceDisposeTextures);
|
|
this.clearCoat.dispose(forceDisposeTextures);
|
|
this.sheen.dispose(forceDisposeTextures);
|
|
this.sheen.dispose(forceDisposeTextures);
|