sharpenPostProcess.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { __decorate } from "../tslib.es6.js";
  2. import { PostProcess } from "./postProcess.js";
  3. import "../Shaders/sharpen.fragment.js";
  4. import { RegisterClass } from "../Misc/typeStore.js";
  5. import { serialize } from "../Misc/decorators.js";
  6. import { SerializationHelper } from "../Misc/decorators.serialization.js";
  7. /**
  8. * The SharpenPostProcess applies a sharpen kernel to every pixel
  9. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  10. */
  11. export class SharpenPostProcess extends PostProcess {
  12. /**
  13. * Gets a string identifying the name of the class
  14. * @returns "SharpenPostProcess" string
  15. */
  16. getClassName() {
  17. return "SharpenPostProcess";
  18. }
  19. /**
  20. * Creates a new instance ConvolutionPostProcess
  21. * @param name The name of the effect.
  22. * @param options The required width/height ratio to downsize to before computing the render pass.
  23. * @param camera The camera to apply the render pass to.
  24. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25. * @param engine The engine which the post process will be applied. (default: current engine)
  26. * @param reusable If the post process can be reused on the same frame. (default: false)
  27. * @param textureType Type of textures used when performing the post process. (default: 0)
  28. * @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)
  29. */
  30. constructor(name, options, camera, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
  31. super(name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation);
  32. /**
  33. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  34. */
  35. this.colorAmount = 1.0;
  36. /**
  37. * How much sharpness should be applied (default: 0.3)
  38. */
  39. this.edgeAmount = 0.3;
  40. this.onApply = (effect) => {
  41. effect.setFloat2("screenSize", this.width, this.height);
  42. effect.setFloat2("sharpnessAmounts", this.edgeAmount, this.colorAmount);
  43. };
  44. }
  45. /**
  46. * @internal
  47. */
  48. static _Parse(parsedPostProcess, targetCamera, scene, rootUrl) {
  49. return SerializationHelper.Parse(() => {
  50. return new SharpenPostProcess(parsedPostProcess.name, parsedPostProcess.options, targetCamera, parsedPostProcess.renderTargetSamplingMode, scene.getEngine(), parsedPostProcess.textureType, parsedPostProcess.reusable);
  51. }, parsedPostProcess, scene, rootUrl);
  52. }
  53. }
  54. __decorate([
  55. serialize()
  56. ], SharpenPostProcess.prototype, "colorAmount", void 0);
  57. __decorate([
  58. serialize()
  59. ], SharpenPostProcess.prototype, "edgeAmount", void 0);
  60. RegisterClass("BABYLON.SharpenPostProcess", SharpenPostProcess);
  61. //# sourceMappingURL=sharpenPostProcess.js.map