|
@@ -1,5 +1,9 @@
|
|
|
module BABYLON {
|
|
|
+
|
|
|
//TODO is there something this class should extend?. I dont think this fits as a postprocess or pipeline.
|
|
|
+ /**
|
|
|
+ * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
|
|
|
+ */
|
|
|
export class DepthOfFieldEffect {
|
|
|
private readonly DepthOfFieldPassPostProcessId: string = "DepthOfFieldPassPostProcessId";
|
|
|
private readonly CircleOfConfusionPostProcessId: string = "CircleOfConfusionPostProcessEffect";
|
|
@@ -13,6 +17,9 @@ module BABYLON {
|
|
|
private depthOfFieldBlurY: DepthOfFieldBlurPostProcess;
|
|
|
private depthOfFieldMerge: DepthOfFieldMergePostProcess;
|
|
|
|
|
|
+ /**
|
|
|
+ * The size of the kernel to be used for the blur
|
|
|
+ */
|
|
|
public set kernelSize(value: number){
|
|
|
this.depthOfFieldBlurX.kernel = value;
|
|
|
this.depthOfFieldBlurY.kernel = value;
|
|
@@ -20,24 +27,36 @@ module BABYLON {
|
|
|
public get kernelSize(){
|
|
|
return this.depthOfFieldBlurX.kernel;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * The focal the length of the camera used in the effect
|
|
|
+ */
|
|
|
public set focalLength(value: number){
|
|
|
this.circleOfConfusion.focalLength = value;
|
|
|
}
|
|
|
public get focalLength(){
|
|
|
return this.circleOfConfusion.focalLength;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
|
|
|
+ */
|
|
|
public set fStop(value: number){
|
|
|
this.circleOfConfusion.fStop = value;
|
|
|
}
|
|
|
public get fStop(){
|
|
|
return this.circleOfConfusion.fStop;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
|
|
|
+ */
|
|
|
public set focusDistance(value: number){
|
|
|
this.circleOfConfusion.focusDistance = value;
|
|
|
}
|
|
|
public get focusDistance(){
|
|
|
return this.circleOfConfusion.focusDistance;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
|
|
|
+ */
|
|
|
public set lensSize(value: number){
|
|
|
this.circleOfConfusion.lensSize = value;
|
|
|
}
|
|
@@ -45,6 +64,13 @@ module BABYLON {
|
|
|
return this.circleOfConfusion.lensSize;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Creates a new instance of @see DepthOfFieldEffect
|
|
|
+ * @param pipeline The pipeline to add the depth of field effect to.
|
|
|
+ * @param scene The scene the effect belongs to.
|
|
|
+ * @param camera The camera to apply the depth of field on.
|
|
|
+ * @param pipelineTextureType The type of texture to be used when performing the post processing.
|
|
|
+ */
|
|
|
constructor(pipeline: PostProcessRenderPipeline, scene: Scene, camera:Camera, pipelineTextureType = 0) {
|
|
|
// Enable and get current depth map
|
|
|
var depthMap = scene.enableDepthRenderer().getDepthMap();
|
|
@@ -68,6 +94,10 @@ module BABYLON {
|
|
|
pipeline.addEffect(new PostProcessRenderEffect(scene.getEngine(), this.DepthOfFieldMergePostProcessId, () => { return this.depthOfFieldMerge; }, true));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Disposes each of the internal effects for a given camera.
|
|
|
+ * @param camera The camera to dispose the effect on.
|
|
|
+ */
|
|
|
public disposeEffects(camera:Camera){
|
|
|
this.depthOfFieldPass.dispose(camera);
|
|
|
this.circleOfConfusion.dispose(camera);
|