|
@@ -15,7 +15,7 @@
|
|
private _matrices: { [name: string]: Matrix } = {};
|
|
private _matrices: { [name: string]: Matrix } = {};
|
|
private _matrices3x3: { [name: string]: Float32Array } = {};
|
|
private _matrices3x3: { [name: string]: Float32Array } = {};
|
|
private _matrices2x2: { [name: string]: Float32Array } = {};
|
|
private _matrices2x2: { [name: string]: Float32Array } = {};
|
|
- private _vectors2Arrays: { [name: string]: number[] } = {};
|
|
|
|
|
|
+ private _vectors2Arrays: { [name: string]: number[] } = {};
|
|
private _vectors3Arrays: { [name: string]: number[] } = {};
|
|
private _vectors3Arrays: { [name: string]: number[] } = {};
|
|
private _cachedWorldViewMatrix = new Matrix();
|
|
private _cachedWorldViewMatrix = new Matrix();
|
|
private _renderId: number;
|
|
private _renderId: number;
|
|
@@ -151,14 +151,14 @@
|
|
|
|
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
-
|
|
|
|
- public setArray2(name: string, value: number[]): ShaderMaterial {
|
|
|
|
|
|
+
|
|
|
|
+ public setArray2(name: string, value: number[]): ShaderMaterial {
|
|
this._checkUniform(name);
|
|
this._checkUniform(name);
|
|
this._vectors2Arrays[name] = value;
|
|
this._vectors2Arrays[name] = value;
|
|
|
|
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public setArray3(name: string, value: number[]): ShaderMaterial {
|
|
public setArray3(name: string, value: number[]): ShaderMaterial {
|
|
this._checkUniform(name);
|
|
this._checkUniform(name);
|
|
this._vectors3Arrays[name] = value;
|
|
this._vectors3Arrays[name] = value;
|
|
@@ -177,7 +177,7 @@
|
|
|
|
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean {
|
|
public isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean {
|
|
var scene = this.getScene();
|
|
var scene = this.getScene();
|
|
var engine = scene.getEngine();
|
|
var engine = scene.getEngine();
|
|
@@ -210,7 +210,7 @@
|
|
attribs.push(VertexBuffer.ColorKind);
|
|
attribs.push(VertexBuffer.ColorKind);
|
|
defines.push("#define VERTEXCOLOR");
|
|
defines.push("#define VERTEXCOLOR");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Bones
|
|
// Bones
|
|
if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
|
|
if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
|
|
attribs.push(VertexBuffer.MatricesIndicesKind);
|
|
attribs.push(VertexBuffer.MatricesIndicesKind);
|
|
@@ -229,7 +229,7 @@
|
|
|
|
|
|
} else {
|
|
} else {
|
|
defines.push("#define NUM_BONE_INFLUENCERS 0");
|
|
defines.push("#define NUM_BONE_INFLUENCERS 0");
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
// Textures
|
|
// Textures
|
|
for (var name in this._textures) {
|
|
for (var name in this._textures) {
|
|
@@ -247,15 +247,15 @@
|
|
var join = defines.join("\n");
|
|
var join = defines.join("\n");
|
|
|
|
|
|
this._effect = engine.createEffect(this._shaderPath, <EffectCreationOptions>{
|
|
this._effect = engine.createEffect(this._shaderPath, <EffectCreationOptions>{
|
|
- attributes: attribs,
|
|
|
|
- uniformsNames: this._options.uniforms,
|
|
|
|
- uniformBuffersNames: this._options.uniformBuffers,
|
|
|
|
- samplers: this._options.samplers,
|
|
|
|
- defines: join,
|
|
|
|
- fallbacks: fallbacks,
|
|
|
|
- onCompiled: this.onCompiled,
|
|
|
|
- onError: this.onError
|
|
|
|
- }, engine);
|
|
|
|
|
|
+ attributes: attribs,
|
|
|
|
+ uniformsNames: this._options.uniforms,
|
|
|
|
+ uniformBuffersNames: this._options.uniformBuffers,
|
|
|
|
+ samplers: this._options.samplers,
|
|
|
|
+ defines: join,
|
|
|
|
+ fallbacks: fallbacks,
|
|
|
|
+ onCompiled: this.onCompiled,
|
|
|
|
+ onError: this.onError
|
|
|
|
+ }, engine);
|
|
|
|
|
|
if (!this._effect.isReady()) {
|
|
if (!this._effect.isReady()) {
|
|
return false;
|
|
return false;
|
|
@@ -376,12 +376,12 @@
|
|
for (name in this._matrices2x2) {
|
|
for (name in this._matrices2x2) {
|
|
this._effect.setMatrix2x2(name, this._matrices2x2[name]);
|
|
this._effect.setMatrix2x2(name, this._matrices2x2[name]);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Vector2Array
|
|
// Vector2Array
|
|
for (name in this._vectors2Arrays) {
|
|
for (name in this._vectors2Arrays) {
|
|
this._effect.setArray2(name, this._vectors2Arrays[name]);
|
|
this._effect.setArray2(name, this._vectors2Arrays[name]);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Vector3Array
|
|
// Vector3Array
|
|
for (name in this._vectors3Arrays) {
|
|
for (name in this._vectors3Arrays) {
|
|
this._effect.setArray3(name, this._vectors3Arrays[name]);
|
|
this._effect.setArray3(name, this._vectors3Arrays[name]);
|
|
@@ -417,7 +417,7 @@
|
|
if (this._textures[name] === texture) {
|
|
if (this._textures[name] === texture) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
for (var name in this._textureArrays) {
|
|
for (var name in this._textureArrays) {
|
|
var array = this._textureArrays[name];
|
|
var array = this._textureArrays[name];
|
|
@@ -426,9 +426,9 @@
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- return false;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
public clone(name: string): ShaderMaterial {
|
|
public clone(name: string): ShaderMaterial {
|
|
@@ -461,7 +461,7 @@
|
|
public serialize(): any {
|
|
public serialize(): any {
|
|
var serializationObject = SerializationHelper.Serialize(this);
|
|
var serializationObject = SerializationHelper.Serialize(this);
|
|
serializationObject.customType = "BABYLON.ShaderMaterial";
|
|
serializationObject.customType = "BABYLON.ShaderMaterial";
|
|
-
|
|
|
|
|
|
+
|
|
serializationObject.options = this._options;
|
|
serializationObject.options = this._options;
|
|
serializationObject.shaderPath = this._shaderPath;
|
|
serializationObject.shaderPath = this._shaderPath;
|
|
|
|
|
|
@@ -548,8 +548,8 @@
|
|
for (name in this._matrices2x2) {
|
|
for (name in this._matrices2x2) {
|
|
serializationObject.matrices2x2[name] = this._matrices2x2[name];
|
|
serializationObject.matrices2x2[name] = this._matrices2x2[name];
|
|
}
|
|
}
|
|
-
|
|
|
|
- // Vector2Array
|
|
|
|
|
|
+
|
|
|
|
+ // Vector2Array
|
|
serializationObject.vectors2Arrays = {};
|
|
serializationObject.vectors2Arrays = {};
|
|
for (name in this._vectors2Arrays) {
|
|
for (name in this._vectors2Arrays) {
|
|
serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
|
|
serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
|
|
@@ -560,7 +560,7 @@
|
|
for (name in this._vectors3Arrays) {
|
|
for (name in this._vectors3Arrays) {
|
|
serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
|
|
serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return serializationObject;
|
|
return serializationObject;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -647,8 +647,8 @@
|
|
for (name in source.matrices2x2) {
|
|
for (name in source.matrices2x2) {
|
|
material.setMatrix2x2(name, source.matrices2x2[name]);
|
|
material.setMatrix2x2(name, source.matrices2x2[name]);
|
|
}
|
|
}
|
|
-
|
|
|
|
- // Vector2Array
|
|
|
|
|
|
+
|
|
|
|
+ // Vector2Array
|
|
for (name in source.vectors2Arrays) {
|
|
for (name in source.vectors2Arrays) {
|
|
material.setArray2(name, source.vectors2Arrays[name]);
|
|
material.setArray2(name, source.vectors2Arrays[name]);
|
|
}
|
|
}
|
|
@@ -657,7 +657,7 @@
|
|
for (name in source.vectors3Arrays) {
|
|
for (name in source.vectors3Arrays) {
|
|
material.setArray3(name, source.vectors3Arrays[name]);
|
|
material.setArray3(name, source.vectors3Arrays[name]);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return material;
|
|
return material;
|
|
}
|
|
}
|
|
}
|
|
}
|