babylon.postProcess.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. module BABYLON {
  2. /**
  3. * Size options for a post process
  4. */
  5. export type PostProcessOptions = { width: number, height: number };
  6. /**
  7. * PostProcess can be used to apply a shader to a texture after it has been rendered
  8. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  9. */
  10. export class PostProcess {
  11. /**
  12. * Width of the texture to apply the post process on
  13. */
  14. public width = -1;
  15. /**
  16. * Height of the texture to apply the post process on
  17. */
  18. public height = -1;
  19. /**
  20. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  21. * @hidden
  22. */
  23. public _outputTexture: Nullable<InternalTexture> = null;
  24. /**
  25. * Sampling mode used by the shader
  26. * See https://doc.babylonjs.com/classes/3.1/texture
  27. */
  28. public renderTargetSamplingMode: number;
  29. /**
  30. * Clear color to use when screen clearing
  31. */
  32. public clearColor: Color4;
  33. /**
  34. * If the buffer needs to be cleared before applying the post process. (default: true)
  35. * Should be set to false if shader will overwrite all previous pixels.
  36. */
  37. public autoClear = true;
  38. /**
  39. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  40. */
  41. public alphaMode = Engine.ALPHA_DISABLE;
  42. /**
  43. * Sets the setAlphaBlendConstants of the babylon engine
  44. */
  45. public alphaConstants: Color4;
  46. /**
  47. * Animations to be used for the post processing
  48. */
  49. public animations = new Array<Animation>();
  50. /**
  51. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  52. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  53. */
  54. public enablePixelPerfectMode = false;
  55. /**
  56. * Force the postprocess to be applied without taking in account viewport
  57. */
  58. public forceFullscreenViewport = true;
  59. /**
  60. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  61. *
  62. * | Value | Type | Description |
  63. * | ----- | ----------------------------------- | ----------- |
  64. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  65. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  66. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  67. *
  68. */
  69. public scaleMode = Engine.SCALEMODE_FLOOR;
  70. /**
  71. * Force textures to be a power of two (default: false)
  72. */
  73. public alwaysForcePOT = false;
  74. private _samples = 1;
  75. /**
  76. * Number of sample textures (default: 1)
  77. */
  78. public get samples() {
  79. return this._samples;
  80. }
  81. public set samples(n: number) {
  82. this._samples = n;
  83. this._textures.forEach((texture) => {
  84. if (texture.samples !== this._samples) {
  85. this._engine.updateRenderTargetTextureSampleCount(texture, this._samples);
  86. }
  87. });
  88. }
  89. /**
  90. * Modify the scale of the post process to be the same as the viewport (default: false)
  91. */
  92. public adaptScaleToCurrentViewport = false;
  93. private _camera: Camera;
  94. private _scene: Scene;
  95. private _engine: Engine;
  96. private _options: number | PostProcessOptions;
  97. private _reusable = false;
  98. private _textureType: number;
  99. /**
  100. * Smart array of input and output textures for the post process.
  101. * @hidden
  102. */
  103. public _textures = new SmartArray<InternalTexture>(2);
  104. /**
  105. * The index in _textures that corresponds to the output texture.
  106. * @hidden
  107. */
  108. public _currentRenderTextureInd = 0;
  109. private _effect: Effect;
  110. private _samplers: string[];
  111. private _fragmentUrl: string;
  112. private _vertexUrl: string;
  113. private _parameters: string[];
  114. private _scaleRatio = new Vector2(1, 1);
  115. protected _indexParameters: any;
  116. private _shareOutputWithPostProcess: Nullable<PostProcess>;
  117. private _texelSize = Vector2.Zero();
  118. private _forcedOutputTexture: InternalTexture;
  119. // Events
  120. /**
  121. * An event triggered when the postprocess is activated.
  122. */
  123. public onActivateObservable = new Observable<Camera>();
  124. private _onActivateObserver: Nullable<Observer<Camera>>;
  125. /**
  126. * A function that is added to the onActivateObservable
  127. */
  128. public set onActivate(callback: Nullable<(camera: Camera) => void>) {
  129. if (this._onActivateObserver) {
  130. this.onActivateObservable.remove(this._onActivateObserver);
  131. }
  132. if (callback) {
  133. this._onActivateObserver = this.onActivateObservable.add(callback);
  134. }
  135. }
  136. /**
  137. * An event triggered when the postprocess changes its size.
  138. */
  139. public onSizeChangedObservable = new Observable<PostProcess>();
  140. private _onSizeChangedObserver: Nullable<Observer<PostProcess>>;
  141. /**
  142. * A function that is added to the onSizeChangedObservable
  143. */
  144. public set onSizeChanged(callback: (postProcess: PostProcess) => void) {
  145. if (this._onSizeChangedObserver) {
  146. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  147. }
  148. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  149. }
  150. /**
  151. * An event triggered when the postprocess applies its effect.
  152. */
  153. public onApplyObservable = new Observable<Effect>();
  154. private _onApplyObserver: Nullable<Observer<Effect>>;
  155. /**
  156. * A function that is added to the onApplyObservable
  157. */
  158. public set onApply(callback: (effect: Effect) => void) {
  159. if (this._onApplyObserver) {
  160. this.onApplyObservable.remove(this._onApplyObserver);
  161. }
  162. this._onApplyObserver = this.onApplyObservable.add(callback);
  163. }
  164. /**
  165. * An event triggered before rendering the postprocess
  166. */
  167. public onBeforeRenderObservable = new Observable<Effect>();
  168. private _onBeforeRenderObserver: Nullable<Observer<Effect>>;
  169. /**
  170. * A function that is added to the onBeforeRenderObservable
  171. */
  172. public set onBeforeRender(callback: (effect: Effect) => void) {
  173. if (this._onBeforeRenderObserver) {
  174. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  175. }
  176. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  177. }
  178. /**
  179. * An event triggered after rendering the postprocess
  180. */
  181. public onAfterRenderObservable = new Observable<Effect>();
  182. private _onAfterRenderObserver: Nullable<Observer<Effect>>;
  183. /**
  184. * A function that is added to the onAfterRenderObservable
  185. */
  186. public set onAfterRender(callback: (efect: Effect) => void) {
  187. if (this._onAfterRenderObserver) {
  188. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  189. }
  190. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  191. }
  192. /**
  193. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  194. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  195. */
  196. public get inputTexture(): InternalTexture {
  197. return this._textures.data[this._currentRenderTextureInd];
  198. }
  199. public set inputTexture(value: InternalTexture) {
  200. this._forcedOutputTexture = value;
  201. }
  202. /**
  203. * Gets the camera which post process is applied to.
  204. * @returns The camera the post process is applied to.
  205. */
  206. public getCamera(): Camera {
  207. return this._camera;
  208. }
  209. /**
  210. * Gets the texel size of the postprocess.
  211. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  212. */
  213. public get texelSize(): Vector2 {
  214. if (this._shareOutputWithPostProcess) {
  215. return this._shareOutputWithPostProcess.texelSize;
  216. }
  217. if (this._forcedOutputTexture) {
  218. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  219. }
  220. return this._texelSize;
  221. }
  222. /**
  223. * Creates a new instance PostProcess
  224. * @param name The name of the PostProcess.
  225. * @param fragmentUrl The url of the fragment shader to be used.
  226. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  227. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  228. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  229. * @param camera The camera to apply the render pass to.
  230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  231. * @param engine The engine which the post process will be applied. (default: current engine)
  232. * @param reusable If the post process can be reused on the same frame. (default: false)
  233. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  234. * @param textureType Type of textures used when performing the post process. (default: 0)
  235. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  236. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  237. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  238. */
  239. constructor(
  240. /** Name of the PostProcess. */
  241. public name: string,
  242. fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>,
  243. samplingMode: number = Texture.NEAREST_SAMPLINGMODE, engine?: Engine, reusable?: boolean, defines: Nullable<string> = null, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, vertexUrl: string = "postprocess", indexParameters?: any, blockCompilation = false) {
  244. if (camera != null) {
  245. this._camera = camera;
  246. this._scene = camera.getScene();
  247. camera.attachPostProcess(this);
  248. this._engine = this._scene.getEngine();
  249. this._scene.postProcesses.push(this);
  250. }
  251. else if (engine) {
  252. this._engine = engine;
  253. this._engine.postProcesses.push(this);
  254. }
  255. this._options = options;
  256. this.renderTargetSamplingMode = samplingMode ? samplingMode : Texture.NEAREST_SAMPLINGMODE;
  257. this._reusable = reusable || false;
  258. this._textureType = textureType;
  259. this._samplers = samplers || [];
  260. this._samplers.push("textureSampler");
  261. this._fragmentUrl = fragmentUrl;
  262. this._vertexUrl = vertexUrl;
  263. this._parameters = parameters || [];
  264. this._parameters.push("scale");
  265. this._indexParameters = indexParameters;
  266. if (!blockCompilation) {
  267. this.updateEffect(defines);
  268. }
  269. }
  270. /**
  271. * Gets the engine which this post process belongs to.
  272. * @returns The engine the post process was enabled with.
  273. */
  274. public getEngine(): Engine {
  275. return this._engine;
  276. }
  277. /**
  278. * The effect that is created when initializing the post process.
  279. * @returns The created effect corrisponding the the postprocess.
  280. */
  281. public getEffect(): Effect {
  282. return this._effect;
  283. }
  284. /**
  285. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  286. * @param postProcess The post process to share the output with.
  287. * @returns This post process.
  288. */
  289. public shareOutputWith(postProcess: PostProcess): PostProcess {
  290. this._disposeTextures();
  291. this._shareOutputWithPostProcess = postProcess;
  292. return this;
  293. }
  294. /**
  295. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  296. * This should be called if the post process that shares output with this post process is disabled/disposed.
  297. */
  298. public useOwnOutput() {
  299. if (this._textures.length == 0) {
  300. this._textures = new SmartArray<InternalTexture>(2);
  301. }
  302. this._shareOutputWithPostProcess = null;
  303. }
  304. /**
  305. * Updates the effect with the current post process compile time values and recompiles the shader.
  306. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  307. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  308. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  309. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  310. * @param onCompiled Called when the shader has been compiled.
  311. * @param onError Called if there is an error when compiling a shader.
  312. */
  313. public updateEffect(defines: Nullable<string> = null, uniforms: Nullable<string[]> = null, samplers: Nullable<string[]> = null, indexParameters?: any,
  314. onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void) {
  315. this._effect = this._engine.createEffect({ vertex: this._vertexUrl, fragment: this._fragmentUrl },
  316. ["position"],
  317. uniforms || this._parameters,
  318. samplers || this._samplers,
  319. defines !== null ? defines : "",
  320. undefined,
  321. onCompiled,
  322. onError,
  323. indexParameters || this._indexParameters
  324. );
  325. }
  326. /**
  327. * The post process is reusable if it can be used multiple times within one frame.
  328. * @returns If the post process is reusable
  329. */
  330. public isReusable(): boolean {
  331. return this._reusable;
  332. }
  333. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  334. public markTextureDirty(): void {
  335. this.width = -1;
  336. }
  337. /**
  338. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  339. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  340. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  341. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  342. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  343. * @returns The target texture that was bound to be written to.
  344. */
  345. public activate(camera: Nullable<Camera>, sourceTexture: Nullable<InternalTexture> = null, forceDepthStencil?: boolean): InternalTexture {
  346. camera = camera || this._camera;
  347. var scene = camera.getScene();
  348. var engine = scene.getEngine();
  349. var maxSize = engine.getCaps().maxTextureSize;
  350. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * <number>this._options) | 0;
  351. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * <number>this._options) | 0;
  352. // If rendering to a webvr camera's left or right eye only half the width should be used to avoid resize when rendered to screen
  353. var webVRCamera = (<WebVRFreeCamera>camera.parent);
  354. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  355. requiredWidth /= 2;
  356. }
  357. var desiredWidth = ((<PostProcessOptions>this._options).width || requiredWidth);
  358. var desiredHeight = (<PostProcessOptions>this._options).height || requiredHeight;
  359. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  360. if (this.adaptScaleToCurrentViewport) {
  361. let currentViewport = engine.currentViewport;
  362. if (currentViewport) {
  363. desiredWidth *= currentViewport.width;
  364. desiredHeight *= currentViewport.height;
  365. }
  366. }
  367. if (this.renderTargetSamplingMode === Texture.TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  368. if (!(<PostProcessOptions>this._options).width) {
  369. desiredWidth = engine.needPOTTextures ? Tools.GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  370. }
  371. if (!(<PostProcessOptions>this._options).height) {
  372. desiredHeight = engine.needPOTTextures ? Tools.GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  373. }
  374. }
  375. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  376. if (this._textures.length > 0) {
  377. for (var i = 0; i < this._textures.length; i++) {
  378. this._engine._releaseTexture(this._textures.data[i]);
  379. }
  380. this._textures.reset();
  381. }
  382. this.width = desiredWidth;
  383. this.height = desiredHeight;
  384. let textureSize = { width: this.width, height: this.height };
  385. let textureOptions = {
  386. generateMipMaps: false,
  387. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  388. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  389. samplingMode: this.renderTargetSamplingMode,
  390. type: this._textureType
  391. };
  392. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  393. if (this._reusable) {
  394. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  395. }
  396. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  397. this.onSizeChangedObservable.notifyObservers(this);
  398. }
  399. this._textures.forEach((texture) => {
  400. if (texture.samples !== this.samples) {
  401. this._engine.updateRenderTargetTextureSampleCount(texture, this.samples);
  402. }
  403. });
  404. }
  405. var target: InternalTexture;
  406. if (this._shareOutputWithPostProcess) {
  407. target = this._shareOutputWithPostProcess.inputTexture;
  408. } else if (this._forcedOutputTexture) {
  409. target = this._forcedOutputTexture;
  410. this.width = this._forcedOutputTexture.width;
  411. this.height = this._forcedOutputTexture.height;
  412. } else {
  413. target = this.inputTexture;
  414. }
  415. // Bind the input of this post process to be used as the output of the previous post process.
  416. if (this.enablePixelPerfectMode) {
  417. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  418. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  419. }
  420. else {
  421. this._scaleRatio.copyFromFloats(1, 1);
  422. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  423. }
  424. this.onActivateObservable.notifyObservers(camera);
  425. // Clear
  426. if (this.autoClear && this.alphaMode === Engine.ALPHA_DISABLE) {
  427. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  428. }
  429. if (this._reusable) {
  430. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  431. }
  432. return target;
  433. }
  434. /**
  435. * If the post process is supported.
  436. */
  437. public get isSupported(): boolean {
  438. return this._effect.isSupported;
  439. }
  440. /**
  441. * The aspect ratio of the output texture.
  442. */
  443. public get aspectRatio(): number {
  444. if (this._shareOutputWithPostProcess) {
  445. return this._shareOutputWithPostProcess.aspectRatio;
  446. }
  447. if (this._forcedOutputTexture) {
  448. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  449. }
  450. return this.width / this.height;
  451. }
  452. /**
  453. * Get a value indicating if the post-process is ready to be used
  454. * @returns true if the post-process is ready (shader is compiled)
  455. */
  456. public isReady(): boolean {
  457. return this._effect && this._effect.isReady();
  458. }
  459. /**
  460. * Binds all textures and uniforms to the shader, this will be run on every pass.
  461. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  462. */
  463. public apply(): Nullable<Effect> {
  464. // Check
  465. if (!this._effect || !this._effect.isReady()) {
  466. return null;
  467. }
  468. // States
  469. this._engine.enableEffect(this._effect);
  470. this._engine.setState(false);
  471. this._engine.setDepthBuffer(false);
  472. this._engine.setDepthWrite(false);
  473. // Alpha
  474. this._engine.setAlphaMode(this.alphaMode);
  475. if (this.alphaConstants) {
  476. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  477. }
  478. // Bind the output texture of the preivous post process as the input to this post process.
  479. var source: InternalTexture;
  480. if (this._shareOutputWithPostProcess) {
  481. source = this._shareOutputWithPostProcess.inputTexture;
  482. } else if (this._forcedOutputTexture) {
  483. source = this._forcedOutputTexture;
  484. } else {
  485. source = this.inputTexture;
  486. }
  487. this._effect._bindTexture("textureSampler", source);
  488. // Parameters
  489. this._effect.setVector2("scale", this._scaleRatio);
  490. this.onApplyObservable.notifyObservers(this._effect);
  491. return this._effect;
  492. }
  493. private _disposeTextures() {
  494. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  495. return;
  496. }
  497. if (this._textures.length > 0) {
  498. for (var i = 0; i < this._textures.length; i++) {
  499. this._engine._releaseTexture(this._textures.data[i]);
  500. }
  501. }
  502. this._textures.dispose();
  503. }
  504. /**
  505. * Disposes the post process.
  506. * @param camera The camera to dispose the post process on.
  507. */
  508. public dispose(camera?: Camera): void {
  509. camera = camera || this._camera;
  510. this._disposeTextures();
  511. if (this._scene) {
  512. let index = this._scene.postProcesses.indexOf(this);
  513. if (index !== -1) {
  514. this._scene.postProcesses.splice(index, 1);
  515. }
  516. } else {
  517. let index = this._engine.postProcesses.indexOf(this);
  518. if (index !== -1) {
  519. this._engine.postProcesses.splice(index, 1);
  520. }
  521. }
  522. if (!camera) {
  523. return;
  524. }
  525. camera.detachPostProcess(this);
  526. var index = camera._postProcesses.indexOf(this);
  527. if (index === 0 && camera._postProcesses.length > 0) {
  528. var firstPostProcess = this._camera._getFirstPostProcess();
  529. if (firstPostProcess) {
  530. firstPostProcess.markTextureDirty();
  531. }
  532. }
  533. this.onActivateObservable.clear();
  534. this.onAfterRenderObservable.clear();
  535. this.onApplyObservable.clear();
  536. this.onBeforeRenderObservable.clear();
  537. this.onSizeChangedObservable.clear();
  538. }
  539. }
  540. }