58736b97e6eaa1d43b32ca964d67346769e8222e.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. System.register(["__unresolved_0", "cc", "cc/env", "__unresolved_1", "__unresolved_2", "__unresolved_3"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, assert, CCBoolean, CCFloat, CCInteger, gfx, Material, rendering, Vec3, Vec4, EDITOR, BuiltinPipelineSettings, BuiltinPipelinePassBuilder, getPingPongRenderTarget, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _crd, ccclass, disallowMultiple, executeInEditMode, menu, property, requireComponent, type, Color, LoadOp, StoreOp, BuiltinDepthOfFieldPass;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. function _reportPossibleCrUseOfBuiltinPipelineSettings(extras) {
  8. _reporterNs.report("BuiltinPipelineSettings", "./builtin-pipeline-settings", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfBuiltinPipelinePassBuilder(extras) {
  11. _reporterNs.report("BuiltinPipelinePassBuilder", "./builtin-pipeline-pass", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfCameraConfigs(extras) {
  14. _reporterNs.report("CameraConfigs", "./builtin-pipeline", _context.meta, extras);
  15. }
  16. function _reportPossibleCrUseOfgetPingPongRenderTarget(extras) {
  17. _reporterNs.report("getPingPongRenderTarget", "./builtin-pipeline", _context.meta, extras);
  18. }
  19. function _reportPossibleCrUseOfPipelineConfigs(extras) {
  20. _reporterNs.report("PipelineConfigs", "./builtin-pipeline", _context.meta, extras);
  21. }
  22. function _reportPossibleCrUseOfPipelineContext(extras) {
  23. _reporterNs.report("PipelineContext", "./builtin-pipeline", _context.meta, extras);
  24. }
  25. return {
  26. setters: [function (_unresolved_) {
  27. _reporterNs = _unresolved_;
  28. }, function (_cc) {
  29. _cclegacy = _cc.cclegacy;
  30. __checkObsolete__ = _cc.__checkObsolete__;
  31. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  32. _decorator = _cc._decorator;
  33. assert = _cc.assert;
  34. CCBoolean = _cc.CCBoolean;
  35. CCFloat = _cc.CCFloat;
  36. CCInteger = _cc.CCInteger;
  37. gfx = _cc.gfx;
  38. Material = _cc.Material;
  39. rendering = _cc.rendering;
  40. Vec3 = _cc.Vec3;
  41. Vec4 = _cc.Vec4;
  42. }, function (_ccEnv) {
  43. EDITOR = _ccEnv.EDITOR;
  44. }, function (_unresolved_2) {
  45. BuiltinPipelineSettings = _unresolved_2.BuiltinPipelineSettings;
  46. }, function (_unresolved_3) {
  47. BuiltinPipelinePassBuilder = _unresolved_3.BuiltinPipelinePassBuilder;
  48. }, function (_unresolved_4) {
  49. getPingPongRenderTarget = _unresolved_4.getPingPongRenderTarget;
  50. }],
  51. execute: function () {
  52. _crd = true;
  53. _cclegacy._RF.push({}, "11f31MOwIxHu6IJcdEUWU5t", "builtin-dof-pass", undefined);
  54. /*
  55. Copyright (c) 2021-2024 Xiamen Yaji Software Co., Ltd.
  56. https://www.cocos.com/
  57. Permission is hereby granted, free of charge, to any person obtaining a copy
  58. of this software and associated documentation files (the "Software"), to deal
  59. in the Software without restriction, including without limitation the rights to
  60. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  61. of the Software, and to permit persons to whom the Software is furnished to do so,
  62. subject to the following conditions:
  63. The above copyright notice and this permission notice shall be included in
  64. all copies or substantial portions of the Software.
  65. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  66. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  67. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  68. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  69. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  70. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  71. THE SOFTWARE.
  72. */
  73. __checkObsolete__(['_decorator', 'assert', 'CCBoolean', 'CCFloat', 'CCInteger', 'gfx', 'Material', 'renderer', 'rendering', 'Vec3', 'Vec4']);
  74. ({
  75. ccclass,
  76. disallowMultiple,
  77. executeInEditMode,
  78. menu,
  79. property,
  80. requireComponent,
  81. type
  82. } = _decorator);
  83. ({
  84. Color,
  85. LoadOp,
  86. StoreOp
  87. } = gfx);
  88. _export("BuiltinDepthOfFieldPass", BuiltinDepthOfFieldPass = (_dec = ccclass('BuiltinDepthOfFieldPass'), _dec2 = menu('Rendering/BuiltinDepthOfFieldPass'), _dec3 = requireComponent(_crd && BuiltinPipelineSettings === void 0 ? (_reportPossibleCrUseOfBuiltinPipelineSettings({
  89. error: Error()
  90. }), BuiltinPipelineSettings) : BuiltinPipelineSettings), _dec4 = property({
  91. group: {
  92. id: 'BuiltinPass',
  93. name: 'Pass Settings',
  94. style: 'section'
  95. },
  96. type: CCInteger
  97. }), _dec5 = property({
  98. group: {
  99. id: 'BuiltinPass',
  100. name: 'Pass Settings',
  101. style: 'section'
  102. },
  103. type: CCInteger
  104. }), _dec6 = property({
  105. group: {
  106. id: 'DepthOfField',
  107. name: 'DepthOfField (PostProcessing)',
  108. style: 'section'
  109. },
  110. type: CCBoolean,
  111. visible: true
  112. }), _dec7 = property({
  113. group: {
  114. id: 'DepthOfField',
  115. name: 'DepthOfField (PostProcessing)',
  116. style: 'section'
  117. },
  118. type: Material,
  119. visible: true
  120. }), _dec8 = property({
  121. group: {
  122. id: 'DepthOfField',
  123. name: 'DepthOfField (PostProcessing)',
  124. style: 'section'
  125. },
  126. type: CCFloat,
  127. min: 0,
  128. visible: true
  129. }), _dec9 = property({
  130. group: {
  131. id: 'DepthOfField',
  132. name: 'DepthOfField (PostProcessing)',
  133. style: 'section'
  134. },
  135. type: CCFloat,
  136. min: 0,
  137. visible: true
  138. }), _dec10 = property({
  139. group: {
  140. id: 'DepthOfField',
  141. name: 'DepthOfField (PostProcessing)',
  142. style: 'section'
  143. },
  144. type: CCFloat,
  145. range: [0.0, 2, 0.01],
  146. slide: true,
  147. visible: true
  148. }), _dec11 = type(CCFloat), _dec12 = property({
  149. group: {
  150. id: 'DepthOfField',
  151. name: 'DepthOfField (PostProcessing)',
  152. style: 'section'
  153. },
  154. type: CCFloat,
  155. range: [0.01, 10, 0.01],
  156. slide: true,
  157. visible: true
  158. }), _dec13 = type(Vec3), _dec14 = property({
  159. group: {
  160. id: 'DepthOfField',
  161. name: 'DepthOfField (PostProcessing)',
  162. style: 'section'
  163. },
  164. type: Vec3,
  165. visible: true
  166. }), _dec(_class = _dec2(_class = _dec3(_class = disallowMultiple(_class = executeInEditMode(_class = (_class2 = class BuiltinDepthOfFieldPass extends (_crd && BuiltinPipelinePassBuilder === void 0 ? (_reportPossibleCrUseOfBuiltinPipelinePassBuilder({
  167. error: Error()
  168. }), BuiltinPipelinePassBuilder) : BuiltinPipelinePassBuilder) {
  169. constructor() {
  170. super(...arguments);
  171. _initializerDefineProperty(this, "configOrder", _descriptor, this);
  172. _initializerDefineProperty(this, "renderOrder", _descriptor2, this);
  173. _initializerDefineProperty(this, "_enableDof", _descriptor3, this);
  174. _initializerDefineProperty(this, "_material", _descriptor4, this);
  175. _initializerDefineProperty(this, "_minRange", _descriptor5, this);
  176. _initializerDefineProperty(this, "_maxRange", _descriptor6, this);
  177. _initializerDefineProperty(this, "_blurRadius", _descriptor7, this);
  178. _initializerDefineProperty(this, "_intensity", _descriptor8, this);
  179. _initializerDefineProperty(this, "_focusPos", _descriptor9, this);
  180. // Runtime members
  181. this._clearColorTransparentBlack = new Color(0, 0, 0, 0);
  182. this._cocParams = new Vec4(0, 0, 0, 0);
  183. this._focusPosVec4 = new Vec4(0, 0, 0, 1);
  184. this._cocTexSize = new Vec4(0, 0, 0, 0);
  185. }
  186. // DepthOfField
  187. set dofEnable(value) {
  188. this._enableDof = value;
  189. if (EDITOR) {
  190. this._parent._tryEnableEditorPreview();
  191. }
  192. }
  193. get dofEnable() {
  194. return this._enableDof;
  195. }
  196. set dofMaterial(value) {
  197. if (this._material === value) {
  198. return;
  199. }
  200. this._material = value;
  201. if (EDITOR) {
  202. this._parent._tryEnableEditorPreview();
  203. }
  204. }
  205. get dofMaterial() {
  206. return this._material;
  207. }
  208. set dofMinRange(value) {
  209. this._minRange = value;
  210. }
  211. get dofMinRange() {
  212. return this._minRange;
  213. }
  214. set dofMaxRange(value) {
  215. this._maxRange = value;
  216. }
  217. get dofMaxRange() {
  218. return this._maxRange;
  219. }
  220. set dofIntensity(value) {
  221. this._intensity = value;
  222. }
  223. get dofIntensity() {
  224. return this._intensity;
  225. }
  226. set dofBlurRadius(value) {
  227. this._blurRadius = value;
  228. }
  229. get dofBlurRadius() {
  230. return this._blurRadius;
  231. }
  232. set dofFocusPos(value) {
  233. this._focusPos = value;
  234. }
  235. get dofFocusPos() {
  236. return this._focusPos;
  237. } // PipelinePassBuilder
  238. getConfigOrder() {
  239. return this.configOrder;
  240. }
  241. getRenderOrder() {
  242. return this.renderOrder;
  243. }
  244. configCamera(camera, pplConfigs, cameraConfigs) {
  245. cameraConfigs.enableDof = pplConfigs.supportDepthSample && this._enableDof && !!this._material;
  246. if (cameraConfigs.enableDof) {
  247. // Output scene depth, this is allowed but has performance impact
  248. cameraConfigs.enableStoreSceneDepth = true;
  249. ++cameraConfigs.remainingPasses;
  250. }
  251. }
  252. windowResize(ppl, pplConfigs, cameraConfigs, window) {
  253. var id = window.renderWindowId;
  254. if (cameraConfigs.enableDof) {
  255. ppl.addRenderTarget("DofRadiance" + id, cameraConfigs.radianceFormat, cameraConfigs.width, cameraConfigs.height);
  256. }
  257. }
  258. setup(ppl, pplConfigs, cameraConfigs, camera, context, prevRenderPass) {
  259. if (!cameraConfigs.enableDof) {
  260. return prevRenderPass;
  261. }
  262. --cameraConfigs.remainingPasses;
  263. assert(!!this._material);
  264. if (cameraConfigs.remainingPasses === 0) {
  265. return this._addDepthOfFieldPasses(ppl, pplConfigs, cameraConfigs, this._material, camera, cameraConfigs.width, cameraConfigs.height, context.colorName, context.depthStencilName, cameraConfigs.colorName);
  266. } else {
  267. var prefix = cameraConfigs.enableShadingScale ? "ScaledRadiance" : "Radiance";
  268. var outputRadianceName = (_crd && getPingPongRenderTarget === void 0 ? (_reportPossibleCrUseOfgetPingPongRenderTarget({
  269. error: Error()
  270. }), getPingPongRenderTarget) : getPingPongRenderTarget)(context.colorName, prefix, cameraConfigs.renderWindowId);
  271. var inputRadianceName = context.colorName;
  272. context.colorName = outputRadianceName;
  273. return this._addDepthOfFieldPasses(ppl, pplConfigs, cameraConfigs, this._material, camera, cameraConfigs.width, cameraConfigs.height, inputRadianceName, context.depthStencilName, outputRadianceName);
  274. }
  275. }
  276. _addDepthOfFieldPasses(ppl, pplConfigs, cameraConfigs, dofMaterial, camera, width, height, inputRadiance, inputDepthStencil, outputRadianceName) {
  277. this._cocParams.x = this._minRange;
  278. this._cocParams.y = this._maxRange;
  279. this._cocParams.z = this._blurRadius;
  280. this._cocParams.w = this._intensity;
  281. this._focusPosVec4.x = this._focusPos.x;
  282. this._focusPosVec4.y = this._focusPos.y;
  283. this._focusPosVec4.z = this._focusPos.z;
  284. this._cocTexSize.x = 1.0 / width;
  285. this._cocTexSize.y = 1.0 / height;
  286. this._cocTexSize.z = width;
  287. this._cocTexSize.w = height;
  288. var id = cameraConfigs.renderWindowId;
  289. var tempRadiance = "DofRadiance" + id; // Blur Pass
  290. var blurPass = ppl.addRenderPass(width, height, 'cc-dof-blur');
  291. blurPass.addRenderTarget(tempRadiance, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  292. blurPass.addTexture(inputRadiance, 'screenTex');
  293. blurPass.setVec4('g_platform', pplConfigs.platform);
  294. blurPass.setVec4('blurParams', this._cocParams);
  295. blurPass.setVec4('mainTexTexelSize', this._cocTexSize);
  296. blurPass.addQueue(rendering.QueueHint.OPAQUE).addCameraQuad(camera, dofMaterial, 0); // addCameraQuad will set camera related UBOs
  297. // coc pass
  298. var cocPass = ppl.addRenderPass(width, height, 'cc-dof-coc');
  299. cocPass.addRenderTarget(outputRadianceName, LoadOp.CLEAR, StoreOp.STORE, this._clearColorTransparentBlack);
  300. cocPass.addTexture(tempRadiance, 'colorTex');
  301. cocPass.addTexture(inputDepthStencil, "DepthTex");
  302. cocPass.addTexture(inputRadiance, "screenTex");
  303. cocPass.setVec4('g_platform', pplConfigs.platform);
  304. cocPass.setMat4('proj', camera.matProj);
  305. cocPass.setMat4('invProj', camera.matProjInv);
  306. cocPass.setMat4('viewMatInv', camera.node.worldMatrix);
  307. cocPass.setVec4('cocParams', this._cocParams);
  308. cocPass.setVec4('focus', this._focusPosVec4);
  309. cocPass.addQueue(rendering.QueueHint.OPAQUE).addCameraQuad(camera, dofMaterial, 1);
  310. return cocPass;
  311. }
  312. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "configOrder", [_dec4], {
  313. configurable: true,
  314. enumerable: true,
  315. writable: true,
  316. initializer: function initializer() {
  317. return 0;
  318. }
  319. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "renderOrder", [_dec5], {
  320. configurable: true,
  321. enumerable: true,
  322. writable: true,
  323. initializer: function initializer() {
  324. return 150;
  325. }
  326. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_enableDof", [property], {
  327. configurable: true,
  328. enumerable: true,
  329. writable: true,
  330. initializer: function initializer() {
  331. return false;
  332. }
  333. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_material", [property], {
  334. configurable: true,
  335. enumerable: true,
  336. writable: true,
  337. initializer: function initializer() {
  338. return null;
  339. }
  340. }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "_minRange", [property], {
  341. configurable: true,
  342. enumerable: true,
  343. writable: true,
  344. initializer: function initializer() {
  345. return 0;
  346. }
  347. }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "_maxRange", [property], {
  348. configurable: true,
  349. enumerable: true,
  350. writable: true,
  351. initializer: function initializer() {
  352. return 2;
  353. }
  354. }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "_blurRadius", [property], {
  355. configurable: true,
  356. enumerable: true,
  357. writable: true,
  358. initializer: function initializer() {
  359. return 1;
  360. }
  361. }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "_intensity", [property], {
  362. configurable: true,
  363. enumerable: true,
  364. writable: true,
  365. initializer: function initializer() {
  366. return 1;
  367. }
  368. }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "_focusPos", [property], {
  369. configurable: true,
  370. enumerable: true,
  371. writable: true,
  372. initializer: function initializer() {
  373. return new Vec3(0, 0, 0);
  374. }
  375. }), _applyDecoratedDescriptor(_class2.prototype, "dofEnable", [_dec6], Object.getOwnPropertyDescriptor(_class2.prototype, "dofEnable"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofMaterial", [_dec7], Object.getOwnPropertyDescriptor(_class2.prototype, "dofMaterial"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofMinRange", [_dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "dofMinRange"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofMaxRange", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "dofMaxRange"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofIntensity", [_dec10], Object.getOwnPropertyDescriptor(_class2.prototype, "dofIntensity"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofBlurRadius", [_dec11, _dec12], Object.getOwnPropertyDescriptor(_class2.prototype, "dofBlurRadius"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "dofFocusPos", [_dec13, _dec14], Object.getOwnPropertyDescriptor(_class2.prototype, "dofFocusPos"), _class2.prototype)), _class2)) || _class) || _class) || _class) || _class) || _class));
  376. _cclegacy._RF.pop();
  377. _crd = false;
  378. }
  379. };
  380. });
  381. //# sourceMappingURL=58736b97e6eaa1d43b32ca964d67346769e8222e.js.map