|
@@ -6,20 +6,21 @@ module BABYLON {
|
|
|
/**
|
|
|
* 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.
|
|
|
*/
|
|
|
- lensSize = 50
|
|
|
+ public lensSize = 50
|
|
|
/**
|
|
|
* F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
|
|
|
*/
|
|
|
- fStop = 1.4;
|
|
|
+ public fStop = 1.4;
|
|
|
/**
|
|
|
* Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
|
|
|
*/
|
|
|
- focusDistance = 2000;
|
|
|
+ public focusDistance = 2000;
|
|
|
/**
|
|
|
* Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
|
|
|
*/
|
|
|
- focalLength = 50;
|
|
|
+ public focalLength = 50;
|
|
|
|
|
|
+ private _depthTexture:Nullable<RenderTargetTexture> = null;
|
|
|
/**
|
|
|
* Creates a new instance of @see CircleOfConfusionPostProcess
|
|
|
* @param name The name of the effect.
|
|
@@ -31,10 +32,15 @@ module BABYLON {
|
|
|
* @param reusable If the post process can be reused on the same frame. (default: false)
|
|
|
* @param textureType Type of textures used when performing the post process. (default: 0)
|
|
|
*/
|
|
|
- constructor(name: string, depthTexture: RenderTargetTexture, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
|
|
|
+ constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
|
|
|
super(name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType);
|
|
|
+ this._depthTexture = depthTexture;
|
|
|
this.onApplyObservable.add((effect: Effect) => {
|
|
|
- effect.setTexture("depthSampler", depthTexture);
|
|
|
+ if(!this._depthTexture){
|
|
|
+ BABYLON.Tools.Warn("No depth texture set on CircleOfConfusionPostProcess")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ effect.setTexture("depthSampler", this._depthTexture);
|
|
|
|
|
|
// Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
|
|
|
var aperture = this.lensSize/this.fStop;
|
|
@@ -42,8 +48,12 @@ module BABYLON {
|
|
|
|
|
|
effect.setFloat('focusDistance', this.focusDistance);
|
|
|
effect.setFloat('cocPrecalculation', cocPrecalculation);
|
|
|
- effect.setFloat2('cameraMinMaxZ', depthTexture.activeCamera!.minZ, depthTexture.activeCamera!.maxZ);
|
|
|
+ effect.setFloat2('cameraMinMaxZ', this._depthTexture.activeCamera!.minZ, this._depthTexture.activeCamera!.maxZ);
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ public set depthTexture(value: RenderTargetTexture){
|
|
|
+ this._depthTexture = value;
|
|
|
+ }
|
|
|
}
|
|
|
}
|