sharpenPostProcess.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { Nullable } from "../types";
  2. import { Camera } from "../Cameras/camera";
  3. import { Effect } from "../Materials/effect";
  4. import { PostProcess, PostProcessOptions } from "./postProcess";
  5. import { Constants } from "../Engines/constants";
  6. import "../Shaders/sharpen.fragment";
  7. declare type Engine = import("../Engines/engine").Engine;
  8. /**
  9. * The SharpenPostProcess applies a sharpen kernel to every pixel
  10. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  11. */
  12. export class SharpenPostProcess extends PostProcess {
  13. /**
  14. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  15. */
  16. public colorAmount: number = 1.0;
  17. /**
  18. * How much sharpness should be applied (default: 0.3)
  19. */
  20. public edgeAmount: number = 0.3;
  21. /**
  22. * Creates a new instance ConvolutionPostProcess
  23. * @param name The name of the effect.
  24. * @param options The required width/height ratio to downsize to before computing the render pass.
  25. * @param camera The camera to apply the render pass to.
  26. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27. * @param engine The engine which the post process will be applied. (default: current engine)
  28. * @param reusable If the post process can be reused on the same frame. (default: false)
  29. * @param textureType Type of textures used when performing the post process. (default: 0)
  30. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  31. */
  32. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT, blockCompilation = false) {
  33. super(name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation);
  34. this.onApply = (effect: Effect) => {
  35. effect.setFloat2("screenSize", this.width, this.height);
  36. effect.setFloat2("sharpnessAmounts", this.edgeAmount, this.colorAmount);
  37. };
  38. }
  39. }