blackAndWhitePostProcess.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { PostProcess, PostProcessOptions } from "./postProcess";
  2. import { Camera } from "Cameras/camera";
  3. import { Effect } from "Materials/effect";
  4. import { Engine } from "Engines/engine";
  5. import "Shaders/blackAndWhite.fragment";
  6. /**
  7. * Post process used to render in black and white
  8. */
  9. export class BlackAndWhitePostProcess extends PostProcess {
  10. /**
  11. * Linear about to convert he result to black and white (default: 1)
  12. */
  13. public degree = 1;
  14. /**
  15. * Creates a black and white post process
  16. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  17. * @param name The name of the effect.
  18. * @param options The required width/height ratio to downsize to before computing the render pass.
  19. * @param camera The camera to apply the render pass to.
  20. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21. * @param engine The engine which the post process will be applied. (default: current engine)
  22. * @param reusable If the post process can be reused on the same frame. (default: false)
  23. */
  24. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
  25. super(name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable);
  26. this.onApplyObservable.add((effect: Effect) => {
  27. effect.setFloat("degree", this.degree);
  28. });
  29. }
  30. }