filterPostProcess.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { Nullable } from "types";
  2. import { Matrix } from "Math";
  3. import { Camera } from "Cameras";
  4. import { Effect } from "Materials";
  5. import { PostProcess, PostProcessOptions } from "PostProcess";
  6. import { Engine } from "Engine";
  7. /**
  8. * Applies a kernel filter to the image
  9. */
  10. export class FilterPostProcess extends PostProcess {
  11. /**
  12. *
  13. * @param name The name of the effect.
  14. * @param kernelMatrix The matrix to be applied to the image
  15. * @param options The required width/height ratio to downsize to before computing the render pass.
  16. * @param camera The camera to apply the render pass to.
  17. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18. * @param engine The engine which the post process will be applied. (default: current engine)
  19. * @param reusable If the post process can be reused on the same frame. (default: false)
  20. */
  21. constructor(name: string,
  22. /** The matrix to be applied to the image */
  23. public kernelMatrix: Matrix,
  24. options: number | PostProcessOptions,
  25. camera: Nullable<Camera>,
  26. samplingMode?: number,
  27. engine?: Engine,
  28. reusable?: boolean
  29. ) {
  30. super(name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable);
  31. this.onApply = (effect: Effect) => {
  32. effect.setMatrix("kernelMatrix", this.kernelMatrix);
  33. };
  34. }
  35. }