|
@@ -403,6 +403,12 @@ export class Material implements IAnimatable {
|
|
public forceDepthWrite = false;
|
|
public forceDepthWrite = false;
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * Specifies the depth function that should be used. 0 means the default engine function
|
|
|
|
+ */
|
|
|
|
+ @serialize()
|
|
|
|
+ public depthFunction = 0;
|
|
|
|
+
|
|
|
|
+ /**
|
|
* Specifies if there should be a separate pass for culling
|
|
* Specifies if there should be a separate pass for culling
|
|
*/
|
|
*/
|
|
@serialize()
|
|
@serialize()
|
|
@@ -541,6 +547,11 @@ export class Material implements IAnimatable {
|
|
private _cachedDepthWriteState: boolean = false;
|
|
private _cachedDepthWriteState: boolean = false;
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * Specifies if the depth function state should be cached
|
|
|
|
+ */
|
|
|
|
+ private _cachedDepthFunctionState: number = 0;
|
|
|
|
+
|
|
|
|
+ /**
|
|
* Stores the uniform buffer
|
|
* Stores the uniform buffer
|
|
*/
|
|
*/
|
|
protected _uniformBuffer: UniformBuffer;
|
|
protected _uniformBuffer: UniformBuffer;
|
|
@@ -799,6 +810,12 @@ export class Material implements IAnimatable {
|
|
this._cachedDepthWriteState = engine.getDepthWrite();
|
|
this._cachedDepthWriteState = engine.getDepthWrite();
|
|
engine.setDepthWrite(false);
|
|
engine.setDepthWrite(false);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (this.depthFunction !== 0) {
|
|
|
|
+ var engine = this._scene.getEngine();
|
|
|
|
+ this._cachedDepthFunctionState = engine.getDepthFunction() || 0;
|
|
|
|
+ engine.setDepthFunction(this.depthFunction);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -809,6 +826,11 @@ export class Material implements IAnimatable {
|
|
this._onUnBindObservable.notifyObservers(this);
|
|
this._onUnBindObservable.notifyObservers(this);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (this.depthFunction !== 0) {
|
|
|
|
+ var engine = this._scene.getEngine();
|
|
|
|
+ engine.setDepthFunction(this._cachedDepthFunctionState);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (this.disableDepthWrite) {
|
|
if (this.disableDepthWrite) {
|
|
var engine = this._scene.getEngine();
|
|
var engine = this._scene.getEngine();
|
|
engine.setDepthWrite(this._cachedDepthWriteState);
|
|
engine.setDepthWrite(this._cachedDepthWriteState);
|