|
@@ -60,10 +60,6 @@ module BABYLON {
|
|
public CAMERACOLORGRADING = false;
|
|
public CAMERACOLORGRADING = false;
|
|
public CAMERACOLORCURVES = false;
|
|
public CAMERACOLORCURVES = false;
|
|
|
|
|
|
- public _areTexturesDirty = true;
|
|
|
|
- public _areFresnelDirty = true;
|
|
|
|
- public _areMiscDirty = true;
|
|
|
|
-
|
|
|
|
constructor() {
|
|
constructor() {
|
|
super(true);
|
|
super(true);
|
|
this.rebuild();
|
|
this.rebuild();
|
|
@@ -83,132 +79,51 @@ module BABYLON {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- export class StandardMaterial extends Material {
|
|
|
|
|
|
+ export class StandardMaterial extends PushMaterial {
|
|
@serializeAsTexture("diffuseTexture")
|
|
@serializeAsTexture("diffuseTexture")
|
|
private _diffuseTexture: BaseTexture;
|
|
private _diffuseTexture: BaseTexture;
|
|
- public set diffuseTexture(value : BaseTexture) {
|
|
|
|
- if (this._diffuseTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._diffuseTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get diffuseTexture(): BaseTexture {
|
|
|
|
- return this._diffuseTexture;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public diffuseTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("ambientTexture")
|
|
@serializeAsTexture("ambientTexture")
|
|
private _ambientTexture: BaseTexture;
|
|
private _ambientTexture: BaseTexture;
|
|
- public set ambientTexture(value : BaseTexture) {
|
|
|
|
- if (this._ambientTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._ambientTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get ambientTexture(): BaseTexture {
|
|
|
|
- return this._ambientTexture;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public ambientTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("opacityTexture")
|
|
@serializeAsTexture("opacityTexture")
|
|
- private _opacityTexture: BaseTexture;
|
|
|
|
- public set opacityTexture(value : BaseTexture) {
|
|
|
|
- if (this._opacityTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._opacityTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get opacityTexture(): BaseTexture {
|
|
|
|
- return this._opacityTexture;
|
|
|
|
- }
|
|
|
|
|
|
+ private _opacityTexture: BaseTexture;
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public opacityTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("reflectionTexture")
|
|
@serializeAsTexture("reflectionTexture")
|
|
private _reflectionTexture: BaseTexture;
|
|
private _reflectionTexture: BaseTexture;
|
|
- public set reflectionTexture(value : BaseTexture) {
|
|
|
|
- if (this._reflectionTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._reflectionTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get reflectionTexture(): BaseTexture {
|
|
|
|
- return this._reflectionTexture;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public reflectionTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("emissiveTexture")
|
|
@serializeAsTexture("emissiveTexture")
|
|
private _emissiveTexture: BaseTexture;
|
|
private _emissiveTexture: BaseTexture;
|
|
- public set emissiveTexture(value : BaseTexture) {
|
|
|
|
- if (this._emissiveTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._emissiveTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get emissiveTexture(): BaseTexture {
|
|
|
|
- return this._emissiveTexture;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public emissiveTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("specularTexture")
|
|
@serializeAsTexture("specularTexture")
|
|
private _specularTexture: BaseTexture;
|
|
private _specularTexture: BaseTexture;
|
|
- public set specularTexture(value : BaseTexture) {
|
|
|
|
- if (this._specularTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._specularTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get specularTexture(): BaseTexture {
|
|
|
|
- return this._specularTexture;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public specularTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("bumpTexture")
|
|
@serializeAsTexture("bumpTexture")
|
|
private _bumpTexture: BaseTexture;
|
|
private _bumpTexture: BaseTexture;
|
|
- public set bumpTexture(value : BaseTexture) {
|
|
|
|
- if (this._bumpTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._bumpTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get bumpTexture(): BaseTexture {
|
|
|
|
- return this._bumpTexture;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public bumpTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("lightmapTexture")
|
|
@serializeAsTexture("lightmapTexture")
|
|
private _lightmapTexture: BaseTexture;
|
|
private _lightmapTexture: BaseTexture;
|
|
- public set lightmapTexture(value : BaseTexture) {
|
|
|
|
- if (this._lightmapTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._lightmapTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get lightmapTexture(): BaseTexture {
|
|
|
|
- return this._lightmapTexture;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public lightmapTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("refractionTexture")
|
|
@serializeAsTexture("refractionTexture")
|
|
private _refractionTexture: BaseTexture;
|
|
private _refractionTexture: BaseTexture;
|
|
- public set refractionTexture(value : BaseTexture) {
|
|
|
|
- if (this._refractionTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._refractionTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get refractionTexture(): BaseTexture {
|
|
|
|
- return this._refractionTexture;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public refractionTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsColor3("ambient")
|
|
@serializeAsColor3("ambient")
|
|
public ambientColor = new Color3(0, 0, 0);
|
|
public ambientColor = new Color3(0, 0, 0);
|
|
@@ -227,123 +142,52 @@ module BABYLON {
|
|
|
|
|
|
@serialize("useAlphaFromDiffuseTexture")
|
|
@serialize("useAlphaFromDiffuseTexture")
|
|
private _useAlphaFromDiffuseTexture = false;
|
|
private _useAlphaFromDiffuseTexture = false;
|
|
- public set useAlphaFromDiffuseTexture(value : boolean) {
|
|
|
|
- if (this._useAlphaFromDiffuseTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._useAlphaFromDiffuseTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get useAlphaFromDiffuseTexture(): boolean {
|
|
|
|
- return this._useAlphaFromDiffuseTexture;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public useAlphaFromDiffuseTexture: boolean;
|
|
|
|
|
|
@serialize("useEmissiveAsIllumination")
|
|
@serialize("useEmissiveAsIllumination")
|
|
private _useEmissiveAsIllumination = false;
|
|
private _useEmissiveAsIllumination = false;
|
|
- public set useEmissiveAsIllumination(value : boolean) {
|
|
|
|
- if (this._useAlphaFromDiffuseTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._useEmissiveAsIllumination = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get useEmissiveAsIllumination(): boolean {
|
|
|
|
- return this._useEmissiveAsIllumination;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public useEmissiveAsIllumination: boolean;
|
|
|
|
|
|
@serialize("linkEmissiveWithDiffuse")
|
|
@serialize("linkEmissiveWithDiffuse")
|
|
private _linkEmissiveWithDiffuse = false;
|
|
private _linkEmissiveWithDiffuse = false;
|
|
- public set linkEmissiveWithDiffuse(value : boolean) {
|
|
|
|
- if (this._linkEmissiveWithDiffuse === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._linkEmissiveWithDiffuse = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get linkEmissiveWithDiffuse(): boolean {
|
|
|
|
- return this._linkEmissiveWithDiffuse;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public linkEmissiveWithDiffuse: boolean;
|
|
|
|
|
|
@serialize("useSpecularOverAlpha")
|
|
@serialize("useSpecularOverAlpha")
|
|
private _useSpecularOverAlpha = false;
|
|
private _useSpecularOverAlpha = false;
|
|
- public set useSpecularOverAlpha(value : boolean) {
|
|
|
|
- if (this._useSpecularOverAlpha === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._useSpecularOverAlpha = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get useSpecularOverAlpha(): boolean {
|
|
|
|
- return this._useSpecularOverAlpha;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public useSpecularOverAlpha: boolean;
|
|
|
|
|
|
@serialize("useReflectionOverAlpha")
|
|
@serialize("useReflectionOverAlpha")
|
|
private _useReflectionOverAlpha = false;
|
|
private _useReflectionOverAlpha = false;
|
|
- public set useReflectionOverAlpha(value : boolean) {
|
|
|
|
- if (this._useReflectionOverAlpha === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._useReflectionOverAlpha = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get useReflectionOverAlpha(): boolean {
|
|
|
|
- return this._useReflectionOverAlpha;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public useReflectionOverAlpha: boolean;
|
|
|
|
|
|
@serialize("disableLighting")
|
|
@serialize("disableLighting")
|
|
private _disableLighting = false;
|
|
private _disableLighting = false;
|
|
- public set disableLighting(value : boolean) {
|
|
|
|
- if (this._disableLighting === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._disableLighting = value;
|
|
|
|
- this._markAllSubMeshesAsLightsDirty();
|
|
|
|
- }
|
|
|
|
- public get disableLighting(): boolean {
|
|
|
|
- return this._disableLighting;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
|
|
+ public disableLighting: boolean;
|
|
|
|
+
|
|
|
|
|
|
@serialize("useParallax")
|
|
@serialize("useParallax")
|
|
private _useParallax = false;
|
|
private _useParallax = false;
|
|
- public set useParallax(value : boolean) {
|
|
|
|
- if (this._useParallax === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._useParallax = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get useParallax(): boolean {
|
|
|
|
- return this._useParallax;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public useParallax: boolean;
|
|
|
|
|
|
@serialize("useParallaxOcclusion")
|
|
@serialize("useParallaxOcclusion")
|
|
private _useParallaxOcclusion = false;
|
|
private _useParallaxOcclusion = false;
|
|
- public set useParallaxOcclusion(value : boolean) {
|
|
|
|
- if (this._useParallaxOcclusion === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._useParallaxOcclusion = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get useParallaxOcclusion(): boolean {
|
|
|
|
- return this._useParallaxOcclusion;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public useParallaxOcclusion: boolean;
|
|
|
|
|
|
@serialize()
|
|
@serialize()
|
|
public parallaxScaleBias = 0.05;
|
|
public parallaxScaleBias = 0.05;
|
|
|
|
|
|
@serialize("roughness")
|
|
@serialize("roughness")
|
|
private _roughness = 0;
|
|
private _roughness = 0;
|
|
- public set roughness(value : number) {
|
|
|
|
- if (this._roughness === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._roughness = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get roughness(): number {
|
|
|
|
- return this._roughness;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public roughness: number;
|
|
|
|
|
|
@serialize()
|
|
@serialize()
|
|
public indexOfRefraction = 0.98;
|
|
public indexOfRefraction = 0.98;
|
|
@@ -353,189 +197,84 @@ module BABYLON {
|
|
|
|
|
|
@serialize("useLightmapAsShadowmap")
|
|
@serialize("useLightmapAsShadowmap")
|
|
private _useLightmapAsShadowmap = false;
|
|
private _useLightmapAsShadowmap = false;
|
|
- public set useLightmapAsShadowmap(value : boolean) {
|
|
|
|
- if (this._useLightmapAsShadowmap === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._useLightmapAsShadowmap = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get useLightmapAsShadowmap(): boolean {
|
|
|
|
- return this._useLightmapAsShadowmap;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public useLightmapAsShadowmap: boolean;
|
|
|
|
|
|
// Fresnel
|
|
// Fresnel
|
|
@serializeAsFresnelParameters("diffuseFresnelParameters")
|
|
@serializeAsFresnelParameters("diffuseFresnelParameters")
|
|
private _diffuseFresnelParameters: FresnelParameters;
|
|
private _diffuseFresnelParameters: FresnelParameters;
|
|
- public set diffuseFresnelParameters(value : FresnelParameters) {
|
|
|
|
- if (this._diffuseFresnelParameters === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._diffuseFresnelParameters = value;
|
|
|
|
- this._markAllSubMeshesAsFresnelDirty();
|
|
|
|
- }
|
|
|
|
- public get diffuseFresnelParameters(): FresnelParameters {
|
|
|
|
- return this._diffuseFresnelParameters;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
|
|
+ public diffuseFresnelParameters: FresnelParameters;
|
|
|
|
|
|
@serializeAsFresnelParameters("opacityFresnelParameters")
|
|
@serializeAsFresnelParameters("opacityFresnelParameters")
|
|
private _opacityFresnelParameters: FresnelParameters;
|
|
private _opacityFresnelParameters: FresnelParameters;
|
|
- public set opacityFresnelParameters(value : FresnelParameters) {
|
|
|
|
- if (this._opacityFresnelParameters === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._opacityFresnelParameters = value;
|
|
|
|
- this._markAllSubMeshesAsFresnelDirty();
|
|
|
|
- }
|
|
|
|
- public get opacityFresnelParameters(): FresnelParameters {
|
|
|
|
- return this._opacityFresnelParameters;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
|
|
+ public opacityFresnelParameters: FresnelParameters;
|
|
|
|
+
|
|
|
|
|
|
@serializeAsFresnelParameters("reflectionFresnelParameters")
|
|
@serializeAsFresnelParameters("reflectionFresnelParameters")
|
|
private _reflectionFresnelParameters: FresnelParameters;
|
|
private _reflectionFresnelParameters: FresnelParameters;
|
|
- public set reflectionFresnelParameters(value : FresnelParameters) {
|
|
|
|
- if (this._reflectionFresnelParameters === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._reflectionFresnelParameters = value;
|
|
|
|
- this._markAllSubMeshesAsFresnelDirty();
|
|
|
|
- }
|
|
|
|
- public get reflectionFresnelParameters(): FresnelParameters {
|
|
|
|
- return this._reflectionFresnelParameters;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
|
|
+ public reflectionFresnelParameters: FresnelParameters;
|
|
|
|
|
|
@serializeAsFresnelParameters("refractionFresnelParameters")
|
|
@serializeAsFresnelParameters("refractionFresnelParameters")
|
|
private _refractionFresnelParameters: FresnelParameters;
|
|
private _refractionFresnelParameters: FresnelParameters;
|
|
- public set refractionFresnelParameters(value : FresnelParameters) {
|
|
|
|
- if (this._refractionFresnelParameters === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._refractionFresnelParameters = value;
|
|
|
|
- this._markAllSubMeshesAsFresnelDirty();
|
|
|
|
- }
|
|
|
|
- public get refractionFresnelParameters(): FresnelParameters {
|
|
|
|
- return this._refractionFresnelParameters;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
|
|
+ public refractionFresnelParameters: FresnelParameters;
|
|
|
|
|
|
@serializeAsFresnelParameters("emissiveFresnelParameters")
|
|
@serializeAsFresnelParameters("emissiveFresnelParameters")
|
|
private _emissiveFresnelParameters: FresnelParameters;
|
|
private _emissiveFresnelParameters: FresnelParameters;
|
|
- public set emissiveFresnelParameters(value : FresnelParameters) {
|
|
|
|
- if (this._emissiveFresnelParameters === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._emissiveFresnelParameters = value;
|
|
|
|
- this._markAllSubMeshesAsFresnelDirty();
|
|
|
|
- }
|
|
|
|
- public get emissiveFresnelParameters(): FresnelParameters {
|
|
|
|
- return this._emissiveFresnelParameters;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
|
|
+ public emissiveFresnelParameters: FresnelParameters;
|
|
|
|
|
|
@serialize("useReflectionFresnelFromSpecular")
|
|
@serialize("useReflectionFresnelFromSpecular")
|
|
private _useReflectionFresnelFromSpecular = false;
|
|
private _useReflectionFresnelFromSpecular = false;
|
|
- public set useReflectionFresnelFromSpecular(value : boolean) {
|
|
|
|
- if (this._useReflectionFresnelFromSpecular === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._useReflectionFresnelFromSpecular = value;
|
|
|
|
- this._markAllSubMeshesAsFresnelDirty();
|
|
|
|
- }
|
|
|
|
- public get useReflectionFresnelFromSpecular(): boolean {
|
|
|
|
- return this._useReflectionFresnelFromSpecular;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
|
|
+ public useReflectionFresnelFromSpecular: boolean;
|
|
|
|
|
|
@serialize("useGlossinessFromSpecularMapAlpha")
|
|
@serialize("useGlossinessFromSpecularMapAlpha")
|
|
private _useGlossinessFromSpecularMapAlpha = false;
|
|
private _useGlossinessFromSpecularMapAlpha = false;
|
|
- public set useGlossinessFromSpecularMapAlpha(value : boolean) {
|
|
|
|
- if (this._useGlossinessFromSpecularMapAlpha === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._useGlossinessFromSpecularMapAlpha = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get useGlossinessFromSpecularMapAlpha(): boolean {
|
|
|
|
- return this._useGlossinessFromSpecularMapAlpha;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public useGlossinessFromSpecularMapAlpha: boolean;
|
|
|
|
+
|
|
@serialize("maxSimultaneousLights")
|
|
@serialize("maxSimultaneousLights")
|
|
private _maxSimultaneousLights = 4;
|
|
private _maxSimultaneousLights = 4;
|
|
- public set maxSimultaneousLights(value : number) {
|
|
|
|
- if (this._maxSimultaneousLights === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._maxSimultaneousLights = value;
|
|
|
|
- this._markAllSubMeshesAsLightsDirty();
|
|
|
|
- }
|
|
|
|
- public get maxSimultaneousLights(): number {
|
|
|
|
- return this._maxSimultaneousLights;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
|
|
+ public maxSimultaneousLights: number;
|
|
|
|
|
|
/**
|
|
/**
|
|
* If sets to true, x component of normal map value will invert (x = 1.0 - x).
|
|
* If sets to true, x component of normal map value will invert (x = 1.0 - x).
|
|
*/
|
|
*/
|
|
@serialize("invertNormalMapX")
|
|
@serialize("invertNormalMapX")
|
|
private _invertNormalMapX = false;
|
|
private _invertNormalMapX = false;
|
|
- public set invertNormalMapX(value : boolean) {
|
|
|
|
- if (this._invertNormalMapX === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._invertNormalMapX = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get invertNormalMapX(): boolean {
|
|
|
|
- return this._invertNormalMapX;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public invertNormalMapX: boolean;
|
|
|
|
|
|
/**
|
|
/**
|
|
* If sets to true, y component of normal map value will invert (y = 1.0 - y).
|
|
* If sets to true, y component of normal map value will invert (y = 1.0 - y).
|
|
*/
|
|
*/
|
|
@serialize("invertNormalMapY")
|
|
@serialize("invertNormalMapY")
|
|
private _invertNormalMapY = false;
|
|
private _invertNormalMapY = false;
|
|
- public set invertNormalMapY(value : boolean) {
|
|
|
|
- if (this._invertNormalMapY === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._invertNormalMapY = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get invertNormalMapY(): boolean {
|
|
|
|
- return this._invertNormalMapY;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public invertNormalMapY: boolean;
|
|
|
|
|
|
/**
|
|
/**
|
|
* If sets to true and backfaceCulling is false, normals will be flipped on the backside.
|
|
* If sets to true and backfaceCulling is false, normals will be flipped on the backside.
|
|
*/
|
|
*/
|
|
@serialize("twoSidedLighting")
|
|
@serialize("twoSidedLighting")
|
|
private _twoSidedLighting = false;
|
|
private _twoSidedLighting = false;
|
|
- public set twoSidedLighting(value : boolean) {
|
|
|
|
- if (this._twoSidedLighting === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._twoSidedLighting = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
- public get inverttwoSidedLightingNormalMapY(): boolean {
|
|
|
|
- return this._twoSidedLighting;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public twoSidedLighting: boolean;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Color Grading 2D Lookup Texture.
|
|
* Color Grading 2D Lookup Texture.
|
|
* This allows special effects like sepia, black and white to sixties rendering style.
|
|
* This allows special effects like sepia, black and white to sixties rendering style.
|
|
*/
|
|
*/
|
|
- @serializeAsTexture()
|
|
|
|
|
|
+ @serializeAsTexture("cameraColorGradingTexture")
|
|
private _cameraColorGradingTexture: BaseTexture;
|
|
private _cameraColorGradingTexture: BaseTexture;
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public cameraColorGradingTexture: BaseTexture;
|
|
|
|
|
|
- public set cameraColorGradingTexture(value : BaseTexture) {
|
|
|
|
- if (this._cameraColorGradingTexture === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._cameraColorGradingTexture = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get cameraColorGradingTexture(): BaseTexture {
|
|
|
|
- return this._cameraColorGradingTexture;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
|
|
* The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
|
|
* They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
|
|
* They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
|
|
@@ -544,17 +283,8 @@ module BABYLON {
|
|
*/
|
|
*/
|
|
@serializeAsColorCurves("cameraColorCurves")
|
|
@serializeAsColorCurves("cameraColorCurves")
|
|
private _cameraColorCurves: ColorCurves = null;
|
|
private _cameraColorCurves: ColorCurves = null;
|
|
- public set cameraColorCurves(value : ColorCurves) {
|
|
|
|
- if (this._cameraColorCurves === value) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this._cameraColorCurves = value;
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public get cameraColorCurves(): ColorCurves {
|
|
|
|
- return this._cameraColorCurves;
|
|
|
|
- }
|
|
|
|
|
|
+ @expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
|
|
+ public cameraColorCurves: ColorCurves;
|
|
|
|
|
|
public customShaderNameResolve: (shaderName: string) => string;
|
|
public customShaderNameResolve: (shaderName: string) => string;
|
|
|
|
|
|
@@ -566,7 +296,6 @@ module BABYLON {
|
|
|
|
|
|
constructor(name: string, scene: Scene) {
|
|
constructor(name: string, scene: Scene) {
|
|
super(name, scene);
|
|
super(name, scene);
|
|
- this.storeEffectOnSubMeshes = true;
|
|
|
|
|
|
|
|
this.getRenderTargetTextures = (): SmartArray<RenderTargetTexture> => {
|
|
this.getRenderTargetTextures = (): SmartArray<RenderTargetTexture> => {
|
|
this._renderTargets.reset();
|
|
this._renderTargets.reset();
|
|
@@ -583,8 +312,6 @@ module BABYLON {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private _activeEffect: Effect;
|
|
|
|
-
|
|
|
|
public getClassName(): string {
|
|
public getClassName(): string {
|
|
return "StandardMaterial";
|
|
return "StandardMaterial";
|
|
}
|
|
}
|
|
@@ -619,44 +346,6 @@ module BABYLON {
|
|
/**
|
|
/**
|
|
* Child classes can use it to update shaders
|
|
* Child classes can use it to update shaders
|
|
*/
|
|
*/
|
|
- public markAsDirty(flag: number): void {
|
|
|
|
- if (flag & Material.TextureDirtyFlag) {
|
|
|
|
- this._markAllSubMeshesAsTexturesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (flag & Material.LightDirtyFlag) {
|
|
|
|
- this._markAllSubMeshesAsLightsDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (flag & Material.FresnelDirtyFlag) {
|
|
|
|
- this._markAllSubMeshesAsFresnelDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (flag & Material.AttributesDirtyFlag) {
|
|
|
|
- this._markAllSubMeshesAsAttributesDirty();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (flag & Material.MiscDirtyFlag) {
|
|
|
|
- this._markAllSubMeshesAsMiscDirty();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public getEffect(): Effect {
|
|
|
|
- return this._activeEffect;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean {
|
|
|
|
- if (!mesh) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean {
|
|
public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean {
|
|
if (this.isFrozen) {
|
|
if (this.isFrozen) {
|
|
if (this._wasPreviouslyReady && subMesh.effect) {
|
|
if (this._wasPreviouslyReady && subMesh.effect) {
|
|
@@ -668,20 +357,20 @@ module BABYLON {
|
|
subMesh._materialDefines = new StandardMaterialDefines();
|
|
subMesh._materialDefines = new StandardMaterialDefines();
|
|
}
|
|
}
|
|
|
|
|
|
- var defines = <StandardMaterialDefines>subMesh._materialDefines;
|
|
|
|
var scene = this.getScene();
|
|
var scene = this.getScene();
|
|
- var engine = scene.getEngine();
|
|
|
|
-
|
|
|
|
- // Lights
|
|
|
|
- defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, this._maxSimultaneousLights, this._disableLighting);
|
|
|
|
- defines._areLightsDirty = false;
|
|
|
|
-
|
|
|
|
|
|
+ var defines = <StandardMaterialDefines>subMesh._materialDefines;
|
|
if (!this.checkReadyOnEveryCall && subMesh.effect) {
|
|
if (!this.checkReadyOnEveryCall && subMesh.effect) {
|
|
if (defines._renderId === scene.getRenderId()) {
|
|
if (defines._renderId === scene.getRenderId()) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var engine = scene.getEngine();
|
|
|
|
+
|
|
|
|
+ // Lights
|
|
|
|
+ defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, this._maxSimultaneousLights, this._disableLighting);
|
|
|
|
+ defines._areLightsDirty = false;
|
|
|
|
+
|
|
// Textures
|
|
// Textures
|
|
if (defines._areTexturesDirty) {
|
|
if (defines._areTexturesDirty) {
|
|
defines._needUVs = false;
|
|
defines._needUVs = false;
|
|
@@ -1073,14 +762,6 @@ module BABYLON {
|
|
this._activeEffect.setMatrix("world", world);
|
|
this._activeEffect.setMatrix("world", world);
|
|
}
|
|
}
|
|
|
|
|
|
- public bind(world: Matrix, mesh?: Mesh): void {
|
|
|
|
- if (!mesh) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {
|
|
public bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void {
|
|
var scene = this.getScene();
|
|
var scene = this.getScene();
|
|
|
|
|
|
@@ -1098,7 +779,7 @@ module BABYLON {
|
|
// Bones
|
|
// Bones
|
|
MaterialHelper.BindBonesParameters(mesh, effect);
|
|
MaterialHelper.BindBonesParameters(mesh, effect);
|
|
|
|
|
|
- if (scene.getCachedEffect() !== effect || scene.getCachedMaterial() !== this) {
|
|
|
|
|
|
+ if (this._mustRebind(scene, effect)) {
|
|
effect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
effect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
|
|
|
|
if (StandardMaterial.FresnelEnabled) {
|
|
if (StandardMaterial.FresnelEnabled) {
|
|
@@ -1230,7 +911,7 @@ module BABYLON {
|
|
effect.setColor3("vEmissiveColor", this.emissiveColor);
|
|
effect.setColor3("vEmissiveColor", this.emissiveColor);
|
|
}
|
|
}
|
|
|
|
|
|
- if (scene.getCachedEffect() !== effect || scene.getCachedMaterial() !== this || !this.isFrozen) {
|
|
|
|
|
|
+ if (this._mustRebind(scene, effect) || !this.isFrozen) {
|
|
// Diffuse
|
|
// Diffuse
|
|
effect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
|
|
effect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
|
|
|
|
|
|
@@ -1256,8 +937,7 @@ module BABYLON {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- super.bindForSubMesh(world, mesh, subMesh);
|
|
|
|
- super.bind(world, mesh);
|
|
|
|
|
|
+ this._afterBind(mesh, this._activeEffect);
|
|
}
|
|
}
|
|
|
|
|
|
public getAnimatables(): IAnimatable[] {
|
|
public getAnimatables(): IAnimatable[] {
|
|
@@ -1360,43 +1040,6 @@ module BABYLON {
|
|
return SerializationHelper.Serialize(this);
|
|
return SerializationHelper.Serialize(this);
|
|
}
|
|
}
|
|
|
|
|
|
- private _markAllSubMeshesAsDirty(func: (defines: StandardMaterialDefines) => void) {
|
|
|
|
- for (var mesh of this.getScene().meshes) {
|
|
|
|
- if (!mesh.subMeshes) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- for (var subMesh of mesh.subMeshes) {
|
|
|
|
- if (subMesh.getMaterial() !== this) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (!subMesh._materialDefines) {
|
|
|
|
- subMesh._materialDefines = new StandardMaterialDefines();
|
|
|
|
- }
|
|
|
|
- func(<StandardMaterialDefines>(subMesh._materialDefines));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private _markAllSubMeshesAsTexturesDirty() {
|
|
|
|
- this._markAllSubMeshesAsDirty(defines => defines._areTexturesDirty = true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private _markAllSubMeshesAsFresnelDirty() {
|
|
|
|
- this._markAllSubMeshesAsDirty(defines => defines._areFresnelDirty = true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private _markAllSubMeshesAsLightsDirty() {
|
|
|
|
- this._markAllSubMeshesAsDirty(defines => defines._areLightsDirty = true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private _markAllSubMeshesAsAttributesDirty() {
|
|
|
|
- this._markAllSubMeshesAsDirty(defines => defines._areAttributesDirty = true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private _markAllSubMeshesAsMiscDirty() {
|
|
|
|
- this._markAllSubMeshesAsDirty(defines => defines._areMiscDirty = true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Statics
|
|
// Statics
|
|
public static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial {
|
|
public static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial {
|
|
return SerializationHelper.Parse(() => new StandardMaterial(source.name, scene), source, scene, rootUrl);
|
|
return SerializationHelper.Parse(() => new StandardMaterial(source.name, scene), source, scene, rootUrl);
|