|
@@ -18,11 +18,11 @@
|
|
|
public specularTexture: BaseTexture;
|
|
|
public bumpTexture: BaseTexture;
|
|
|
|
|
|
- public ambientColor = new BABYLON.Color3(0, 0, 0);
|
|
|
- public diffuseColor = new BABYLON.Color3(1, 1, 1);
|
|
|
- public specularColor = new BABYLON.Color3(1, 1, 1);
|
|
|
+ public ambientColor = new Color3(0, 0, 0);
|
|
|
+ public diffuseColor = new Color3(1, 1, 1);
|
|
|
+ public specularColor = new Color3(1, 1, 1);
|
|
|
public specularPower = 64;
|
|
|
- public emissiveColor = new BABYLON.Color3(0, 0, 0);
|
|
|
+ public emissiveColor = new Color3(0, 0, 0);
|
|
|
public useAlphaFromDiffuseTexture = false;
|
|
|
public useSpecularOverAlpha = true;
|
|
|
public fogEnabled = true;
|
|
@@ -33,11 +33,11 @@
|
|
|
public emissiveFresnelParameters: FresnelParameters;
|
|
|
|
|
|
private _cachedDefines = null;
|
|
|
- private _renderTargets = new BABYLON.SmartArray<RenderTargetTexture>(16);
|
|
|
- private _worldViewProjectionMatrix = BABYLON.Matrix.Zero();
|
|
|
- private _globalAmbientColor = new BABYLON.Color3(0, 0, 0);
|
|
|
- private _scaledDiffuse = new BABYLON.Color3();
|
|
|
- private _scaledSpecular = new BABYLON.Color3();
|
|
|
+ private _renderTargets = new SmartArray<RenderTargetTexture>(16);
|
|
|
+ private _worldViewProjectionMatrix = Matrix.Zero();
|
|
|
+ private _globalAmbientColor = new Color3(0, 0, 0);
|
|
|
+ private _scaledDiffuse = new Color3();
|
|
|
+ private _scaledSpecular = new Color3();
|
|
|
private _renderId: number;
|
|
|
|
|
|
constructor(name: string, scene: Scene) {
|
|
@@ -92,7 +92,7 @@
|
|
|
|
|
|
// Textures
|
|
|
if (scene.texturesEnabled) {
|
|
|
- if (this.diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
|
|
|
+ if (this.diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
|
|
|
if (!this.diffuseTexture.isReady()) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -100,7 +100,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (this.ambientTexture && BABYLON.StandardMaterial.AmbientTextureEnabled) {
|
|
|
+ if (this.ambientTexture && StandardMaterial.AmbientTextureEnabled) {
|
|
|
if (!this.ambientTexture.isReady()) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -108,7 +108,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (this.opacityTexture && BABYLON.StandardMaterial.OpacityTextureEnabled) {
|
|
|
+ if (this.opacityTexture && StandardMaterial.OpacityTextureEnabled) {
|
|
|
if (!this.opacityTexture.isReady()) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -120,7 +120,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (this.reflectionTexture && BABYLON.StandardMaterial.ReflectionTextureEnabled) {
|
|
|
+ if (this.reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
|
|
|
if (!this.reflectionTexture.isReady()) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -129,7 +129,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (this.emissiveTexture && BABYLON.StandardMaterial.EmissiveTextureEnabled) {
|
|
|
+ if (this.emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
|
|
|
if (!this.emissiveTexture.isReady()) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -137,7 +137,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (this.specularTexture && BABYLON.StandardMaterial.SpecularTextureEnabled) {
|
|
|
+ if (this.specularTexture && StandardMaterial.SpecularTextureEnabled) {
|
|
|
if (!this.specularTexture.isReady()) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -147,7 +147,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (scene.getEngine().getCaps().standardDerivatives && this.bumpTexture && BABYLON.StandardMaterial.BumpTextureEnabled) {
|
|
|
+ if (scene.getEngine().getCaps().standardDerivatives && this.bumpTexture && StandardMaterial.BumpTextureEnabled) {
|
|
|
if (!this.bumpTexture.isReady()) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -175,12 +175,12 @@
|
|
|
}
|
|
|
|
|
|
// Point size
|
|
|
- if (this.pointsCloud) {
|
|
|
+ if (this.pointsCloud || scene.forcePointsCloud) {
|
|
|
defines.push("#define POINTSIZE");
|
|
|
}
|
|
|
|
|
|
// Fog
|
|
|
- if (mesh && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
|
|
|
+ if (mesh && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled) {
|
|
|
defines.push("#define FOG");
|
|
|
fallbacks.addFallback(1, "FOG");
|
|
|
}
|
|
@@ -232,9 +232,9 @@
|
|
|
}
|
|
|
|
|
|
var type;
|
|
|
- if (light instanceof BABYLON.SpotLight) {
|
|
|
+ if (light instanceof SpotLight) {
|
|
|
type = "#define SPOTLIGHT" + lightIndex;
|
|
|
- } else if (light instanceof BABYLON.HemisphericLight) {
|
|
|
+ } else if (light instanceof HemisphericLight) {
|
|
|
type = "#define HEMILIGHT" + lightIndex;
|
|
|
} else {
|
|
|
type = "#define POINTDIRLIGHT" + lightIndex;
|
|
@@ -274,7 +274,7 @@
|
|
|
}
|
|
|
|
|
|
lightIndex++;
|
|
|
- if (lightIndex == maxSimultaneousLights)
|
|
|
+ if (lightIndex === maxSimultaneousLights)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -317,27 +317,27 @@
|
|
|
|
|
|
|
|
|
// Attribs
|
|
|
- var attribs = [BABYLON.VertexBuffer.PositionKind, BABYLON.VertexBuffer.NormalKind];
|
|
|
+ var attribs = [VertexBuffer.PositionKind, VertexBuffer.NormalKind];
|
|
|
if (mesh) {
|
|
|
- if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
|
|
|
- attribs.push(BABYLON.VertexBuffer.UVKind);
|
|
|
+ if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
|
|
|
+ attribs.push(VertexBuffer.UVKind);
|
|
|
defines.push("#define UV1");
|
|
|
}
|
|
|
- if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)) {
|
|
|
- attribs.push(BABYLON.VertexBuffer.UV2Kind);
|
|
|
+ if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind)) {
|
|
|
+ attribs.push(VertexBuffer.UV2Kind);
|
|
|
defines.push("#define UV2");
|
|
|
}
|
|
|
- if (mesh.useVertexColors && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind)) {
|
|
|
- attribs.push(BABYLON.VertexBuffer.ColorKind);
|
|
|
+ if (mesh.useVertexColors && mesh.isVerticesDataPresent(VertexBuffer.ColorKind)) {
|
|
|
+ attribs.push(VertexBuffer.ColorKind);
|
|
|
defines.push("#define VERTEXCOLOR");
|
|
|
|
|
|
if (mesh.hasVertexAlpha) {
|
|
|
defines.push("#define VERTEXALPHA");
|
|
|
}
|
|
|
}
|
|
|
- if (mesh.skeleton && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)) {
|
|
|
- attribs.push(BABYLON.VertexBuffer.MatricesIndicesKind);
|
|
|
- attribs.push(BABYLON.VertexBuffer.MatricesWeightsKind);
|
|
|
+ if (mesh.skeleton && scene.skeletonsEnabled && mesh.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)) {
|
|
|
+ attribs.push(VertexBuffer.MatricesIndicesKind);
|
|
|
+ attribs.push(VertexBuffer.MatricesWeightsKind);
|
|
|
defines.push("#define BONES");
|
|
|
defines.push("#define BonesPerMesh " + (mesh.skeleton.bones.length + 1));
|
|
|
defines.push("#define BONES4");
|
|
@@ -356,9 +356,11 @@
|
|
|
|
|
|
// Get correct effect
|
|
|
var join = defines.join("\n");
|
|
|
- if (this._cachedDefines != join) {
|
|
|
+ if (this._cachedDefines !== join) {
|
|
|
this._cachedDefines = join;
|
|
|
|
|
|
+ scene.resetCachedMaterial();
|
|
|
+
|
|
|
// Legacy browser patch
|
|
|
var shaderName = "default";
|
|
|
if (!scene.getEngine().getCaps().standardDerivatives) {
|
|
@@ -412,101 +414,116 @@
|
|
|
this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
|
|
|
|
// Bones
|
|
|
- if (mesh.skeleton && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)) {
|
|
|
+ if (mesh.skeleton && scene.skeletonsEnabled && mesh.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)) {
|
|
|
this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
|
|
|
}
|
|
|
|
|
|
- // Fresnel
|
|
|
- if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
|
|
|
- this._effect.setColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
|
|
|
- this._effect.setColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
|
|
|
- }
|
|
|
+ if (scene.getCachedMaterial() !== this) {
|
|
|
+ // Fresnel
|
|
|
+ if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
|
|
|
+ this._effect.setColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
|
|
|
+ this._effect.setColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
|
|
|
+ }
|
|
|
|
|
|
- if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
|
|
|
- this._effect.setColor4("opacityParts", new BABYLON.Color3(this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power);
|
|
|
- }
|
|
|
+ if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
|
|
|
+ this._effect.setColor4("opacityParts", new Color3(this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power);
|
|
|
+ }
|
|
|
|
|
|
- if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
|
|
|
- this._effect.setColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
|
|
|
- this._effect.setColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
|
|
|
- }
|
|
|
+ if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
|
|
|
+ this._effect.setColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
|
|
|
+ this._effect.setColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
|
|
|
+ }
|
|
|
|
|
|
- if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
|
|
|
- this._effect.setColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
|
|
|
- this._effect.setColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
|
|
|
- }
|
|
|
+ if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
|
|
|
+ this._effect.setColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
|
|
|
+ this._effect.setColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
|
|
|
+ }
|
|
|
|
|
|
- // Textures
|
|
|
- if (this.diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
|
|
|
- this._effect.setTexture("diffuseSampler", this.diffuseTexture);
|
|
|
+ // Textures
|
|
|
+ if (this.diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
|
|
|
+ this._effect.setTexture("diffuseSampler", this.diffuseTexture);
|
|
|
|
|
|
- this._effect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
|
|
|
- this._effect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
|
|
|
- }
|
|
|
+ this._effect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
|
|
|
+ this._effect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
|
|
|
+ }
|
|
|
|
|
|
- if (this.ambientTexture && BABYLON.StandardMaterial.AmbientTextureEnabled) {
|
|
|
- this._effect.setTexture("ambientSampler", this.ambientTexture);
|
|
|
+ if (this.ambientTexture && StandardMaterial.AmbientTextureEnabled) {
|
|
|
+ this._effect.setTexture("ambientSampler", this.ambientTexture);
|
|
|
|
|
|
- this._effect.setFloat2("vAmbientInfos", this.ambientTexture.coordinatesIndex, this.ambientTexture.level);
|
|
|
- this._effect.setMatrix("ambientMatrix", this.ambientTexture.getTextureMatrix());
|
|
|
- }
|
|
|
+ this._effect.setFloat2("vAmbientInfos", this.ambientTexture.coordinatesIndex, this.ambientTexture.level);
|
|
|
+ this._effect.setMatrix("ambientMatrix", this.ambientTexture.getTextureMatrix());
|
|
|
+ }
|
|
|
|
|
|
- if (this.opacityTexture && BABYLON.StandardMaterial.OpacityTextureEnabled) {
|
|
|
- this._effect.setTexture("opacitySampler", this.opacityTexture);
|
|
|
+ if (this.opacityTexture && StandardMaterial.OpacityTextureEnabled) {
|
|
|
+ this._effect.setTexture("opacitySampler", this.opacityTexture);
|
|
|
|
|
|
- this._effect.setFloat2("vOpacityInfos", this.opacityTexture.coordinatesIndex, this.opacityTexture.level);
|
|
|
- this._effect.setMatrix("opacityMatrix", this.opacityTexture.getTextureMatrix());
|
|
|
- }
|
|
|
+ this._effect.setFloat2("vOpacityInfos", this.opacityTexture.coordinatesIndex, this.opacityTexture.level);
|
|
|
+ this._effect.setMatrix("opacityMatrix", this.opacityTexture.getTextureMatrix());
|
|
|
+ }
|
|
|
|
|
|
- if (this.reflectionTexture && BABYLON.StandardMaterial.ReflectionTextureEnabled) {
|
|
|
- if (this.reflectionTexture.isCube) {
|
|
|
- this._effect.setTexture("reflectionCubeSampler", this.reflectionTexture);
|
|
|
- } else {
|
|
|
- this._effect.setTexture("reflection2DSampler", this.reflectionTexture);
|
|
|
+ if (this.reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
|
|
|
+ if (this.reflectionTexture.isCube) {
|
|
|
+ this._effect.setTexture("reflectionCubeSampler", this.reflectionTexture);
|
|
|
+ } else {
|
|
|
+ this._effect.setTexture("reflection2DSampler", this.reflectionTexture);
|
|
|
+ }
|
|
|
+
|
|
|
+ this._effect.setMatrix("reflectionMatrix", this.reflectionTexture.getReflectionTextureMatrix());
|
|
|
+ this._effect.setFloat3("vReflectionInfos", this.reflectionTexture.coordinatesMode, this.reflectionTexture.level, this.reflectionTexture.isCube ? 1 : 0);
|
|
|
}
|
|
|
|
|
|
- this._effect.setMatrix("reflectionMatrix", this.reflectionTexture.getReflectionTextureMatrix());
|
|
|
- this._effect.setFloat3("vReflectionInfos", this.reflectionTexture.coordinatesMode, this.reflectionTexture.level, this.reflectionTexture.isCube ? 1 : 0);
|
|
|
- }
|
|
|
+ if (this.emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
|
|
|
+ this._effect.setTexture("emissiveSampler", this.emissiveTexture);
|
|
|
|
|
|
- if (this.emissiveTexture && BABYLON.StandardMaterial.EmissiveTextureEnabled) {
|
|
|
- this._effect.setTexture("emissiveSampler", this.emissiveTexture);
|
|
|
+ this._effect.setFloat2("vEmissiveInfos", this.emissiveTexture.coordinatesIndex, this.emissiveTexture.level);
|
|
|
+ this._effect.setMatrix("emissiveMatrix", this.emissiveTexture.getTextureMatrix());
|
|
|
+ }
|
|
|
|
|
|
- this._effect.setFloat2("vEmissiveInfos", this.emissiveTexture.coordinatesIndex, this.emissiveTexture.level);
|
|
|
- this._effect.setMatrix("emissiveMatrix", this.emissiveTexture.getTextureMatrix());
|
|
|
- }
|
|
|
+ if (this.specularTexture && StandardMaterial.SpecularTextureEnabled) {
|
|
|
+ this._effect.setTexture("specularSampler", this.specularTexture);
|
|
|
|
|
|
- if (this.specularTexture && BABYLON.StandardMaterial.SpecularTextureEnabled) {
|
|
|
- this._effect.setTexture("specularSampler", this.specularTexture);
|
|
|
+ this._effect.setFloat2("vSpecularInfos", this.specularTexture.coordinatesIndex, this.specularTexture.level);
|
|
|
+ this._effect.setMatrix("specularMatrix", this.specularTexture.getTextureMatrix());
|
|
|
+ }
|
|
|
|
|
|
- this._effect.setFloat2("vSpecularInfos", this.specularTexture.coordinatesIndex, this.specularTexture.level);
|
|
|
- this._effect.setMatrix("specularMatrix", this.specularTexture.getTextureMatrix());
|
|
|
- }
|
|
|
+ if (this.bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
|
|
|
+ this._effect.setTexture("bumpSampler", this.bumpTexture);
|
|
|
|
|
|
- if (this.bumpTexture && scene.getEngine().getCaps().standardDerivatives && BABYLON.StandardMaterial.BumpTextureEnabled) {
|
|
|
- this._effect.setTexture("bumpSampler", this.bumpTexture);
|
|
|
+ this._effect.setFloat2("vBumpInfos", this.bumpTexture.coordinatesIndex, 1.0 / this.bumpTexture.level);
|
|
|
+ this._effect.setMatrix("bumpMatrix", this.bumpTexture.getTextureMatrix());
|
|
|
+ }
|
|
|
|
|
|
- this._effect.setFloat2("vBumpInfos", this.bumpTexture.coordinatesIndex, 1.0 / this.bumpTexture.level);
|
|
|
- this._effect.setMatrix("bumpMatrix", this.bumpTexture.getTextureMatrix());
|
|
|
- }
|
|
|
+ // Clip plane
|
|
|
+ if (scene.clipPlane) {
|
|
|
+ var clipPlane = scene.clipPlane;
|
|
|
+ this._effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
|
|
|
+ }
|
|
|
|
|
|
- // Colors
|
|
|
- scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
|
|
|
+ // Point size
|
|
|
+ if (this.pointsCloud) {
|
|
|
+ this._effect.setFloat("pointSize", this.pointSize);
|
|
|
+ }
|
|
|
|
|
|
- // Scaling down colors according to emissive
|
|
|
+ // Colors
|
|
|
+ scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
|
|
|
+
|
|
|
+ // Scaling down color according to emissive
|
|
|
+ this._scaledSpecular.r = this.specularColor.r * Tools.Clamp(1.0 - this.emissiveColor.r);
|
|
|
+ this._scaledSpecular.g = this.specularColor.g * Tools.Clamp(1.0 - this.emissiveColor.g);
|
|
|
+ this._scaledSpecular.b = this.specularColor.b * Tools.Clamp(1.0 - this.emissiveColor.b);
|
|
|
+
|
|
|
+ this._effect.setVector3("vEyePosition", scene.activeCamera.position);
|
|
|
+ this._effect.setColor3("vAmbientColor", this._globalAmbientColor);
|
|
|
+ this._effect.setColor4("vSpecularColor", this._scaledSpecular, this.specularPower);
|
|
|
+ this._effect.setColor3("vEmissiveColor", this.emissiveColor);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Scaling down color according to emissive
|
|
|
this._scaledDiffuse.r = this.diffuseColor.r * Tools.Clamp(1.0 - this.emissiveColor.r);
|
|
|
this._scaledDiffuse.g = this.diffuseColor.g * Tools.Clamp(1.0 - this.emissiveColor.g);
|
|
|
this._scaledDiffuse.b = this.diffuseColor.b * Tools.Clamp(1.0 - this.emissiveColor.b);
|
|
|
|
|
|
- this._scaledSpecular.r = this.specularColor.r * Tools.Clamp(1.0 - this.emissiveColor.r);
|
|
|
- this._scaledSpecular.g = this.specularColor.g * Tools.Clamp(1.0 - this.emissiveColor.g);
|
|
|
- this._scaledSpecular.b = this.specularColor.b * Tools.Clamp(1.0 - this.emissiveColor.b);
|
|
|
-
|
|
|
- this._effect.setVector3("vEyePosition", scene.activeCamera.position);
|
|
|
- this._effect.setColor3("vAmbientColor", this._globalAmbientColor);
|
|
|
this._effect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
|
|
|
- this._effect.setColor4("vSpecularColor", this._scaledSpecular, this.specularPower);
|
|
|
- this._effect.setColor3("vEmissiveColor", this.emissiveColor);
|
|
|
|
|
|
if (scene.lightsEnabled) {
|
|
|
var lightIndex = 0;
|
|
@@ -521,16 +538,16 @@
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (light instanceof BABYLON.PointLight) {
|
|
|
+ if (light instanceof PointLight) {
|
|
|
// Point Light
|
|
|
light.transferToEffect(this._effect, "vLightData" + lightIndex);
|
|
|
- } else if (light instanceof BABYLON.DirectionalLight) {
|
|
|
+ } else if (light instanceof DirectionalLight) {
|
|
|
// Directional Light
|
|
|
light.transferToEffect(this._effect, "vLightData" + lightIndex);
|
|
|
- } else if (light instanceof BABYLON.SpotLight) {
|
|
|
+ } else if (light instanceof SpotLight) {
|
|
|
// Spot Light
|
|
|
light.transferToEffect(this._effect, "vLightData" + lightIndex, "vLightDirection" + lightIndex);
|
|
|
- } else if (light instanceof BABYLON.HemisphericLight) {
|
|
|
+ } else if (light instanceof HemisphericLight) {
|
|
|
// Hemispheric Light
|
|
|
light.transferToEffect(this._effect, "vLightData" + lightIndex, "vLightGround" + lightIndex);
|
|
|
}
|
|
@@ -552,31 +569,23 @@
|
|
|
|
|
|
lightIndex++;
|
|
|
|
|
|
- if (lightIndex == maxSimultaneousLights)
|
|
|
+ if (lightIndex === maxSimultaneousLights)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (scene.clipPlane) {
|
|
|
- var clipPlane = scene.clipPlane;
|
|
|
- this._effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
|
|
|
- }
|
|
|
-
|
|
|
// View
|
|
|
- if (mesh.applyFog &&scene.fogMode !== BABYLON.Scene.FOGMODE_NONE || this.reflectionTexture) {
|
|
|
+ if (mesh.applyFog &&scene.fogMode !== Scene.FOGMODE_NONE || this.reflectionTexture) {
|
|
|
this._effect.setMatrix("view", scene.getViewMatrix());
|
|
|
}
|
|
|
|
|
|
// Fog
|
|
|
- if (mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
|
|
|
+ if (mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
|
|
this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
|
|
|
this._effect.setColor3("vFogColor", scene.fogColor);
|
|
|
}
|
|
|
|
|
|
- // Point size
|
|
|
- if (this.pointsCloud) {
|
|
|
- this._effect.setFloat("pointSize", this.pointSize);
|
|
|
- }
|
|
|
+ super.bind(world, mesh);
|
|
|
}
|
|
|
|
|
|
public getAnimatables(): IAnimatable[] {
|
|
@@ -646,7 +655,7 @@
|
|
|
}
|
|
|
|
|
|
public clone(name: string): StandardMaterial {
|
|
|
- var newStandardMaterial = new BABYLON.StandardMaterial(name, this.getScene());
|
|
|
+ var newStandardMaterial = new StandardMaterial(name, this.getScene());
|
|
|
|
|
|
// Base material
|
|
|
newStandardMaterial.checkReadyOnEveryCall = this.checkReadyOnEveryCall;
|