babylon.extractHighlightsPostProcess.ts 1.5 KB

123456789101112131415161718192021222324252627282930
  1. module BABYLON {
  2. /**
  3. * The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
  4. */
  5. export class ExtractHighlightsPostProcess extends PostProcess {
  6. /**
  7. * The luminance threshold, pixels below this value will be set to black.
  8. */
  9. public threshold = 0.9;
  10. /**
  11. * Internal
  12. */
  13. public _exposure = 1;
  14. /**
  15. * Post process which has the input texture to be used when performing highlight extraction
  16. */
  17. public _inputPostProcess:Nullable<PostProcess> = null;
  18. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, blockCompilation = false) {
  19. super(name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation);
  20. this.onApplyObservable.add((effect: Effect) => {
  21. if(this._inputPostProcess){
  22. effect.setTextureFromPostProcess("textureSampler", this._inputPostProcess);
  23. }
  24. effect.setFloat('threshold', Math.pow(this.threshold, BABYLON.ToGammaSpace));
  25. effect.setFloat('exposure', this._exposure);
  26. })
  27. }
  28. }
  29. }