babylon.standardRenderingPipeline.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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._cameras);
  69. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRGaussianBlurV" + blurIndex, this._cameras);
  70. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRDepthOfField", this._cameras);
  71. this._depthRenderer = this._scene.enableDepthRenderer();
  72. }
  73. else if (!enabled && this._depthOfFieldEnabled) {
  74. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRGaussianBlurH" + blurIndex, this._cameras);
  75. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRGaussianBlurV" + blurIndex, this._cameras);
  76. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRDepthOfField", this._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._cameras);
  88. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRLensFlareShift", this._cameras);
  89. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRGaussianBlurH" + blurIndex, this._cameras);
  90. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRGaussianBlurV" + blurIndex, this._cameras);
  91. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, "HDRLensFlareCompose", this._cameras);
  92. this._setDepthOfFieldSavePostProcess("HDRPostLensFlareDepthOfFieldSource");
  93. }
  94. else if (!enabled && this._lensFlareEnabled) {
  95. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRLensFlare", this._cameras);
  96. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRLensFlareShift", this._cameras);
  97. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRGaussianBlurH" + blurIndex, this._cameras);
  98. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRGaussianBlurV" + blurIndex, this._cameras);
  99. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRLensFlareCompose", this._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. this._cameras = cameras || [];
  119. // Initialize
  120. this._scene = scene;
  121. // Create pass post-processe
  122. if (!originalPostProcess) {
  123. this.originalPostProcess = new PostProcess("HDRPass", "standard", [], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", Engine.TEXTURETYPE_FLOAT);
  124. }
  125. else {
  126. this.originalPostProcess = originalPostProcess;
  127. }
  128. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRPassPostProcess", () => { return this.originalPostProcess; }, true));
  129. // Create down sample X4 post-process
  130. this._createDownSampleX4PostProcess(scene, ratio / 2);
  131. // Create bright pass post-process
  132. this._createBrightPassPostProcess(scene, ratio / 2);
  133. // Create gaussian blur post-processes (down sampling blurs)
  134. this._createGaussianBlurPostProcesses(scene, ratio / 2, 0);
  135. this._createGaussianBlurPostProcesses(scene, ratio / 4, 1);
  136. this._createGaussianBlurPostProcesses(scene, ratio / 8, 2);
  137. this._createGaussianBlurPostProcesses(scene, ratio / 16, 3);
  138. // Create texture adder post-process
  139. this._createTextureAdderPostProcess(scene, ratio);
  140. // Create depth-of-field source post-process
  141. this.textureAdderFinalPostProcess = new PostProcess("HDRDepthOfFieldSource", "standard", [], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", Engine.TEXTURETYPE_UNSIGNED_INT);
  142. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRBaseDepthOfFieldSource", () => { return this.textureAdderFinalPostProcess; }, true));
  143. // Create lens flare post-process
  144. this._createLensFlarePostProcess(scene, ratio);
  145. // Create depth-of-field source post-process post lens-flare and disable it now
  146. this.lensFlareFinalPostProcess = new PostProcess("HDRPostLensFlareDepthOfFieldSource", "standard", [], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define PASS_POST_PROCESS", Engine.TEXTURETYPE_UNSIGNED_INT);
  147. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", () => { return this.lensFlareFinalPostProcess; }, true));
  148. // Create gaussian blur used by depth-of-field
  149. this._createGaussianBlurPostProcesses(scene, ratio / 2, 5, "depthOfFieldBlurWidth");
  150. // Create depth-of-field post-process
  151. this._createDepthOfFieldPostProcess(scene, ratio);
  152. // Finish
  153. scene.postProcessRenderPipelineManager.addPipeline(this);
  154. if (cameras !== null) {
  155. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  156. }
  157. // Deactivate
  158. this.LensFlareEnabled = false;
  159. this.DepthOfFieldEnabled = false;
  160. }
  161. // Sets depth-of-field save post-process
  162. private _setDepthOfFieldSavePostProcess(name: string): void {
  163. this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name, "HDRPostLensFlareDepthOfFieldSource", this._cameras);
  164. this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name, name, this._cameras);
  165. switch (name) {
  166. case "HDRBaseDepthOfFieldSource": this._currentDepthOfFieldSource = this.textureAdderFinalPostProcess; break;
  167. case "HDRPostLensFlareDepthOfFieldSource": this._currentDepthOfFieldSource = this.lensFlareFinalPostProcess; break;
  168. default: break;
  169. }
  170. }
  171. // Down Sample X4 Post-Processs
  172. private _createDownSampleX4PostProcess(scene: Scene, ratio: number): void {
  173. var downSampleX4Offsets = new Array<number>(32);
  174. this.downSampleX4PostProcess = new PostProcess("HDRDownSampleX4", "standard", ["dsOffsets"], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define DOWN_SAMPLE_X4", Engine.TEXTURETYPE_UNSIGNED_INT);
  175. this.downSampleX4PostProcess.onApply = (effect: Effect) => {
  176. var id = 0;
  177. for (var i = -2; i < 2; i++) {
  178. for (var j = -2; j < 2; j++) {
  179. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / this.downSampleX4PostProcess.width);
  180. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / this.downSampleX4PostProcess.height);
  181. id += 2;
  182. }
  183. }
  184. effect.setArray2("dsOffsets", downSampleX4Offsets);
  185. };
  186. // Add to pipeline
  187. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRDownSampleX4", () => { return this.downSampleX4PostProcess; }, true));
  188. }
  189. // Brightpass Post-Process
  190. private _createBrightPassPostProcess(scene: Scene, ratio: number): void {
  191. var brightOffsets = new Array<number>(8);
  192. this.brightPassPostProcess = new PostProcess("HDRBrightPass", "standard", ["dsOffsets", "brightThreshold"], [], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define BRIGHT_PASS", Engine.TEXTURETYPE_UNSIGNED_INT);
  193. this.brightPassPostProcess.onApply = (effect: Effect) => {
  194. var sU = (1.0 / this.brightPassPostProcess.width);
  195. var sV = (1.0 / this.brightPassPostProcess.height);
  196. brightOffsets[0] = -0.5 * sU;
  197. brightOffsets[1] = 0.5 * sV;
  198. brightOffsets[2] = 0.5 * sU;
  199. brightOffsets[3] = 0.5 * sV;
  200. brightOffsets[4] = -0.5 * sU;
  201. brightOffsets[5] = -0.5 * sV;
  202. brightOffsets[6] = 0.5 * sU;
  203. brightOffsets[7] = -0.5 * sV;
  204. effect.setArray2("dsOffsets", brightOffsets);
  205. effect.setFloat("brightThreshold", this.brightThreshold);
  206. }
  207. // Add to pipeline
  208. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRBrightPass", () => { return this.brightPassPostProcess; }, true));
  209. }
  210. // Create gaussian blur H&V post-processes
  211. private _createGaussianBlurPostProcesses(scene: Scene, ratio: number, indice: number, blurWidthKey: string = "blurWidth"): void {
  212. var blurOffsets = new Array<number>(9);
  213. var blurWeights = new Array<number>(9);
  214. var uniforms: string[] = ["blurOffsets", "blurWeights", "blurWidth"];
  215. var callback = (height: boolean) => {
  216. return (effect: Effect) => {
  217. // Weights
  218. var x: number = 0.0;
  219. for (var i = 0; i < 9; i++) {
  220. x = (i - 4.0) / 4.0;
  221. blurWeights[i] =
  222. this.gaussianCoefficient
  223. * (1.0 / Math.sqrt(2.0 * Math.PI * this.gaussianStandardDeviation))
  224. * Math.exp((-((x - this.gaussianMean) * (x - this.gaussianMean))) / (2.0 * this.gaussianStandardDeviation * this.gaussianStandardDeviation));
  225. }
  226. var lastOutputDimensions: any = {
  227. width: scene.getEngine().getRenderWidth(),
  228. height: scene.getEngine().getRenderHeight()
  229. };
  230. for (var i = 0; i < 9; i++) {
  231. var value = (i - 4.0) * (1.0 / (height === true ? lastOutputDimensions.height : lastOutputDimensions.width));
  232. blurOffsets[i] = value;
  233. }
  234. effect.setArray("blurOffsets", blurOffsets);
  235. effect.setArray("blurWeights", blurWeights);
  236. if (height) {
  237. effect.setFloat("blurWidth", this.horizontalBlur ? 1.0 : this[blurWidthKey]);
  238. }
  239. else {
  240. effect.setFloat("blurWidth", this[blurWidthKey]);
  241. }
  242. };
  243. };
  244. // Create horizontal gaussian blur post-processes
  245. 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);
  246. gaussianBlurHPostProcess.onApply = callback(false);
  247. // Create vertical gaussian blur post-process
  248. 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);
  249. gaussianBlurVPostProcess.onApply = callback(true);
  250. // Add to pipeline
  251. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRGaussianBlurH" + indice, () => { return gaussianBlurHPostProcess; }, true));
  252. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRGaussianBlurV" + indice, () => { return gaussianBlurVPostProcess; }, true));
  253. // Finish
  254. this.gaussianBlurHPostProcesses.push(gaussianBlurHPostProcess);
  255. this.gaussianBlurVPostProcesses.push(gaussianBlurVPostProcess);
  256. }
  257. // Create texture adder post-process
  258. private _createTextureAdderPostProcess(scene: Scene, ratio: number): void {
  259. this.textureAdderPostProcess = new PostProcess("HDRTextureAdder", "standard", ["exposure"], ["otherSampler", "lensSampler"], ratio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define TEXTURE_ADDER", Engine.TEXTURETYPE_UNSIGNED_INT);
  260. this.textureAdderPostProcess.onApply = (effect: Effect) => {
  261. effect.setTextureFromPostProcess("otherSampler", this.originalPostProcess);
  262. effect.setTexture("lensSampler", this.lensTexture);
  263. effect.setFloat("exposure", this.exposure);
  264. };
  265. // Add to pipeline
  266. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRTextureAdder", () => { return this.textureAdderPostProcess; }, true));
  267. }
  268. // Create lens flare post-process
  269. private _createLensFlarePostProcess(scene: Scene, ratio: number): void {
  270. 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);
  271. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRLensFlare", () => { return this.lensFlarePostProcess; }, true));
  272. this._createGaussianBlurPostProcesses(scene, ratio / 4, 4);
  273. 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);
  274. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRLensFlareCompose", () => { return this.lensFlareComposePostProcess; }, true));
  275. var resolution = new Vector2(0, 0);
  276. // Lens flare
  277. this.lensFlarePostProcess.onApply = (effect: Effect) => {
  278. effect.setTextureFromPostProcess("textureSampler", this.gaussianBlurHPostProcesses[0]);
  279. effect.setTexture("lensColorSampler", this.lensColorTexture);
  280. effect.setFloat("strength", this.lensFlareStrength);
  281. effect.setFloat("ghostDispersal", this.lensFlareGhostDispersal);
  282. effect.setFloat("haloWidth", this.lensFlareHaloWidth);
  283. // Shift
  284. resolution.x = this.lensFlarePostProcess.width;
  285. resolution.y = this.lensFlarePostProcess.height;
  286. effect.setVector2("resolution", resolution);
  287. effect.setFloat("distortionStrength", this.lensFlareDistortionStrength);
  288. };
  289. // Compose
  290. var scaleBias1 = Matrix.FromValues(
  291. 2.0, 0.0, -1.0, 0.0,
  292. 0.0, 2.0, -1.0, 0.0,
  293. 0.0, 0.0, 1.0, 0.0,
  294. 0.0, 0.0, 0.0, 1.0
  295. );
  296. var scaleBias2 = Matrix.FromValues(
  297. 0.5, 0.0, 0.5, 0.0,
  298. 0.0, 0.5, 0.5, 0.0,
  299. 0.0, 0.0, 1.0, 0.0,
  300. 0.0, 0.0, 0.0, 1.0
  301. );
  302. this.lensFlareComposePostProcess.onApply = (effect: Effect) => {
  303. effect.setTextureFromPostProcess("otherSampler", this.textureAdderFinalPostProcess);
  304. effect.setTexture("lensDirtSampler", this.lensFlareDirtTexture);
  305. effect.setTexture("lensStarSampler", this.lensStarTexture);
  306. // Lens start rotation matrix
  307. var camerax = this._scene.activeCamera.getViewMatrix().getRow(0);
  308. var cameraz = this._scene.activeCamera.getViewMatrix().getRow(2);
  309. 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));
  310. camRot *= 4.0;
  311. var starRotation = Matrix.FromValues(
  312. Math.cos(camRot) * 0.5, -Math.sin(camRot), 0.0, 0.0,
  313. Math.sin(camRot), Math.cos(camRot) * 0.5, 0.0, 0.0,
  314. 0.0, 0.0, 1.0, 0.0,
  315. 0.0, 0.0, 0.0, 1.0
  316. );
  317. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  318. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  319. };
  320. }
  321. // Create depth-of-field post-process
  322. private _createDepthOfFieldPostProcess(scene: Scene, ratio: number): void {
  323. 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);
  324. this.depthOfFieldPostProcess.onApply = (effect: Effect) => {
  325. effect.setTextureFromPostProcess("otherSampler", this._currentDepthOfFieldSource);
  326. effect.setTexture("depthSampler", this._depthRenderer.getDepthMap());
  327. effect.setFloat("distance", this.depthOfFieldDistance);
  328. };
  329. // Add to pipeline
  330. this.addEffect(new PostProcessRenderEffect(scene.getEngine(), "HDRDepthOfField", () => { return this.depthOfFieldPostProcess; }, true));
  331. }
  332. // Dispose
  333. public dispose(): void {
  334. for (var i = 0; i < this._cameras.length; i++) {
  335. var camera = this._cameras[i];
  336. this.originalPostProcess.dispose(camera);
  337. this.downSampleX4PostProcess.dispose(camera);
  338. this.brightPassPostProcess.dispose(camera);
  339. this.textureAdderPostProcess.dispose(camera);
  340. for (var j = 0; j < this.gaussianBlurHPostProcesses.length; j++) {
  341. this.gaussianBlurHPostProcesses[j].dispose(camera);
  342. }
  343. for (var j = 0; j < this.gaussianBlurVPostProcesses.length; j++) {
  344. this.gaussianBlurVPostProcesses[j].dispose(camera);
  345. }
  346. this.textureAdderFinalPostProcess.dispose(camera);
  347. this.lensFlarePostProcess.dispose(camera);
  348. this.lensFlareComposePostProcess.dispose(camera);
  349. this.depthOfFieldPostProcess.dispose(camera);
  350. }
  351. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  352. super.dispose();
  353. }
  354. // Serialize rendering pipeline
  355. public serialize(): any {
  356. var serializationObject = SerializationHelper.Serialize(this);
  357. serializationObject.customType = "StandardRenderingPipeline";
  358. return serializationObject;
  359. }
  360. // Parse serialized pipeline
  361. public static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline {
  362. return SerializationHelper.Parse(() => new StandardRenderingPipeline(source._name, scene, source._ratio), source, scene, rootUrl);
  363. }
  364. }
  365. }