@@ -137,6 +137,8 @@ class SSRPass extends Pass {
137137
138138		this . _selects  =  selects ; 
139139
140+ 		this . _resolutionScale  =  1 ; 
141+ 
140142		/** 
141143		 * Whether the pass is selective or not. 
142144		 * 
@@ -457,6 +459,29 @@ class SSRPass extends Pass {
457459
458460	} 
459461
462+ 
463+ 	/** 
464+ 	 * The resolution scale. Valid values are in the range 
465+ 	 * `[0,1]`. `1` means best quality but also results in 
466+ 	 * more computational overhead. Setting to `0.5` means 
467+ 	 * the effect is computed in half-resolution. 
468+ 	 * 
469+ 	 * @type  {number } 
470+ 	 * @default  1 
471+ 	 */ 
472+ 	get  resolutionScale ( )  { 
473+ 
474+ 		return  this . _resolutionScale ; 
475+ 
476+ 	} 
477+ 
478+ 	set  resolutionScale (  value  )  { 
479+ 
480+ 		this . _resolutionScale  =  value ; 
481+ 		this . setSize (  this . width ,  this . height  ) ;  // force a resize when resolution scaling changes 
482+ 
483+ 	} 
484+ 
460485	/** 
461486	 * Frees the GPU-related resources allocated by this instance. Call this 
462487	 * method whenever the pass is no longer used in your app. 
@@ -661,23 +686,27 @@ class SSRPass extends Pass {
661686		this . width  =  width ; 
662687		this . height  =  height ; 
663688
664- 		this . ssrMaterial . defines . MAX_STEP  =  Math . sqrt (  width  *  width  +  height  *  height  ) ; 
689+ 		const  effectiveWidth  =  Math . round (  this . resolutionScale  *  width  ) ; 
690+ 		const  effectiveHeight  =  Math . round (  this . resolutionScale  *  height  ) ; 
691+ 
692+ 		this . ssrMaterial . defines . MAX_STEP  =  Math . sqrt (  effectiveWidth  *  effectiveWidth  +  effectiveHeight  *  effectiveHeight  ) ; 
665693		this . ssrMaterial . needsUpdate  =  true ; 
694+ 
666695		this . beautyRenderTarget . setSize (  width ,  height  ) ; 
667- 		this . prevRenderTarget . setSize (  width ,  height  ) ; 
668- 		this . ssrRenderTarget . setSize (  width ,  height  ) ; 
669696		this . normalRenderTarget . setSize (  width ,  height  ) ; 
670697		this . metalnessRenderTarget . setSize (  width ,  height  ) ; 
671- 		this . blurRenderTarget . setSize (  width ,  height  ) ; 
672- 		this . blurRenderTarget2 . setSize (  width ,  height  ) ; 
698+ 		this . ssrRenderTarget . setSize (  effectiveWidth ,  effectiveHeight  ) ; 
699+ 		this . prevRenderTarget . setSize (  effectiveWidth ,  effectiveHeight  ) ; 
700+ 		this . blurRenderTarget . setSize (  effectiveWidth ,  effectiveHeight  ) ; 
701+ 		this . blurRenderTarget2 . setSize (  effectiveWidth ,  effectiveHeight  ) ; 
673702		// this.blurRenderTarget3.setSize(width, height); 
674703
675- 		this . ssrMaterial . uniforms [  'resolution'  ] . value . set (  width ,   height  ) ; 
704+ 		this . ssrMaterial . uniforms [  'resolution'  ] . value . set (  effectiveWidth ,   effectiveHeight  ) ; 
676705		this . ssrMaterial . uniforms [  'cameraProjectionMatrix'  ] . value . copy (  this . camera . projectionMatrix  ) ; 
677706		this . ssrMaterial . uniforms [  'cameraInverseProjectionMatrix'  ] . value . copy (  this . camera . projectionMatrixInverse  ) ; 
678707
679- 		this . blurMaterial . uniforms [  'resolution'  ] . value . set (  width ,   height  ) ; 
680- 		this . blurMaterial2 . uniforms [  'resolution'  ] . value . set (  width ,   height  ) ; 
708+ 		this . blurMaterial . uniforms [  'resolution'  ] . value . set (  effectiveWidth ,   effectiveHeight  ) ; 
709+ 		this . blurMaterial2 . uniforms [  'resolution'  ] . value . set (  effectiveWidth ,   effectiveHeight  ) ; 
681710
682711	} 
683712
0 commit comments