index.js 114 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = Object.setPrototypeOf ||
  3. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5. return function (d, b) {
  6. extendStatics(d, b);
  7. function __() { this.constructor = d; }
  8. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9. };
  10. })();
  11. if(typeof require !== 'undefined'){
  12. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : this);
  13. var BABYLON = globalObject["BABYLON"] || {};
  14. var BABYLON0 = require('babylonjs/core');
  15. if(BABYLON !== BABYLON0) __extends(BABYLON, BABYLON0);
  16. var BABYLON;
  17. (function (BABYLON) {
  18. var CubeTexture = /** @class */ (function (_super) {
  19. __extends(CubeTexture, _super);
  20. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension) {
  21. if (extensions === void 0) { extensions = null; }
  22. if (noMipmap === void 0) { noMipmap = false; }
  23. if (files === void 0) { files = null; }
  24. if (onLoad === void 0) { onLoad = null; }
  25. if (onError === void 0) { onError = null; }
  26. if (format === void 0) { format = BABYLON.Engine.TEXTUREFORMAT_RGBA; }
  27. if (prefiltered === void 0) { prefiltered = false; }
  28. if (forcedExtension === void 0) { forcedExtension = null; }
  29. var _this = _super.call(this, scene) || this;
  30. _this.coordinatesMode = BABYLON.Texture.CUBIC_MODE;
  31. _this.name = rootUrl;
  32. _this.url = rootUrl;
  33. _this._noMipmap = noMipmap;
  34. _this.hasAlpha = false;
  35. _this._format = format;
  36. _this._prefiltered = prefiltered;
  37. _this.isCube = true;
  38. _this._textureMatrix = BABYLON.Matrix.Identity();
  39. if (prefiltered) {
  40. _this.gammaSpace = false;
  41. }
  42. if (!rootUrl && !files) {
  43. return _this;
  44. }
  45. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  46. var lastDot = rootUrl.lastIndexOf(".");
  47. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  48. var isDDS = (extension === ".dds");
  49. if (!files) {
  50. if (!isDDS && !extensions) {
  51. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  52. }
  53. files = [];
  54. if (extensions) {
  55. for (var index = 0; index < extensions.length; index++) {
  56. files.push(rootUrl + extensions[index]);
  57. }
  58. }
  59. }
  60. _this._files = files;
  61. if (!_this._texture) {
  62. if (!scene.useDelayedTextureLoading) {
  63. if (prefiltered) {
  64. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, _this.lodGenerationScale, _this.lodGenerationOffset, onLoad, onError, format, forcedExtension);
  65. }
  66. else {
  67. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension);
  68. }
  69. }
  70. else {
  71. _this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
  72. }
  73. }
  74. else if (onLoad) {
  75. if (_this._texture.isReady) {
  76. BABYLON.Tools.SetImmediate(function () { return onLoad(); });
  77. }
  78. else {
  79. _this._texture.onLoadedObservable.add(onLoad);
  80. }
  81. }
  82. return _this;
  83. }
  84. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  85. return new CubeTexture("", scene, null, noMipmap, files);
  86. };
  87. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension) {
  88. if (forcedExtension === void 0) { forcedExtension = null; }
  89. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension);
  90. };
  91. // Methods
  92. CubeTexture.prototype.delayLoad = function () {
  93. if (this.delayLoadState !== BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
  94. return;
  95. }
  96. var scene = this.getScene();
  97. if (!scene) {
  98. return;
  99. }
  100. this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADED;
  101. this._texture = this._getFromCache(this.url, this._noMipmap);
  102. if (!this._texture) {
  103. if (this._prefiltered) {
  104. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, undefined, undefined, this._format);
  105. }
  106. else {
  107. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, undefined, undefined, this._format);
  108. }
  109. }
  110. };
  111. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  112. return this._textureMatrix;
  113. };
  114. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  115. this._textureMatrix = value;
  116. };
  117. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  118. var texture = BABYLON.SerializationHelper.Parse(function () {
  119. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions);
  120. }, parsedTexture, scene);
  121. // Animations
  122. if (parsedTexture.animations) {
  123. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  124. var parsedAnimation = parsedTexture.animations[animationIndex];
  125. texture.animations.push(BABYLON.Animation.Parse(parsedAnimation));
  126. }
  127. }
  128. return texture;
  129. };
  130. CubeTexture.prototype.clone = function () {
  131. var _this = this;
  132. return BABYLON.SerializationHelper.Clone(function () {
  133. var scene = _this.getScene();
  134. if (!scene) {
  135. return _this;
  136. }
  137. return new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  138. }, this);
  139. };
  140. return CubeTexture;
  141. }(BABYLON.BaseTexture));
  142. BABYLON.CubeTexture = CubeTexture;
  143. })(BABYLON || (BABYLON = {}));
  144. //# sourceMappingURL=babylon.cubeTexture.js.map
  145. var BABYLON;
  146. (function (BABYLON) {
  147. var RenderTargetTexture = /** @class */ (function (_super) {
  148. __extends(RenderTargetTexture, _super);
  149. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti) {
  150. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  151. if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
  152. if (isCube === void 0) { isCube = false; }
  153. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  154. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  155. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  156. if (isMulti === void 0) { isMulti = false; }
  157. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  158. _this.isCube = isCube;
  159. /**
  160. * Use this list to define the list of mesh you want to render.
  161. */
  162. _this.renderList = new Array();
  163. _this.renderParticles = true;
  164. _this.renderSprites = false;
  165. _this.coordinatesMode = BABYLON.Texture.PROJECTION_MODE;
  166. _this.ignoreCameraViewport = false;
  167. // Events
  168. /**
  169. * An event triggered when the texture is unbind.
  170. * @type {BABYLON.Observable}
  171. */
  172. _this.onBeforeBindObservable = new BABYLON.Observable();
  173. /**
  174. * An event triggered when the texture is unbind.
  175. * @type {BABYLON.Observable}
  176. */
  177. _this.onAfterUnbindObservable = new BABYLON.Observable();
  178. /**
  179. * An event triggered before rendering the texture
  180. * @type {BABYLON.Observable}
  181. */
  182. _this.onBeforeRenderObservable = new BABYLON.Observable();
  183. /**
  184. * An event triggered after rendering the texture
  185. * @type {BABYLON.Observable}
  186. */
  187. _this.onAfterRenderObservable = new BABYLON.Observable();
  188. /**
  189. * An event triggered after the texture clear
  190. * @type {BABYLON.Observable}
  191. */
  192. _this.onClearObservable = new BABYLON.Observable();
  193. _this._currentRefreshId = -1;
  194. _this._refreshRate = 1;
  195. _this._samples = 1;
  196. scene = _this.getScene();
  197. if (!scene) {
  198. return _this;
  199. }
  200. _this._engine = scene.getEngine();
  201. _this.name = name;
  202. _this.isRenderTarget = true;
  203. _this._initialSizeParameter = size;
  204. _this._processSizeParameter(size);
  205. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  206. });
  207. _this._generateMipMaps = generateMipMaps ? true : false;
  208. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  209. // Rendering groups
  210. _this._renderingManager = new BABYLON.RenderingManager(scene);
  211. if (isMulti) {
  212. return _this;
  213. }
  214. _this._renderTargetOptions = {
  215. generateMipMaps: generateMipMaps,
  216. type: type,
  217. samplingMode: samplingMode,
  218. generateDepthBuffer: generateDepthBuffer,
  219. generateStencilBuffer: generateStencilBuffer
  220. };
  221. if (samplingMode === BABYLON.Texture.NEAREST_SAMPLINGMODE) {
  222. _this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
  223. _this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
  224. }
  225. if (isCube) {
  226. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  227. _this.coordinatesMode = BABYLON.Texture.INVCUBIC_MODE;
  228. _this._textureMatrix = BABYLON.Matrix.Identity();
  229. }
  230. else {
  231. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  232. }
  233. return _this;
  234. }
  235. Object.defineProperty(RenderTargetTexture, "REFRESHRATE_RENDER_ONCE", {
  236. get: function () {
  237. return RenderTargetTexture._REFRESHRATE_RENDER_ONCE;
  238. },
  239. enumerable: true,
  240. configurable: true
  241. });
  242. Object.defineProperty(RenderTargetTexture, "REFRESHRATE_RENDER_ONEVERYFRAME", {
  243. get: function () {
  244. return RenderTargetTexture._REFRESHRATE_RENDER_ONEVERYFRAME;
  245. },
  246. enumerable: true,
  247. configurable: true
  248. });
  249. Object.defineProperty(RenderTargetTexture, "REFRESHRATE_RENDER_ONEVERYTWOFRAMES", {
  250. get: function () {
  251. return RenderTargetTexture._REFRESHRATE_RENDER_ONEVERYTWOFRAMES;
  252. },
  253. enumerable: true,
  254. configurable: true
  255. });
  256. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  257. set: function (callback) {
  258. if (this._onAfterUnbindObserver) {
  259. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  260. }
  261. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  262. },
  263. enumerable: true,
  264. configurable: true
  265. });
  266. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  267. set: function (callback) {
  268. if (this._onBeforeRenderObserver) {
  269. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  270. }
  271. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  272. },
  273. enumerable: true,
  274. configurable: true
  275. });
  276. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  277. set: function (callback) {
  278. if (this._onAfterRenderObserver) {
  279. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  280. }
  281. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  282. },
  283. enumerable: true,
  284. configurable: true
  285. });
  286. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  287. set: function (callback) {
  288. if (this._onClearObserver) {
  289. this.onClearObservable.remove(this._onClearObserver);
  290. }
  291. this._onClearObserver = this.onClearObservable.add(callback);
  292. },
  293. enumerable: true,
  294. configurable: true
  295. });
  296. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  297. get: function () {
  298. return this._renderTargetOptions;
  299. },
  300. enumerable: true,
  301. configurable: true
  302. });
  303. RenderTargetTexture.prototype._onRatioRescale = function () {
  304. if (this._sizeRatio) {
  305. this.resize(this._initialSizeParameter);
  306. }
  307. };
  308. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  309. if (size.ratio) {
  310. this._sizeRatio = size.ratio;
  311. this._size = {
  312. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  313. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  314. };
  315. }
  316. else {
  317. this._size = size;
  318. }
  319. };
  320. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  321. get: function () {
  322. return this._samples;
  323. },
  324. set: function (value) {
  325. if (this._samples === value) {
  326. return;
  327. }
  328. var scene = this.getScene();
  329. if (!scene) {
  330. return;
  331. }
  332. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  333. },
  334. enumerable: true,
  335. configurable: true
  336. });
  337. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  338. this._currentRefreshId = -1;
  339. };
  340. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  341. get: function () {
  342. return this._refreshRate;
  343. },
  344. // Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  345. set: function (value) {
  346. this._refreshRate = value;
  347. this.resetRefreshCounter();
  348. },
  349. enumerable: true,
  350. configurable: true
  351. });
  352. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  353. if (!this._postProcessManager) {
  354. var scene = this.getScene();
  355. if (!scene) {
  356. return;
  357. }
  358. this._postProcessManager = new BABYLON.PostProcessManager(scene);
  359. this._postProcesses = new Array();
  360. }
  361. this._postProcesses.push(postProcess);
  362. this._postProcesses[0].autoClear = false;
  363. };
  364. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  365. if (!this._postProcesses) {
  366. return;
  367. }
  368. if (dispose) {
  369. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  370. var postProcess = _a[_i];
  371. postProcess.dispose();
  372. }
  373. }
  374. this._postProcesses = [];
  375. };
  376. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  377. if (!this._postProcesses) {
  378. return;
  379. }
  380. var index = this._postProcesses.indexOf(postProcess);
  381. if (index === -1) {
  382. return;
  383. }
  384. this._postProcesses.splice(index, 1);
  385. if (this._postProcesses.length > 0) {
  386. this._postProcesses[0].autoClear = false;
  387. }
  388. };
  389. RenderTargetTexture.prototype._shouldRender = function () {
  390. if (this._currentRefreshId === -1) {
  391. this._currentRefreshId = 1;
  392. return true;
  393. }
  394. if (this.refreshRate === this._currentRefreshId) {
  395. this._currentRefreshId = 1;
  396. return true;
  397. }
  398. this._currentRefreshId++;
  399. return false;
  400. };
  401. RenderTargetTexture.prototype.getRenderSize = function () {
  402. if (this._size.width) {
  403. return this._size.width;
  404. }
  405. return this._size;
  406. };
  407. RenderTargetTexture.prototype.getRenderWidth = function () {
  408. if (this._size.width) {
  409. return this._size.width;
  410. }
  411. return this._size;
  412. };
  413. RenderTargetTexture.prototype.getRenderHeight = function () {
  414. if (this._size.width) {
  415. return this._size.height;
  416. }
  417. return this._size;
  418. };
  419. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  420. get: function () {
  421. return true;
  422. },
  423. enumerable: true,
  424. configurable: true
  425. });
  426. RenderTargetTexture.prototype.scale = function (ratio) {
  427. var newSize = this.getRenderSize() * ratio;
  428. this.resize(newSize);
  429. };
  430. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  431. if (this.isCube) {
  432. return this._textureMatrix;
  433. }
  434. return _super.prototype.getReflectionTextureMatrix.call(this);
  435. };
  436. RenderTargetTexture.prototype.resize = function (size) {
  437. this.releaseInternalTexture();
  438. var scene = this.getScene();
  439. if (!scene) {
  440. return;
  441. }
  442. this._processSizeParameter(size);
  443. if (this.isCube) {
  444. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  445. }
  446. else {
  447. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  448. }
  449. };
  450. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  451. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  452. if (dumpForDebug === void 0) { dumpForDebug = false; }
  453. var scene = this.getScene();
  454. if (!scene) {
  455. return;
  456. }
  457. var engine = scene.getEngine();
  458. if (this.useCameraPostProcesses !== undefined) {
  459. useCameraPostProcess = this.useCameraPostProcesses;
  460. }
  461. if (this._waitingRenderList) {
  462. this.renderList = [];
  463. for (var index = 0; index < this._waitingRenderList.length; index++) {
  464. var id = this._waitingRenderList[index];
  465. var mesh_1 = scene.getMeshByID(id);
  466. if (mesh_1) {
  467. this.renderList.push(mesh_1);
  468. }
  469. }
  470. delete this._waitingRenderList;
  471. }
  472. // Is predicate defined?
  473. if (this.renderListPredicate) {
  474. if (this.renderList) {
  475. this.renderList.splice(0); // Clear previous renderList
  476. }
  477. else {
  478. this.renderList = [];
  479. }
  480. var scene = this.getScene();
  481. if (!scene) {
  482. return;
  483. }
  484. var sceneMeshes = scene.meshes;
  485. for (var index = 0; index < sceneMeshes.length; index++) {
  486. var mesh = sceneMeshes[index];
  487. if (this.renderListPredicate(mesh)) {
  488. this.renderList.push(mesh);
  489. }
  490. }
  491. }
  492. this.onBeforeBindObservable.notifyObservers(this);
  493. // Set custom projection.
  494. // Needs to be before binding to prevent changing the aspect ratio.
  495. var camera;
  496. if (this.activeCamera) {
  497. camera = this.activeCamera;
  498. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  499. if (this.activeCamera !== scene.activeCamera) {
  500. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  501. }
  502. }
  503. else {
  504. camera = scene.activeCamera;
  505. if (camera) {
  506. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  507. }
  508. }
  509. // Prepare renderingManager
  510. this._renderingManager.reset();
  511. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  512. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  513. var sceneRenderId = scene.getRenderId();
  514. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  515. var mesh = currentRenderList[meshIndex];
  516. if (mesh) {
  517. if (!mesh.isReady()) {
  518. // Reset _currentRefreshId
  519. this.resetRefreshCounter();
  520. continue;
  521. }
  522. mesh._preActivateForIntermediateRendering(sceneRenderId);
  523. var isMasked = void 0;
  524. if (!this.renderList && camera) {
  525. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  526. }
  527. else {
  528. isMasked = false;
  529. }
  530. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  531. mesh._activate(sceneRenderId);
  532. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  533. var subMesh = mesh.subMeshes[subIndex];
  534. scene._activeIndices.addCount(subMesh.indexCount, false);
  535. this._renderingManager.dispatch(subMesh, mesh);
  536. }
  537. }
  538. }
  539. }
  540. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  541. var particleSystem = scene.particleSystems[particleIndex];
  542. var emitter = particleSystem.emitter;
  543. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  544. continue;
  545. }
  546. if (currentRenderList.indexOf(emitter) >= 0) {
  547. this._renderingManager.dispatchParticles(particleSystem);
  548. }
  549. }
  550. if (this.isCube) {
  551. for (var face = 0; face < 6; face++) {
  552. this.renderToTarget(face, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  553. scene.incrementRenderId();
  554. scene.resetCachedMaterial();
  555. }
  556. }
  557. else {
  558. this.renderToTarget(0, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  559. }
  560. this.onAfterUnbindObservable.notifyObservers(this);
  561. if (scene.activeCamera) {
  562. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  563. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  564. }
  565. engine.setViewport(scene.activeCamera.viewport);
  566. }
  567. scene.resetCachedMaterial();
  568. };
  569. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  570. var minimum = 128;
  571. var x = renderDimension * scale;
  572. var curved = BABYLON.Tools.NearestPOT(x + (minimum * minimum / (minimum + x)));
  573. // Ensure we don't exceed the render dimension (while staying POT)
  574. return Math.min(BABYLON.Tools.FloorPOT(renderDimension), curved);
  575. };
  576. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  577. var _this = this;
  578. if (!this._texture) {
  579. return;
  580. }
  581. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  582. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  583. });
  584. };
  585. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug) {
  586. var scene = this.getScene();
  587. if (!scene) {
  588. return;
  589. }
  590. var engine = scene.getEngine();
  591. if (!this._texture) {
  592. return;
  593. }
  594. // Bind
  595. if (this._postProcessManager) {
  596. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  597. }
  598. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  599. if (this._texture) {
  600. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport);
  601. }
  602. }
  603. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  604. // Clear
  605. if (this.onClearObservable.hasObservers()) {
  606. this.onClearObservable.notifyObservers(engine);
  607. }
  608. else {
  609. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  610. }
  611. if (!this._doNotChangeAspectRatio) {
  612. scene.updateTransformMatrix(true);
  613. }
  614. // Render
  615. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  616. if (this._postProcessManager) {
  617. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  618. }
  619. else if (useCameraPostProcess) {
  620. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  621. }
  622. if (!this._doNotChangeAspectRatio) {
  623. scene.updateTransformMatrix(true);
  624. }
  625. // Dump ?
  626. if (dumpForDebug) {
  627. BABYLON.Tools.DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  628. }
  629. // Unbind
  630. if (!this.isCube || faceIndex === 5) {
  631. if (this.isCube) {
  632. if (faceIndex === 5) {
  633. engine.generateMipMapsForCubemap(this._texture);
  634. }
  635. }
  636. this.unbindFrameBuffer(engine, faceIndex);
  637. }
  638. else {
  639. this.onAfterRenderObservable.notifyObservers(faceIndex);
  640. }
  641. };
  642. /**
  643. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  644. * This allowed control for front to back rendering or reversly depending of the special needs.
  645. *
  646. * @param renderingGroupId The rendering group id corresponding to its index
  647. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  648. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  649. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  650. */
  651. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  652. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  653. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  654. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  655. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  656. };
  657. /**
  658. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  659. *
  660. * @param renderingGroupId The rendering group id corresponding to its index
  661. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  662. */
  663. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  664. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  665. };
  666. RenderTargetTexture.prototype.clone = function () {
  667. var textureSize = this.getSize();
  668. var newTexture = new RenderTargetTexture(this.name, textureSize.width, this.getScene(), this._renderTargetOptions.generateMipMaps, this._doNotChangeAspectRatio, this._renderTargetOptions.type, this.isCube, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer, this._renderTargetOptions.generateStencilBuffer);
  669. // Base texture
  670. newTexture.hasAlpha = this.hasAlpha;
  671. newTexture.level = this.level;
  672. // RenderTarget Texture
  673. newTexture.coordinatesMode = this.coordinatesMode;
  674. if (this.renderList) {
  675. newTexture.renderList = this.renderList.slice(0);
  676. }
  677. return newTexture;
  678. };
  679. RenderTargetTexture.prototype.serialize = function () {
  680. if (!this.name) {
  681. return null;
  682. }
  683. var serializationObject = _super.prototype.serialize.call(this);
  684. serializationObject.renderTargetSize = this.getRenderSize();
  685. serializationObject.renderList = [];
  686. if (this.renderList) {
  687. for (var index = 0; index < this.renderList.length; index++) {
  688. serializationObject.renderList.push(this.renderList[index].id);
  689. }
  690. }
  691. return serializationObject;
  692. };
  693. // This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  694. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  695. var objBuffer = this.getInternalTexture();
  696. var scene = this.getScene();
  697. if (objBuffer && scene) {
  698. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  699. }
  700. };
  701. RenderTargetTexture.prototype.dispose = function () {
  702. if (this._postProcessManager) {
  703. this._postProcessManager.dispose();
  704. this._postProcessManager = null;
  705. }
  706. this.clearPostProcesses(true);
  707. if (this._resizeObserver) {
  708. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  709. this._resizeObserver = null;
  710. }
  711. this.renderList = null;
  712. // Remove from custom render targets
  713. var scene = this.getScene();
  714. if (!scene) {
  715. return;
  716. }
  717. var index = scene.customRenderTargets.indexOf(this);
  718. if (index >= 0) {
  719. scene.customRenderTargets.splice(index, 1);
  720. }
  721. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  722. var camera = _a[_i];
  723. index = camera.customRenderTargets.indexOf(this);
  724. if (index >= 0) {
  725. camera.customRenderTargets.splice(index, 1);
  726. }
  727. }
  728. _super.prototype.dispose.call(this);
  729. };
  730. RenderTargetTexture.prototype._rebuild = function () {
  731. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  732. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  733. }
  734. if (this._postProcessManager) {
  735. this._postProcessManager._rebuild();
  736. }
  737. };
  738. RenderTargetTexture._REFRESHRATE_RENDER_ONCE = 0;
  739. RenderTargetTexture._REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  740. RenderTargetTexture._REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  741. return RenderTargetTexture;
  742. }(BABYLON.Texture));
  743. BABYLON.RenderTargetTexture = RenderTargetTexture;
  744. })(BABYLON || (BABYLON = {}));
  745. //# sourceMappingURL=babylon.renderTargetTexture.js.map
  746. BABYLON.Effect.ShadersStore['defaultVertexShader'] = "#include<__decl__defaultVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL \nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n}";
  747. BABYLON.Effect.ShadersStore['defaultPixelShader'] = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb*vRefractionInfos.x;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb*vRefractionInfos.x;\n#endif\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb*vReflectionInfos.x;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x;\n#endif\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\ngl_FragColor=color;\n}";
  748. var BABYLON;
  749. (function (BABYLON) {
  750. ;
  751. var MultiRenderTarget = /** @class */ (function (_super) {
  752. __extends(MultiRenderTarget, _super);
  753. function MultiRenderTarget(name, size, count, scene, options) {
  754. var _this = this;
  755. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  756. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  757. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  758. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  759. _this._engine = scene.getEngine();
  760. if (!_this.isSupported) {
  761. _this.dispose();
  762. return;
  763. }
  764. var types = [];
  765. var samplingModes = [];
  766. for (var i = 0; i < count; i++) {
  767. if (options && options.types && options.types[i] !== undefined) {
  768. types.push(options.types[i]);
  769. }
  770. else {
  771. types.push(options && options.defaultType ? options.defaultType : BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT);
  772. }
  773. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  774. samplingModes.push(options.samplingModes[i]);
  775. }
  776. else {
  777. samplingModes.push(BABYLON.Texture.BILINEAR_SAMPLINGMODE);
  778. }
  779. }
  780. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  781. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  782. _this._size = size;
  783. _this._multiRenderTargetOptions = {
  784. samplingModes: samplingModes,
  785. generateMipMaps: generateMipMaps,
  786. generateDepthBuffer: generateDepthBuffer,
  787. generateStencilBuffer: generateStencilBuffer,
  788. generateDepthTexture: generateDepthTexture,
  789. types: types,
  790. textureCount: count
  791. };
  792. _this._createInternalTextures();
  793. _this._createTextures();
  794. return _this;
  795. }
  796. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  797. get: function () {
  798. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  799. },
  800. enumerable: true,
  801. configurable: true
  802. });
  803. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  804. get: function () {
  805. return this._textures;
  806. },
  807. enumerable: true,
  808. configurable: true
  809. });
  810. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  811. get: function () {
  812. return this._textures[this._textures.length - 1];
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  818. set: function (wrap) {
  819. if (this._textures) {
  820. for (var i = 0; i < this._textures.length; i++) {
  821. this._textures[i].wrapU = wrap;
  822. }
  823. }
  824. },
  825. enumerable: true,
  826. configurable: true
  827. });
  828. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  829. set: function (wrap) {
  830. if (this._textures) {
  831. for (var i = 0; i < this._textures.length; i++) {
  832. this._textures[i].wrapV = wrap;
  833. }
  834. }
  835. },
  836. enumerable: true,
  837. configurable: true
  838. });
  839. MultiRenderTarget.prototype._rebuild = function () {
  840. this.releaseInternalTextures();
  841. this._createInternalTextures();
  842. for (var i = 0; i < this._internalTextures.length; i++) {
  843. var texture = this._textures[i];
  844. texture._texture = this._internalTextures[i];
  845. }
  846. // Keeps references to frame buffer and stencil/depth buffer
  847. this._texture = this._internalTextures[0];
  848. };
  849. MultiRenderTarget.prototype._createInternalTextures = function () {
  850. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  851. };
  852. MultiRenderTarget.prototype._createTextures = function () {
  853. this._textures = [];
  854. for (var i = 0; i < this._internalTextures.length; i++) {
  855. var texture = new BABYLON.Texture(null, this.getScene());
  856. texture._texture = this._internalTextures[i];
  857. this._textures.push(texture);
  858. }
  859. // Keeps references to frame buffer and stencil/depth buffer
  860. this._texture = this._internalTextures[0];
  861. };
  862. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  863. get: function () {
  864. return this._samples;
  865. },
  866. set: function (value) {
  867. if (this._samples === value) {
  868. return;
  869. }
  870. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  871. },
  872. enumerable: true,
  873. configurable: true
  874. });
  875. MultiRenderTarget.prototype.resize = function (size) {
  876. this.releaseInternalTextures();
  877. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  878. this._createInternalTextures();
  879. };
  880. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  881. var _this = this;
  882. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  883. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  884. });
  885. };
  886. MultiRenderTarget.prototype.dispose = function () {
  887. this.releaseInternalTextures();
  888. _super.prototype.dispose.call(this);
  889. };
  890. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  891. if (!this._internalTextures) {
  892. return;
  893. }
  894. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  895. if (this._internalTextures[i] !== undefined) {
  896. this._internalTextures[i].dispose();
  897. this._internalTextures.splice(i, 1);
  898. }
  899. }
  900. };
  901. return MultiRenderTarget;
  902. }(BABYLON.RenderTargetTexture));
  903. BABYLON.MultiRenderTarget = MultiRenderTarget;
  904. })(BABYLON || (BABYLON = {}));
  905. //# sourceMappingURL=babylon.multiRenderTarget.js.map
  906. var BABYLON;
  907. (function (BABYLON) {
  908. var MirrorTexture = /** @class */ (function (_super) {
  909. __extends(MirrorTexture, _super);
  910. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  911. if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
  912. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.BILINEAR_SAMPLINGMODE; }
  913. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  914. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  915. _this.mirrorPlane = new BABYLON.Plane(0, 1, 0, 1);
  916. _this._transformMatrix = BABYLON.Matrix.Zero();
  917. _this._mirrorMatrix = BABYLON.Matrix.Zero();
  918. _this._adaptiveBlurKernel = 0;
  919. _this._blurKernelX = 0;
  920. _this._blurKernelY = 0;
  921. _this._blurRatio = 1.0;
  922. _this.ignoreCameraViewport = true;
  923. _this.onBeforeRenderObservable.add(function () {
  924. BABYLON.Matrix.ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  925. _this._savedViewMatrix = scene.getViewMatrix();
  926. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  927. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  928. scene.clipPlane = _this.mirrorPlane;
  929. scene.getEngine().cullBackFaces = false;
  930. scene._mirroredCameraPosition = BABYLON.Vector3.TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  931. });
  932. _this.onAfterRenderObservable.add(function () {
  933. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  934. scene.getEngine().cullBackFaces = true;
  935. scene._mirroredCameraPosition = null;
  936. delete scene.clipPlane;
  937. });
  938. return _this;
  939. }
  940. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  941. get: function () {
  942. return this._blurRatio;
  943. },
  944. set: function (value) {
  945. if (this._blurRatio === value) {
  946. return;
  947. }
  948. this._blurRatio = value;
  949. this._preparePostProcesses();
  950. },
  951. enumerable: true,
  952. configurable: true
  953. });
  954. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  955. set: function (value) {
  956. this._adaptiveBlurKernel = value;
  957. this._autoComputeBlurKernel();
  958. },
  959. enumerable: true,
  960. configurable: true
  961. });
  962. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  963. set: function (value) {
  964. this.blurKernelX = value;
  965. this.blurKernelY = value;
  966. },
  967. enumerable: true,
  968. configurable: true
  969. });
  970. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  971. get: function () {
  972. return this._blurKernelX;
  973. },
  974. set: function (value) {
  975. if (this._blurKernelX === value) {
  976. return;
  977. }
  978. this._blurKernelX = value;
  979. this._preparePostProcesses();
  980. },
  981. enumerable: true,
  982. configurable: true
  983. });
  984. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  985. get: function () {
  986. return this._blurKernelY;
  987. },
  988. set: function (value) {
  989. if (this._blurKernelY === value) {
  990. return;
  991. }
  992. this._blurKernelY = value;
  993. this._preparePostProcesses();
  994. },
  995. enumerable: true,
  996. configurable: true
  997. });
  998. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  999. var engine = this.getScene().getEngine();
  1000. var dw = this.getRenderWidth() / engine.getRenderWidth();
  1001. var dh = this.getRenderHeight() / engine.getRenderHeight();
  1002. this.blurKernelX = this._adaptiveBlurKernel * dw;
  1003. this.blurKernelY = this._adaptiveBlurKernel * dh;
  1004. };
  1005. MirrorTexture.prototype._onRatioRescale = function () {
  1006. if (this._sizeRatio) {
  1007. this.resize(this._initialSizeParameter);
  1008. if (!this._adaptiveBlurKernel) {
  1009. this._preparePostProcesses();
  1010. }
  1011. }
  1012. if (this._adaptiveBlurKernel) {
  1013. this._autoComputeBlurKernel();
  1014. }
  1015. };
  1016. MirrorTexture.prototype._preparePostProcesses = function () {
  1017. this.clearPostProcesses(true);
  1018. if (this._blurKernelX && this._blurKernelY) {
  1019. var engine = this.getScene().getEngine();
  1020. var textureType = engine.getCaps().textureFloatRender ? BABYLON.Engine.TEXTURETYPE_FLOAT : BABYLON.Engine.TEXTURETYPE_HALF_FLOAT;
  1021. this._blurX = new BABYLON.BlurPostProcess("horizontal blur", new BABYLON.Vector2(1.0, 0), this._blurKernelX, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
  1022. this._blurX.autoClear = false;
  1023. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  1024. this._blurX.outputTexture = this._texture;
  1025. }
  1026. else {
  1027. this._blurX.alwaysForcePOT = true;
  1028. }
  1029. this._blurY = new BABYLON.BlurPostProcess("vertical blur", new BABYLON.Vector2(0, 1.0), this._blurKernelY, this._blurRatio, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false, textureType);
  1030. this._blurY.autoClear = false;
  1031. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  1032. this.addPostProcess(this._blurX);
  1033. this.addPostProcess(this._blurY);
  1034. }
  1035. else {
  1036. if (this._blurY) {
  1037. this.removePostProcess(this._blurY);
  1038. this._blurY.dispose();
  1039. this._blurY = null;
  1040. }
  1041. if (this._blurX) {
  1042. this.removePostProcess(this._blurX);
  1043. this._blurX.dispose();
  1044. this._blurX = null;
  1045. }
  1046. }
  1047. };
  1048. MirrorTexture.prototype.clone = function () {
  1049. var scene = this.getScene();
  1050. if (!scene) {
  1051. return this;
  1052. }
  1053. var textureSize = this.getSize();
  1054. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  1055. // Base texture
  1056. newTexture.hasAlpha = this.hasAlpha;
  1057. newTexture.level = this.level;
  1058. // Mirror Texture
  1059. newTexture.mirrorPlane = this.mirrorPlane.clone();
  1060. if (this.renderList) {
  1061. newTexture.renderList = this.renderList.slice(0);
  1062. }
  1063. return newTexture;
  1064. };
  1065. MirrorTexture.prototype.serialize = function () {
  1066. if (!this.name) {
  1067. return null;
  1068. }
  1069. var serializationObject = _super.prototype.serialize.call(this);
  1070. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  1071. return serializationObject;
  1072. };
  1073. return MirrorTexture;
  1074. }(BABYLON.RenderTargetTexture));
  1075. BABYLON.MirrorTexture = MirrorTexture;
  1076. })(BABYLON || (BABYLON = {}));
  1077. //# sourceMappingURL=babylon.mirrorTexture.js.map
  1078. var BABYLON;
  1079. (function (BABYLON) {
  1080. /**
  1081. * Creates a refraction texture used by refraction channel of the standard material.
  1082. * @param name the texture name
  1083. * @param size size of the underlying texture
  1084. * @param scene root scene
  1085. */
  1086. var RefractionTexture = /** @class */ (function (_super) {
  1087. __extends(RefractionTexture, _super);
  1088. function RefractionTexture(name, size, scene, generateMipMaps) {
  1089. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  1090. _this.refractionPlane = new BABYLON.Plane(0, 1, 0, 1);
  1091. _this.depth = 2.0;
  1092. _this.onBeforeRenderObservable.add(function () {
  1093. scene.clipPlane = _this.refractionPlane;
  1094. });
  1095. _this.onAfterRenderObservable.add(function () {
  1096. delete scene.clipPlane;
  1097. });
  1098. return _this;
  1099. }
  1100. RefractionTexture.prototype.clone = function () {
  1101. var scene = this.getScene();
  1102. if (!scene) {
  1103. return this;
  1104. }
  1105. var textureSize = this.getSize();
  1106. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  1107. // Base texture
  1108. newTexture.hasAlpha = this.hasAlpha;
  1109. newTexture.level = this.level;
  1110. // Refraction Texture
  1111. newTexture.refractionPlane = this.refractionPlane.clone();
  1112. if (this.renderList) {
  1113. newTexture.renderList = this.renderList.slice(0);
  1114. }
  1115. newTexture.depth = this.depth;
  1116. return newTexture;
  1117. };
  1118. RefractionTexture.prototype.serialize = function () {
  1119. if (!this.name) {
  1120. return null;
  1121. }
  1122. var serializationObject = _super.prototype.serialize.call(this);
  1123. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  1124. serializationObject.depth = this.depth;
  1125. return serializationObject;
  1126. };
  1127. return RefractionTexture;
  1128. }(BABYLON.RenderTargetTexture));
  1129. BABYLON.RefractionTexture = RefractionTexture;
  1130. })(BABYLON || (BABYLON = {}));
  1131. //# sourceMappingURL=babylon.refractionTexture.js.map
  1132. var BABYLON;
  1133. (function (BABYLON) {
  1134. var DynamicTexture = /** @class */ (function (_super) {
  1135. __extends(DynamicTexture, _super);
  1136. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  1137. if (scene === void 0) { scene = null; }
  1138. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  1139. if (format === void 0) { format = BABYLON.Engine.TEXTUREFORMAT_RGBA; }
  1140. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  1141. _this.name = name;
  1142. _this._engine = _this.getScene().getEngine();
  1143. _this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
  1144. _this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
  1145. _this._generateMipMaps = generateMipMaps;
  1146. if (options.getContext) {
  1147. _this._canvas = options;
  1148. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  1149. }
  1150. else {
  1151. _this._canvas = document.createElement("canvas");
  1152. if (options.width) {
  1153. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  1154. }
  1155. else {
  1156. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  1157. }
  1158. }
  1159. var textureSize = _this.getSize();
  1160. _this._canvas.width = textureSize.width;
  1161. _this._canvas.height = textureSize.height;
  1162. _this._context = _this._canvas.getContext("2d");
  1163. return _this;
  1164. }
  1165. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  1166. get: function () {
  1167. return true;
  1168. },
  1169. enumerable: true,
  1170. configurable: true
  1171. });
  1172. DynamicTexture.prototype._recreate = function (textureSize) {
  1173. this._canvas.width = textureSize.width;
  1174. this._canvas.height = textureSize.height;
  1175. this.releaseInternalTexture();
  1176. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this._samplingMode);
  1177. };
  1178. DynamicTexture.prototype.scale = function (ratio) {
  1179. var textureSize = this.getSize();
  1180. textureSize.width *= ratio;
  1181. textureSize.height *= ratio;
  1182. this._recreate(textureSize);
  1183. };
  1184. DynamicTexture.prototype.scaleTo = function (width, height) {
  1185. var textureSize = this.getSize();
  1186. textureSize.width = width;
  1187. textureSize.height = height;
  1188. this._recreate(textureSize);
  1189. };
  1190. DynamicTexture.prototype.getContext = function () {
  1191. return this._context;
  1192. };
  1193. DynamicTexture.prototype.clear = function () {
  1194. var size = this.getSize();
  1195. this._context.fillRect(0, 0, size.width, size.height);
  1196. };
  1197. DynamicTexture.prototype.update = function (invertY) {
  1198. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, undefined, this._format || undefined);
  1199. };
  1200. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  1201. if (update === void 0) { update = true; }
  1202. var size = this.getSize();
  1203. if (clearColor) {
  1204. this._context.fillStyle = clearColor;
  1205. this._context.fillRect(0, 0, size.width, size.height);
  1206. }
  1207. this._context.font = font;
  1208. if (x === null || x === undefined) {
  1209. var textSize = this._context.measureText(text);
  1210. x = (size.width - textSize.width) / 2;
  1211. }
  1212. if (y === null || y === undefined) {
  1213. var fontSize = parseInt((font.replace(/\D/g, '')));
  1214. ;
  1215. y = (size.height / 2) + (fontSize / 3.65);
  1216. }
  1217. this._context.fillStyle = color;
  1218. this._context.fillText(text, x, y);
  1219. if (update) {
  1220. this.update(invertY);
  1221. }
  1222. };
  1223. DynamicTexture.prototype.clone = function () {
  1224. var scene = this.getScene();
  1225. if (!scene) {
  1226. return this;
  1227. }
  1228. var textureSize = this.getSize();
  1229. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  1230. // Base texture
  1231. newTexture.hasAlpha = this.hasAlpha;
  1232. newTexture.level = this.level;
  1233. // Dynamic Texture
  1234. newTexture.wrapU = this.wrapU;
  1235. newTexture.wrapV = this.wrapV;
  1236. return newTexture;
  1237. };
  1238. DynamicTexture.prototype._rebuild = function () {
  1239. this.update();
  1240. };
  1241. return DynamicTexture;
  1242. }(BABYLON.Texture));
  1243. BABYLON.DynamicTexture = DynamicTexture;
  1244. })(BABYLON || (BABYLON = {}));
  1245. //# sourceMappingURL=babylon.dynamicTexture.js.map
  1246. var BABYLON;
  1247. (function (BABYLON) {
  1248. var VideoTexture = /** @class */ (function (_super) {
  1249. __extends(VideoTexture, _super);
  1250. /**
  1251. * Creates a video texture.
  1252. * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing
  1253. * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element.
  1254. * @param {BABYLON.Scene} scene is obviously the current scene.
  1255. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  1256. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  1257. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  1258. */
  1259. function VideoTexture(name, urlsOrVideo, scene, generateMipMaps, invertY, samplingMode) {
  1260. if (generateMipMaps === void 0) { generateMipMaps = false; }
  1261. if (invertY === void 0) { invertY = false; }
  1262. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  1263. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  1264. _this._autoLaunch = true;
  1265. var urls = null;
  1266. _this.name = name;
  1267. if (urlsOrVideo instanceof HTMLVideoElement) {
  1268. _this.video = urlsOrVideo;
  1269. }
  1270. else {
  1271. urls = urlsOrVideo;
  1272. _this.video = document.createElement("video");
  1273. _this.video.autoplay = false;
  1274. _this.video.loop = true;
  1275. BABYLON.Tools.SetCorsBehavior(urls, _this.video);
  1276. }
  1277. _this._engine = _this.getScene().getEngine();
  1278. _this._generateMipMaps = generateMipMaps;
  1279. _this._samplingMode = samplingMode;
  1280. if (!_this._engine.needPOTTextures || (BABYLON.Tools.IsExponentOfTwo(_this.video.videoWidth) && BABYLON.Tools.IsExponentOfTwo(_this.video.videoHeight))) {
  1281. _this.wrapU = BABYLON.Texture.WRAP_ADDRESSMODE;
  1282. _this.wrapV = BABYLON.Texture.WRAP_ADDRESSMODE;
  1283. }
  1284. else {
  1285. _this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
  1286. _this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
  1287. _this._generateMipMaps = false;
  1288. }
  1289. if (urls) {
  1290. _this.video.addEventListener("canplay", function () {
  1291. if (_this._texture === undefined) {
  1292. _this._createTexture();
  1293. }
  1294. });
  1295. urls.forEach(function (url) {
  1296. var source = document.createElement("source");
  1297. source.src = url;
  1298. _this.video.appendChild(source);
  1299. });
  1300. }
  1301. else {
  1302. _this._createTexture();
  1303. }
  1304. _this._lastUpdate = BABYLON.Tools.Now;
  1305. return _this;
  1306. }
  1307. VideoTexture.prototype.__setTextureReady = function () {
  1308. if (this._texture) {
  1309. this._texture.isReady = true;
  1310. }
  1311. };
  1312. VideoTexture.prototype._createTexture = function () {
  1313. this._texture = this._engine.createDynamicTexture(this.video.videoWidth, this.video.videoHeight, this._generateMipMaps, this._samplingMode);
  1314. if (this._autoLaunch) {
  1315. this._autoLaunch = false;
  1316. this.video.play();
  1317. }
  1318. this._setTextureReady = this.__setTextureReady.bind(this);
  1319. this.video.addEventListener("playing", this._setTextureReady);
  1320. };
  1321. VideoTexture.prototype._rebuild = function () {
  1322. this.update();
  1323. };
  1324. VideoTexture.prototype.update = function () {
  1325. var now = BABYLON.Tools.Now;
  1326. if (now - this._lastUpdate < 15 || this.video.readyState !== this.video.HAVE_ENOUGH_DATA) {
  1327. return false;
  1328. }
  1329. this._lastUpdate = now;
  1330. this._engine.updateVideoTexture(this._texture, this.video, this._invertY);
  1331. return true;
  1332. };
  1333. VideoTexture.prototype.dispose = function () {
  1334. _super.prototype.dispose.call(this);
  1335. this.video.removeEventListener("playing", this._setTextureReady);
  1336. };
  1337. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
  1338. var video = document.createElement("video");
  1339. var constraintsDeviceId;
  1340. if (constraints && constraints.deviceId) {
  1341. constraintsDeviceId = {
  1342. exact: constraints.deviceId
  1343. };
  1344. }
  1345. navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
  1346. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  1347. if (navigator.getUserMedia) {
  1348. navigator.getUserMedia({
  1349. video: {
  1350. deviceId: constraintsDeviceId,
  1351. width: {
  1352. min: (constraints && constraints.minWidth) || 256,
  1353. max: (constraints && constraints.maxWidth) || 640
  1354. },
  1355. height: {
  1356. min: (constraints && constraints.minHeight) || 256,
  1357. max: (constraints && constraints.maxHeight) || 480
  1358. }
  1359. }
  1360. }, function (stream) {
  1361. if (video.mozSrcObject !== undefined) {
  1362. video.mozSrcObject = stream;
  1363. }
  1364. else {
  1365. video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
  1366. }
  1367. video.play();
  1368. if (onReady) {
  1369. onReady(new VideoTexture("video", video, scene, true, true));
  1370. }
  1371. }, function (e) {
  1372. BABYLON.Tools.Error(e.name);
  1373. });
  1374. }
  1375. };
  1376. return VideoTexture;
  1377. }(BABYLON.Texture));
  1378. BABYLON.VideoTexture = VideoTexture;
  1379. })(BABYLON || (BABYLON = {}));
  1380. //# sourceMappingURL=babylon.videoTexture.js.map
  1381. var BABYLON;
  1382. (function (BABYLON) {
  1383. var RawTexture = /** @class */ (function (_super) {
  1384. __extends(RawTexture, _super);
  1385. function RawTexture(data, width, height, format, scene, generateMipMaps, invertY, samplingMode, type) {
  1386. if (generateMipMaps === void 0) { generateMipMaps = true; }
  1387. if (invertY === void 0) { invertY = false; }
  1388. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  1389. if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
  1390. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  1391. _this.format = format;
  1392. _this._engine = scene.getEngine();
  1393. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  1394. _this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
  1395. _this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
  1396. return _this;
  1397. }
  1398. RawTexture.prototype.update = function (data) {
  1399. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  1400. };
  1401. // Statics
  1402. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  1403. if (generateMipMaps === void 0) { generateMipMaps = true; }
  1404. if (invertY === void 0) { invertY = false; }
  1405. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  1406. return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  1407. };
  1408. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  1409. if (generateMipMaps === void 0) { generateMipMaps = true; }
  1410. if (invertY === void 0) { invertY = false; }
  1411. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  1412. return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  1413. };
  1414. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  1415. if (generateMipMaps === void 0) { generateMipMaps = true; }
  1416. if (invertY === void 0) { invertY = false; }
  1417. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  1418. return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  1419. };
  1420. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  1421. if (generateMipMaps === void 0) { generateMipMaps = true; }
  1422. if (invertY === void 0) { invertY = false; }
  1423. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  1424. if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
  1425. return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  1426. };
  1427. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  1428. if (generateMipMaps === void 0) { generateMipMaps = true; }
  1429. if (invertY === void 0) { invertY = false; }
  1430. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE; }
  1431. if (type === void 0) { type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT; }
  1432. return new RawTexture(data, width, height, BABYLON.Engine.TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  1433. };
  1434. return RawTexture;
  1435. }(BABYLON.Texture));
  1436. BABYLON.RawTexture = RawTexture;
  1437. })(BABYLON || (BABYLON = {}));
  1438. //# sourceMappingURL=babylon.rawTexture.js.map
  1439. BABYLON.Effect.IncludesShadersStore['depthPrePass'] = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  1440. BABYLON.Effect.IncludesShadersStore['bonesDeclaration'] = "#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mBones[BonesPerMesh];\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#endif";
  1441. BABYLON.Effect.IncludesShadersStore['instancesDeclaration'] = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  1442. BABYLON.Effect.IncludesShadersStore['pointCloudVertexDeclaration'] = "#ifdef POINTSIZE\nuniform float pointSize;\n#endif";
  1443. BABYLON.Effect.IncludesShadersStore['bumpVertexDeclaration'] = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n";
  1444. BABYLON.Effect.IncludesShadersStore['clipPlaneVertexDeclaration'] = "#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif";
  1445. BABYLON.Effect.IncludesShadersStore['fogVertexDeclaration'] = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  1446. BABYLON.Effect.IncludesShadersStore['morphTargetsVertexGlobalDeclaration'] = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  1447. BABYLON.Effect.IncludesShadersStore['morphTargetsVertexDeclaration'] = "#ifdef MORPHTARGETS\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#endif";
  1448. BABYLON.Effect.IncludesShadersStore['logDepthDeclaration'] = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  1449. BABYLON.Effect.IncludesShadersStore['morphTargetsVertex'] = "#ifdef MORPHTARGETS\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#endif";
  1450. BABYLON.Effect.IncludesShadersStore['instancesVertex'] = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  1451. BABYLON.Effect.IncludesShadersStore['bonesVertex'] = "#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif \nfinalWorld=finalWorld*influence;\n#endif";
  1452. BABYLON.Effect.IncludesShadersStore['bumpVertex'] = "#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif";
  1453. BABYLON.Effect.IncludesShadersStore['clipPlaneVertex'] = "#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif";
  1454. BABYLON.Effect.IncludesShadersStore['fogVertex'] = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  1455. BABYLON.Effect.IncludesShadersStore['shadowsVertex'] = "#ifdef SHADOWS\n#if defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\nvDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n#endif\n#endif";
  1456. BABYLON.Effect.IncludesShadersStore['pointCloudVertex'] = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  1457. BABYLON.Effect.IncludesShadersStore['logDepthVertex'] = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  1458. BABYLON.Effect.IncludesShadersStore['helperFunctions'] = "const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nvec3 dither(vec2 seed,vec3 color) {\nfloat rand=getRand(seed);\ncolor+=mix(-0.5/255.0,0.5/255.0,rand);\ncolor=max(color,0.0);\nreturn color;\n}";
  1459. BABYLON.Effect.IncludesShadersStore['lightFragmentDeclaration'] = "#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec3 vLightSpecular{X};\n#else\nvec3 vLightSpecular{X}=vec3(0.);\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform sampler2D shadowSampler{X};\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\n#endif\n#ifdef HEMILIGHT{X}\nuniform vec3 vLightGround{X};\n#endif\n#endif";
  1460. BABYLON.Effect.IncludesShadersStore['lightsFragmentFunctions'] = "\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\n";
  1461. BABYLON.Effect.IncludesShadersStore['lightUboDeclaration'] = "#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec3 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\n#endif\n#ifdef HEMILIGHT{X}\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform sampler2D shadowSampler{X};\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif";
  1462. BABYLON.Effect.IncludesShadersStore['defaultVertexDeclaration'] = "\nuniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n";
  1463. BABYLON.Effect.IncludesShadersStore['defaultFragmentDeclaration'] = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";
  1464. BABYLON.Effect.IncludesShadersStore['defaultUboDeclaration'] = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor; \nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix; \nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize; \n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  1465. BABYLON.Effect.IncludesShadersStore['shadowsFragmentFunctions'] = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPCFCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); \nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPCF(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#endif\n";
  1466. BABYLON.Effect.IncludesShadersStore['fresnelFunction'] = "#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif";
  1467. BABYLON.Effect.IncludesShadersStore['reflectionFunction'] = "vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvec3 direction=normalize(vDirectionW);\nfloat t=clamp(direction.y*-0.5+0.5,0.,1.0);\nfloat s=atan(direction.z,direction.x)*RECIPROCAL_PI2+0.5;\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\nvec3 r=reflect(cameraToVertex,worldNormal);\nfloat t=clamp(r.y*-0.5+0.5,0.,1.0);\nfloat s=atan(r.z,r.x)*RECIPROCAL_PI2+0.5;\nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef INVERTCUBICMAP\ncoords.y=1.0-coords.y;\n#endif\nreturn vec3(reflectionMatrix*vec4(coords,0));\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}";
  1468. BABYLON.Effect.IncludesShadersStore['imageProcessingDeclaration'] = "#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif";
  1469. BABYLON.Effect.IncludesShadersStore['imageProcessingFunctions'] = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
  1470. BABYLON.Effect.IncludesShadersStore['bumpFragmentFunctions'] = "#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif";
  1471. BABYLON.Effect.IncludesShadersStore['clipPlaneFragmentDeclaration'] = "#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif";
  1472. BABYLON.Effect.IncludesShadersStore['fogFragmentDeclaration'] = "#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR == vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2 == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif";
  1473. BABYLON.Effect.IncludesShadersStore['clipPlaneFragment'] = "#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif";
  1474. BABYLON.Effect.IncludesShadersStore['bumpFragment'] = "vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else \nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif";
  1475. BABYLON.Effect.IncludesShadersStore['lightFragment'] = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#else\n#ifdef SHADOWESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#else \n#ifdef SHADOWPCF{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPCFCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPCF(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif\n#endif\n#endif";
  1476. BABYLON.Effect.IncludesShadersStore['logDepthFragment'] = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  1477. BABYLON.Effect.IncludesShadersStore['fogFragment'] = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  1478. (function() {
  1479. var EXPORTS = {};EXPORTS['CubeTexture'] = BABYLON['CubeTexture'];EXPORTS['RenderTargetTexture'] = BABYLON['RenderTargetTexture'];EXPORTS['MultiRenderTarget'] = BABYLON['MultiRenderTarget'];EXPORTS['MirrorTexture'] = BABYLON['MirrorTexture'];EXPORTS['RefractionTexture'] = BABYLON['RefractionTexture'];EXPORTS['DynamicTexture'] = BABYLON['DynamicTexture'];EXPORTS['VideoTexture'] = BABYLON['VideoTexture'];EXPORTS['RawTexture'] = BABYLON['RawTexture'];
  1480. globalObject["BABYLON"] = globalObject["BABYLON"] || BABYLON;
  1481. module.exports = EXPORTS;
  1482. })();
  1483. }