|
@@ -81,6 +81,7 @@ var BABYLON;
|
|
|
this.ROUGHNESS = false;
|
|
|
this.EMISSIVEASILLUMINATION = false;
|
|
|
this.REFLECTIONFRESNELFROMSPECULAR = false;
|
|
|
+ this.LIGHTMAP = false;
|
|
|
this._keys = Object.keys(this);
|
|
|
}
|
|
|
StandardMaterialDefines.prototype.isEqual = function (other) {
|
|
@@ -140,6 +141,7 @@ var BABYLON;
|
|
|
this.useSpecularOverAlpha = true;
|
|
|
this.fogEnabled = true;
|
|
|
this.roughness = 0;
|
|
|
+ this.lightmapThreshold = 0;
|
|
|
this.useGlossinessFromSpecularMapAlpha = false;
|
|
|
this._renderTargets = new BABYLON.SmartArray(16);
|
|
|
this._worldViewProjectionMatrix = BABYLON.Matrix.Zero();
|
|
@@ -240,6 +242,15 @@ var BABYLON;
|
|
|
this._defines.EMISSIVE = true;
|
|
|
}
|
|
|
}
|
|
|
+ if (this.lightmapTexture && StandardMaterial.LightmapEnabled) {
|
|
|
+ if (!this.lightmapTexture.isReady()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ needUVs = true;
|
|
|
+ this._defines.LIGHTMAP = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (this.specularTexture && StandardMaterial.SpecularTextureEnabled) {
|
|
|
if (!this.specularTexture.isReady()) {
|
|
|
return false;
|
|
@@ -499,13 +510,13 @@ var BABYLON;
|
|
|
"vLightData2", "vLightDiffuse2", "vLightSpecular2", "vLightDirection2", "vLightGround2", "lightMatrix2",
|
|
|
"vLightData3", "vLightDiffuse3", "vLightSpecular3", "vLightDirection3", "vLightGround3", "lightMatrix3",
|
|
|
"vFogInfos", "vFogColor", "pointSize",
|
|
|
- "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos",
|
|
|
+ "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos",
|
|
|
"mBones",
|
|
|
- "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix",
|
|
|
+ "vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "lightmapMatrix",
|
|
|
"shadowsInfo0", "shadowsInfo1", "shadowsInfo2", "shadowsInfo3",
|
|
|
"diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor",
|
|
|
"roughness"
|
|
|
- ], ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler",
|
|
|
+ ], ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
|
|
|
"shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
|
|
|
], join, fallbacks, this.onCompiled, this.onError);
|
|
|
}
|
|
@@ -587,6 +598,11 @@ var BABYLON;
|
|
|
this._effect.setFloat2("vEmissiveInfos", this.emissiveTexture.coordinatesIndex, this.emissiveTexture.level);
|
|
|
this._effect.setMatrix("emissiveMatrix", this.emissiveTexture.getTextureMatrix());
|
|
|
}
|
|
|
+ if (this.lightmapTexture && StandardMaterial.LightmapEnabled) {
|
|
|
+ this._effect.setTexture("lightmapSampler", this.lightmapTexture);
|
|
|
+ this._effect.setFloat3("vLightmapInfos", this.lightmapTexture.coordinatesIndex, this.lightmapTexture.level, this.lightmapThreshold);
|
|
|
+ this._effect.setMatrix("lightmapMatrix", this.lightmapTexture.getTextureMatrix());
|
|
|
+ }
|
|
|
if (this.specularTexture && StandardMaterial.SpecularTextureEnabled) {
|
|
|
this._effect.setTexture("specularSampler", this.specularTexture);
|
|
|
this._effect.setFloat2("vSpecularInfos", this.specularTexture.coordinatesIndex, this.specularTexture.level);
|
|
@@ -776,6 +792,7 @@ var BABYLON;
|
|
|
StandardMaterial.SpecularTextureEnabled = true;
|
|
|
StandardMaterial.BumpTextureEnabled = true;
|
|
|
StandardMaterial.FresnelEnabled = true;
|
|
|
+ StandardMaterial.LightmapEnabled = true;
|
|
|
return StandardMaterial;
|
|
|
})(BABYLON.Material);
|
|
|
BABYLON.StandardMaterial = StandardMaterial;
|