babylon.stereoscopicInterlacePostProcess.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233
  1. module BABYLON {
  2. /**
  3. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  4. */
  5. export class StereoscopicInterlacePostProcess extends PostProcess {
  6. private _stepSize : Vector2;
  7. private _passedProcess : Nullable<PostProcess>;
  8. /**
  9. * Initializes a StereoscopicInterlacePostProcess
  10. * @param name The name of the effect.
  11. * @param rigCameras The rig cameras to be appled to the post process
  12. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  13. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14. * @param engine The engine which the post process will be applied. (default: current engine)
  15. * @param reusable If the post process can be reused on the same frame. (default: false)
  16. */
  17. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean) {
  18. super(name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined);
  19. this._passedProcess = rigCameras[0]._rigPostProcess;
  20. this._stepSize = new Vector2(1 / this.width, 1 / this.height);
  21. this.onSizeChangedObservable.add(() => {
  22. this._stepSize = new Vector2(1 / this.width, 1 / this.height);
  23. });
  24. this.onApplyObservable.add((effect: Effect) => {
  25. effect.setTextureFromPostProcess("camASampler", this._passedProcess);
  26. effect.setFloat2("stepSize", this._stepSize.x, this._stepSize.y);
  27. });
  28. }
  29. }
  30. }