|
@@ -1,7 +1,7 @@
|
|
module BABYLON {
|
|
module BABYLON {
|
|
export class GeometryRenderer {
|
|
export class GeometryRenderer {
|
|
private _scene: Scene;
|
|
private _scene: Scene;
|
|
- private _multiRenderTarger: MultiRenderTarget;
|
|
|
|
|
|
+ private _multiRenderTarget: MultiRenderTarget;
|
|
private _effect: Effect;
|
|
private _effect: Effect;
|
|
|
|
|
|
private _viewMatrix = Matrix.Zero();
|
|
private _viewMatrix = Matrix.Zero();
|
|
@@ -16,7 +16,7 @@ module BABYLON {
|
|
var engine = scene.getEngine();
|
|
var engine = scene.getEngine();
|
|
|
|
|
|
// Render target
|
|
// Render target
|
|
- this._multiRenderTarger = new MultiRenderTarget("gBuffer", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, 4, this._scene);
|
|
|
|
|
|
+ this._multiRenderTarget = new MultiRenderTarget("gBuffer", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, 2, this._scene);
|
|
|
|
|
|
// Custom render function
|
|
// Custom render function
|
|
var renderSubMesh = (subMesh: SubMesh): void => {
|
|
var renderSubMesh = (subMesh: SubMesh): void => {
|
|
@@ -45,25 +45,13 @@ module BABYLON {
|
|
|
|
|
|
this._effect.setFloat("far", scene.activeCamera.maxZ);
|
|
this._effect.setFloat("far", scene.activeCamera.maxZ);
|
|
|
|
|
|
- // Alpha test
|
|
|
|
- if (material && material.needAlphaTesting()) {
|
|
|
|
- var alphaTexture = material.getAlphaTestTexture();
|
|
|
|
- this._effect.setTexture("diffuseSampler", alphaTexture);
|
|
|
|
- this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Bones
|
|
|
|
- if (mesh.useBones && mesh.computeBonesUsingShaders) {
|
|
|
|
- this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Draw
|
|
// Draw
|
|
mesh._processRendering(subMesh, this._effect, Material.TriangleFillMode, batch, hardwareInstancedRendering,
|
|
mesh._processRendering(subMesh, this._effect, Material.TriangleFillMode, batch, hardwareInstancedRendering,
|
|
(isInstance, world) => this._effect.setMatrix("world", world));
|
|
(isInstance, world) => this._effect.setMatrix("world", world));
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- this._multiRenderTarger.customRenderFunction = (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>): void => {
|
|
|
|
|
|
+ this._multiRenderTarget.customRenderFunction = (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>): void => {
|
|
var index;
|
|
var index;
|
|
|
|
|
|
for (index = 0; index < opaqueSubMeshes.length; index++) {
|
|
for (index = 0; index < opaqueSubMeshes.length; index++) {
|
|
@@ -91,37 +79,10 @@ module BABYLON {
|
|
var mesh = subMesh.getMesh();
|
|
var mesh = subMesh.getMesh();
|
|
var scene = mesh.getScene();
|
|
var scene = mesh.getScene();
|
|
|
|
|
|
- if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
|
|
|
|
- attribs.push(VertexBuffer.UVKind);
|
|
|
|
- defines.push("#define UV1");
|
|
|
|
- }
|
|
|
|
- if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind)) {
|
|
|
|
- attribs.push(VertexBuffer.UV2Kind);
|
|
|
|
- defines.push("#define UV2");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Bones
|
|
|
|
- if (mesh.useBones && mesh.computeBonesUsingShaders) {
|
|
|
|
- attribs.push(VertexBuffer.MatricesIndicesKind);
|
|
|
|
- attribs.push(VertexBuffer.MatricesWeightsKind);
|
|
|
|
- if (mesh.numBoneInfluencers > 4) {
|
|
|
|
- attribs.push(VertexBuffer.MatricesIndicesExtraKind);
|
|
|
|
- attribs.push(VertexBuffer.MatricesWeightsExtraKind);
|
|
|
|
- }
|
|
|
|
- defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
|
|
|
|
- defines.push("#define BonesPerMesh " + (mesh.skeleton.bones.length + 1));
|
|
|
|
- } else {
|
|
|
|
- defines.push("#define NUM_BONE_INFLUENCERS 0");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Instances
|
|
|
|
- if (useInstances) {
|
|
|
|
- defines.push("#define INSTANCES");
|
|
|
|
- attribs.push("world0");
|
|
|
|
- attribs.push("world1");
|
|
|
|
- attribs.push("world2");
|
|
|
|
- attribs.push("world3");
|
|
|
|
- }
|
|
|
|
|
|
+ // if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
|
|
|
|
+ // attribs.push(VertexBuffer.UVKind);
|
|
|
|
+ // defines.push("#define UV1");
|
|
|
|
+ // }
|
|
|
|
|
|
// Get correct effect
|
|
// Get correct effect
|
|
var join = defines.join("\n");
|
|
var join = defines.join("\n");
|
|
@@ -129,20 +90,20 @@ module BABYLON {
|
|
this._cachedDefines = join;
|
|
this._cachedDefines = join;
|
|
this._effect = this._scene.getEngine().createEffect("geometry",
|
|
this._effect = this._scene.getEngine().createEffect("geometry",
|
|
attribs,
|
|
attribs,
|
|
- ["world", "mBones", "viewProjection", "diffuseMatrix", "far"],
|
|
|
|
- ["diffuseSampler"], join);
|
|
|
|
|
|
+ ["world", "viewProjection", "far"],
|
|
|
|
+ [], join);
|
|
}
|
|
}
|
|
|
|
|
|
return this._effect.isReady();
|
|
return this._effect.isReady();
|
|
}
|
|
}
|
|
|
|
|
|
public getGBuffer(): MultiRenderTarget {
|
|
public getGBuffer(): MultiRenderTarget {
|
|
- return this._multiRenderTarger;
|
|
|
|
|
|
+ return this._multiRenderTarget;
|
|
}
|
|
}
|
|
|
|
|
|
// Methods
|
|
// Methods
|
|
public dispose(): void {
|
|
public dispose(): void {
|
|
- this.getGBuffer.dispose();
|
|
|
|
|
|
+ this.getGBuffer().dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|