passPostProcess.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import { PostProcess } from "./postProcess.js";
  2. import { AbstractEngine } from "../Engines/abstractEngine.js";
  3. import "../Shaders/pass.fragment.js";
  4. import "../Shaders/passCube.fragment.js";
  5. import { RegisterClass } from "../Misc/typeStore.js";
  6. import { SerializationHelper } from "../Misc/decorators.serialization.js";
  7. /**
  8. * PassPostProcess which produces an output the same as it's input
  9. */
  10. export class PassPostProcess extends PostProcess {
  11. /**
  12. * Gets a string identifying the name of the class
  13. * @returns "PassPostProcess" string
  14. */
  15. getClassName() {
  16. return "PassPostProcess";
  17. }
  18. /**
  19. * Creates the PassPostProcess
  20. * @param name The name of the effect.
  21. * @param options The required width/height ratio to downsize to before computing the render pass.
  22. * @param camera The camera to apply the render pass to.
  23. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24. * @param engine The engine which the post process will be applied. (default: current engine)
  25. * @param reusable If the post process can be reused on the same frame. (default: false)
  26. * @param textureType The type of texture to be used when performing the post processing.
  27. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  28. */
  29. constructor(name, options, camera = null, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
  30. super(name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation);
  31. }
  32. /**
  33. * @internal
  34. */
  35. static _Parse(parsedPostProcess, targetCamera, scene, rootUrl) {
  36. return SerializationHelper.Parse(() => {
  37. return new PassPostProcess(parsedPostProcess.name, parsedPostProcess.options, targetCamera, parsedPostProcess.renderTargetSamplingMode, parsedPostProcess._engine, parsedPostProcess.reusable);
  38. }, parsedPostProcess, scene, rootUrl);
  39. }
  40. }
  41. RegisterClass("BABYLON.PassPostProcess", PassPostProcess);
  42. /**
  43. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44. */
  45. export class PassCubePostProcess extends PostProcess {
  46. /**
  47. * Gets or sets the cube face to display.
  48. * * 0 is +X
  49. * * 1 is -X
  50. * * 2 is +Y
  51. * * 3 is -Y
  52. * * 4 is +Z
  53. * * 5 is -Z
  54. */
  55. get face() {
  56. return this._face;
  57. }
  58. set face(value) {
  59. if (value < 0 || value > 5) {
  60. return;
  61. }
  62. this._face = value;
  63. switch (this._face) {
  64. case 0:
  65. this.updateEffect("#define POSITIVEX");
  66. break;
  67. case 1:
  68. this.updateEffect("#define NEGATIVEX");
  69. break;
  70. case 2:
  71. this.updateEffect("#define POSITIVEY");
  72. break;
  73. case 3:
  74. this.updateEffect("#define NEGATIVEY");
  75. break;
  76. case 4:
  77. this.updateEffect("#define POSITIVEZ");
  78. break;
  79. case 5:
  80. this.updateEffect("#define NEGATIVEZ");
  81. break;
  82. }
  83. }
  84. /**
  85. * Gets a string identifying the name of the class
  86. * @returns "PassCubePostProcess" string
  87. */
  88. getClassName() {
  89. return "PassCubePostProcess";
  90. }
  91. /**
  92. * Creates the PassCubePostProcess
  93. * @param name The name of the effect.
  94. * @param options The required width/height ratio to downsize to before computing the render pass.
  95. * @param camera The camera to apply the render pass to.
  96. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97. * @param engine The engine which the post process will be applied. (default: current engine)
  98. * @param reusable If the post process can be reused on the same frame. (default: false)
  99. * @param textureType The type of texture to be used when performing the post processing.
  100. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  101. */
  102. constructor(name, options, camera = null, samplingMode, engine, reusable, textureType = 0, blockCompilation = false) {
  103. super(name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation);
  104. this._face = 0;
  105. }
  106. /**
  107. * @internal
  108. */
  109. static _Parse(parsedPostProcess, targetCamera, scene, rootUrl) {
  110. return SerializationHelper.Parse(() => {
  111. return new PassCubePostProcess(parsedPostProcess.name, parsedPostProcess.options, targetCamera, parsedPostProcess.renderTargetSamplingMode, parsedPostProcess._engine, parsedPostProcess.reusable);
  112. }, parsedPostProcess, scene, rootUrl);
  113. }
  114. }
  115. AbstractEngine._RescalePostProcessFactory = (engine) => {
  116. return new PassPostProcess("rescale", 1, null, 2, engine, false, 0);
  117. };
  118. //# sourceMappingURL=passPostProcess.js.map