minMaxReducer.d.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import type { Nullable } from "../types";
  2. import type { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
  3. import type { Camera } from "../Cameras/camera";
  4. import type { Observer } from "./observable";
  5. import { Observable } from "./observable";
  6. import { PostProcess } from "../PostProcesses/postProcess";
  7. import { PostProcessManager } from "../PostProcesses/postProcessManager";
  8. import type { AbstractEngine } from "../Engines/abstractEngine";
  9. import "../Shaders/minmaxRedux.fragment";
  10. /**
  11. * This class computes a min/max reduction from a texture: it means it computes the minimum
  12. * and maximum values from all values of the texture.
  13. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  14. * The source values are read from the red channel of the texture.
  15. */
  16. export declare class MinMaxReducer {
  17. /**
  18. * Observable triggered when the computation has been performed
  19. */
  20. onAfterReductionPerformed: Observable<{
  21. min: number;
  22. max: number;
  23. }>;
  24. protected _camera: Camera;
  25. protected _sourceTexture: Nullable<RenderTargetTexture>;
  26. protected _reductionSteps: Nullable<Array<PostProcess>>;
  27. protected _postProcessManager: PostProcessManager;
  28. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  29. protected _forceFullscreenViewport: boolean;
  30. protected _onContextRestoredObserver: Nullable<Observer<AbstractEngine>>;
  31. /**
  32. * Creates a min/max reducer
  33. * @param camera The camera to use for the post processes
  34. */
  35. constructor(camera: Camera);
  36. /**
  37. * Gets the texture used to read the values from.
  38. */
  39. get sourceTexture(): Nullable<RenderTargetTexture>;
  40. /**
  41. * Sets the source texture to read the values from.
  42. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  43. * because in such textures '1' value must not be taken into account to compute the maximum
  44. * as this value is used to clear the texture.
  45. * Note that the computation is not activated by calling this function, you must call activate() for that!
  46. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  47. * @param depthRedux Indicates if the texture is a depth texture or not
  48. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  49. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  50. */
  51. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  52. /**
  53. * Defines the refresh rate of the computation.
  54. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55. */
  56. get refreshRate(): number;
  57. set refreshRate(value: number);
  58. protected _activated: boolean;
  59. /**
  60. * Gets the activation status of the reducer
  61. */
  62. get activated(): boolean;
  63. /**
  64. * Activates the reduction computation.
  65. * When activated, the observers registered in onAfterReductionPerformed are
  66. * called after the computation is performed
  67. */
  68. activate(): void;
  69. /**
  70. * Deactivates the reduction computation.
  71. */
  72. deactivate(): void;
  73. /**
  74. * Disposes the min/max reducer
  75. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  76. */
  77. dispose(disposeAll?: boolean): void;
  78. }