|
@@ -1,4 +1,8 @@
|
|
|
module BABYLON {
|
|
|
+ /**
|
|
|
+ * This represents a depth renderer in Babylon.
|
|
|
+ * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
|
|
|
+ */
|
|
|
export class DepthRenderer {
|
|
|
private _scene: Scene;
|
|
|
private _depthMap: RenderTargetTexture;
|
|
@@ -7,6 +11,12 @@
|
|
|
private _cachedDefines: string;
|
|
|
private _camera:Nullable<Camera>;
|
|
|
|
|
|
+ /**
|
|
|
+ * Instantiates a depth renderer
|
|
|
+ * @param scene The scene the renderer belongs to
|
|
|
+ * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
|
|
|
+ * @param camera The camera to be used to render the depth map (default: scene's active camera)
|
|
|
+ */
|
|
|
constructor(scene: Scene, type: number = Engine.TEXTURETYPE_FLOAT, camera:Nullable<Camera> = null) {
|
|
|
this._scene = scene;
|
|
|
this._camera = camera;
|
|
@@ -104,6 +114,12 @@
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Creates the depth rendering effect and checks if the effect is ready.
|
|
|
+ * @param subMesh The submesh to be used to render the depth map of
|
|
|
+ * @param useInstances If multiple world instances should be used
|
|
|
+ * @returns if the depth renderer is ready to render the depth map
|
|
|
+ */
|
|
|
public isReady(subMesh: SubMesh, useInstances: boolean): boolean {
|
|
|
var material: any = subMesh.getMaterial();
|
|
|
if (material.disableDepthWrite) {
|
|
@@ -165,11 +181,17 @@
|
|
|
return this._effect.isReady();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Gets the texture which the depth map will be written to.
|
|
|
+ * @returns The depth map texture
|
|
|
+ */
|
|
|
public getDepthMap(): RenderTargetTexture {
|
|
|
return this._depthMap;
|
|
|
}
|
|
|
|
|
|
- // Methods
|
|
|
+ /**
|
|
|
+ * Disposes of the depth renderer.
|
|
|
+ */
|
|
|
public dispose(): void {
|
|
|
this._depthMap.dispose();
|
|
|
}
|