SSRPass.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. import {
  2. AddEquation,
  3. Color,
  4. NormalBlending,
  5. DepthTexture,
  6. SrcAlphaFactor,
  7. OneMinusSrcAlphaFactor,
  8. LinearFilter,
  9. MeshNormalMaterial,
  10. MeshBasicMaterial,
  11. NearestFilter,
  12. NoBlending,
  13. RGBAFormat,
  14. ShaderMaterial,
  15. UniformsUtils,
  16. UnsignedShortType,
  17. WebGLRenderTarget,
  18. HalfFloatType,
  19. } from '../../../build/three.module.js';
  20. import { Pass, FullScreenQuad } from '../postprocessing/Pass.js';
  21. import { SSRShader } from '../shaders/SSRShader.js';
  22. import { SSRBlurShader } from '../shaders/SSRShader.js';
  23. import { SSRDepthShader } from '../shaders/SSRShader.js';
  24. import { CopyShader } from '../shaders/CopyShader.js';
  25. class SSRPass extends Pass {
  26. constructor( { renderer, scene, camera, width, height, selects, encoding, bouncing = false, morphTargets = false, groundReflector } ) {
  27. super();
  28. this.width = ( width !== undefined ) ? width : 512;
  29. this.height = ( height !== undefined ) ? height : 512;
  30. this.clear = true;
  31. this.renderer = renderer;
  32. this.scene = scene;
  33. this.camera = camera;
  34. this.groundReflector = groundReflector;
  35. this.opacity = SSRShader.uniforms.opacity.value;
  36. this.output = 0;
  37. this.maxDistance = SSRShader.uniforms.maxDistance.value;
  38. this.surfDist = SSRShader.uniforms.surfDist.value;
  39. this.encoding = encoding;
  40. this.tempColor = new Color();
  41. this._selects = selects;
  42. this.selective = Array.isArray( this._selects );
  43. Object.defineProperty( this, 'selects', {
  44. get() {
  45. return this._selects;
  46. },
  47. set( val ) {
  48. if ( this._selects === val ) return;
  49. this._selects = val;
  50. if ( Array.isArray( val ) ) {
  51. this.selective = true;
  52. this.ssrMaterial.defines.SELECTIVE = true;
  53. this.ssrMaterial.needsUpdate = true;
  54. } else {
  55. this.selective = false;
  56. this.ssrMaterial.defines.SELECTIVE = false;
  57. this.ssrMaterial.needsUpdate = true;
  58. }
  59. }
  60. } );
  61. this._bouncing = bouncing;
  62. Object.defineProperty( this, 'bouncing', {
  63. get() {
  64. return this._bouncing;
  65. },
  66. set( val ) {
  67. if ( this._bouncing === val ) return;
  68. this._bouncing = val;
  69. if ( val ) {
  70. this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.prevRenderTarget.texture;
  71. } else {
  72. this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
  73. }
  74. }
  75. } );
  76. this.blur = true;
  77. this._distanceAttenuation = SSRShader.defines.DISTANCE_ATTENUATION;
  78. Object.defineProperty( this, 'distanceAttenuation', {
  79. get() {
  80. return this._distanceAttenuation;
  81. },
  82. set( val ) {
  83. if ( this._distanceAttenuation === val ) return;
  84. this._distanceAttenuation = val;
  85. this.ssrMaterial.defines.DISTANCE_ATTENUATION = val;
  86. this.ssrMaterial.needsUpdate = true;
  87. }
  88. } );
  89. this._fresnel = SSRShader.defines.FRESNEL;
  90. Object.defineProperty( this, 'fresnel', {
  91. get() {
  92. return this._fresnel;
  93. },
  94. set( val ) {
  95. if ( this._fresnel === val ) return;
  96. this._fresnel = val;
  97. this.ssrMaterial.defines.FRESNEL = val;
  98. this.ssrMaterial.needsUpdate = true;
  99. }
  100. } );
  101. this._infiniteThick = SSRShader.defines.INFINITE_THICK;
  102. Object.defineProperty( this, 'infiniteThick', {
  103. get() {
  104. return this._infiniteThick;
  105. },
  106. set( val ) {
  107. if ( this._infiniteThick === val ) return;
  108. this._infiniteThick = val;
  109. this.ssrMaterial.defines.INFINITE_THICK = val;
  110. this.ssrMaterial.needsUpdate = true;
  111. }
  112. } );
  113. this.thickTolerance = SSRShader.uniforms.thickTolerance.value;
  114. // beauty render target with depth buffer
  115. const depthTexture = new DepthTexture();
  116. depthTexture.type = UnsignedShortType;
  117. depthTexture.minFilter = NearestFilter;
  118. depthTexture.magFilter = NearestFilter;
  119. this.beautyRenderTarget = new WebGLRenderTarget( this.width, this.height, {
  120. minFilter: LinearFilter,
  121. magFilter: LinearFilter,
  122. format: RGBAFormat,
  123. depthTexture: depthTexture,
  124. depthBuffer: true
  125. } );
  126. //for bouncing
  127. this.prevRenderTarget = new WebGLRenderTarget( this.width, this.height, {
  128. minFilter: LinearFilter,
  129. magFilter: LinearFilter,
  130. format: RGBAFormat,
  131. } );
  132. // normal render target
  133. this.normalRenderTarget = new WebGLRenderTarget( this.width, this.height, {
  134. minFilter: NearestFilter,
  135. magFilter: NearestFilter,
  136. format: RGBAFormat,
  137. type: HalfFloatType,
  138. } );
  139. // metalness render target
  140. this.metalnessRenderTarget = new WebGLRenderTarget( this.width, this.height, {
  141. minFilter: NearestFilter,
  142. magFilter: NearestFilter,
  143. format: RGBAFormat
  144. } );
  145. // ssr render target
  146. this.ssrRenderTarget = new WebGLRenderTarget( this.width, this.height, {
  147. minFilter: LinearFilter,
  148. magFilter: LinearFilter,
  149. format: RGBAFormat
  150. } );
  151. this.blurRenderTarget = this.ssrRenderTarget.clone();
  152. this.blurRenderTarget2 = this.ssrRenderTarget.clone();
  153. // this.blurRenderTarget3 = this.ssrRenderTarget.clone();
  154. // ssr material
  155. if ( SSRShader === undefined ) {
  156. console.error( 'THREE.SSRPass: The pass relies on SSRShader.' );
  157. }
  158. this.ssrMaterial = new ShaderMaterial( {
  159. defines: Object.assign( {}, SSRShader.defines, {
  160. MAX_STEP: Math.sqrt( this.width * this.width + this.height * this.height )
  161. } ),
  162. uniforms: UniformsUtils.clone( SSRShader.uniforms ),
  163. vertexShader: SSRShader.vertexShader,
  164. fragmentShader: SSRShader.fragmentShader,
  165. blending: NoBlending
  166. } );
  167. this.ssrMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
  168. this.ssrMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
  169. this.ssrMaterial.defines.SELECTIVE = this.selective;
  170. this.ssrMaterial.needsUpdate = true;
  171. this.ssrMaterial.uniforms[ 'tMetalness' ].value = this.metalnessRenderTarget.texture;
  172. this.ssrMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
  173. this.ssrMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
  174. this.ssrMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
  175. this.ssrMaterial.uniforms[ 'surfDist' ].value = this.surfDist;
  176. this.ssrMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
  177. this.ssrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
  178. this.ssrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
  179. // normal material
  180. this.normalMaterial = new MeshNormalMaterial( { morphTargets } );
  181. this.normalMaterial.blending = NoBlending;
  182. // metalnessOn material
  183. this.metalnessOnMaterial = new MeshBasicMaterial( {
  184. color: 'white'
  185. } );
  186. // metalnessOff material
  187. this.metalnessOffMaterial = new MeshBasicMaterial( {
  188. color: 'black'
  189. } );
  190. // blur material
  191. this.blurMaterial = new ShaderMaterial( {
  192. defines: Object.assign( {}, SSRBlurShader.defines ),
  193. uniforms: UniformsUtils.clone( SSRBlurShader.uniforms ),
  194. vertexShader: SSRBlurShader.vertexShader,
  195. fragmentShader: SSRBlurShader.fragmentShader
  196. } );
  197. this.blurMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
  198. this.blurMaterial.uniforms[ 'resolution' ].value.set( this.width, this.height );
  199. // blur material 2
  200. this.blurMaterial2 = new ShaderMaterial( {
  201. defines: Object.assign( {}, SSRBlurShader.defines ),
  202. uniforms: UniformsUtils.clone( SSRBlurShader.uniforms ),
  203. vertexShader: SSRBlurShader.vertexShader,
  204. fragmentShader: SSRBlurShader.fragmentShader
  205. } );
  206. this.blurMaterial2.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget.texture;
  207. this.blurMaterial2.uniforms[ 'resolution' ].value.set( this.width, this.height );
  208. // // blur material 3
  209. // this.blurMaterial3 = new ShaderMaterial({
  210. // defines: Object.assign({}, SSRBlurShader.defines),
  211. // uniforms: UniformsUtils.clone(SSRBlurShader.uniforms),
  212. // vertexShader: SSRBlurShader.vertexShader,
  213. // fragmentShader: SSRBlurShader.fragmentShader
  214. // });
  215. // this.blurMaterial3.uniforms['tDiffuse'].value = this.blurRenderTarget2.texture;
  216. // this.blurMaterial3.uniforms['resolution'].value.set(this.width, this.height);
  217. // material for rendering the depth
  218. this.depthRenderMaterial = new ShaderMaterial( {
  219. defines: Object.assign( {}, SSRDepthShader.defines ),
  220. uniforms: UniformsUtils.clone( SSRDepthShader.uniforms ),
  221. vertexShader: SSRDepthShader.vertexShader,
  222. fragmentShader: SSRDepthShader.fragmentShader,
  223. blending: NoBlending
  224. } );
  225. this.depthRenderMaterial.uniforms[ 'tDepth' ].value = this.beautyRenderTarget.depthTexture;
  226. this.depthRenderMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
  227. this.depthRenderMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
  228. // material for rendering the content of a render target
  229. this.copyMaterial = new ShaderMaterial( {
  230. uniforms: UniformsUtils.clone( CopyShader.uniforms ),
  231. vertexShader: CopyShader.vertexShader,
  232. fragmentShader: CopyShader.fragmentShader,
  233. transparent: true,
  234. depthTest: false,
  235. depthWrite: false,
  236. blendSrc: SrcAlphaFactor,
  237. blendDst: OneMinusSrcAlphaFactor,
  238. blendEquation: AddEquation,
  239. blendSrcAlpha: SrcAlphaFactor,
  240. blendDstAlpha: OneMinusSrcAlphaFactor,
  241. blendEquationAlpha: AddEquation,
  242. // premultipliedAlpha:true,
  243. } );
  244. this.fsQuad = new FullScreenQuad( null );
  245. this.originalClearColor = new Color();
  246. }
  247. dispose() {
  248. // dispose render targets
  249. this.beautyRenderTarget.dispose();
  250. this.prevRenderTarget.dispose();
  251. this.normalRenderTarget.dispose();
  252. this.metalnessRenderTarget.dispose();
  253. this.ssrRenderTarget.dispose();
  254. this.blurRenderTarget.dispose();
  255. this.blurRenderTarget2.dispose();
  256. // this.blurRenderTarget3.dispose();
  257. // dispose materials
  258. this.normalMaterial.dispose();
  259. this.metalnessOnMaterial.dispose();
  260. this.metalnessOffMaterial.dispose();
  261. this.blurMaterial.dispose();
  262. this.blurMaterial2.dispose();
  263. this.copyMaterial.dispose();
  264. this.depthRenderMaterial.dispose();
  265. // dipsose full screen quad
  266. this.fsQuad.dispose();
  267. }
  268. render( renderer, writeBuffer /*, readBuffer, deltaTime, maskActive */ ) {
  269. // render beauty and depth
  270. if ( this.encoding ) this.beautyRenderTarget.texture.encoding = this.encoding;
  271. renderer.setRenderTarget( this.beautyRenderTarget );
  272. renderer.clear();
  273. if ( this.groundReflector ) {
  274. this.groundReflector.visible = false;
  275. this.groundReflector.doRender( this.renderer, this.scene, this.camera );
  276. this.groundReflector.visible = true;
  277. }
  278. renderer.render( this.scene, this.camera );
  279. if ( this.groundReflector ) this.groundReflector.visible = false;
  280. // render normals
  281. this.renderOverride( renderer, this.normalMaterial, this.normalRenderTarget, 0, 0 );
  282. // render metalnesses
  283. if ( this.selective ) {
  284. this.renderMetalness( renderer, this.metalnessOnMaterial, this.metalnessRenderTarget, 0, 0 );
  285. }
  286. // render SSR
  287. this.ssrMaterial.uniforms[ 'opacity' ].value = this.opacity;
  288. this.ssrMaterial.uniforms[ 'maxDistance' ].value = this.maxDistance;
  289. this.ssrMaterial.uniforms[ 'surfDist' ].value = this.surfDist;
  290. this.ssrMaterial.uniforms[ 'thickTolerance' ].value = this.thickTolerance;
  291. this.renderPass( renderer, this.ssrMaterial, this.ssrRenderTarget );
  292. // render blur
  293. if ( this.blur ) {
  294. this.renderPass( renderer, this.blurMaterial, this.blurRenderTarget );
  295. this.renderPass( renderer, this.blurMaterial2, this.blurRenderTarget2 );
  296. // this.renderPass(renderer, this.blurMaterial3, this.blurRenderTarget3);
  297. }
  298. // output result to screen
  299. switch ( this.output ) {
  300. case SSRPass.OUTPUT.Default:
  301. if ( this.bouncing ) {
  302. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
  303. this.copyMaterial.blending = NoBlending;
  304. this.renderPass( renderer, this.copyMaterial, this.prevRenderTarget );
  305. if ( this.blur )
  306. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget2.texture;
  307. else
  308. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
  309. this.copyMaterial.blending = NormalBlending;
  310. this.renderPass( renderer, this.copyMaterial, this.prevRenderTarget );
  311. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.prevRenderTarget.texture;
  312. this.copyMaterial.blending = NoBlending;
  313. this.renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
  314. } else {
  315. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
  316. this.copyMaterial.blending = NoBlending;
  317. this.renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
  318. if ( this.blur )
  319. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget2.texture;
  320. else
  321. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
  322. this.copyMaterial.blending = NormalBlending;
  323. this.renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
  324. }
  325. break;
  326. case SSRPass.OUTPUT.SSR:
  327. if ( this.blur )
  328. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget2.texture;
  329. else
  330. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
  331. this.copyMaterial.blending = NoBlending;
  332. this.renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
  333. if ( this.bouncing ) {
  334. if ( this.blur )
  335. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.blurRenderTarget2.texture;
  336. else
  337. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
  338. this.copyMaterial.blending = NoBlending;
  339. this.renderPass( renderer, this.copyMaterial, this.prevRenderTarget );
  340. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssrRenderTarget.texture;
  341. this.copyMaterial.blending = NormalBlending;
  342. this.renderPass( renderer, this.copyMaterial, this.prevRenderTarget );
  343. }
  344. break;
  345. case SSRPass.OUTPUT.Beauty:
  346. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.beautyRenderTarget.texture;
  347. this.copyMaterial.blending = NoBlending;
  348. this.renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
  349. break;
  350. case SSRPass.OUTPUT.Depth:
  351. this.renderPass( renderer, this.depthRenderMaterial, this.renderToScreen ? null : writeBuffer );
  352. break;
  353. case SSRPass.OUTPUT.Normal:
  354. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.normalRenderTarget.texture;
  355. this.copyMaterial.blending = NoBlending;
  356. this.renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
  357. break;
  358. case SSRPass.OUTPUT.Metalness:
  359. this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.metalnessRenderTarget.texture;
  360. this.copyMaterial.blending = NoBlending;
  361. this.renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
  362. break;
  363. default:
  364. console.warn( 'THREE.SSRPass: Unknown output type.' );
  365. }
  366. }
  367. renderPass( renderer, passMaterial, renderTarget, clearColor, clearAlpha ) {
  368. // save original state
  369. this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
  370. const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
  371. const originalAutoClear = renderer.autoClear;
  372. renderer.setRenderTarget( renderTarget );
  373. // setup pass state
  374. renderer.autoClear = false;
  375. if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
  376. renderer.setClearColor( clearColor );
  377. renderer.setClearAlpha( clearAlpha || 0.0 );
  378. renderer.clear();
  379. }
  380. this.fsQuad.material = passMaterial;
  381. this.fsQuad.render( renderer );
  382. // restore original state
  383. renderer.autoClear = originalAutoClear;
  384. renderer.setClearColor( this.originalClearColor );
  385. renderer.setClearAlpha( originalClearAlpha );
  386. }
  387. renderOverride( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
  388. this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
  389. const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
  390. const originalAutoClear = renderer.autoClear;
  391. renderer.setRenderTarget( renderTarget );
  392. renderer.autoClear = false;
  393. clearColor = overrideMaterial.clearColor || clearColor;
  394. clearAlpha = overrideMaterial.clearAlpha || clearAlpha;
  395. if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
  396. renderer.setClearColor( clearColor );
  397. renderer.setClearAlpha( clearAlpha || 0.0 );
  398. renderer.clear();
  399. }
  400. this.scene.overrideMaterial = overrideMaterial;
  401. renderer.render( this.scene, this.camera );
  402. this.scene.overrideMaterial = null;
  403. // restore original state
  404. renderer.autoClear = originalAutoClear;
  405. renderer.setClearColor( this.originalClearColor );
  406. renderer.setClearAlpha( originalClearAlpha );
  407. }
  408. renderMetalness( renderer, overrideMaterial, renderTarget, clearColor, clearAlpha ) {
  409. this.originalClearColor.copy( renderer.getClearColor( this.tempColor ) );
  410. const originalClearAlpha = renderer.getClearAlpha( this.tempColor );
  411. const originalAutoClear = renderer.autoClear;
  412. renderer.setRenderTarget( renderTarget );
  413. renderer.autoClear = false;
  414. clearColor = overrideMaterial.clearColor || clearColor;
  415. clearAlpha = overrideMaterial.clearAlpha || clearAlpha;
  416. if ( ( clearColor !== undefined ) && ( clearColor !== null ) ) {
  417. renderer.setClearColor( clearColor );
  418. renderer.setClearAlpha( clearAlpha || 0.0 );
  419. renderer.clear();
  420. }
  421. this.scene.traverseVisible( child => {
  422. child._SSRPassBackupMaterial = child.material;
  423. if ( this._selects.includes( child ) ) {
  424. child.material = this.metalnessOnMaterial;
  425. } else {
  426. child.material = this.metalnessOffMaterial;
  427. }
  428. } );
  429. renderer.render( this.scene, this.camera );
  430. this.scene.traverseVisible( child => {
  431. child.material = child._SSRPassBackupMaterial;
  432. } );
  433. // restore original state
  434. renderer.autoClear = originalAutoClear;
  435. renderer.setClearColor( this.originalClearColor );
  436. renderer.setClearAlpha( originalClearAlpha );
  437. }
  438. setSize( width, height ) {
  439. this.width = width;
  440. this.height = height;
  441. this.ssrMaterial.defines.MAX_STEP = Math.sqrt( width * width + height * height );
  442. this.ssrMaterial.needsUpdate = true;
  443. this.beautyRenderTarget.setSize( width, height );
  444. this.prevRenderTarget.setSize( width, height );
  445. this.ssrRenderTarget.setSize( width, height );
  446. this.normalRenderTarget.setSize( width, height );
  447. this.metalnessRenderTarget.setSize( width, height );
  448. this.blurRenderTarget.setSize( width, height );
  449. this.blurRenderTarget2.setSize( width, height );
  450. // this.blurRenderTarget3.setSize(width, height);
  451. this.ssrMaterial.uniforms[ 'resolution' ].value.set( width, height );
  452. this.ssrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
  453. this.ssrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
  454. this.blurMaterial.uniforms[ 'resolution' ].value.set( width, height );
  455. this.blurMaterial2.uniforms[ 'resolution' ].value.set( width, height );
  456. }
  457. }
  458. SSRPass.OUTPUT = {
  459. 'Default': 0,
  460. 'SSR': 1,
  461. 'Beauty': 3,
  462. 'Depth': 4,
  463. 'Normal': 5,
  464. 'Metalness': 7,
  465. };
  466. export { SSRPass };