|
@@ -4054,15 +4054,12 @@ var BABYLON;
|
|
_this.REFRACTION = false;
|
|
_this.REFRACTION = false;
|
|
_this.REFRACTIONMAP_3D = false;
|
|
_this.REFRACTIONMAP_3D = false;
|
|
_this.REFLECTIONOVERALPHA = false;
|
|
_this.REFLECTIONOVERALPHA = false;
|
|
- _this.INVERTNORMALMAPX = false;
|
|
|
|
- _this.INVERTNORMALMAPY = false;
|
|
|
|
_this.TWOSIDEDLIGHTING = false;
|
|
_this.TWOSIDEDLIGHTING = false;
|
|
_this.SHADOWFLOAT = false;
|
|
_this.SHADOWFLOAT = false;
|
|
_this.MORPHTARGETS = false;
|
|
_this.MORPHTARGETS = false;
|
|
_this.MORPHTARGETS_NORMAL = false;
|
|
_this.MORPHTARGETS_NORMAL = false;
|
|
_this.MORPHTARGETS_TANGENT = false;
|
|
_this.MORPHTARGETS_TANGENT = false;
|
|
_this.NUM_MORPH_INFLUENCERS = 0;
|
|
_this.NUM_MORPH_INFLUENCERS = 0;
|
|
- _this.USERIGHTHANDEDSYSTEM = false;
|
|
|
|
_this.IMAGEPROCESSING = false;
|
|
_this.IMAGEPROCESSING = false;
|
|
_this.VIGNETTE = false;
|
|
_this.VIGNETTE = false;
|
|
_this.VIGNETTEBLENDMODEMULTIPLY = false;
|
|
_this.VIGNETTEBLENDMODEMULTIPLY = false;
|
|
@@ -4071,6 +4068,7 @@ var BABYLON;
|
|
_this.CONTRAST = false;
|
|
_this.CONTRAST = false;
|
|
_this.COLORCURVES = false;
|
|
_this.COLORCURVES = false;
|
|
_this.COLORGRADING = false;
|
|
_this.COLORGRADING = false;
|
|
|
|
+ _this.COLORGRADING3D = false;
|
|
_this.SAMPLER3DGREENDEPTH = false;
|
|
_this.SAMPLER3DGREENDEPTH = false;
|
|
_this.SAMPLER3DBGRMAP = false;
|
|
_this.SAMPLER3DBGRMAP = false;
|
|
_this.IMAGEPROCESSINGPOSTPROCESS = false;
|
|
_this.IMAGEPROCESSINGPOSTPROCESS = false;
|
|
@@ -4477,8 +4475,6 @@ var BABYLON;
|
|
else {
|
|
else {
|
|
defines._needUVs = true;
|
|
defines._needUVs = true;
|
|
defines.BUMP = true;
|
|
defines.BUMP = true;
|
|
- defines.INVERTNORMALMAPX = this.invertNormalMapX;
|
|
|
|
- defines.INVERTNORMALMAPY = this.invertNormalMapY;
|
|
|
|
defines.PARALLAX = this._useParallax;
|
|
defines.PARALLAX = this._useParallax;
|
|
defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
|
|
defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
|
|
}
|
|
}
|
|
@@ -4547,12 +4543,7 @@ var BABYLON;
|
|
// Attribs
|
|
// Attribs
|
|
BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
|
|
BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true, true);
|
|
// Values that need to be evaluated on every frame
|
|
// Values that need to be evaluated on every frame
|
|
- BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
|
|
|
|
- if (scene._mirroredCameraPosition && defines.BUMP) {
|
|
|
|
- defines.INVERTNORMALMAPX = !this.invertNormalMapX;
|
|
|
|
- defines.INVERTNORMALMAPY = !this.invertNormalMapY;
|
|
|
|
- defines.markAsUnprocessed();
|
|
|
|
- }
|
|
|
|
|
|
+ BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
|
|
// Get correct effect
|
|
// Get correct effect
|
|
if (defines.isDirty) {
|
|
if (defines.isDirty) {
|
|
defines.markAsProcessed();
|
|
defines.markAsProcessed();
|
|
@@ -4629,7 +4620,7 @@ var BABYLON;
|
|
"mBones",
|
|
"mBones",
|
|
"vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
|
|
"vClipPlane", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
|
|
"diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
|
|
"diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
|
|
- "logarithmicDepthConstant"
|
|
|
|
|
|
+ "logarithmicDepthConstant", "vTangentSpaceParams"
|
|
];
|
|
];
|
|
var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler"];
|
|
var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler"];
|
|
var uniformBuffers = ["Material", "Scene"];
|
|
var uniformBuffers = ["Material", "Scene"];
|
|
@@ -4659,7 +4650,7 @@ var BABYLON;
|
|
}, engine), defines);
|
|
}, engine), defines);
|
|
this.buildUniformLayout();
|
|
this.buildUniformLayout();
|
|
}
|
|
}
|
|
- if (!subMesh.effect.isReady()) {
|
|
|
|
|
|
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
defines._renderId = scene.getRenderId();
|
|
defines._renderId = scene.getRenderId();
|
|
@@ -4693,6 +4684,7 @@ var BABYLON;
|
|
this._uniformBuffer.addUniform("lightmapMatrix", 16);
|
|
this._uniformBuffer.addUniform("lightmapMatrix", 16);
|
|
this._uniformBuffer.addUniform("specularMatrix", 16);
|
|
this._uniformBuffer.addUniform("specularMatrix", 16);
|
|
this._uniformBuffer.addUniform("bumpMatrix", 16);
|
|
this._uniformBuffer.addUniform("bumpMatrix", 16);
|
|
|
|
+ this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
|
|
this._uniformBuffer.addUniform("refractionMatrix", 16);
|
|
this._uniformBuffer.addUniform("refractionMatrix", 16);
|
|
this._uniformBuffer.addUniform("vRefractionInfos", 4);
|
|
this._uniformBuffer.addUniform("vRefractionInfos", 4);
|
|
this._uniformBuffer.addUniform("vSpecularColor", 4);
|
|
this._uniformBuffer.addUniform("vSpecularColor", 4);
|
|
@@ -4719,6 +4711,9 @@ var BABYLON;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
var effect = subMesh.effect;
|
|
var effect = subMesh.effect;
|
|
|
|
+ if (!effect) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
this._activeEffect = effect;
|
|
this._activeEffect = effect;
|
|
// Matrices
|
|
// Matrices
|
|
this.bindOnlyWorldMatrix(world);
|
|
this.bindOnlyWorldMatrix(world);
|
|
@@ -4783,6 +4778,12 @@ var BABYLON;
|
|
if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial_OldVer.BumpTextureEnabled) {
|
|
if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial_OldVer.BumpTextureEnabled) {
|
|
this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
|
|
this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
|
|
this._uniformBuffer.updateMatrix("bumpMatrix", this._bumpTexture.getTextureMatrix());
|
|
this._uniformBuffer.updateMatrix("bumpMatrix", this._bumpTexture.getTextureMatrix());
|
|
|
|
+ if (scene._mirroredCameraPosition) {
|
|
|
|
+ this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (this._refractionTexture && StandardMaterial_OldVer.RefractionTextureEnabled) {
|
|
if (this._refractionTexture && StandardMaterial_OldVer.RefractionTextureEnabled) {
|
|
var depth = 1.0;
|
|
var depth = 1.0;
|
|
@@ -4851,7 +4852,7 @@ var BABYLON;
|
|
BABYLON.MaterialHelper.BindClipPlane(effect, scene);
|
|
BABYLON.MaterialHelper.BindClipPlane(effect, scene);
|
|
// Colors
|
|
// Colors
|
|
scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
|
|
scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
|
|
- effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.position);
|
|
|
|
|
|
+ BABYLON.MaterialHelper.BindEyePosition(effect, scene);
|
|
effect.setColor3("vAmbientColor", this._globalAmbientColor);
|
|
effect.setColor3("vAmbientColor", this._globalAmbientColor);
|
|
}
|
|
}
|
|
if (this._mustRebind(scene, effect) || !this.isFrozen) {
|
|
if (this._mustRebind(scene, effect) || !this.isFrozen) {
|
|
@@ -5880,6 +5881,7 @@ vColor=color;\n\
|
|
var StandardShaderVersions = /** @class */ (function () {
|
|
var StandardShaderVersions = /** @class */ (function () {
|
|
function StandardShaderVersions() {
|
|
function StandardShaderVersions() {
|
|
}
|
|
}
|
|
|
|
+ StandardShaderVersions.Ver3_0 = "3.0.0";
|
|
return StandardShaderVersions;
|
|
return StandardShaderVersions;
|
|
}());
|
|
}());
|
|
BABYLON.StandardShaderVersions = StandardShaderVersions;
|
|
BABYLON.StandardShaderVersions = StandardShaderVersions;
|
|
@@ -5926,16 +5928,20 @@ vColor=color;\n\
|
|
return arr;
|
|
return arr;
|
|
};
|
|
};
|
|
CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines) {
|
|
CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines) {
|
|
|
|
+ var _this = this;
|
|
if (this._isCreatedShader)
|
|
if (this._isCreatedShader)
|
|
return this._createdShaderName;
|
|
return this._createdShaderName;
|
|
this._isCreatedShader = false;
|
|
this._isCreatedShader = false;
|
|
CustomMaterial.ShaderIndexer++;
|
|
CustomMaterial.ShaderIndexer++;
|
|
- var name = name + "custom_" + CustomMaterial.ShaderIndexer;
|
|
|
|
|
|
+ var name = "custom_" + CustomMaterial.ShaderIndexer;
|
|
this.ReviewUniform("uniform", uniforms);
|
|
this.ReviewUniform("uniform", uniforms);
|
|
this.ReviewUniform("sampler", samplers);
|
|
this.ReviewUniform("sampler", samplers);
|
|
var fn_afterBind = this._afterBind;
|
|
var fn_afterBind = this._afterBind;
|
|
this._afterBind = function (m, e) {
|
|
this._afterBind = function (m, e) {
|
|
- this.AttachAfterBind(m, e);
|
|
|
|
|
|
+ if (!e) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ _this.AttachAfterBind(m, e);
|
|
try {
|
|
try {
|
|
fn_afterBind(m, e);
|
|
fn_afterBind(m, e);
|
|
}
|
|
}
|
|
@@ -5978,7 +5984,7 @@ vColor=color;\n\
|
|
this._newUniformInstances[kind + "-" + name] = param;
|
|
this._newUniformInstances[kind + "-" + name] = param;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- this._newSamplerInstances[kind + "-" + name] = param;
|
|
|
|
|
|
+ this._newUniformInstances[kind + "-" + name] = param;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this._customUniform.push("uniform " + kind + " " + name + ";");
|
|
this._customUniform.push("uniform " + kind + " " + name + ";");
|