bloomMergePostProcess.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { __decorate } from "../tslib.es6.js";
  2. import { PostProcess } from "./postProcess.js";
  3. import "../Shaders/bloomMerge.fragment.js";
  4. import { RegisterClass } from "../Misc/typeStore.js";
  5. import { serialize } from "../Misc/decorators.js";
  6. /**
  7. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  8. */
  9. export class BloomMergePostProcess extends PostProcess {
  10. /**
  11. * Gets a string identifying the name of the class
  12. * @returns "BloomMergePostProcess" string
  13. */
  14. getClassName() {
  15. return "BloomMergePostProcess";
  16. }
  17. /**
  18. * Creates a new instance of @see BloomMergePostProcess
  19. * @param name The name of the effect.
  20. * @param originalFromInput Post process which's input will be used for the merge.
  21. * @param blurred Blurred highlights post process which's output will be used.
  22. * @param weight Weight of the bloom to be added to the original input.
  23. * @param options The required width/height ratio to downsize to before computing the render pass.
  24. * @param camera The camera to apply the render pass to.
  25. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26. * @param engine The engine which the post process will be applied. (default: current engine)
  27. * @param reusable If the post process can be reused on the same frame. (default: false)
  28. * @param textureType Type of textures used when performing the post process. (default: 0)
  29. * @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)
  30. */
  31. constructor(name, originalFromInput, blurred,
  32. /** Weight of the bloom to be added to the original input. */
  33. weight, options, camera, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
  34. super(name, "bloomMerge", ["bloomWeight"], ["bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true);
  35. /** Weight of the bloom to be added to the original input. */
  36. this.weight = 1;
  37. this.weight = weight;
  38. this.externalTextureSamplerBinding = true;
  39. this.onApplyObservable.add((effect) => {
  40. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  41. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  42. effect.setFloat("bloomWeight", this.weight);
  43. });
  44. if (!blockCompilation) {
  45. this.updateEffect();
  46. }
  47. }
  48. }
  49. __decorate([
  50. serialize()
  51. ], BloomMergePostProcess.prototype, "weight", void 0);
  52. RegisterClass("BABYLON.BloomMergePostProcess", BloomMergePostProcess);
  53. //# sourceMappingURL=bloomMergePostProcess.js.map