blackAndWhitePostProcess.ts 1.5 KB

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