extractHighlightsPostProcess.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { __decorate } from "../tslib.es6.js";
  2. import { PostProcess } from "./postProcess.js";
  3. import { ToGammaSpace } from "../Maths/math.constants.js";
  4. import "../Shaders/extractHighlights.fragment.js";
  5. import { serialize } from "../Misc/decorators.js";
  6. import { RegisterClass } from "../Misc/typeStore.js";
  7. /**
  8. * 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.
  9. */
  10. export class ExtractHighlightsPostProcess extends PostProcess {
  11. /**
  12. * Gets a string identifying the name of the class
  13. * @returns "ExtractHighlightsPostProcess" string
  14. */
  15. getClassName() {
  16. return "ExtractHighlightsPostProcess";
  17. }
  18. constructor(name, options, camera, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
  19. super(name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation);
  20. /**
  21. * The luminance threshold, pixels below this value will be set to black.
  22. */
  23. this.threshold = 0.9;
  24. /** @internal */
  25. this._exposure = 1;
  26. /**
  27. * Post process which has the input texture to be used when performing highlight extraction
  28. * @internal
  29. */
  30. this._inputPostProcess = null;
  31. this.onApplyObservable.add((effect) => {
  32. this.externalTextureSamplerBinding = !!this._inputPostProcess;
  33. if (this._inputPostProcess) {
  34. effect.setTextureFromPostProcess("textureSampler", this._inputPostProcess);
  35. }
  36. effect.setFloat("threshold", Math.pow(this.threshold, ToGammaSpace));
  37. effect.setFloat("exposure", this._exposure);
  38. });
  39. }
  40. }
  41. __decorate([
  42. serialize()
  43. ], ExtractHighlightsPostProcess.prototype, "threshold", void 0);
  44. RegisterClass("BABYLON.ExtractHighlightsPostProcess", ExtractHighlightsPostProcess);
  45. //# sourceMappingURL=extractHighlightsPostProcess.js.map