babylon.bloomMergePostProcess.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233
  1. module BABYLON {
  2. /**
  3. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  4. */
  5. export class BloomMergePostProcess extends PostProcess {
  6. /**
  7. * Creates a new instance of @see BloomMergePostProcess
  8. * @param name The name of the effect.
  9. * @param originalFromInput Post process which's input will be used for the merge.
  10. * @param blurred Blurred highlights post process which's output will be used.
  11. * @param weight Weight of the bloom to be added to the original input.
  12. * @param options The required width/height ratio to downsize to before computing the render pass.
  13. * @param camera The camera to apply the render pass to.
  14. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15. * @param engine The engine which the post process will be applied. (default: current engine)
  16. * @param reusable If the post process can be reused on the same frame. (default: false)
  17. * @param textureType Type of textures used when performing the post process. (default: 0)
  18. * @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)
  19. */
  20. constructor(name: string, originalFromInput:PostProcess, blurred:PostProcess, /** Weight of the bloom to be added to the original input. */ public weight:number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, blockCompilation = false) {
  21. super(name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true);
  22. this.onApplyObservable.add((effect: Effect) => {
  23. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  24. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  25. effect.setFloat("bloomWeight", this.weight);
  26. });
  27. if(!blockCompilation){
  28. this.updateEffect();
  29. }
  30. }
  31. }
  32. }