babylon.standardRenderingPipeline.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. /// <reference path="RenderPipeline\babylon.postProcessRenderPipeline.ts" />
  2. module BABYLON {
  3. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  4. /**
  5. * Public members
  6. */
  7. // Post-processes
  8. public originalPostProcess: PostProcess;
  9. public downSampleX4PostProcess: PostProcess = null;
  10. public brightPassPostProcess: PostProcess = null;
  11. public gaussianBlurHPostProcesses: PostProcess[] = [];
  12. public gaussianBlurVPostProcesses: PostProcess[] = [];
  13. public textureAdderPostProcess: PostProcess = null;
  14. public textureAdderFinalPostProcess: PostProcess = null;
  15. public lensFlareFinalPostProcess: PostProcess = null;
  16. public lensFlarePostProcess: PostProcess = null;
  17. public lensFlareComposePostProcess: PostProcess = null;
  18. public depthOfFieldPostProcess: PostProcess = null;
  19. // Values
  20. @serialize()
  21. public brightThreshold: number = 1.0;
  22. @serialize()
  23. public blurWidth: number = 2.0;
  24. @serialize()
  25. public horizontalBlur: boolean = false;
  26. @serialize()
  27. public gaussianCoefficient: number = 0.25;
  28. @serialize()
  29. public gaussianMean: number = 1.0;
  30. @serialize()
  31. public gaussianStandardDeviation: number = 1.0;
  32. @serialize()
  33. public exposure: number = 1.0;
  34. @serializeAsTexture("lensTexture")
  35. public lensTexture: Texture = null;
  36. @serializeAsTexture("lensColorTexture")
  37. public lensColorTexture: Texture = null;
  38. @serialize()
  39. public lensFlareStrength: number = 20.0;
  40. @serialize()
  41. public lensFlareGhostDispersal: number = 1.4;
  42. @serialize()
  43. public lensFlareHaloWidth: number = 0.7;
  44. @serialize()
  45. public lensFlareDistortionStrength: number = 16.0;
  46. @serializeAsTexture("lensStarTexture")
  47. public lensStarTexture: Texture = null;
  48. @serializeAsTexture("lensFlareDirtTexture")
  49. public lensFlareDirtTexture: Texture = null;
  50. @serialize()
  51. public depthOfFieldDistance: number = 10.0;
  52. @serialize()
  53. public depthOfFieldBlurWidth: number = 2.0;
  54. // IAnimatable
  55. public animations: Animation[] = [];
  56. /**
  57. * Private members
  58. */
  59. private _scene: Scene;
  60. private _depthRenderer: DepthRenderer = null;
  61. private _currentDepthOfFieldSource: PostProcess = null;
  62. // Getters and setters
  63. private _depthOfFieldEnabled: boolean = true;
  64. private _lensFlareEnabled: boolean = true;
  65. public set DepthOfFieldEnabled(enabled: boolean) {
  66. var blurIndex = this.gaussianBlurHPostProcesses.length - 1;
  67. if (enabled && !this._depthOfFieldEnabled) {
  68. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRGaussianBlurH" + blurIndex, this._scene.cameras);
  69. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRGaussianBlurV" + blurIndex, this._scene.cameras);
  70. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRDepthOfField", this._scene.cameras);
  71. this._depthRenderer = this._scene.enableDepthRenderer();
  72. }
  73. else if (!enabled && this._depthOfFieldEnabled) {
  74. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRGaussianBlurH" + blurIndex, this._scene.cameras);
  75. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRGaussianBlurV" + blurIndex, this._scene.cameras);
  76. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRDepthOfField", this._scene.cameras);
  77. }
  78. this._depthOfFieldEnabled = enabled;
  79. }
  80. @serialize()
  81. public get DepthOfFieldEnabled(): boolean {
  82. return this._depthOfFieldEnabled;
  83. }
  84. public set LensFlareEnabled(enabled: boolean) {
  85. var blurIndex = this.gaussianBlurHPostProcesses.length - 2;
  86. if (enabled && !this._lensFlareEnabled) {
  87. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRLensFlare", this._scene.cameras);
  88. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRLensFlareShift", this._scene.cameras);
  89. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRGaussianBlurH" + blurIndex, this._scene.cameras);
  90. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRGaussianBlurV" + blurIndex, this._scene.cameras);
  91. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRLensFlareCompose", this._scene.cameras);
  92. this._setDepthOfFieldSavePostProcess("HDRPostLensFlareDepthOfFieldSource");
  93. }
  94. else if (!enabled && this._lensFlareEnabled) {
  95. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRLensFlare", this._scene.cameras);
  96. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRLensFlareShift", this._scene.cameras);
  97. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRGaussianBlurH" + blurIndex, this._scene.cameras);
  98. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRGaussianBlurV" + blurIndex, this._scene.cameras);
  99. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRLensFlareCompose", this._scene.cameras);
  100. this._setDepthOfFieldSavePostProcess("HDRBaseDepthOfFieldSource");
  101. }
  102. this._lensFlareEnabled = enabled;
  103. }
  104. @serialize()
  105. public get LensFlareEnabled(): boolean {
  106. return this._lensFlareEnabled;
  107. }
  108. /**
  109. * @constructor
  110. * @param {string} name - The rendering pipeline name
  111. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  112. * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  113. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  114. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  115. */
  116. constructor(name: string, scene: Scene, ratio: number, originalPostProcess: PostProcess = null, cameras?: Camera[]) {
  117. super(scene.getEngine(), name);
  118. // Initialize
  119. this._scene = scene;
  120. // Create pass post-processe
  121. if (!originalPostProcess) {
  122. this.originalPostProcess = new PostProcess("HDRPass", "standard", [], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", Engine.TEXTURETYPE_FLOAT);
  123. }
  124. else {
  125. this.originalPostProcess = originalPostProcess;
  126. }
  127. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRPassPostProcess", () => { return this.originalPostProcess; }, true));
  128. // Create down sample X4 post-process
  129. this._createDownSampleX4PostProcess(scene, ratio / 2);
  130. // Create bright pass post-process
  131. this._createBrightPassPostProcess(scene, ratio / 2);
  132. // Create gaussian blur post-processes (down sampling blurs)
  133. this._createGaussianBlurPostProcesses(scene, ratio / 2, 0);
  134. this._createGaussianBlurPostProcesses(scene, ratio / 4, 1);
  135. this._createGaussianBlurPostProcesses(scene, ratio / 8, 2);
  136. this._createGaussianBlurPostProcesses(scene, ratio / 16, 3);
  137. // Create texture adder post-process
  138. this._createTextureAdderPostProcess(scene, ratio);
  139. // Create depth-of-field source post-process
  140. this.textureAdderFinalPostProcess = new PostProcess("HDRDepthOfFieldSource", "standard", [], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", Engine.TEXTURETYPE_UNSIGNED_INT);
  141. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRBaseDepthOfFieldSource", () => { return this.textureAdderFinalPostProcess; }, true));
  142. // Create lens flare post-process
  143. this._createLensFlarePostProcess(scene, ratio);
  144. // Create depth-of-field source post-process post lens-flare and disable it now
  145. this.lensFlareFinalPostProcess = new PostProcess("HDRPostLensFlareDepthOfFieldSource", "standard", [], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", Engine.TEXTURETYPE_UNSIGNED_INT);
  146. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", () => { return this.lensFlareFinalPostProcess; }, true));
  147. // Create gaussian blur used by depth-of-field
  148. this._createGaussianBlurPostProcesses(scene, ratio / 2, 5, "depthOfFieldBlurWidth");
  149. // Create depth-of-field post-process
  150. this._createDepthOfFieldPostProcess(scene, ratio);
  151. // Finish
  152. scene.postProcessRenderPipelineManager.addPipeline(this);
  153. if (cameras !== null) {
  154. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  155. }
  156. // Deactivate
  157. this.LensFlareEnabled = false;
  158. this.DepthOfFieldEnabled = false;
  159. }
  160. // Sets depth-of-field save post-process
  161. private _setDepthOfFieldSavePostProcess(name: string): void {
  162. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRPostLensFlareDepthOfFieldSource", this._scene.cameras);
  163. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, name, this._scene.cameras);
  164. switch (name) {
  165. case "HDRBaseDepthOfFieldSource": this._currentDepthOfFieldSource = this.textureAdderFinalPostProcess; break;
  166. case "HDRPostLensFlareDepthOfFieldSource": this._currentDepthOfFieldSource = this.lensFlareFinalPostProcess; break;
  167. default: break;
  168. }
  169. }
  170. // Down Sample X4 Post-Processs
  171. private _createDownSampleX4PostProcess(scene: Scene, ratio: number): void {
  172. var downSampleX4Offsets = new Array<number>(32);
  173. this.downSampleX4PostProcess = new PostProcess("HDRDownSampleX4", "standard", ["dsOffsets"], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define DOWN_SAMPLE_X4", Engine.TEXTURETYPE_UNSIGNED_INT);
  174. this.downSampleX4PostProcess.onApply = (effect: Effect) => {
  175. var id = 0;
  176. for (var i = -2; i < 2; i++) {
  177. for (var j = -2; j < 2; j++) {
  178. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / this.downSampleX4PostProcess.width);
  179. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / this.downSampleX4PostProcess.height);
  180. id += 2;
  181. }
  182. }
  183. effect.setArray2("dsOffsets", downSampleX4Offsets);
  184. };
  185. // Add to pipeline
  186. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRDownSampleX4", () => { return this.downSampleX4PostProcess; }, true));
  187. }
  188. // Brightpass Post-Process
  189. private _createBrightPassPostProcess(scene: Scene, ratio: number): void {
  190. var brightOffsets = new Array<number>(8);
  191. this.brightPassPostProcess = new PostProcess("HDRBrightPass", "standard", ["dsOffsets", "brightThreshold"], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define BRIGHT_PASS", Engine.TEXTURETYPE_UNSIGNED_INT);
  192. this.brightPassPostProcess.onApply = (effect: Effect) => {
  193. var sU = (1.0 / this.brightPassPostProcess.width);
  194. var sV = (1.0 / this.brightPassPostProcess.height);
  195. brightOffsets[0] = -0.5 * sU;
  196. brightOffsets[1] = 0.5 * sV;
  197. brightOffsets[2] = 0.5 * sU;
  198. brightOffsets[3] = 0.5 * sV;
  199. brightOffsets[4] = -0.5 * sU;
  200. brightOffsets[5] = -0.5 * sV;
  201. brightOffsets[6] = 0.5 * sU;
  202. brightOffsets[7] = -0.5 * sV;
  203. effect.setArray2("dsOffsets", brightOffsets);
  204. effect.setFloat("brightThreshold", this.brightThreshold);
  205. }
  206. // Add to pipeline
  207. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRBrightPass", () => { return this.brightPassPostProcess; }, true));
  208. }
  209. // Create gaussian blur H&V post-processes
  210. private _createGaussianBlurPostProcesses(scene: Scene, ratio: number, indice: number, blurWidthKey: string = "blurWidth"): void {
  211. var blurOffsets = new Array<number>(9);
  212. var blurWeights = new Array<number>(9);
  213. var uniforms: string[] = ["blurOffsets", "blurWeights", "blurWidth"];
  214. var callback = (height: boolean) => {
  215. return (effect: Effect) => {
  216. // Weights
  217. var x: number = 0.0;
  218. for (var i = 0; i < 9; i++) {
  219. x = (i - 4.0) / 4.0;
  220. blurWeights[i] =
  221. this.gaussianCoefficient
  222. * (1.0 / Math.sqrt(2.0 * Math.PI * this.gaussianStandardDeviation))
  223. * Math.exp((-((x - this.gaussianMean) * (x - this.gaussianMean))) / (2.0 * this.gaussianStandardDeviation * this.gaussianStandardDeviation));
  224. }
  225. var lastOutputDimensions: any = {
  226. width: scene.getEngine().getRenderWidth(),
  227. height: scene.getEngine().getRenderHeight()
  228. };
  229. for (var i = 0; i < 9; i++) {
  230. var value = (i - 4.0) * (1.0 / (height === true ? lastOutputDimensions.height : lastOutputDimensions.width));
  231. blurOffsets[i] = value;
  232. }
  233. effect.setArray("blurOffsets", blurOffsets);
  234. effect.setArray("blurWeights", blurWeights);
  235. if (height) {
  236. effect.setFloat("blurWidth", this.horizontalBlur ? 1.0 : this[blurWidthKey]);
  237. }
  238. else {
  239. effect.setFloat("blurWidth", this[blurWidthKey]);
  240. }
  241. };
  242. };
  243. // Create horizontal gaussian blur post-processes
  244. var gaussianBlurHPostProcess = new PostProcess("HDRGaussianBlurH_" + ratio + "_" + indice, "standard", uniforms, [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define GAUSSIAN_BLUR_H", Engine.TEXTURETYPE_UNSIGNED_INT);
  245. gaussianBlurHPostProcess.onApply = callback(false);
  246. // Create vertical gaussian blur post-process
  247. var gaussianBlurVPostProcess = new PostProcess("HDRGaussianBlurV_" + ratio + "_" + indice, "standard", uniforms, [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define GAUSSIAN_BLUR_V", Engine.TEXTURETYPE_UNSIGNED_INT);
  248. gaussianBlurVPostProcess.onApply = callback(true);
  249. // Add to pipeline
  250. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRGaussianBlurH" + indice, () => { return gaussianBlurHPostProcess; }, true));
  251. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRGaussianBlurV" + indice, () => { return gaussianBlurVPostProcess; }, true));
  252. // Finish
  253. this.gaussianBlurHPostProcesses.push(gaussianBlurHPostProcess);
  254. this.gaussianBlurVPostProcesses.push(gaussianBlurVPostProcess);
  255. }
  256. // Create texture adder post-process
  257. private _createTextureAdderPostProcess(scene: Scene, ratio: number): void {
  258. this.textureAdderPostProcess = new PostProcess("HDRTextureAdder", "standard", ["exposure"], ["otherSampler", "lensSampler"], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define TEXTURE_ADDER", Engine.TEXTURETYPE_UNSIGNED_INT);
  259. this.textureAdderPostProcess.onApply = (effect: Effect) => {
  260. effect.setTextureFromPostProcess("otherSampler", this.originalPostProcess);
  261. effect.setTexture("lensSampler", this.lensTexture);
  262. effect.setFloat("exposure", this.exposure);
  263. };
  264. // Add to pipeline
  265. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRTextureAdder", () => { return this.textureAdderPostProcess; }, true));
  266. }
  267. // Create lens flare post-process
  268. private _createLensFlarePostProcess(scene: Scene, ratio: number): void {
  269. this.lensFlarePostProcess = new PostProcess("HDRLensFlare", "standard", ["strength", "ghostDispersal", "haloWidth", "resolution", "distortionStrength"], ["lensColorSampler"], ratio / 2, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define LENS_FLARE", Engine.TEXTURETYPE_UNSIGNED_INT);
  270. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRLensFlare", () => { return this.lensFlarePostProcess; }, true));
  271. this._createGaussianBlurPostProcesses(scene, ratio / 4, 4);
  272. this.lensFlareComposePostProcess = new PostProcess("HDRLensFlareCompose", "standard", ["lensStarMatrix"], ["otherSampler", "lensDirtSampler", "lensStarSampler"], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define LENS_FLARE_COMPOSE", Engine.TEXTURETYPE_UNSIGNED_INT);
  273. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRLensFlareCompose", () => { return this.lensFlareComposePostProcess; }, true));
  274. var resolution = new Vector2(0, 0);
  275. // Lens flare
  276. this.lensFlarePostProcess.onApply = (effect: Effect) => {
  277. effect.setTextureFromPostProcess("textureSampler", this.gaussianBlurHPostProcesses[0]);
  278. effect.setTexture("lensColorSampler", this.lensColorTexture);
  279. effect.setFloat("strength", this.lensFlareStrength);
  280. effect.setFloat("ghostDispersal", this.lensFlareGhostDispersal);
  281. effect.setFloat("haloWidth", this.lensFlareHaloWidth);
  282. // Shift
  283. resolution.x = this.lensFlarePostProcess.width;
  284. resolution.y = this.lensFlarePostProcess.height;
  285. effect.setVector2("resolution", resolution);
  286. effect.setFloat("distortionStrength", this.lensFlareDistortionStrength);
  287. };
  288. // Compose
  289. var scaleBias1 = Matrix.FromValues(
  290. 2.0, 0.0, -1.0, 0.0,
  291. 0.0, 2.0, -1.0, 0.0,
  292. 0.0, 0.0, 1.0, 0.0,
  293. 0.0, 0.0, 0.0, 1.0
  294. );
  295. var scaleBias2 = Matrix.FromValues(
  296. 0.5, 0.0, 0.5, 0.0,
  297. 0.0, 0.5, 0.5, 0.0,
  298. 0.0, 0.0, 1.0, 0.0,
  299. 0.0, 0.0, 0.0, 1.0
  300. );
  301. this.lensFlareComposePostProcess.onApply = (effect: Effect) => {
  302. effect.setTextureFromPostProcess("otherSampler", this.textureAdderFinalPostProcess);
  303. effect.setTexture("lensDirtSampler", this.lensFlareDirtTexture);
  304. effect.setTexture("lensStarSampler", this.lensStarTexture);
  305. // Lens start rotation matrix
  306. var camerax = this._scene.activeCamera.getViewMatrix().getRow(0);
  307. var cameraz = this._scene.activeCamera.getViewMatrix().getRow(2);
  308. var camRot = Vector3.Dot(camerax.toVector3(), new Vector3(1.0, 0.0, 0.0)) + Vector3.Dot(cameraz.toVector3(), new Vector3(0.0, 0.0, 1.0));
  309. camRot *= 4.0;
  310. var starRotation = Matrix.FromValues(
  311. Math.cos(camRot) * 0.5, -Math.sin(camRot), 0.0, 0.0,
  312. Math.sin(camRot), Math.cos(camRot) * 0.5, 0.0, 0.0,
  313. 0.0, 0.0, 1.0, 0.0,
  314. 0.0, 0.0, 0.0, 1.0
  315. );
  316. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  317. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  318. };
  319. }
  320. // Create depth-of-field post-process
  321. private _createDepthOfFieldPostProcess(scene: Scene, ratio: number): void {
  322. this.depthOfFieldPostProcess = new PostProcess("HDRDepthOfField", "standard", ["distance"], ["otherSampler", "depthSampler"], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define DEPTH_OF_FIELD", Engine.TEXTURETYPE_UNSIGNED_INT);
  323. this.depthOfFieldPostProcess.onApply = (effect: Effect) => {
  324. effect.setTextureFromPostProcess("otherSampler", this._currentDepthOfFieldSource);
  325. effect.setTexture("depthSampler", this._depthRenderer.getDepthMap());
  326. effect.setFloat("distance", this.depthOfFieldDistance);
  327. };
  328. // Add to pipeline
  329. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRDepthOfField", () => { return this.depthOfFieldPostProcess; }, true));
  330. }
  331. // Dispose
  332. public dispose(): void {
  333. for (var i = 0; i < this._scene.cameras.length; i++) {
  334. var camera = this._scene.cameras[i];
  335. this.originalPostProcess.dispose(camera);
  336. this.downSampleX4PostProcess.dispose(camera);
  337. this.brightPassPostProcess.dispose(camera);
  338. this.textureAdderPostProcess.dispose(camera);
  339. for (var j = 0; j < this.gaussianBlurHPostProcesses.length; j++) {
  340. this.gaussianBlurHPostProcesses[j].dispose(camera);
  341. }
  342. for (var j = 0; j < this.gaussianBlurVPostProcesses.length; j++) {
  343. this.gaussianBlurVPostProcesses[j].dispose(camera);
  344. }
  345. this.textureAdderFinalPostProcess.dispose(camera);
  346. this.lensFlarePostProcess.dispose(camera);
  347. this.lensFlareComposePostProcess.dispose(camera);
  348. this.depthOfFieldPostProcess.dispose(camera);
  349. }
  350. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  351. super.dispose();
  352. }
  353. // Serialize rendering pipeline
  354. public serialize(): any {
  355. var serializationObject = SerializationHelper.Serialize(this);
  356. serializationObject.customType = "StandardRenderingPipeline";
  357. return serializationObject;
  358. }
  359. // Parse serialized pipeline
  360. public static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline {
  361. return SerializationHelper.Parse(() => new StandardRenderingPipeline(source._name, scene, source._ratio), source, scene, rootUrl);
  362. }
  363. }
  364. }