blackAndWhitePostProcess.ts 1.5 KB

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