* Constructs a new SSAO effect. * * @todo Move normalBuffer to options. * @param {Camera} [camera] - The main camera. * @param {Texture} [normalBuffer] - A texture that contains the scene normals. * @param {Object} [options] - The options. * @param {BlendFunction} [options.blendFunction=
(camera, normalBuffer, {
blendFunction = BlendFunction.MULTIPLY,
samples = 9,
rings = 7,
normalDepthBuffer = null,
depthAwareUpsampling = true,
worldDistanceThreshold,
worldDistanceFalloff,
worldProximityThreshold,
worldProximityFalloff,
distanceThreshold = 0.97,
distanceFalloff = 0.03,
rangeThreshold = 0.0005,
rangeFalloff = 0.001,
minRadiusScale = 0.1,
luminanceInfluence = 0.7,
radius = 0.1825,
intensity = 1.0,
bias = 0.025,
fade = 0.01,
color = null,
resolutionScale = 1.0,
width = Resolution.AUTO_SIZE,
height = Resolution.AUTO_SIZE,
resolutionX = width,
resolutionY = height
} = {})
| 62 | */ |
| 63 | |
| 64 | constructor(camera, normalBuffer, { |
| 65 | blendFunction = BlendFunction.MULTIPLY, |
| 66 | samples = 9, |
| 67 | rings = 7, |
| 68 | normalDepthBuffer = null, |
| 69 | depthAwareUpsampling = true, |
| 70 | worldDistanceThreshold, |
| 71 | worldDistanceFalloff, |
| 72 | worldProximityThreshold, |
| 73 | worldProximityFalloff, |
| 74 | distanceThreshold = 0.97, |
| 75 | distanceFalloff = 0.03, |
| 76 | rangeThreshold = 0.0005, |
| 77 | rangeFalloff = 0.001, |
| 78 | minRadiusScale = 0.1, |
| 79 | luminanceInfluence = 0.7, |
| 80 | radius = 0.1825, |
| 81 | intensity = 1.0, |
| 82 | bias = 0.025, |
| 83 | fade = 0.01, |
| 84 | color = null, |
| 85 | resolutionScale = 1.0, |
| 86 | width = Resolution.AUTO_SIZE, |
| 87 | height = Resolution.AUTO_SIZE, |
| 88 | resolutionX = width, |
| 89 | resolutionY = height |
| 90 | } = {}) { |
| 91 | |
| 92 | super("SSAOEffect", fragmentShader, { |
| 93 | blendFunction, |
| 94 | attributes: EffectAttribute.DEPTH, |
| 95 | defines: new Map([ |
| 96 | ["THRESHOLD", "0.997"] |
| 97 | ]), |
| 98 | uniforms: new Map([ |
| 99 | ["aoBuffer", new Uniform(null)], |
| 100 | ["normalDepthBuffer", new Uniform(normalDepthBuffer)], |
| 101 | ["luminanceInfluence", new Uniform(luminanceInfluence)], |
| 102 | ["color", new Uniform(null)], |
| 103 | ["intensity", new Uniform(intensity)], |
| 104 | ["scale", new Uniform(0.0)] // Unused. |
| 105 | ]) |
| 106 | }); |
| 107 | |
| 108 | /** |
| 109 | * A render target. |
| 110 | * |
| 111 | * @type {WebGLRenderTarget} |
| 112 | * @private |
| 113 | */ |
| 114 | |
| 115 | this.renderTarget = new WebGLRenderTarget(1, 1, { depthBuffer: false }); |
| 116 | this.renderTarget.texture.name = "AO.Target"; |
| 117 | this.uniforms.get("aoBuffer").value = this.renderTarget.texture; |
| 118 | |
| 119 | /** |
| 120 | * The resolution. |
| 121 | * |