11import {
2+ Color ,
23 LinearFilter ,
34 RepeatWrapping ,
45 RGBFormat ,
@@ -70,6 +71,7 @@ export class SSAOEffect extends Effect {
7071 * @param {Number } [options.intensity=1.0] - The intensity of the ambient occlusion.
7172 * @param {Number } [options.bias=0.025] - An occlusion bias. Eliminates artifacts caused by depth discontinuities.
7273 * @param {Number } [options.fade=0.01] - Influences the smoothness of the shadows. A lower value results in higher contrast.
74+ * @param {Color } [options.color=null] - The color of the ambient occlusion.
7375 * @param {Number } [options.resolutionScale=1.0] - The resolution scale.
7476 * @param {Number } [options.width=Resizer.AUTO_SIZE] - The render width.
7577 * @param {Number } [options.height=Resizer.AUTO_SIZE] - The render height.
@@ -92,6 +94,7 @@ export class SSAOEffect extends Effect {
9294 intensity = 1.0 ,
9395 bias = 0.025 ,
9496 fade = 0.01 ,
97+ color = null ,
9598 resolutionScale = 1.0 ,
9699 width = Resizer . AUTO_SIZE ,
97100 height = Resizer . AUTO_SIZE
@@ -106,6 +109,7 @@ export class SSAOEffect extends Effect {
106109 [ "aoBuffer" , new Uniform ( null ) ] ,
107110 [ "normalDepthBuffer" , new Uniform ( null ) ] ,
108111 [ "luminanceInfluence" , new Uniform ( luminanceInfluence ) ] ,
112+ [ "color" , new Uniform ( null ) ] ,
109113 [ "scale" , new Uniform ( 0.0 ) ] // Unused.
110114 ] )
111115
@@ -202,6 +206,7 @@ export class SSAOEffect extends Effect {
202206 this . distanceScaling = distanceScaling ;
203207 this . samples = samples ;
204208 this . rings = rings ;
209+ this . color = color ;
205210
206211 // @todo Special case treatment added for backwards-compatibility.
207212 this . radius = ( radius > 1.0 ) ? ( radius / 100.0 ) : radius ;
@@ -384,6 +389,59 @@ export class SSAOEffect extends Effect {
384389
385390 }
386391
392+ /**
393+ * The color of the ambient occlusion.
394+ *
395+ * @type {Color }
396+ */
397+
398+ get color ( ) {
399+
400+ return this . uniforms . get ( "color" ) . value ;
401+
402+ }
403+
404+ /**
405+ * Sets the color of the ambient occlusion.
406+ *
407+ * Set to `null` to disable colorization.
408+ *
409+ * @type {Color }
410+ */
411+
412+ set color ( value ) {
413+
414+ const uniforms = this . uniforms ;
415+ const defines = this . defines ;
416+
417+ if ( value === null ) {
418+
419+ if ( defines . has ( "COLORIZE" ) ) {
420+
421+ defines . delete ( "COLORIZE" ) ;
422+ uniforms . get ( "color" ) . value = null ;
423+ this . setChanged ( ) ;
424+
425+ }
426+
427+ } else {
428+
429+ if ( defines . has ( "COLORIZE" ) ) {
430+
431+ uniforms . get ( "color" ) . value . set ( value ) ;
432+
433+ } else {
434+
435+ defines . set ( "COLORIZE" , "1" ) ;
436+ uniforms . get ( "color" ) . value = new Color ( value ) ;
437+ this . setChanged ( ) ;
438+
439+ }
440+
441+ }
442+
443+ }
444+
387445 /**
388446 * Sets the occlusion distance cutoff.
389447 *
0 commit comments