index.js 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975
  1. System.register("chunks:///_virtual/builtin-pipeline-settings.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './builtin-pipeline-types.ts'], function (exports) {
  2. var _applyDecoratedDescriptor, _inheritsLoose, _initializerDefineProperty, _assertThisInitialized, _createClass, cclegacy, _decorator, Camera, CCBoolean, CCInteger, CCFloat, Material, Texture2D, rendering, Component, fillRequiredPipelineSettings, makePipelineSettings;
  3. return {
  4. setters: [function (module) {
  5. _applyDecoratedDescriptor = module.applyDecoratedDescriptor;
  6. _inheritsLoose = module.inheritsLoose;
  7. _initializerDefineProperty = module.initializerDefineProperty;
  8. _assertThisInitialized = module.assertThisInitialized;
  9. _createClass = module.createClass;
  10. }, function (module) {
  11. cclegacy = module.cclegacy;
  12. _decorator = module._decorator;
  13. Camera = module.Camera;
  14. CCBoolean = module.CCBoolean;
  15. CCInteger = module.CCInteger;
  16. CCFloat = module.CCFloat;
  17. Material = module.Material;
  18. Texture2D = module.Texture2D;
  19. rendering = module.rendering;
  20. Component = module.Component;
  21. }, function (module) {
  22. fillRequiredPipelineSettings = module.fillRequiredPipelineSettings;
  23. makePipelineSettings = module.makePipelineSettings;
  24. }],
  25. execute: function () {
  26. var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _dec25, _dec26, _dec27, _dec28, _dec29, _dec30, _class, _class2, _descriptor, _descriptor2;
  27. cclegacy._RF.push({}, "de1c2EHcMhAIYRZY5nyTQHG", "builtin-pipeline-settings", undefined);
  28. var ccclass = _decorator.ccclass,
  29. disallowMultiple = _decorator.disallowMultiple,
  30. executeInEditMode = _decorator.executeInEditMode,
  31. menu = _decorator.menu,
  32. property = _decorator.property,
  33. requireComponent = _decorator.requireComponent,
  34. type = _decorator.type;
  35. var BuiltinPipelineSettings = exports('BuiltinPipelineSettings', (_dec = ccclass('BuiltinPipelineSettings'), _dec2 = menu('Rendering/BuiltinPipelineSettings'), _dec3 = requireComponent(Camera), _dec4 = property(CCBoolean), _dec5 = property({
  36. displayName: 'Editor Preview (Experimental)',
  37. type: CCBoolean
  38. }), _dec6 = property({
  39. group: {
  40. id: 'MSAA',
  41. name: 'Multisample Anti-Aliasing'
  42. },
  43. type: CCBoolean
  44. }), _dec7 = property({
  45. group: {
  46. id: 'MSAA',
  47. name: 'Multisample Anti-Aliasing',
  48. style: 'section'
  49. },
  50. type: CCInteger,
  51. range: [2, 4, 2]
  52. }), _dec8 = property({
  53. group: {
  54. id: 'ShadingScale',
  55. name: 'ShadingScale',
  56. style: 'section'
  57. },
  58. type: CCBoolean
  59. }), _dec9 = property({
  60. tooltip: 'i18n:postprocess.shadingScale',
  61. group: {
  62. id: 'ShadingScale',
  63. name: 'ShadingScale'
  64. },
  65. type: CCFloat,
  66. range: [0.01, 4, 0.01],
  67. slide: true
  68. }), _dec10 = property({
  69. group: {
  70. id: 'DepthOfField',
  71. name: 'DepthOfField (PostProcessing)',
  72. style: 'section'
  73. },
  74. type: CCBoolean,
  75. visible: false
  76. }), _dec11 = property({
  77. group: {
  78. id: 'DepthOfField',
  79. name: 'DepthOfField (PostProcessing)',
  80. style: 'section'
  81. },
  82. type: Material,
  83. visible: false
  84. }), _dec12 = property({
  85. group: {
  86. id: 'DepthOfField',
  87. name: 'DepthOfField (PostProcessing)',
  88. style: 'section'
  89. },
  90. type: CCFloat,
  91. min: 0,
  92. visible: false
  93. }), _dec13 = property({
  94. group: {
  95. id: 'DepthOfField',
  96. name: 'DepthOfField (PostProcessing)',
  97. style: 'section'
  98. },
  99. type: CCFloat,
  100. min: 0,
  101. visible: false
  102. }), _dec14 = type(CCFloat), _dec15 = property({
  103. group: {
  104. id: 'DepthOfField',
  105. name: 'DepthOfField (PostProcessing)',
  106. style: 'section'
  107. },
  108. type: CCFloat,
  109. range: [1, 10, 0.01],
  110. slide: true,
  111. visible: false
  112. }), _dec16 = property({
  113. group: {
  114. id: 'Bloom',
  115. name: 'Bloom (PostProcessing)',
  116. style: 'section'
  117. },
  118. type: CCBoolean
  119. }), _dec17 = property({
  120. group: {
  121. id: 'Bloom',
  122. name: 'Bloom (PostProcessing)',
  123. style: 'section'
  124. },
  125. type: Material
  126. }), _dec18 = property({
  127. tooltip: 'i18n:bloom.enableAlphaMask',
  128. group: {
  129. id: 'Bloom',
  130. name: 'Bloom (PostProcessing)',
  131. style: 'section'
  132. },
  133. type: CCBoolean
  134. }), _dec19 = property({
  135. tooltip: 'i18n:bloom.iterations',
  136. group: {
  137. id: 'Bloom',
  138. name: 'Bloom (PostProcessing)',
  139. style: 'section'
  140. },
  141. type: CCInteger,
  142. range: [1, 6, 1],
  143. slide: true
  144. }), _dec20 = property({
  145. tooltip: 'i18n:bloom.threshold',
  146. group: {
  147. id: 'Bloom',
  148. name: 'Bloom (PostProcessing)',
  149. style: 'section'
  150. },
  151. type: CCFloat,
  152. min: 0
  153. }), _dec21 = property({
  154. group: {
  155. id: 'Color Grading',
  156. name: 'ColorGrading (LDR) (PostProcessing)',
  157. style: 'section'
  158. },
  159. type: CCBoolean
  160. }), _dec22 = property({
  161. group: {
  162. id: 'Color Grading',
  163. name: 'ColorGrading (LDR) (PostProcessing)',
  164. style: 'section'
  165. },
  166. type: Material
  167. }), _dec23 = property({
  168. tooltip: 'i18n:color_grading.contribute',
  169. group: {
  170. id: 'Color Grading',
  171. name: 'ColorGrading (LDR) (PostProcessing)',
  172. style: 'section'
  173. },
  174. type: CCFloat,
  175. range: [0, 1, 0.01],
  176. slide: true
  177. }), _dec24 = property({
  178. tooltip: 'i18n:color_grading.originalMap',
  179. group: {
  180. id: 'Color Grading',
  181. name: 'ColorGrading (LDR) (PostProcessing)',
  182. style: 'section'
  183. },
  184. type: Texture2D
  185. }), _dec25 = property({
  186. group: {
  187. id: 'FXAA',
  188. name: 'Fast Approximate Anti-Aliasing (PostProcessing)',
  189. style: 'section'
  190. },
  191. type: CCBoolean
  192. }), _dec26 = property({
  193. group: {
  194. id: 'FXAA',
  195. name: 'Fast Approximate Anti-Aliasing (PostProcessing)',
  196. style: 'section'
  197. },
  198. type: Material
  199. }), _dec27 = property({
  200. group: {
  201. id: 'FSR',
  202. name: 'FidelityFX Super Resolution',
  203. style: 'section'
  204. },
  205. type: CCBoolean
  206. }), _dec28 = property({
  207. group: {
  208. id: 'FSR',
  209. name: 'FidelityFX Super Resolution',
  210. style: 'section'
  211. },
  212. type: Material
  213. }), _dec29 = property({
  214. group: {
  215. id: 'FSR',
  216. name: 'FidelityFX Super Resolution',
  217. style: 'section'
  218. },
  219. type: CCFloat,
  220. range: [0, 1, 0.01],
  221. slide: true
  222. }), _dec30 = property({
  223. group: {
  224. id: 'ToneMapping',
  225. name: 'ToneMapping',
  226. style: 'section'
  227. },
  228. type: Material
  229. }), _dec(_class = _dec2(_class = _dec3(_class = disallowMultiple(_class = executeInEditMode(_class = (_class2 = /*#__PURE__*/function (_Component) {
  230. _inheritsLoose(BuiltinPipelineSettings, _Component);
  231. function BuiltinPipelineSettings() {
  232. var _this;
  233. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  234. args[_key] = arguments[_key];
  235. }
  236. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  237. _initializerDefineProperty(_this, "_settings", _descriptor, _assertThisInitialized(_this));
  238. // Editor Preview
  239. _initializerDefineProperty(_this, "_editorPreview", _descriptor2, _assertThisInitialized(_this));
  240. return _this;
  241. }
  242. var _proto = BuiltinPipelineSettings.prototype;
  243. // Enable/Disable
  244. _proto.onEnable = function onEnable() {
  245. fillRequiredPipelineSettings(this._settings);
  246. var cameraComponent = this.getComponent(Camera);
  247. var camera = cameraComponent.camera;
  248. camera.pipelineSettings = this._settings;
  249. };
  250. _proto.onDisable = function onDisable() {
  251. var cameraComponent = this.getComponent(Camera);
  252. var camera = cameraComponent.camera;
  253. camera.pipelineSettings = null;
  254. };
  255. _proto._tryEnableEditorPreview = function _tryEnableEditorPreview() {
  256. if (rendering === undefined) {
  257. return;
  258. }
  259. if (this._editorPreview) {
  260. rendering.setEditorPipelineSettings(this._settings);
  261. } else {
  262. this._disableEditorPreview();
  263. }
  264. };
  265. _proto._disableEditorPreview = function _disableEditorPreview() {
  266. if (rendering === undefined) {
  267. return;
  268. }
  269. var current = rendering.getEditorPipelineSettings();
  270. if (current === this._settings) {
  271. rendering.setEditorPipelineSettings(null);
  272. }
  273. }
  274. // MSAA
  275. ;
  276. _createClass(BuiltinPipelineSettings, [{
  277. key: "editorPreview",
  278. get: function get() {
  279. return this._editorPreview;
  280. },
  281. set: function set(v) {
  282. this._editorPreview = v;
  283. }
  284. }, {
  285. key: "MsaaEnable",
  286. get: function get() {
  287. return this._settings.msaa.enabled;
  288. },
  289. set: function set(value) {
  290. this._settings.msaa.enabled = value;
  291. }
  292. }, {
  293. key: "msaaSampleCount",
  294. get: function get() {
  295. return this._settings.msaa.sampleCount;
  296. }
  297. // Shading Scale
  298. ,
  299. set: function set(value) {
  300. value = Math.pow(2, Math.ceil(Math.log2(Math.max(value, 2))));
  301. value = Math.min(value, 4);
  302. this._settings.msaa.sampleCount = value;
  303. }
  304. }, {
  305. key: "shadingScaleEnable",
  306. get: function get() {
  307. return this._settings.enableShadingScale;
  308. },
  309. set: function set(value) {
  310. this._settings.enableShadingScale = value;
  311. }
  312. }, {
  313. key: "shadingScale",
  314. get: function get() {
  315. return this._settings.shadingScale;
  316. }
  317. // DepthOfField
  318. ,
  319. set: function set(value) {
  320. this._settings.shadingScale = value;
  321. }
  322. }, {
  323. key: "dofEnable",
  324. get: function get() {
  325. return this._settings.depthOfField.enabled;
  326. },
  327. set: function set(value) {
  328. this._settings.depthOfField.enabled = value;
  329. }
  330. }, {
  331. key: "dofMaterial",
  332. get: function get() {
  333. return this._settings.depthOfField.material;
  334. },
  335. set: function set(value) {
  336. if (this._settings.depthOfField.material === value) {
  337. return;
  338. }
  339. this._settings.depthOfField.material = value;
  340. }
  341. }, {
  342. key: "dofFocusDistance",
  343. get: function get() {
  344. return this._settings.depthOfField.focusDistance;
  345. },
  346. set: function set(value) {
  347. this._settings.depthOfField.focusDistance = value;
  348. }
  349. }, {
  350. key: "dofFocusRange",
  351. get: function get() {
  352. return this._settings.depthOfField.focusRange;
  353. },
  354. set: function set(value) {
  355. this._settings.depthOfField.focusRange = value;
  356. }
  357. }, {
  358. key: "dofBokehRadius",
  359. get: function get() {
  360. return this._settings.depthOfField.bokehRadius;
  361. }
  362. // Bloom
  363. ,
  364. set: function set(value) {
  365. this._settings.depthOfField.bokehRadius = value;
  366. }
  367. }, {
  368. key: "bloomEnable",
  369. get: function get() {
  370. return this._settings.bloom.enabled;
  371. },
  372. set: function set(value) {
  373. this._settings.bloom.enabled = value;
  374. }
  375. }, {
  376. key: "bloomMaterial",
  377. get: function get() {
  378. return this._settings.bloom.material;
  379. },
  380. set: function set(value) {
  381. if (this._settings.bloom.material === value) {
  382. return;
  383. }
  384. this._settings.bloom.material = value;
  385. }
  386. }, {
  387. key: "bloomEnableAlphaMask",
  388. get: function get() {
  389. return this._settings.bloom.enableAlphaMask;
  390. },
  391. set: function set(value) {
  392. this._settings.bloom.enableAlphaMask = value;
  393. }
  394. }, {
  395. key: "bloomIterations",
  396. get: function get() {
  397. return this._settings.bloom.iterations;
  398. },
  399. set: function set(value) {
  400. this._settings.bloom.iterations = value;
  401. }
  402. }, {
  403. key: "bloomThreshold",
  404. get: function get() {
  405. return this._settings.bloom.threshold;
  406. },
  407. set: function set(value) {
  408. this._settings.bloom.threshold = value;
  409. }
  410. }, {
  411. key: "bloomIntensity",
  412. get: function get() {
  413. return this._settings.bloom.intensity;
  414. }
  415. // Color Grading (LDR)
  416. ,
  417. set: function set(value) {
  418. this._settings.bloom.intensity = value;
  419. }
  420. }, {
  421. key: "colorGradingEnable",
  422. get: function get() {
  423. return this._settings.colorGrading.enabled;
  424. },
  425. set: function set(value) {
  426. this._settings.colorGrading.enabled = value;
  427. }
  428. }, {
  429. key: "colorGradingMaterial",
  430. get: function get() {
  431. return this._settings.colorGrading.material;
  432. },
  433. set: function set(value) {
  434. if (this._settings.colorGrading.material === value) {
  435. return;
  436. }
  437. this._settings.colorGrading.material = value;
  438. }
  439. }, {
  440. key: "colorGradingContribute",
  441. get: function get() {
  442. return this._settings.colorGrading.contribute;
  443. },
  444. set: function set(value) {
  445. this._settings.colorGrading.contribute = value;
  446. }
  447. }, {
  448. key: "colorGradingMap",
  449. get: function get() {
  450. return this._settings.colorGrading.colorGradingMap;
  451. }
  452. // FXAA
  453. ,
  454. set: function set(val) {
  455. this._settings.colorGrading.colorGradingMap = val;
  456. }
  457. }, {
  458. key: "fxaaEnable",
  459. get: function get() {
  460. return this._settings.fxaa.enabled;
  461. },
  462. set: function set(value) {
  463. this._settings.fxaa.enabled = value;
  464. }
  465. }, {
  466. key: "fxaaMaterial",
  467. get: function get() {
  468. return this._settings.fxaa.material;
  469. }
  470. // FSR
  471. ,
  472. set: function set(value) {
  473. if (this._settings.fxaa.material === value) {
  474. return;
  475. }
  476. this._settings.fxaa.material = value;
  477. }
  478. }, {
  479. key: "fsrEnable",
  480. get: function get() {
  481. return this._settings.fsr.enabled;
  482. },
  483. set: function set(value) {
  484. this._settings.fsr.enabled = value;
  485. }
  486. }, {
  487. key: "fsrMaterial",
  488. get: function get() {
  489. return this._settings.fsr.material;
  490. },
  491. set: function set(value) {
  492. if (this._settings.fsr.material === value) {
  493. return;
  494. }
  495. this._settings.fsr.material = value;
  496. }
  497. }, {
  498. key: "fsrSharpness",
  499. get: function get() {
  500. return this._settings.fsr.sharpness;
  501. },
  502. set: function set(value) {
  503. this._settings.fsr.sharpness = value;
  504. }
  505. }, {
  506. key: "toneMappingMaterial",
  507. get: function get() {
  508. return this._settings.toneMapping.material;
  509. },
  510. set: function set(value) {
  511. if (this._settings.toneMapping.material === value) {
  512. return;
  513. }
  514. this._settings.toneMapping.material = value;
  515. }
  516. }]);
  517. return BuiltinPipelineSettings;
  518. }(Component), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "_settings", [property], {
  519. configurable: true,
  520. enumerable: true,
  521. writable: true,
  522. initializer: function initializer() {
  523. return makePipelineSettings();
  524. }
  525. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_editorPreview", [_dec4], {
  526. configurable: true,
  527. enumerable: true,
  528. writable: true,
  529. initializer: function initializer() {
  530. return false;
  531. }
  532. }), _applyDecoratedDescriptor(_class2.prototype, "editorPreview", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "editorPreview"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "MsaaEnable", [_dec6], Object.getOwnPropertyDescriptor(_class2.prototype, "MsaaEnable"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "msaaSampleCount", [_dec7], Object.getOwnPropertyDescriptor(_class2.prototype, "msaaSampleCount"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "shadingScaleEnable", [_dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "shadingScaleEnable"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "shadingScale", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "shadingScale"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofEnable", [_dec10], Object.getOwnPropertyDescriptor(_class2.prototype, "dofEnable"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofMaterial", [_dec11], Object.getOwnPropertyDescriptor(_class2.prototype, "dofMaterial"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofFocusDistance", [_dec12], Object.getOwnPropertyDescriptor(_class2.prototype, "dofFocusDistance"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofFocusRange", [_dec13], Object.getOwnPropertyDescriptor(_class2.prototype, "dofFocusRange"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofBokehRadius", [_dec14, _dec15], Object.getOwnPropertyDescriptor(_class2.prototype, "dofBokehRadius"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "bloomEnable", [_dec16], Object.getOwnPropertyDescriptor(_class2.prototype, "bloomEnable"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "bloomMaterial", [_dec17], Object.getOwnPropertyDescriptor(_class2.prototype, "bloomMaterial"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "bloomEnableAlphaMask", [_dec18], Object.getOwnPropertyDescriptor(_class2.prototype, "bloomEnableAlphaMask"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "bloomIterations", [_dec19], Object.getOwnPropertyDescriptor(_class2.prototype, "bloomIterations"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "bloomThreshold", [_dec20], Object.getOwnPropertyDescriptor(_class2.prototype, "bloomThreshold"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "colorGradingEnable", [_dec21], Object.getOwnPropertyDescriptor(_class2.prototype, "colorGradingEnable"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "colorGradingMaterial", [_dec22], Object.getOwnPropertyDescriptor(_class2.prototype, "colorGradingMaterial"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "colorGradingContribute", [_dec23], Object.getOwnPropertyDescriptor(_class2.prototype, "colorGradingContribute"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "colorGradingMap", [_dec24], Object.getOwnPropertyDescriptor(_class2.prototype, "colorGradingMap"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "fxaaEnable", [_dec25], Object.getOwnPropertyDescriptor(_class2.prototype, "fxaaEnable"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "fxaaMaterial", [_dec26], Object.getOwnPropertyDescriptor(_class2.prototype, "fxaaMaterial"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "fsrEnable", [_dec27], Object.getOwnPropertyDescriptor(_class2.prototype, "fsrEnable"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "fsrMaterial", [_dec28], Object.getOwnPropertyDescriptor(_class2.prototype, "fsrMaterial"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "fsrSharpness", [_dec29], Object.getOwnPropertyDescriptor(_class2.prototype, "fsrSharpness"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "toneMappingMaterial", [_dec30], Object.getOwnPropertyDescriptor(_class2.prototype, "toneMappingMaterial"), _class2.prototype)), _class2)) || _class) || _class) || _class) || _class) || _class));
  533. cclegacy._RF.pop();
  534. }
  535. };
  536. });
  537. System.register("chunks:///_virtual/builtin-pipeline-types.ts", ['cc'], function (exports) {
  538. var cclegacy, gfx;
  539. return {
  540. setters: [function (module) {
  541. cclegacy = module.cclegacy;
  542. gfx = module.gfx;
  543. }],
  544. execute: function () {
  545. exports({
  546. fillRequiredBloom: fillRequiredBloom,
  547. fillRequiredColorGrading: fillRequiredColorGrading,
  548. fillRequiredDepthOfField: fillRequiredDepthOfField,
  549. fillRequiredFSR: fillRequiredFSR,
  550. fillRequiredFXAA: fillRequiredFXAA,
  551. fillRequiredHBAO: fillRequiredHBAO,
  552. fillRequiredMSAA: fillRequiredMSAA,
  553. fillRequiredPipelineSettings: fillRequiredPipelineSettings,
  554. fillRequiredToneMapping: fillRequiredToneMapping,
  555. makeBloom: makeBloom,
  556. makeColorGrading: makeColorGrading,
  557. makeDepthOfField: makeDepthOfField,
  558. makeFSR: makeFSR,
  559. makeFXAA: makeFXAA,
  560. makeHBAO: makeHBAO,
  561. makeMSAA: makeMSAA,
  562. makePipelineSettings: makePipelineSettings,
  563. makeToneMapping: makeToneMapping
  564. });
  565. cclegacy._RF.push({}, "cbf30kCUX9A3K+QpVC6wnzx", "builtin-pipeline-types", undefined);
  566. var SampleCount = gfx.SampleCount;
  567. function makeMSAA() {
  568. return {
  569. enabled: false,
  570. sampleCount: SampleCount.X4
  571. };
  572. }
  573. function fillRequiredMSAA(value) {
  574. if (value.enabled === undefined) {
  575. value.enabled = false;
  576. }
  577. if (value.sampleCount === undefined) {
  578. value.sampleCount = SampleCount.X4;
  579. }
  580. }
  581. function makeHBAO() {
  582. return {
  583. enabled: false,
  584. radiusScale: 1,
  585. angleBiasDegree: 10,
  586. blurSharpness: 3,
  587. aoSaturation: 1,
  588. needBlur: false
  589. };
  590. }
  591. function fillRequiredHBAO(value) {
  592. if (value.enabled === undefined) {
  593. value.enabled = false;
  594. }
  595. if (value.radiusScale === undefined) {
  596. value.radiusScale = 1;
  597. }
  598. if (value.angleBiasDegree === undefined) {
  599. value.angleBiasDegree = 10;
  600. }
  601. if (value.blurSharpness === undefined) {
  602. value.blurSharpness = 3;
  603. }
  604. if (value.aoSaturation === undefined) {
  605. value.aoSaturation = 1;
  606. }
  607. if (value.needBlur === undefined) {
  608. value.needBlur = false;
  609. }
  610. }
  611. function makeDepthOfField() {
  612. return {
  613. enabled: false,
  614. material: null,
  615. focusDistance: 0,
  616. focusRange: 0,
  617. bokehRadius: 1
  618. };
  619. }
  620. function fillRequiredDepthOfField(value) {
  621. if (value.enabled === undefined) {
  622. value.enabled = false;
  623. }
  624. if (value.material === undefined) {
  625. value.material = null;
  626. }
  627. if (value.focusDistance === undefined) {
  628. value.focusDistance = 0;
  629. }
  630. if (value.focusRange === undefined) {
  631. value.focusRange = 0;
  632. }
  633. if (value.bokehRadius === undefined) {
  634. value.bokehRadius = 1;
  635. }
  636. }
  637. function makeBloom() {
  638. return {
  639. enabled: false,
  640. material: null,
  641. enableAlphaMask: false,
  642. iterations: 3,
  643. threshold: 0.8,
  644. intensity: 2.3
  645. };
  646. }
  647. function fillRequiredBloom(value) {
  648. if (value.enabled === undefined) {
  649. value.enabled = false;
  650. }
  651. if (value.material === undefined) {
  652. value.material = null;
  653. }
  654. if (value.enableAlphaMask === undefined) {
  655. value.enableAlphaMask = false;
  656. }
  657. if (value.iterations === undefined) {
  658. value.iterations = 3;
  659. }
  660. if (value.threshold === undefined) {
  661. value.threshold = 0.8;
  662. }
  663. if (value.intensity === undefined) {
  664. value.intensity = 2.3;
  665. }
  666. }
  667. function makeColorGrading() {
  668. return {
  669. enabled: false,
  670. material: null,
  671. contribute: 1,
  672. colorGradingMap: null
  673. };
  674. }
  675. function fillRequiredColorGrading(value) {
  676. if (value.enabled === undefined) {
  677. value.enabled = false;
  678. }
  679. if (value.material === undefined) {
  680. value.material = null;
  681. }
  682. if (value.contribute === undefined) {
  683. value.contribute = 1;
  684. }
  685. if (value.colorGradingMap === undefined) {
  686. value.colorGradingMap = null;
  687. }
  688. }
  689. function makeFSR() {
  690. return {
  691. enabled: false,
  692. material: null,
  693. sharpness: 0.8
  694. };
  695. }
  696. function fillRequiredFSR(value) {
  697. if (value.enabled === undefined) {
  698. value.enabled = false;
  699. }
  700. if (value.material === undefined) {
  701. value.material = null;
  702. }
  703. if (value.sharpness === undefined) {
  704. value.sharpness = 0.8;
  705. }
  706. }
  707. function makeFXAA() {
  708. return {
  709. enabled: false,
  710. material: null
  711. };
  712. }
  713. function fillRequiredFXAA(value) {
  714. if (value.enabled === undefined) {
  715. value.enabled = false;
  716. }
  717. if (value.material === undefined) {
  718. value.material = null;
  719. }
  720. }
  721. function makeToneMapping() {
  722. return {
  723. material: null
  724. };
  725. }
  726. function fillRequiredToneMapping(value) {
  727. if (value.material === undefined) {
  728. value.material = null;
  729. }
  730. }
  731. function makePipelineSettings() {
  732. return {
  733. msaa: makeMSAA(),
  734. enableShadingScale: false,
  735. shadingScale: 0.5,
  736. depthOfField: makeDepthOfField(),
  737. bloom: makeBloom(),
  738. toneMapping: makeToneMapping(),
  739. colorGrading: makeColorGrading(),
  740. fsr: makeFSR(),
  741. fxaa: makeFXAA()
  742. };
  743. }
  744. function fillRequiredPipelineSettings(value) {
  745. if (!value.msaa) {
  746. value.msaa = makeMSAA();
  747. } else {
  748. fillRequiredMSAA(value.msaa);
  749. }
  750. if (value.enableShadingScale === undefined) {
  751. value.enableShadingScale = false;
  752. }
  753. if (value.shadingScale === undefined) {
  754. value.shadingScale = 0.5;
  755. }
  756. if (!value.depthOfField) {
  757. value.depthOfField = makeDepthOfField();
  758. } else {
  759. fillRequiredDepthOfField(value.depthOfField);
  760. }
  761. if (!value.bloom) {
  762. value.bloom = makeBloom();
  763. } else {
  764. fillRequiredBloom(value.bloom);
  765. }
  766. if (!value.toneMapping) {
  767. value.toneMapping = makeToneMapping();
  768. } else {
  769. fillRequiredToneMapping(value.toneMapping);
  770. }
  771. if (!value.colorGrading) {
  772. value.colorGrading = makeColorGrading();
  773. } else {
  774. fillRequiredColorGrading(value.colorGrading);
  775. }
  776. if (!value.fsr) {
  777. value.fsr = makeFSR();
  778. } else {
  779. fillRequiredFSR(value.fsr);
  780. }
  781. if (!value.fxaa) {
  782. value.fxaa = makeFXAA();
  783. } else {
  784. fillRequiredFXAA(value.fxaa);
  785. }
  786. }
  787. cclegacy._RF.pop();
  788. }
  789. };
  790. });
  791. System.register("chunks:///_virtual/builtin-pipeline.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './builtin-pipeline-types.ts'], function () {
  792. var _createForOfIteratorHelperLoose, cclegacy, geometry, gfx, renderer, rendering, Vec3, Vec4, Vec2, Material, PipelineEventType, assert, warn, clamp, sys, pipeline, Layers, makePipelineSettings;
  793. return {
  794. setters: [function (module) {
  795. _createForOfIteratorHelperLoose = module.createForOfIteratorHelperLoose;
  796. }, function (module) {
  797. cclegacy = module.cclegacy;
  798. geometry = module.geometry;
  799. gfx = module.gfx;
  800. renderer = module.renderer;
  801. rendering = module.rendering;
  802. Vec3 = module.Vec3;
  803. Vec4 = module.Vec4;
  804. Vec2 = module.Vec2;
  805. Material = module.Material;
  806. PipelineEventType = module.PipelineEventType;
  807. assert = module.assert;
  808. warn = module.warn;
  809. clamp = module.clamp;
  810. sys = module.sys;
  811. pipeline = module.pipeline;
  812. Layers = module.Layers;
  813. }, function (module) {
  814. makePipelineSettings = module.makePipelineSettings;
  815. }],
  816. execute: function () {
  817. cclegacy._RF.push({}, "ff9b0GZzgRM/obMbHGfCNbk", "builtin-pipeline", undefined);
  818. var AABB = geometry.AABB,
  819. Sphere = geometry.Sphere,
  820. intersect = geometry.intersect;
  821. var ClearFlagBit = gfx.ClearFlagBit,
  822. Color = gfx.Color,
  823. Format = gfx.Format,
  824. FormatFeatureBit = gfx.FormatFeatureBit,
  825. LoadOp = gfx.LoadOp,
  826. StoreOp = gfx.StoreOp,
  827. TextureType = gfx.TextureType,
  828. Viewport = gfx.Viewport;
  829. var scene = renderer.scene;
  830. var CameraUsage = scene.CameraUsage,
  831. CSMLevel = scene.CSMLevel,
  832. LightType = scene.LightType;
  833. function forwardNeedClearColor(camera) {
  834. return !!(camera.clearFlag & (ClearFlagBit.COLOR | ClearFlagBit.STENCIL << 1));
  835. }
  836. function getCsmMainLightViewport(light, w, h, level, vp, screenSpaceSignY) {
  837. if (light.shadowFixedArea || light.csmLevel === CSMLevel.LEVEL_1) {
  838. vp.left = 0;
  839. vp.top = 0;
  840. vp.width = Math.trunc(w);
  841. vp.height = Math.trunc(h);
  842. } else {
  843. vp.left = Math.trunc(level % 2 * 0.5 * w);
  844. if (screenSpaceSignY > 0) {
  845. vp.top = Math.trunc((1 - Math.floor(level / 2)) * 0.5 * h);
  846. } else {
  847. vp.top = Math.trunc(Math.floor(level / 2) * 0.5 * h);
  848. }
  849. vp.width = Math.trunc(0.5 * w);
  850. vp.height = Math.trunc(0.5 * h);
  851. }
  852. vp.left = Math.max(0, vp.left);
  853. vp.top = Math.max(0, vp.top);
  854. vp.width = Math.max(1, vp.width);
  855. vp.height = Math.max(1, vp.height);
  856. }
  857. var PipelineConfigs = function PipelineConfigs() {
  858. this.isWeb = false;
  859. this.isWebGL1 = false;
  860. this.isWebGPU = false;
  861. this.isMobile = false;
  862. this.isHDR = false;
  863. this.useFloatOutput = false;
  864. this.toneMappingType = 0;
  865. // 0: ACES, 1: None
  866. this.shadowEnabled = false;
  867. this.shadowMapFormat = Format.R32F;
  868. this.shadowMapSize = new Vec2(1, 1);
  869. this.usePlanarShadow = false;
  870. this.screenSpaceSignY = 1;
  871. this.supportDepthSample = false;
  872. this.mobileMaxSpotLightShadowMaps = 1;
  873. this.platform = new Vec4(0, 0, 0, 0);
  874. };
  875. function setupPipelineConfigs(ppl, configs) {
  876. var sampleFeature = FormatFeatureBit.SAMPLED_TEXTURE | FormatFeatureBit.LINEAR_FILTER;
  877. var device = ppl.device;
  878. // Platform
  879. configs.isWeb = !sys.isNative;
  880. configs.isWebGL1 = device.gfxAPI === gfx.API.WEBGL;
  881. configs.isWebGPU = device.gfxAPI === gfx.API.WEBGPU;
  882. configs.isMobile = sys.isMobile;
  883. // Rendering
  884. configs.isHDR = ppl.pipelineSceneData.isHDR; // Has tone mapping
  885. configs.useFloatOutput = ppl.getMacroBool('CC_USE_FLOAT_OUTPUT');
  886. configs.toneMappingType = ppl.pipelineSceneData.postSettings.toneMappingType;
  887. // Shadow
  888. var shadowInfo = ppl.pipelineSceneData.shadows;
  889. configs.shadowEnabled = shadowInfo.enabled;
  890. configs.shadowMapFormat = pipeline.supportsR32FloatTexture(ppl.device) ? Format.R32F : Format.RGBA8;
  891. configs.shadowMapSize.set(shadowInfo.size);
  892. configs.usePlanarShadow = shadowInfo.enabled && shadowInfo.type === renderer.scene.ShadowType.Planar;
  893. // Device
  894. configs.screenSpaceSignY = ppl.device.capabilities.screenSpaceSignY;
  895. configs.supportDepthSample = (ppl.device.getFormatFeatures(Format.DEPTH_STENCIL) & sampleFeature) === sampleFeature;
  896. // Constants
  897. var screenSpaceSignY = device.capabilities.screenSpaceSignY;
  898. configs.platform.x = configs.isMobile ? 1.0 : 0.0;
  899. configs.platform.w = screenSpaceSignY * 0.5 + 0.5 << 1 | device.capabilities.clipSpaceSignY * 0.5 + 0.5;
  900. }
  901. var defaultSettings = makePipelineSettings();
  902. var CameraConfigs = function CameraConfigs() {
  903. this.colorName = '';
  904. this.depthStencilName = '';
  905. this.enableMainLightShadowMap = false;
  906. this.enableMainLightPlanarShadowMap = false;
  907. this.enablePostProcess = false;
  908. this.enableProfiler = false;
  909. this.enableShadingScale = false;
  910. this.enableMSAA = false;
  911. this.enableDOF = false;
  912. this.enableBloom = false;
  913. this.enableColorGrading = false;
  914. this.enableFXAA = false;
  915. this.enableFSR = false;
  916. this.enableHDR = false;
  917. this.enablePlanarReflectionProbe = false;
  918. this.useFullPipeline = false;
  919. this.singleForwardRadiancePass = false;
  920. this.radianceFormat = gfx.Format.RGBA8;
  921. this.shadingScale = 0.5;
  922. this.settings = defaultSettings;
  923. };
  924. function setupPostProcessConfigs(pipelineConfigs, settings, cameraConfigs) {
  925. cameraConfigs.enableDOF = pipelineConfigs.supportDepthSample && settings.depthOfField.enabled && !!settings.depthOfField.material;
  926. cameraConfigs.enableBloom = settings.bloom.enabled && !!settings.bloom.material;
  927. cameraConfigs.enableColorGrading = settings.colorGrading.enabled && !!settings.colorGrading.material && !!settings.colorGrading.colorGradingMap;
  928. cameraConfigs.enableFXAA = settings.fxaa.enabled && !!settings.fxaa.material;
  929. cameraConfigs.enablePostProcess = cameraConfigs.enableDOF || cameraConfigs.enableBloom || cameraConfigs.enableColorGrading || cameraConfigs.enableFXAA;
  930. }
  931. function setupCameraConfigs(camera, pipelineConfigs, cameraConfigs) {
  932. var window = camera.window;
  933. var isMainGameWindow = camera.cameraUsage === CameraUsage.GAME && !!window.swapchain;
  934. var isEditorView = camera.cameraUsage === CameraUsage.SCENE_VIEW || camera.cameraUsage === CameraUsage.PREVIEW;
  935. cameraConfigs.colorName = window.colorName;
  936. cameraConfigs.depthStencilName = window.depthStencilName;
  937. cameraConfigs.useFullPipeline = (camera.visibility & Layers.Enum.DEFAULT) !== 0;
  938. cameraConfigs.enableMainLightShadowMap = pipelineConfigs.shadowEnabled && !pipelineConfigs.usePlanarShadow && !!camera.scene && !!camera.scene.mainLight && camera.scene.mainLight.shadowEnabled;
  939. cameraConfigs.enableMainLightPlanarShadowMap = pipelineConfigs.shadowEnabled && pipelineConfigs.usePlanarShadow && !!camera.scene && !!camera.scene.mainLight && camera.scene.mainLight.shadowEnabled;
  940. cameraConfigs.enablePlanarReflectionProbe = isMainGameWindow || camera.cameraUsage === CameraUsage.SCENE_VIEW;
  941. cameraConfigs.enableProfiler = isMainGameWindow;
  942. cameraConfigs.settings = camera.pipelineSettings ? camera.pipelineSettings : defaultSettings;
  943. setupPostProcessConfigs(pipelineConfigs, cameraConfigs.settings, cameraConfigs);
  944. if (isEditorView) {
  945. var editorSettings = rendering.getEditorPipelineSettings();
  946. if (editorSettings) {
  947. cameraConfigs.settings = editorSettings;
  948. setupPostProcessConfigs(pipelineConfigs, cameraConfigs.settings, cameraConfigs);
  949. }
  950. }
  951. // MSAA
  952. cameraConfigs.enableMSAA = cameraConfigs.settings.msaa.enabled && !pipelineConfigs.isWeb // TODO(zhouzhenglong): remove this constraint
  953. && !pipelineConfigs.isWebGL1;
  954. // Shading scale
  955. cameraConfigs.shadingScale = cameraConfigs.settings.shadingScale;
  956. cameraConfigs.enableShadingScale = cameraConfigs.settings.enableShadingScale && cameraConfigs.shadingScale !== 1.0;
  957. // FSR (Depend on Shading scale)
  958. cameraConfigs.enableFSR = cameraConfigs.settings.fsr.enabled && !!cameraConfigs.settings.fsr.material && cameraConfigs.enableShadingScale && cameraConfigs.shadingScale < 1.0;
  959. // Forward rendering (Depend on MSAA and TBR)
  960. cameraConfigs.singleForwardRadiancePass = pipelineConfigs.isMobile || cameraConfigs.enableMSAA;
  961. cameraConfigs.enableHDR = cameraConfigs.useFullPipeline && pipelineConfigs.useFloatOutput;
  962. cameraConfigs.radianceFormat = cameraConfigs.enableHDR ? gfx.Format.RGBA16F : gfx.Format.RGBA8;
  963. }
  964. if (rendering) {
  965. var QueueHint = rendering.QueueHint,
  966. SceneFlags = rendering.SceneFlags,
  967. ResourceFlags = rendering.ResourceFlags,
  968. ResourceResidency = rendering.ResourceResidency;
  969. var ForwardLighting = /*#__PURE__*/function () {
  970. function ForwardLighting() {
  971. // Active lights
  972. this.lights = [];
  973. // Active spot lights with shadows (Mutually exclusive with `lights`)
  974. this.shadowEnabledSpotLights = [];
  975. // Internal cached resources
  976. this._sphere = Sphere.create(0, 0, 0, 1);
  977. this._boundingBox = new AABB();
  978. this._rangedDirLightBoundingBox = new AABB(0.0, 0.0, 0.0, 0.5, 0.5, 0.5);
  979. }
  980. var _proto = ForwardLighting.prototype;
  981. // ----------------------------------------------------------------
  982. // Interface
  983. // ----------------------------------------------------------------
  984. _proto.cullLights = function cullLights(scene, frustum, cameraPos) {
  985. // TODO(zhouzhenglong): Make light culling native
  986. this.lights.length = 0;
  987. this.shadowEnabledSpotLights.length = 0;
  988. // spot lights
  989. for (var _iterator = _createForOfIteratorHelperLoose(scene.spotLights), _step; !(_step = _iterator()).done;) {
  990. var light = _step.value;
  991. if (light.baked) {
  992. continue;
  993. }
  994. Sphere.set(this._sphere, light.position.x, light.position.y, light.position.z, light.range);
  995. if (intersect.sphereFrustum(this._sphere, frustum)) {
  996. if (light.shadowEnabled) {
  997. this.shadowEnabledSpotLights.push(light);
  998. } else {
  999. this.lights.push(light);
  1000. }
  1001. }
  1002. }
  1003. // sphere lights
  1004. for (var _iterator2 = _createForOfIteratorHelperLoose(scene.sphereLights), _step2; !(_step2 = _iterator2()).done;) {
  1005. var _light = _step2.value;
  1006. if (_light.baked) {
  1007. continue;
  1008. }
  1009. Sphere.set(this._sphere, _light.position.x, _light.position.y, _light.position.z, _light.range);
  1010. if (intersect.sphereFrustum(this._sphere, frustum)) {
  1011. this.lights.push(_light);
  1012. }
  1013. }
  1014. // point lights
  1015. for (var _iterator3 = _createForOfIteratorHelperLoose(scene.pointLights), _step3; !(_step3 = _iterator3()).done;) {
  1016. var _light2 = _step3.value;
  1017. if (_light2.baked) {
  1018. continue;
  1019. }
  1020. Sphere.set(this._sphere, _light2.position.x, _light2.position.y, _light2.position.z, _light2.range);
  1021. if (intersect.sphereFrustum(this._sphere, frustum)) {
  1022. this.lights.push(_light2);
  1023. }
  1024. }
  1025. // ranged dir lights
  1026. for (var _iterator4 = _createForOfIteratorHelperLoose(scene.rangedDirLights), _step4; !(_step4 = _iterator4()).done;) {
  1027. var _light3 = _step4.value;
  1028. AABB.transform(this._boundingBox, this._rangedDirLightBoundingBox, _light3.node.getWorldMatrix());
  1029. if (intersect.aabbFrustum(this._boundingBox, frustum)) {
  1030. this.lights.push(_light3);
  1031. }
  1032. }
  1033. if (cameraPos) {
  1034. this.shadowEnabledSpotLights.sort(function (lhs, rhs) {
  1035. return Vec3.squaredDistance(cameraPos, lhs.position) - Vec3.squaredDistance(cameraPos, rhs.position);
  1036. });
  1037. }
  1038. };
  1039. _proto._addLightQueues = function _addLightQueues(camera, pass) {
  1040. for (var _iterator5 = _createForOfIteratorHelperLoose(this.lights), _step5; !(_step5 = _iterator5()).done;) {
  1041. var light = _step5.value;
  1042. var queue = pass.addQueue(QueueHint.BLEND, 'forward-add');
  1043. switch (light.type) {
  1044. case LightType.SPHERE:
  1045. queue.name = 'sphere-light';
  1046. break;
  1047. case LightType.SPOT:
  1048. queue.name = 'spot-light';
  1049. break;
  1050. case LightType.POINT:
  1051. queue.name = 'point-light';
  1052. break;
  1053. case LightType.RANGED_DIRECTIONAL:
  1054. queue.name = 'ranged-directional-light';
  1055. break;
  1056. default:
  1057. queue.name = 'unknown-light';
  1058. }
  1059. queue.addScene(camera, SceneFlags.BLEND, light);
  1060. }
  1061. };
  1062. _proto.addSpotlightShadowPasses = function addSpotlightShadowPasses(ppl, camera, maxNumShadowMaps) {
  1063. var i = 0;
  1064. for (var _iterator6 = _createForOfIteratorHelperLoose(this.shadowEnabledSpotLights), _step6; !(_step6 = _iterator6()).done;) {
  1065. var light = _step6.value;
  1066. var shadowMapSize = ppl.pipelineSceneData.shadows.size;
  1067. var shadowPass = ppl.addRenderPass(shadowMapSize.x, shadowMapSize.y, 'default');
  1068. shadowPass.name = "SpotLightShadowPass" + i;
  1069. shadowPass.addRenderTarget("SpotShadowMap" + i, LoadOp.CLEAR, StoreOp.STORE, new Color(1, 1, 1, 1));
  1070. shadowPass.addDepthStencil("SpotShadowDepth" + i, LoadOp.CLEAR, StoreOp.DISCARD);
  1071. shadowPass.addQueue(QueueHint.NONE, 'shadow-caster').addScene(camera, SceneFlags.OPAQUE | SceneFlags.MASK | SceneFlags.SHADOW_CASTER).useLightFrustum(light);
  1072. ++i;
  1073. if (i >= maxNumShadowMaps) {
  1074. break;
  1075. }
  1076. }
  1077. };
  1078. _proto.addLightQueues = function addLightQueues(pass, camera, maxNumShadowMaps) {
  1079. this._addLightQueues(camera, pass);
  1080. var i = 0;
  1081. for (var _iterator7 = _createForOfIteratorHelperLoose(this.shadowEnabledSpotLights), _step7; !(_step7 = _iterator7()).done;) {
  1082. var light = _step7.value;
  1083. // Add spot-light pass
  1084. // Save last RenderPass to the `pass` variable
  1085. // TODO(zhouzhenglong): Fix per queue addTexture
  1086. pass.addTexture("SpotShadowMap" + i, 'cc_spotShadowMap');
  1087. var queue = pass.addQueue(QueueHint.BLEND, 'forward-add');
  1088. queue.addScene(camera, SceneFlags.BLEND, light);
  1089. ++i;
  1090. if (i >= maxNumShadowMaps) {
  1091. break;
  1092. }
  1093. }
  1094. }
  1095. // Notice: ForwardLighting cannot handle a lot of lights.
  1096. // If there are too many lights, the performance will be very poor.
  1097. // If many lights are needed, please implement a forward+ or deferred rendering pipeline.
  1098. ;
  1099. _proto.addLightPasses = function addLightPasses(colorName, depthStencilName, depthStencilStoreOp, id,
  1100. // window id
  1101. width, height, camera, viewport, ppl, pass) {
  1102. this._addLightQueues(camera, pass);
  1103. var count = 0;
  1104. var shadowMapSize = ppl.pipelineSceneData.shadows.size;
  1105. for (var _iterator8 = _createForOfIteratorHelperLoose(this.shadowEnabledSpotLights), _step8; !(_step8 = _iterator8()).done;) {
  1106. var light = _step8.value;
  1107. var shadowPass = ppl.addRenderPass(shadowMapSize.x, shadowMapSize.y, 'default');
  1108. shadowPass.name = 'SpotlightShadowPass';
  1109. // Reuse csm shadow map
  1110. shadowPass.addRenderTarget("ShadowMap" + id, LoadOp.CLEAR, StoreOp.STORE, new Color(1, 1, 1, 1));
  1111. shadowPass.addDepthStencil("ShadowDepth" + id, LoadOp.CLEAR, StoreOp.DISCARD);
  1112. shadowPass.addQueue(QueueHint.NONE, 'shadow-caster').addScene(camera, SceneFlags.OPAQUE | SceneFlags.MASK | SceneFlags.SHADOW_CASTER).useLightFrustum(light);
  1113. // Add spot-light pass
  1114. // Save last RenderPass to the `pass` variable
  1115. ++count;
  1116. var storeOp = count === this.shadowEnabledSpotLights.length ? depthStencilStoreOp : StoreOp.STORE;
  1117. pass = ppl.addRenderPass(width, height, 'default');
  1118. pass.name = 'SpotlightWithShadowMap';
  1119. pass.setViewport(viewport);
  1120. pass.addRenderTarget(colorName, LoadOp.LOAD);
  1121. pass.addDepthStencil(depthStencilName, LoadOp.LOAD, storeOp);
  1122. pass.addTexture("ShadowMap" + id, 'cc_spotShadowMap');
  1123. var queue = pass.addQueue(QueueHint.BLEND, 'forward-add');
  1124. queue.addScene(camera, SceneFlags.BLEND, light);
  1125. }
  1126. return pass;
  1127. };
  1128. _proto.isMultipleLightPassesNeeded = function isMultipleLightPassesNeeded() {
  1129. return this.shadowEnabledSpotLights.length > 0;
  1130. };
  1131. return ForwardLighting;
  1132. }();
  1133. var BuiltinPipelineBuilder = /*#__PURE__*/function () {
  1134. function BuiltinPipelineBuilder() {
  1135. this._pipelineEvent = cclegacy.director.root.pipelineEvent;
  1136. // Internal cached resources
  1137. this._clearColor = new Color(0, 0, 0, 1);
  1138. this._clearColorTransparentBlack = new Color(0, 0, 0, 0);
  1139. this._reflectionProbeClearColor = new Vec3(0, 0, 0);
  1140. this._viewport = new Viewport();
  1141. this._configs = new PipelineConfigs();
  1142. this._cameraConfigs = new CameraConfigs();
  1143. // DepthOfField
  1144. this._cocParams = new Vec4(0, 0, 0, 0);
  1145. this._cocTexSize = new Vec4(0, 0, 0, 0);
  1146. // Bloom
  1147. this._bloomParams = new Vec4(0, 0, 0, 0);
  1148. this._bloomTexSize = new Vec4(0, 0, 0, 0);
  1149. this._bloomWidths = [];
  1150. this._bloomHeights = [];
  1151. this._bloomTexNames = [];
  1152. // Color Grading
  1153. this._colorGradingTexSize = new Vec2(0, 0);
  1154. // FXAA
  1155. this._fxaaParams = new Vec4(0, 0, 0, 0);
  1156. // FSR
  1157. this._fsrParams = new Vec4(0, 0, 0, 0);
  1158. this._fsrTexSize = new Vec4(0, 0, 0, 0);
  1159. // Materials
  1160. this._copyAndTonemapMaterial = new Material();
  1161. // Internal States
  1162. this._initialized = false;
  1163. // TODO(zhouzhenglong): Make default effect asset loading earlier and remove this flag
  1164. // Forward lighting
  1165. this.forwardLighting = new ForwardLighting();
  1166. }
  1167. var _proto2 = BuiltinPipelineBuilder.prototype;
  1168. // ----------------------------------------------------------------
  1169. // Interface
  1170. // ----------------------------------------------------------------
  1171. _proto2.windowResize = function windowResize(ppl, window, camera, nativeWidth, nativeHeight) {
  1172. setupPipelineConfigs(ppl, this._configs);
  1173. setupCameraConfigs(camera, this._configs, this._cameraConfigs);
  1174. var settings = this._cameraConfigs.settings;
  1175. var id = window.renderWindowId;
  1176. var width = this._cameraConfigs.enableShadingScale ? Math.max(Math.floor(nativeWidth * this._cameraConfigs.shadingScale), 1) : nativeWidth;
  1177. var height = this._cameraConfigs.enableShadingScale ? Math.max(Math.floor(nativeHeight * this._cameraConfigs.shadingScale), 1) : nativeHeight;
  1178. // Render Window (UI)
  1179. ppl.addRenderWindow(this._cameraConfigs.colorName, Format.RGBA8, nativeWidth, nativeHeight, window, this._cameraConfigs.depthStencilName);
  1180. if (this._cameraConfigs.enableShadingScale) {
  1181. ppl.addDepthStencil("ScaledSceneDepth" + id, Format.DEPTH_STENCIL, width, height);
  1182. ppl.addRenderTarget("ScaledRadiance" + id, this._cameraConfigs.radianceFormat, width, height);
  1183. ppl.addRenderTarget("ScaledLdrColor" + id, Format.RGBA8, width, height);
  1184. } else {
  1185. ppl.addDepthStencil("SceneDepth" + id, Format.DEPTH_STENCIL, width, height);
  1186. ppl.addRenderTarget("Radiance" + id, this._cameraConfigs.radianceFormat, width, height);
  1187. ppl.addRenderTarget("LdrColor" + id, Format.RGBA8, width, height);
  1188. }
  1189. if (this._cameraConfigs.enableFSR) {
  1190. ppl.addRenderTarget("FsrColor" + id, Format.RGBA8, nativeWidth, nativeHeight);
  1191. }
  1192. // MsaaRadiance
  1193. if (this._cameraConfigs.enableMSAA) {
  1194. // Notice: We never store multisample results.
  1195. // These samples are always resolved and discarded at the end of the render pass.
  1196. // So the ResourceResidency should be MEMORYLESS.
  1197. if (this._cameraConfigs.enableHDR) {
  1198. ppl.addTexture("MsaaRadiance" + id, TextureType.TEX2D, this._cameraConfigs.radianceFormat, width, height, 1, 1, 1, settings.msaa.sampleCount, ResourceFlags.COLOR_ATTACHMENT, ResourceResidency.MEMORYLESS);
  1199. } else {
  1200. ppl.addTexture("MsaaRadiance" + id, TextureType.TEX2D, Format.RGBA8, width, height, 1, 1, 1, settings.msaa.sampleCount, ResourceFlags.COLOR_ATTACHMENT, ResourceResidency.MEMORYLESS);
  1201. }
  1202. ppl.addTexture("MsaaDepthStencil" + id, TextureType.TEX2D, Format.DEPTH_STENCIL, width, height, 1, 1, 1, settings.msaa.sampleCount, ResourceFlags.DEPTH_STENCIL_ATTACHMENT, ResourceResidency.MEMORYLESS);
  1203. }
  1204. // Mainlight ShadowMap
  1205. ppl.addRenderTarget("ShadowMap" + id, this._configs.shadowMapFormat, this._configs.shadowMapSize.x, this._configs.shadowMapSize.y);
  1206. ppl.addDepthStencil("ShadowDepth" + id, Format.DEPTH_STENCIL, this._configs.shadowMapSize.x, this._configs.shadowMapSize.y);
  1207. // Spot-light shadow maps
  1208. if (this._cameraConfigs.singleForwardRadiancePass) {
  1209. var count = this._configs.mobileMaxSpotLightShadowMaps;
  1210. for (var i = 0; i !== count; ++i) {
  1211. ppl.addRenderTarget("SpotShadowMap" + i, this._configs.shadowMapFormat, this._configs.shadowMapSize.x, this._configs.shadowMapSize.y);
  1212. ppl.addDepthStencil("SpotShadowDepth" + i, Format.DEPTH_STENCIL, this._configs.shadowMapSize.x, this._configs.shadowMapSize.y);
  1213. }
  1214. }
  1215. // ---------------------------------------------------------
  1216. // Post Process
  1217. // ---------------------------------------------------------
  1218. // DepthOfField
  1219. if (this._cameraConfigs.enableDOF) {
  1220. var halfWidth = Math.max(Math.floor(width / 2), 1);
  1221. var halfHeight = Math.max(Math.floor(height / 2), 1);
  1222. // `DofCoc${id}` texture will reuse ldrColorName
  1223. ppl.addRenderTarget("DofRadiance" + id, this._cameraConfigs.radianceFormat, width, height);
  1224. ppl.addRenderTarget("DofPrefilter" + id, this._cameraConfigs.radianceFormat, halfWidth, halfHeight);
  1225. ppl.addRenderTarget("DofBokeh" + id, this._cameraConfigs.radianceFormat, halfWidth, halfHeight);
  1226. ppl.addRenderTarget("DofFilter" + id, this._cameraConfigs.radianceFormat, halfWidth, halfHeight);
  1227. }
  1228. // Bloom (Kawase Dual Filter)
  1229. if (this._cameraConfigs.enableBloom) {
  1230. var bloomWidth = width;
  1231. var bloomHeight = height;
  1232. for (var _i = 0; _i !== settings.bloom.iterations + 1; ++_i) {
  1233. bloomWidth = Math.max(Math.floor(bloomWidth / 2), 1);
  1234. bloomHeight = Math.max(Math.floor(bloomHeight / 2), 1);
  1235. ppl.addRenderTarget("BloomTex" + id + "_" + _i, this._cameraConfigs.radianceFormat, bloomWidth, bloomHeight);
  1236. }
  1237. }
  1238. // Color Grading
  1239. if (this._cameraConfigs.enableColorGrading && settings.colorGrading.material && settings.colorGrading.colorGradingMap) {
  1240. settings.colorGrading.material.setProperty('colorGradingMap', settings.colorGrading.colorGradingMap);
  1241. }
  1242. // FXAA
  1243. if (this._cameraConfigs.enableFXAA && this._cameraConfigs.enableShadingScale) {
  1244. ppl.addRenderTarget("AaColor" + id, Format.RGBA8, width, height);
  1245. }
  1246. };
  1247. _proto2.setup = function setup(cameras, ppl) {
  1248. // TODO(zhouzhenglong): Make default effect asset loading earlier and remove _initMaterials
  1249. if (this._initMaterials(ppl)) {
  1250. return;
  1251. }
  1252. // Render cameras
  1253. // log(`==================== One Frame ====================`);
  1254. for (var _iterator9 = _createForOfIteratorHelperLoose(cameras), _step9; !(_step9 = _iterator9()).done;) {
  1255. var camera = _step9.value;
  1256. // Skip invalid camera
  1257. if (!camera.scene || !camera.window) {
  1258. continue;
  1259. }
  1260. // Setup camera configs
  1261. setupCameraConfigs(camera, this._configs, this._cameraConfigs);
  1262. // log(`Setup camera: ${camera.node!.name}, window: ${camera.window.renderWindowId}, isFull: ${this._cameraConfigs.useFullPipeline}, `
  1263. // + `size: ${camera.window.width}x${camera.window.height}`);
  1264. this._pipelineEvent.emit(PipelineEventType.RENDER_CAMERA_BEGIN, camera);
  1265. // Build pipeline
  1266. if (this._cameraConfigs.useFullPipeline) {
  1267. this._buildForwardPipeline(ppl, camera, camera.scene);
  1268. } else {
  1269. this._buildSimplePipeline(ppl, camera);
  1270. }
  1271. this._pipelineEvent.emit(PipelineEventType.RENDER_CAMERA_END, camera);
  1272. }
  1273. }
  1274. // ----------------------------------------------------------------
  1275. // Pipelines
  1276. // ----------------------------------------------------------------
  1277. ;
  1278. _proto2._buildSimplePipeline = function _buildSimplePipeline(ppl, camera) {
  1279. var width = Math.max(Math.floor(camera.window.width), 1);
  1280. var height = Math.max(Math.floor(camera.window.height), 1);
  1281. var colorName = this._cameraConfigs.colorName;
  1282. var depthStencilName = this._cameraConfigs.depthStencilName;
  1283. var viewport = camera.viewport; // Reduce C++/TS interop
  1284. this._viewport.left = Math.round(viewport.x * width);
  1285. this._viewport.top = Math.round(viewport.y * height);
  1286. // Here we must use camera.viewport.width instead of camera.viewport.z, which
  1287. // is undefined on native platform. The same as camera.viewport.height.
  1288. this._viewport.width = Math.max(Math.round(viewport.width * width), 1);
  1289. this._viewport.height = Math.max(Math.round(viewport.height * height), 1);
  1290. var clearColor = camera.clearColor; // Reduce C++/TS interop
  1291. this._clearColor.x = clearColor.x;
  1292. this._clearColor.y = clearColor.y;
  1293. this._clearColor.z = clearColor.z;
  1294. this._clearColor.w = clearColor.w;
  1295. var pass = ppl.addRenderPass(width, height, 'default');
  1296. // bind output render target
  1297. if (forwardNeedClearColor(camera)) {
  1298. pass.addRenderTarget(colorName, LoadOp.CLEAR, StoreOp.STORE, this._clearColor);
  1299. } else {
  1300. pass.addRenderTarget(colorName, LoadOp.LOAD, StoreOp.STORE);
  1301. }
  1302. // bind depth stencil buffer
  1303. if (camera.clearFlag & ClearFlagBit.DEPTH_STENCIL) {
  1304. pass.addDepthStencil(depthStencilName, LoadOp.CLEAR, StoreOp.DISCARD, camera.clearDepth, camera.clearStencil, camera.clearFlag & ClearFlagBit.DEPTH_STENCIL);
  1305. } else {
  1306. pass.addDepthStencil(depthStencilName, LoadOp.LOAD, StoreOp.DISCARD);
  1307. }
  1308. pass.setViewport(this._viewport);
  1309. // The opaque queue is used for Reflection probe preview
  1310. pass.addQueue(QueueHint.OPAQUE).addScene(camera, SceneFlags.OPAQUE);
  1311. // The blend queue is used for UI and Gizmos
  1312. var flags = SceneFlags.BLEND | SceneFlags.UI;
  1313. if (this._cameraConfigs.enableProfiler) {
  1314. flags |= SceneFlags.PROFILER;
  1315. pass.showStatistics = true;
  1316. }
  1317. pass.addQueue(QueueHint.BLEND).addScene(camera, flags);
  1318. };
  1319. _proto2._buildForwardPipeline = function _buildForwardPipeline(ppl, camera, scene) {
  1320. // Init
  1321. var settings = this._cameraConfigs.settings;
  1322. var nativeWidth = Math.max(Math.floor(camera.window.width), 1);
  1323. var nativeHeight = Math.max(Math.floor(camera.window.height), 1);
  1324. var width = this._cameraConfigs.enableShadingScale ? Math.max(Math.floor(nativeWidth * this._cameraConfigs.shadingScale), 1) : nativeWidth;
  1325. var height = this._cameraConfigs.enableShadingScale ? Math.max(Math.floor(nativeHeight * this._cameraConfigs.shadingScale), 1) : nativeHeight;
  1326. var id = camera.window.renderWindowId;
  1327. var colorName = this._cameraConfigs.colorName;
  1328. var sceneDepth = this._cameraConfigs.enableShadingScale ? "ScaledSceneDepth" + id : "SceneDepth" + id;
  1329. var radianceName = this._cameraConfigs.enableShadingScale ? "ScaledRadiance" + id : "Radiance" + id;
  1330. var ldrColorName = this._cameraConfigs.enableShadingScale ? "ScaledLdrColor" + id : "LdrColor" + id;
  1331. var mainLight = scene.mainLight;
  1332. // Forward Lighting (Light Culling)
  1333. this.forwardLighting.cullLights(scene, camera.frustum);
  1334. // Main Directional light CSM Shadow Map
  1335. if (this._cameraConfigs.enableMainLightShadowMap) {
  1336. assert(!!mainLight);
  1337. this._addCascadedShadowMapPass(ppl, id, mainLight, camera);
  1338. }
  1339. // Spot light shadow maps (Mobile or MSAA)
  1340. if (this._cameraConfigs.singleForwardRadiancePass) {
  1341. // Currently, only support 1 spot light with shadow map on mobile platform.
  1342. // TODO(zhouzhenglong): Relex this limitation.
  1343. this.forwardLighting.addSpotlightShadowPasses(ppl, camera, this._configs.mobileMaxSpotLightShadowMaps);
  1344. }
  1345. this._tryAddReflectionProbePasses(ppl, id, mainLight, camera.scene);
  1346. // Forward Lighting
  1347. var lastPass;
  1348. if (this._cameraConfigs.enablePostProcess) {
  1349. // Post Process
  1350. // Radiance and DoF
  1351. if (this._cameraConfigs.enableDOF) {
  1352. assert(!!settings.depthOfField.material);
  1353. var dofRadianceName = "DofRadiance" + id;
  1354. // Disable MSAA, depth stencil cannot be resolved cross-platformly
  1355. this._addForwardRadiancePasses(ppl, id, camera, width, height, mainLight, dofRadianceName, sceneDepth, true, StoreOp.STORE);
  1356. this._addDepthOfFieldPasses(ppl, settings, settings.depthOfField.material, id, camera, width, height, dofRadianceName, sceneDepth, radianceName, ldrColorName);
  1357. } else {
  1358. this._addForwardRadiancePasses(ppl, id, camera, width, height, mainLight, radianceName, sceneDepth);
  1359. }
  1360. // Bloom
  1361. if (this._cameraConfigs.enableBloom) {
  1362. assert(!!settings.bloom.material);
  1363. this._addKawaseDualFilterBloomPasses(ppl, settings, settings.bloom.material, id, width, height, radianceName);
  1364. }
  1365. // Tone Mapping and FXAA
  1366. if (this._cameraConfigs.enableFXAA) {
  1367. assert(!!settings.fxaa.material);
  1368. var copyAndTonemapPassNeeded = this._cameraConfigs.enableHDR || this._cameraConfigs.enableColorGrading;
  1369. var ldrColorBufferName = copyAndTonemapPassNeeded ? ldrColorName : radianceName;
  1370. // FXAA is applied after tone mapping
  1371. if (copyAndTonemapPassNeeded) {
  1372. this._addCopyAndTonemapPass(ppl, settings, width, height, radianceName, ldrColorBufferName);
  1373. }
  1374. // Apply FXAA
  1375. if (this._cameraConfigs.enableShadingScale) {
  1376. var aaColorName = "AaColor" + id;
  1377. // Apply FXAA on scaled image
  1378. this._addFxaaPass(ppl, settings.fxaa.material, width, height, ldrColorBufferName, aaColorName);
  1379. // Copy FXAA result to screen
  1380. if (this._cameraConfigs.enableFSR && settings.fsr.material) {
  1381. // Apply FSR
  1382. lastPass = this._addFsrPass(ppl, settings, settings.fsr.material, id, width, height, aaColorName, nativeWidth, nativeHeight, colorName);
  1383. } else {
  1384. // Scale FXAA result to screen
  1385. lastPass = this._addCopyPass(ppl, nativeWidth, nativeHeight, aaColorName, colorName);
  1386. }
  1387. } else {
  1388. // Image not scaled, output FXAA result to screen directly
  1389. lastPass = this._addFxaaPass(ppl, settings.fxaa.material, nativeWidth, nativeHeight, ldrColorBufferName, colorName);
  1390. }
  1391. } else {
  1392. // No FXAA (Size might be scaled)
  1393. lastPass = this._addTonemapResizeOrSuperResolutionPasses(ppl, settings, id, width, height, radianceName, ldrColorName, nativeWidth, nativeHeight, colorName);
  1394. }
  1395. } else if (this._cameraConfigs.enableHDR || this._cameraConfigs.enableShadingScale) {
  1396. // HDR or Scaled LDR
  1397. this._addForwardRadiancePasses(ppl, id, camera, width, height, mainLight, radianceName, sceneDepth);
  1398. lastPass = this._addTonemapResizeOrSuperResolutionPasses(ppl, settings, id, width, height, radianceName, ldrColorName, nativeWidth, nativeHeight, colorName);
  1399. } else {
  1400. // LDR (Size is not scaled)
  1401. lastPass = this._addForwardRadiancePasses(ppl, id, camera, nativeWidth, nativeHeight, mainLight, colorName, this._cameraConfigs.depthStencilName);
  1402. }
  1403. // UI size is not scaled, does not have AA
  1404. this._addUIQueue(camera, lastPass);
  1405. }
  1406. // ----------------------------------------------------------------
  1407. // Common Passes
  1408. // ----------------------------------------------------------------
  1409. ;
  1410. _proto2._addTonemapResizeOrSuperResolutionPasses = function _addTonemapResizeOrSuperResolutionPasses(ppl, settings, id, width, height, radianceName, ldrColorName, nativeWidth, nativeHeight, colorName) {
  1411. var lastPass;
  1412. if (this._cameraConfigs.enableFSR && settings.fsr.material) {
  1413. // Apply FSR
  1414. this._addCopyAndTonemapPass(ppl, settings, width, height, radianceName, ldrColorName);
  1415. lastPass = this._addFsrPass(ppl, settings, settings.fsr.material, id, width, height, ldrColorName, nativeWidth, nativeHeight, colorName);
  1416. } else {
  1417. // Output HDR/LDR result to screen directly (Size might be scaled)
  1418. lastPass = this._addCopyAndTonemapPass(ppl, settings, nativeWidth, nativeHeight, radianceName, colorName);
  1419. }
  1420. return lastPass;
  1421. };
  1422. _proto2._addCascadedShadowMapPass = function _addCascadedShadowMapPass(ppl, id, light, camera) {
  1423. // ----------------------------------------------------------------
  1424. // Dynamic states
  1425. // ----------------------------------------------------------------
  1426. var width = ppl.pipelineSceneData.shadows.size.x;
  1427. var height = ppl.pipelineSceneData.shadows.size.y;
  1428. this._viewport.left = 0;
  1429. this._viewport.top = 0;
  1430. this._viewport.width = width;
  1431. this._viewport.height = height;
  1432. // ----------------------------------------------------------------
  1433. // CSM Shadow Map
  1434. // ----------------------------------------------------------------
  1435. var pass = ppl.addRenderPass(width, height, 'default');
  1436. pass.name = 'CascadedShadowMap';
  1437. pass.addRenderTarget("ShadowMap" + id, LoadOp.CLEAR, StoreOp.STORE, new Color(1, 1, 1, 1));
  1438. pass.addDepthStencil("ShadowDepth" + id, LoadOp.CLEAR, StoreOp.DISCARD);
  1439. var csmLevel = ppl.pipelineSceneData.csmSupported ? light.csmLevel : 1;
  1440. // Add shadow map viewports
  1441. for (var level = 0; level !== csmLevel; ++level) {
  1442. getCsmMainLightViewport(light, width, height, level, this._viewport, this._configs.screenSpaceSignY);
  1443. var queue = pass.addQueue(QueueHint.NONE, 'shadow-caster');
  1444. if (!this._configs.isWebGPU) {
  1445. // Temporary workaround for WebGPU
  1446. queue.setViewport(this._viewport);
  1447. }
  1448. queue.addScene(camera, SceneFlags.OPAQUE | SceneFlags.MASK | SceneFlags.SHADOW_CASTER).useLightFrustum(light, level);
  1449. }
  1450. };
  1451. _proto2._addCopyPass = function _addCopyPass(ppl, width, height, input, output) {
  1452. var pass = ppl.addRenderPass(width, height, 'cc-tone-mapping');
  1453. pass.addRenderTarget(output, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1454. pass.addTexture(input, 'inputTexture');
  1455. pass.setVec4('g_platform', this._configs.platform);
  1456. pass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(this._copyAndTonemapMaterial, 1);
  1457. return pass;
  1458. };
  1459. _proto2._addCopyAndTonemapPass = function _addCopyAndTonemapPass(ppl, settings, width, height, radianceName, colorName) {
  1460. var pass;
  1461. if (this._cameraConfigs.enableColorGrading && settings.colorGrading.material && settings.colorGrading.colorGradingMap) {
  1462. var lutTex = settings.colorGrading.colorGradingMap;
  1463. this._colorGradingTexSize.x = lutTex.width;
  1464. this._colorGradingTexSize.y = lutTex.height;
  1465. var isSquareMap = lutTex.width === lutTex.height;
  1466. if (isSquareMap) {
  1467. pass = ppl.addRenderPass(width, height, 'cc-color-grading-8x8');
  1468. } else {
  1469. pass = ppl.addRenderPass(width, height, 'cc-color-grading-nx1');
  1470. }
  1471. pass.addRenderTarget(colorName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1472. pass.addTexture(radianceName, 'sceneColorMap');
  1473. pass.setVec4('g_platform', this._configs.platform);
  1474. pass.setVec2('lutTextureSize', this._colorGradingTexSize);
  1475. pass.setFloat('contribute', settings.colorGrading.contribute);
  1476. pass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(settings.colorGrading.material, isSquareMap ? 1 : 0);
  1477. } else {
  1478. pass = ppl.addRenderPass(width, height, 'cc-tone-mapping');
  1479. pass.addRenderTarget(colorName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1480. pass.addTexture(radianceName, 'inputTexture');
  1481. pass.setVec4('g_platform', this._configs.platform);
  1482. if (settings.toneMapping.material) {
  1483. pass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(settings.toneMapping.material, 0);
  1484. } else {
  1485. pass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(this._copyAndTonemapMaterial, 0);
  1486. }
  1487. }
  1488. return pass;
  1489. };
  1490. _proto2._buildForwardMainLightPass = function _buildForwardMainLightPass(pass, id, camera, colorName, depthStencilName, depthStencilStoreOp, mainLight, scene) {
  1491. if (scene === void 0) {
  1492. scene = null;
  1493. }
  1494. // set viewport
  1495. pass.setViewport(this._viewport);
  1496. var colorStoreOp = this._cameraConfigs.enableMSAA ? StoreOp.DISCARD : StoreOp.STORE;
  1497. // bind output render target
  1498. if (forwardNeedClearColor(camera)) {
  1499. pass.addRenderTarget(colorName, LoadOp.CLEAR, colorStoreOp, this._clearColor);
  1500. } else {
  1501. pass.addRenderTarget(colorName, LoadOp.LOAD, colorStoreOp);
  1502. }
  1503. // bind depth stencil buffer
  1504. {
  1505. if (colorName === this._cameraConfigs.colorName && depthStencilName !== this._cameraConfigs.depthStencilName) {
  1506. warn('Default framebuffer cannot use custom depth stencil buffer');
  1507. }
  1508. }
  1509. if (camera.clearFlag & ClearFlagBit.DEPTH_STENCIL) {
  1510. pass.addDepthStencil(depthStencilName, LoadOp.CLEAR, depthStencilStoreOp, camera.clearDepth, camera.clearStencil, camera.clearFlag & ClearFlagBit.DEPTH_STENCIL);
  1511. } else {
  1512. pass.addDepthStencil(depthStencilName, LoadOp.LOAD, depthStencilStoreOp);
  1513. }
  1514. // Set shadow map if enabled
  1515. if (this._cameraConfigs.enableMainLightShadowMap) {
  1516. pass.addTexture("ShadowMap" + id, 'cc_shadowMap');
  1517. }
  1518. // TODO(zhouzhenglong): Separate OPAQUE and MASK queue
  1519. // add opaque and mask queue
  1520. pass.addQueue(QueueHint.NONE) // Currently we put OPAQUE and MASK into one queue, so QueueHint is NONE
  1521. .addScene(camera, SceneFlags.OPAQUE | SceneFlags.MASK, mainLight || undefined, scene ? scene : undefined);
  1522. };
  1523. _proto2._addDepthOfFieldPasses = function _addDepthOfFieldPasses(ppl, settings, dofMaterial, id, camera, width, height, dofRadianceName, depthStencil, radianceName, ldrColorName) {
  1524. // https://catlikecoding.com/unity/tutorials/advanced-rendering/depth-of-field/
  1525. this._cocParams.x = settings.depthOfField.focusDistance;
  1526. this._cocParams.y = settings.depthOfField.focusRange;
  1527. this._cocParams.z = settings.depthOfField.bokehRadius;
  1528. this._cocParams.w = 0.0;
  1529. this._cocTexSize.x = 1.0 / width;
  1530. this._cocTexSize.y = 1.0 / height;
  1531. this._cocTexSize.z = width;
  1532. this._cocTexSize.w = height;
  1533. var halfWidth = Math.max(Math.floor(width / 2), 1);
  1534. var halfHeight = Math.max(Math.floor(height / 2), 1);
  1535. var cocName = ldrColorName;
  1536. var prefilterName = "DofPrefilter" + id;
  1537. var bokehName = "DofBokeh" + id;
  1538. var filterName = "DofFilter" + id;
  1539. // CoC
  1540. var cocPass = ppl.addRenderPass(width, height, 'cc-dof-coc');
  1541. cocPass.addRenderTarget(cocName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1542. cocPass.addTexture(depthStencil, 'DepthTex');
  1543. cocPass.setVec4('g_platform', this._configs.platform);
  1544. cocPass.setMat4('proj', camera.matProj);
  1545. cocPass.setVec4('cocParams', this._cocParams);
  1546. cocPass.addQueue(QueueHint.OPAQUE).addCameraQuad(camera, dofMaterial, 0); // addCameraQuad will set camera related UBOs
  1547. // Downsample and Prefilter
  1548. var prefilterPass = ppl.addRenderPass(halfWidth, halfHeight, 'cc-dof-prefilter');
  1549. prefilterPass.addRenderTarget(prefilterName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1550. prefilterPass.addTexture(dofRadianceName, 'colorTex');
  1551. prefilterPass.addTexture(cocName, 'cocTex');
  1552. prefilterPass.setVec4('g_platform', this._configs.platform);
  1553. prefilterPass.setVec4('mainTexTexelSize', this._cocTexSize);
  1554. prefilterPass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(dofMaterial, 1);
  1555. // Bokeh blur
  1556. var bokehPass = ppl.addRenderPass(halfWidth, halfHeight, 'cc-dof-bokeh');
  1557. bokehPass.addRenderTarget(bokehName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1558. bokehPass.addTexture(prefilterName, 'prefilterTex');
  1559. bokehPass.setVec4('g_platform', this._configs.platform);
  1560. bokehPass.setVec4('mainTexTexelSize', this._cocTexSize);
  1561. bokehPass.setVec4('cocParams', this._cocParams);
  1562. bokehPass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(dofMaterial, 2);
  1563. // Filtering
  1564. var filterPass = ppl.addRenderPass(halfWidth, halfHeight, 'cc-dof-filter');
  1565. filterPass.addRenderTarget(filterName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1566. filterPass.addTexture(bokehName, 'bokehTex');
  1567. filterPass.setVec4('g_platform', this._configs.platform);
  1568. filterPass.setVec4('mainTexTexelSize', this._cocTexSize);
  1569. filterPass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(dofMaterial, 3);
  1570. // Combine
  1571. var combinePass = ppl.addRenderPass(width, height, 'cc-dof-combine');
  1572. combinePass.addRenderTarget(radianceName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1573. combinePass.addTexture(dofRadianceName, 'colorTex');
  1574. combinePass.addTexture(cocName, 'cocTex');
  1575. combinePass.addTexture(filterName, 'filterTex');
  1576. combinePass.setVec4('g_platform', this._configs.platform);
  1577. combinePass.setVec4('cocParams', this._cocParams);
  1578. combinePass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(dofMaterial, 4);
  1579. };
  1580. _proto2._addKawaseDualFilterBloomPasses = function _addKawaseDualFilterBloomPasses(ppl, settings, bloomMaterial, id, width, height, radianceName) {
  1581. // Based on Kawase Dual Filter Blur. Saves bandwidth on mobile devices.
  1582. // eslint-disable-next-line max-len
  1583. // https://community.arm.com/cfs-file/__key/communityserver-blogs-components-weblogfiles/00-00-00-20-66/siggraph2015_2D00_mmg_2D00_marius_2D00_slides.pdf
  1584. // Size: [prefilter(1/2), downsample(1/4), downsample(1/8), downsample(1/16), ...]
  1585. var iterations = settings.bloom.iterations;
  1586. var sizeCount = iterations + 1;
  1587. this._bloomWidths.length = sizeCount;
  1588. this._bloomHeights.length = sizeCount;
  1589. this._bloomWidths[0] = Math.max(Math.floor(width / 2), 1);
  1590. this._bloomHeights[0] = Math.max(Math.floor(height / 2), 1);
  1591. for (var i = 1; i !== sizeCount; ++i) {
  1592. this._bloomWidths[i] = Math.max(Math.floor(this._bloomWidths[i - 1] / 2), 1);
  1593. this._bloomHeights[i] = Math.max(Math.floor(this._bloomHeights[i - 1] / 2), 1);
  1594. }
  1595. // Bloom texture names
  1596. this._bloomTexNames.length = sizeCount;
  1597. for (var _i2 = 0; _i2 !== sizeCount; ++_i2) {
  1598. this._bloomTexNames[_i2] = "BloomTex" + id + "_" + _i2;
  1599. }
  1600. // Setup bloom parameters
  1601. this._bloomParams.x = this._configs.useFloatOutput ? 1 : 0;
  1602. this._bloomParams.x = 0; // unused
  1603. this._bloomParams.z = settings.bloom.threshold;
  1604. this._bloomParams.w = settings.bloom.enableAlphaMask ? 1 : 0;
  1605. // Prefilter pass
  1606. var prefilterPass = ppl.addRenderPass(this._bloomWidths[0], this._bloomHeights[0], 'cc-bloom-prefilter');
  1607. prefilterPass.addRenderTarget(this._bloomTexNames[0], LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1608. prefilterPass.addTexture(radianceName, 'inputTexture');
  1609. prefilterPass.setVec4('g_platform', this._configs.platform);
  1610. prefilterPass.setVec4('bloomParams', this._bloomParams);
  1611. prefilterPass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(bloomMaterial, 0);
  1612. // Downsample passes
  1613. for (var _i3 = 1; _i3 !== sizeCount; ++_i3) {
  1614. var downPass = ppl.addRenderPass(this._bloomWidths[_i3], this._bloomHeights[_i3], 'cc-bloom-downsample');
  1615. downPass.addRenderTarget(this._bloomTexNames[_i3], LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1616. downPass.addTexture(this._bloomTexNames[_i3 - 1], 'bloomTexture');
  1617. this._bloomTexSize.x = this._bloomWidths[_i3 - 1];
  1618. this._bloomTexSize.y = this._bloomHeights[_i3 - 1];
  1619. downPass.setVec4('g_platform', this._configs.platform);
  1620. downPass.setVec4('bloomTexSize', this._bloomTexSize);
  1621. downPass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(bloomMaterial, 1);
  1622. }
  1623. // Upsample passes
  1624. for (var _i4 = iterations; _i4-- > 0;) {
  1625. var upPass = ppl.addRenderPass(this._bloomWidths[_i4], this._bloomHeights[_i4], 'cc-bloom-upsample');
  1626. upPass.addRenderTarget(this._bloomTexNames[_i4], LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1627. upPass.addTexture(this._bloomTexNames[_i4 + 1], 'bloomTexture');
  1628. this._bloomTexSize.x = this._bloomWidths[_i4 + 1];
  1629. this._bloomTexSize.y = this._bloomHeights[_i4 + 1];
  1630. upPass.setVec4('g_platform', this._configs.platform);
  1631. upPass.setVec4('bloomTexSize', this._bloomTexSize);
  1632. upPass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(bloomMaterial, 2);
  1633. }
  1634. // Combine pass
  1635. var combinePass = ppl.addRenderPass(width, height, 'cc-bloom-combine');
  1636. combinePass.addRenderTarget(radianceName, LoadOp.LOAD, StoreOp.STORE);
  1637. combinePass.addTexture(this._bloomTexNames[0], 'bloomTexture');
  1638. combinePass.setVec4('g_platform', this._configs.platform);
  1639. combinePass.setVec4('bloomParams', this._bloomParams);
  1640. combinePass.addQueue(QueueHint.BLEND).addFullscreenQuad(bloomMaterial, 3);
  1641. };
  1642. _proto2._addFsrPass = function _addFsrPass(ppl, settings, fsrMaterial, id, width, height, ldrColorName, nativeWidth, nativeHeight, colorName) {
  1643. this._fsrTexSize.x = width;
  1644. this._fsrTexSize.y = height;
  1645. this._fsrTexSize.z = nativeWidth;
  1646. this._fsrTexSize.w = nativeHeight;
  1647. this._fsrParams.x = clamp(1.0 - settings.fsr.sharpness, 0.02, 0.98);
  1648. var fsrColorName = "FsrColor" + id;
  1649. var easuPass = ppl.addRenderPass(nativeWidth, nativeHeight, 'cc-fsr-easu');
  1650. easuPass.addRenderTarget(fsrColorName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1651. easuPass.addTexture(ldrColorName, 'outputResultMap');
  1652. easuPass.setVec4('g_platform', this._configs.platform);
  1653. easuPass.setVec4('fsrTexSize', this._fsrTexSize);
  1654. easuPass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(fsrMaterial, 0);
  1655. var rcasPass = ppl.addRenderPass(nativeWidth, nativeHeight, 'cc-fsr-rcas');
  1656. rcasPass.addRenderTarget(colorName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1657. rcasPass.addTexture(fsrColorName, 'outputResultMap');
  1658. rcasPass.setVec4('g_platform', this._configs.platform);
  1659. rcasPass.setVec4('fsrTexSize', this._fsrTexSize);
  1660. rcasPass.setVec4('fsrParams', this._fsrParams);
  1661. rcasPass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(fsrMaterial, 1);
  1662. return rcasPass;
  1663. };
  1664. _proto2._addFxaaPass = function _addFxaaPass(ppl, fxaaMaterial, width, height, ldrColorName, colorName) {
  1665. this._fxaaParams.x = width;
  1666. this._fxaaParams.y = height;
  1667. this._fxaaParams.z = 1 / width;
  1668. this._fxaaParams.w = 1 / height;
  1669. var pass = ppl.addRenderPass(width, height, 'cc-fxaa');
  1670. pass.addRenderTarget(colorName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  1671. pass.addTexture(ldrColorName, 'sceneColorMap');
  1672. pass.setVec4('g_platform', this._configs.platform);
  1673. pass.setVec4('texSize', this._fxaaParams);
  1674. pass.addQueue(QueueHint.OPAQUE).addFullscreenQuad(fxaaMaterial, 0);
  1675. return pass;
  1676. };
  1677. _proto2._addUIQueue = function _addUIQueue(camera, pass) {
  1678. var flags = SceneFlags.UI;
  1679. if (this._cameraConfigs.enableProfiler) {
  1680. flags |= SceneFlags.PROFILER;
  1681. pass.showStatistics = true;
  1682. }
  1683. pass.addQueue(QueueHint.BLEND, 'default', 'default').addScene(camera, flags);
  1684. }
  1685. // ----------------------------------------------------------------
  1686. // Forward
  1687. // ----------------------------------------------------------------
  1688. ;
  1689. _proto2._addForwardRadiancePasses = function _addForwardRadiancePasses(ppl, id, camera, width, height, mainLight, colorName, depthStencilName, disableMSAA, depthStencilStoreOp) {
  1690. if (disableMSAA === void 0) {
  1691. disableMSAA = false;
  1692. }
  1693. if (depthStencilStoreOp === void 0) {
  1694. depthStencilStoreOp = StoreOp.DISCARD;
  1695. }
  1696. // ----------------------------------------------------------------
  1697. // Dynamic states
  1698. // ----------------------------------------------------------------
  1699. // Prepare camera clear color
  1700. var clearColor = camera.clearColor; // Reduce C++/TS interop
  1701. this._clearColor.x = clearColor.x;
  1702. this._clearColor.y = clearColor.y;
  1703. this._clearColor.z = clearColor.z;
  1704. this._clearColor.w = clearColor.w;
  1705. // Prepare camera viewport
  1706. var viewport = camera.viewport; // Reduce C++/TS interop
  1707. this._viewport.left = Math.round(viewport.x * width);
  1708. this._viewport.top = Math.round(viewport.y * height);
  1709. // Here we must use camera.viewport.width instead of camera.viewport.z, which
  1710. // is undefined on native platform. The same as camera.viewport.height.
  1711. this._viewport.width = Math.max(Math.round(viewport.width * width), 1);
  1712. this._viewport.height = Math.max(Math.round(viewport.height * height), 1);
  1713. // MSAA
  1714. var enableMSAA = !disableMSAA && this._cameraConfigs.enableMSAA;
  1715. assert(!enableMSAA || this._cameraConfigs.singleForwardRadiancePass);
  1716. // ----------------------------------------------------------------
  1717. // Forward Lighting (Main Directional Light)
  1718. // ----------------------------------------------------------------
  1719. var pass = this._cameraConfigs.singleForwardRadiancePass ? this._addForwardSingleRadiancePass(ppl, id, camera, enableMSAA, width, height, mainLight, colorName, depthStencilName, depthStencilStoreOp) : this._addForwardMultipleRadiancePasses(ppl, id, camera, width, height, mainLight, colorName, depthStencilName, depthStencilStoreOp);
  1720. // Planar Shadow
  1721. if (this._cameraConfigs.enableMainLightPlanarShadowMap) {
  1722. this.addPlanarShadowQueue(camera, mainLight, pass);
  1723. }
  1724. // ----------------------------------------------------------------
  1725. // Forward Lighting (Blend)
  1726. // ----------------------------------------------------------------
  1727. // Add transparent queue
  1728. var sceneFlags = SceneFlags.BLEND | (camera.geometryRenderer ? SceneFlags.GEOMETRY : SceneFlags.NONE);
  1729. pass.addQueue(QueueHint.BLEND).addScene(camera, sceneFlags, mainLight || undefined);
  1730. return pass;
  1731. };
  1732. _proto2._addForwardSingleRadiancePass = function _addForwardSingleRadiancePass(ppl, id, camera, enableMSAA, width, height, mainLight, colorName, depthStencilName, depthStencilStoreOp) {
  1733. assert(this._cameraConfigs.singleForwardRadiancePass);
  1734. // ----------------------------------------------------------------
  1735. // Forward Lighting (Main Directional Light)
  1736. // ----------------------------------------------------------------
  1737. var pass;
  1738. if (enableMSAA) {
  1739. var msaaRadianceName = "MsaaRadiance" + id;
  1740. var msaaDepthStencilName = "MsaaDepthStencil" + id;
  1741. var sampleCount = this._cameraConfigs.settings.msaa.sampleCount;
  1742. var msPass = ppl.addMultisampleRenderPass(width, height, sampleCount, 0, 'default');
  1743. msPass.name = 'MsaaForwardPass';
  1744. // MSAA always discards depth stencil
  1745. this._buildForwardMainLightPass(msPass, id, camera, msaaRadianceName, msaaDepthStencilName, StoreOp.DISCARD, mainLight);
  1746. msPass.resolveRenderTarget(msaaRadianceName, colorName);
  1747. pass = msPass;
  1748. } else {
  1749. pass = ppl.addRenderPass(width, height, 'default');
  1750. pass.name = 'ForwardPass';
  1751. this._buildForwardMainLightPass(pass, id, camera, colorName, depthStencilName, depthStencilStoreOp, mainLight);
  1752. }
  1753. assert(pass !== undefined);
  1754. // Forward Lighting (Additive Lights)
  1755. this.forwardLighting.addLightQueues(pass, camera, this._configs.mobileMaxSpotLightShadowMaps);
  1756. return pass;
  1757. };
  1758. _proto2.addPlanarShadowQueue = function addPlanarShadowQueue(camera, mainLight, pass) {
  1759. pass.addQueue(QueueHint.BLEND, 'planar-shadow').addScene(camera, SceneFlags.SHADOW_CASTER | SceneFlags.PLANAR_SHADOW | SceneFlags.BLEND, mainLight || undefined);
  1760. };
  1761. _proto2._addForwardMultipleRadiancePasses = function _addForwardMultipleRadiancePasses(ppl, id, camera, width, height, mainLight, colorName, depthStencilName, depthStencilStoreOp) {
  1762. assert(!this._cameraConfigs.singleForwardRadiancePass);
  1763. // Forward Lighting (Main Directional Light)
  1764. var pass = ppl.addRenderPass(width, height, 'default');
  1765. pass.name = 'ForwardPass';
  1766. var firstStoreOp = this.forwardLighting.isMultipleLightPassesNeeded() ? StoreOp.STORE : depthStencilStoreOp;
  1767. this._buildForwardMainLightPass(pass, id, camera, colorName, depthStencilName, firstStoreOp, mainLight);
  1768. // Forward Lighting (Additive Lights)
  1769. pass = this.forwardLighting.addLightPasses(colorName, depthStencilName, depthStencilStoreOp, id, width, height, camera, this._viewport, ppl, pass);
  1770. return pass;
  1771. };
  1772. _proto2._buildReflectionProbePass = function _buildReflectionProbePass(pass, id, camera, colorName, depthStencilName, mainLight, scene) {
  1773. if (scene === void 0) {
  1774. scene = null;
  1775. }
  1776. // set viewport
  1777. var colorStoreOp = this._cameraConfigs.enableMSAA ? StoreOp.DISCARD : StoreOp.STORE;
  1778. // bind output render target
  1779. if (forwardNeedClearColor(camera)) {
  1780. this._reflectionProbeClearColor.x = camera.clearColor.x;
  1781. this._reflectionProbeClearColor.y = camera.clearColor.y;
  1782. this._reflectionProbeClearColor.z = camera.clearColor.z;
  1783. var clearColor = rendering.packRGBE(this._reflectionProbeClearColor);
  1784. this._clearColor.x = clearColor.x;
  1785. this._clearColor.y = clearColor.y;
  1786. this._clearColor.z = clearColor.z;
  1787. this._clearColor.w = clearColor.w;
  1788. pass.addRenderTarget(colorName, LoadOp.CLEAR, colorStoreOp, this._clearColor);
  1789. } else {
  1790. pass.addRenderTarget(colorName, LoadOp.LOAD, colorStoreOp);
  1791. }
  1792. // bind depth stencil buffer
  1793. if (camera.clearFlag & ClearFlagBit.DEPTH_STENCIL) {
  1794. pass.addDepthStencil(depthStencilName, LoadOp.CLEAR, StoreOp.DISCARD, camera.clearDepth, camera.clearStencil, camera.clearFlag & ClearFlagBit.DEPTH_STENCIL);
  1795. } else {
  1796. pass.addDepthStencil(depthStencilName, LoadOp.LOAD, StoreOp.DISCARD);
  1797. }
  1798. // Set shadow map if enabled
  1799. if (this._cameraConfigs.enableMainLightShadowMap) {
  1800. pass.addTexture("ShadowMap" + id, 'cc_shadowMap');
  1801. }
  1802. // TODO(zhouzhenglong): Separate OPAQUE and MASK queue
  1803. // add opaque and mask queue
  1804. pass.addQueue(QueueHint.NONE, 'reflect-map') // Currently we put OPAQUE and MASK into one queue, so QueueHint is NONE
  1805. .addScene(camera, SceneFlags.OPAQUE | SceneFlags.MASK | SceneFlags.REFLECTION_PROBE, mainLight || undefined, scene ? scene : undefined);
  1806. };
  1807. _proto2._tryAddReflectionProbePasses = function _tryAddReflectionProbePasses(ppl, id, mainLight, scene) {
  1808. var reflectionProbeManager = cclegacy.internal.reflectionProbeManager;
  1809. if (!reflectionProbeManager) {
  1810. return;
  1811. }
  1812. var probes = reflectionProbeManager.getProbes();
  1813. var maxProbeCount = 4;
  1814. var probeID = 0;
  1815. for (var _iterator10 = _createForOfIteratorHelperLoose(probes), _step10; !(_step10 = _iterator10()).done;) {
  1816. var probe = _step10.value;
  1817. if (!probe.needRender) {
  1818. continue;
  1819. }
  1820. var area = probe.renderArea();
  1821. var width = Math.max(Math.floor(area.x), 1);
  1822. var height = Math.max(Math.floor(area.y), 1);
  1823. if (probe.probeType === renderer.scene.ProbeType.PLANAR) {
  1824. if (!this._cameraConfigs.enablePlanarReflectionProbe) {
  1825. continue;
  1826. }
  1827. var window = probe.realtimePlanarTexture.window;
  1828. var colorName = "PlanarProbeRT" + probeID;
  1829. var depthStencilName = "PlanarProbeDS" + probeID;
  1830. // ProbeResource
  1831. ppl.addRenderWindow(colorName, this._cameraConfigs.radianceFormat, width, height, window);
  1832. ppl.addDepthStencil(depthStencilName, gfx.Format.DEPTH_STENCIL, width, height, ResourceResidency.MEMORYLESS);
  1833. // Rendering
  1834. var probePass = ppl.addRenderPass(width, height, 'default');
  1835. probePass.name = "PlanarReflectionProbe" + probeID;
  1836. this._buildReflectionProbePass(probePass, id, probe.camera, colorName, depthStencilName, mainLight, scene);
  1837. }
  1838. ++probeID;
  1839. if (probeID === maxProbeCount) {
  1840. break;
  1841. }
  1842. }
  1843. };
  1844. _proto2._initMaterials = function _initMaterials(ppl) {
  1845. if (this._initialized) {
  1846. return 0;
  1847. }
  1848. setupPipelineConfigs(ppl, this._configs);
  1849. // When add new effect asset, please add its uuid to the dependentAssets in cc.config.json.
  1850. this._copyAndTonemapMaterial._uuid = "builtin-pipeline-tone-mapping-material";
  1851. this._copyAndTonemapMaterial.initialize({
  1852. effectName: 'pipeline/post-process/tone-mapping'
  1853. });
  1854. if (this._copyAndTonemapMaterial.effectAsset) {
  1855. this._initialized = true;
  1856. }
  1857. return this._initialized ? 0 : 1;
  1858. };
  1859. return BuiltinPipelineBuilder;
  1860. }();
  1861. rendering.setCustomPipeline('Builtin', new BuiltinPipelineBuilder());
  1862. } // if (rendering)
  1863. cclegacy._RF.pop();
  1864. }
  1865. };
  1866. });
  1867. System.register("chunks:///_virtual/internal", ['./builtin-pipeline-settings.ts', './builtin-pipeline-types.ts', './builtin-pipeline.ts'], function () {
  1868. return {
  1869. setters: [null, null, null],
  1870. execute: function () {}
  1871. };
  1872. });
  1873. (function(r) {
  1874. r('virtual:///prerequisite-imports/internal', 'chunks:///_virtual/internal');
  1875. })(function(mid, cid) {
  1876. System.register(mid, [cid], function (_export, _context) {
  1877. return {
  1878. setters: [function(_m) {
  1879. var _exportObj = {};
  1880. for (var _key in _m) {
  1881. if (_key !== "default" && _key !== "__esModule") _exportObj[_key] = _m[_key];
  1882. }
  1883. _export(_exportObj);
  1884. }],
  1885. execute: function () { }
  1886. };
  1887. });
  1888. });