|
@@ -18,6 +18,8 @@ module BABYLON {
|
|
public BonesPerMesh = 0;
|
|
public BonesPerMesh = 0;
|
|
public INSTANCES = false;
|
|
public INSTANCES = false;
|
|
public SPECULARTERM = false;
|
|
public SPECULARTERM = false;
|
|
|
|
+ public LOGARITHMICDEPTH = false;
|
|
|
|
+
|
|
|
|
|
|
constructor() {
|
|
constructor() {
|
|
super();
|
|
super();
|
|
@@ -106,8 +108,10 @@ module BABYLON {
|
|
|
|
|
|
private _defines = new WaterMaterialDefines();
|
|
private _defines = new WaterMaterialDefines();
|
|
private _cachedDefines = new WaterMaterialDefines();
|
|
private _cachedDefines = new WaterMaterialDefines();
|
|
-
|
|
|
|
- /**
|
|
|
|
|
|
+
|
|
|
|
+ private _useLogarithmicDepth: boolean;
|
|
|
|
+
|
|
|
|
+ /**
|
|
* Constructor
|
|
* Constructor
|
|
*/
|
|
*/
|
|
constructor(name: string, scene: Scene, public renderTargetSize: Vector2 = new Vector2(512, 512)) {
|
|
constructor(name: string, scene: Scene, public renderTargetSize: Vector2 = new Vector2(512, 512)) {
|
|
@@ -116,7 +120,16 @@ module BABYLON {
|
|
// Create render targets
|
|
// Create render targets
|
|
this._createRenderTargets(scene, renderTargetSize);
|
|
this._createRenderTargets(scene, renderTargetSize);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ @serialize()
|
|
|
|
+ public get useLogarithmicDepth(): boolean {
|
|
|
|
+ return this._useLogarithmicDepth;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public set useLogarithmicDepth(value: boolean) {
|
|
|
|
+ this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
|
|
|
|
+ }
|
|
|
|
+
|
|
// Get / Set
|
|
// Get / Set
|
|
public get refractionTexture(): RenderTargetTexture {
|
|
public get refractionTexture(): RenderTargetTexture {
|
|
return this._refractionRTT;
|
|
return this._refractionRTT;
|
|
@@ -228,6 +241,10 @@ module BABYLON {
|
|
this._defines.POINTSIZE = true;
|
|
this._defines.POINTSIZE = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (this.useLogarithmicDepth) {
|
|
|
|
+ this._defines.LOGARITHMICDEPTH = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
// Fog
|
|
// Fog
|
|
if (scene.fogEnabled && mesh && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled) {
|
|
if (scene.fogEnabled && mesh && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled) {
|
|
this._defines.FOG = true;
|
|
this._defines.FOG = true;
|
|
@@ -284,6 +301,10 @@ module BABYLON {
|
|
fallbacks.addFallback(1, "FOG");
|
|
fallbacks.addFallback(1, "FOG");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (this._defines.LOGARITHMICDEPTH) {
|
|
|
|
+ fallbacks.addFallback(0, "LOGARITHMICDEPTH");
|
|
|
|
+ }
|
|
|
|
+
|
|
MaterialHelper.HandleFallbacksForShadows(this._defines, fallbacks, this.maxSimultaneousLights);
|
|
MaterialHelper.HandleFallbacksForShadows(this._defines, fallbacks, this.maxSimultaneousLights);
|
|
|
|
|
|
if (this._defines.NUM_BONE_INFLUENCERS > 0) {
|
|
if (this._defines.NUM_BONE_INFLUENCERS > 0) {
|
|
@@ -320,6 +341,8 @@ module BABYLON {
|
|
"vNormalInfos",
|
|
"vNormalInfos",
|
|
"mBones",
|
|
"mBones",
|
|
"vClipPlane", "normalMatrix",
|
|
"vClipPlane", "normalMatrix",
|
|
|
|
+ "logarithmicDepthConstant",
|
|
|
|
+
|
|
// Water
|
|
// Water
|
|
"worldReflectionViewProjection", "windDirection", "waveLength", "time", "windForce",
|
|
"worldReflectionViewProjection", "windDirection", "waveLength", "time", "windForce",
|
|
"cameraPosition", "bumpHeight", "waveHeight", "waterColor", "colorBlendFactor", "waveSpeed"
|
|
"cameraPosition", "bumpHeight", "waveHeight", "waterColor", "colorBlendFactor", "waveSpeed"
|
|
@@ -403,7 +426,10 @@ module BABYLON {
|
|
|
|
|
|
// Fog
|
|
// Fog
|
|
MaterialHelper.BindFogParameters(scene, mesh, this._effect);
|
|
MaterialHelper.BindFogParameters(scene, mesh, this._effect);
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ // Log. depth
|
|
|
|
+ MaterialHelper.BindLogDepth(this._defines, this._effect, scene);
|
|
|
|
+
|
|
// Water
|
|
// Water
|
|
if (StandardMaterial.ReflectionTextureEnabled) {
|
|
if (StandardMaterial.ReflectionTextureEnabled) {
|
|
this._effect.setTexture("refractionSampler", this._refractionRTT);
|
|
this._effect.setTexture("refractionSampler", this._refractionRTT);
|