babylon.depthOfFieldBlurPostProcess.ts 1.3 KB

1234567891011121314151617181920
  1. module BABYLON {
  2. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  3. constructor(name: string, public direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Camera, depthMap:RenderTargetTexture, imageToBlur:Nullable<PostProcess> = null, samplingMode: number = Texture.BILINEAR_SAMPLINGMODE, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
  4. // TODO: passing in camera here unexpectedly causes the 1 frame behind issue and forces me to make the calling of this reusable.
  5. super(name, direction, kernel, options, null, samplingMode = Texture.BILINEAR_SAMPLINGMODE, engine, reusable, textureType = Engine.TEXTURETYPE_UNSIGNED_INT)
  6. this._staticDefines += `#define DOF 1\r\n`;
  7. this.onApplyObservable.add((effect: Effect) => {
  8. // TODO: setTextureFromPostProcess seems to be setting the input texture instead of output of the post process passed in
  9. if(imageToBlur != null){
  10. effect.setTextureFromPostProcess("textureSampler", imageToBlur)
  11. }
  12. effect.setTexture("depthSampler", depthMap)
  13. effect.setFloat('near', camera.minZ);
  14. effect.setFloat('far', camera.maxZ);
  15. });
  16. }
  17. }
  18. }