|
@@ -6,6 +6,7 @@ import {
|
|
|
DataTexture,
|
|
|
SrcAlphaFactor,
|
|
|
OneMinusSrcAlphaFactor,
|
|
|
+ DepthStencilFormat,
|
|
|
OneMinusDstColorFactor,
|
|
|
DstAlphaFactor,
|
|
|
OneFactor,
|
|
@@ -91,14 +92,14 @@ class SSRPass extends Pass {
|
|
|
|
|
|
|
|
|
//ssao
|
|
|
- this.ssao = false
|
|
|
- this.kernelRadius = 0.1;
|
|
|
- this.kernel = [];
|
|
|
- this.kernelSize = 32;
|
|
|
- this.depthBiasValue = -0.003;
|
|
|
- this.rangeStrength = 0.005;
|
|
|
- this.power = 1.0;
|
|
|
- this.minDistance = 0.001
|
|
|
+ // this.ssao = false
|
|
|
+ // this.kernelRadius = 0.1;
|
|
|
+ // this.kernel = [];
|
|
|
+ // this.kernelSize = 32;
|
|
|
+ // this.depthBiasValue = -0.003;
|
|
|
+ // this.rangeStrength = 0.005;
|
|
|
+ // this.power = 1.0;
|
|
|
+ // this.minDistance = 0.001
|
|
|
|
|
|
//hbao
|
|
|
this.hbao = true
|
|
@@ -122,6 +123,7 @@ class SSRPass extends Pass {
|
|
|
|
|
|
// metalness render target
|
|
|
const depthTexture = new DepthTexture();
|
|
|
+ depthTexture.format = DepthStencilFormat;
|
|
|
depthTexture.type = UnsignedInt248Type;
|
|
|
|
|
|
this.metalnessRenderTarget = new WebGLMultipleRenderTargets( this.width, this.height, 5, {
|
|
@@ -145,7 +147,6 @@ class SSRPass extends Pass {
|
|
|
|
|
|
// ssr render target
|
|
|
this.ssrRenderTarget = new WebGLRenderTarget( this.downSampleResX, this.downSampleResY, {
|
|
|
- samples: 0,
|
|
|
type: HalfFloatType,
|
|
|
minFilter: LinearFilter,
|
|
|
magFilter: LinearFilter,
|
|
@@ -154,12 +155,13 @@ class SSRPass extends Pass {
|
|
|
|
|
|
|
|
|
// ssao render target
|
|
|
- this.ssaoRenderTarget = new WebGLRenderTarget( this.downSampleResX, this.downSampleResY, {
|
|
|
- type: HalfFloatType
|
|
|
+ this.aoRenderTarget = new WebGLRenderTarget( this.downSampleResX, this.downSampleResY, {
|
|
|
+ type: HalfFloatType,
|
|
|
+ minFilter: LinearFilter,
|
|
|
+ magFilter: LinearFilter,
|
|
|
} );
|
|
|
|
|
|
this.historyRenderTarget = new WebGLRenderTarget( this.downSampleResX, this.downSampleResY, {
|
|
|
- samples: 0,
|
|
|
type: HalfFloatType,
|
|
|
minFilter: LinearFilter,
|
|
|
magFilter: LinearFilter,
|
|
@@ -197,24 +199,24 @@ class SSRPass extends Pass {
|
|
|
this.ssrMaterial.needsUpdate = true;
|
|
|
|
|
|
//ssao material
|
|
|
- this.ssaoMaterial = new ShaderMaterial( {
|
|
|
- defines: Object.assign( {}, SSAOShader.defines ),
|
|
|
- uniforms: UniformsUtils.clone( SSAOShader.uniforms ),
|
|
|
- vertexShader: SSAOShader.vertexShader,
|
|
|
- fragmentShader: SSAOShader.fragmentShader,
|
|
|
- blending: NoBlending
|
|
|
- } );
|
|
|
- this.ssaoMaterial.defines[ 'KERNEL_SIZE' ] = this.kernelSize;
|
|
|
- this.ssaoMaterial.uniforms[ 'tNormal' ].value = this.metalnessRenderTarget.texture[1];
|
|
|
- this.ssaoMaterial.uniforms[ 'tDepth' ].value = this.metalnessRenderTarget.depthTexture;
|
|
|
- this.ssaoMaterial.uniforms[ 'tMetalness' ].value = this.metalnessRenderTarget.texture[2];
|
|
|
- this.ssaoMaterial.uniforms[ 'tNoise' ].value = this.noiseTexture;
|
|
|
- this.ssaoMaterial.uniforms[ 'kernel' ].value = this.kernel;
|
|
|
- this.ssaoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
|
|
|
- this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
|
|
|
- this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.downSampleResX, this.downSampleResY );
|
|
|
- this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
|
|
|
- this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
|
|
|
+ // this.ssaoMaterial = new ShaderMaterial( {
|
|
|
+ // defines: Object.assign( {}, SSAOShader.defines ),
|
|
|
+ // uniforms: UniformsUtils.clone( SSAOShader.uniforms ),
|
|
|
+ // vertexShader: SSAOShader.vertexShader,
|
|
|
+ // fragmentShader: SSAOShader.fragmentShader,
|
|
|
+ // blending: NoBlending
|
|
|
+ // } );
|
|
|
+ // this.ssaoMaterial.defines[ 'KERNEL_SIZE' ] = this.kernelSize;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'tNormal' ].value = this.metalnessRenderTarget.texture[1];
|
|
|
+ // this.ssaoMaterial.uniforms[ 'tDepth' ].value = this.metalnessRenderTarget.depthTexture;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'tMetalness' ].value = this.metalnessRenderTarget.texture[2];
|
|
|
+ // this.ssaoMaterial.uniforms[ 'tNoise' ].value = this.noiseTexture;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'kernel' ].value = this.kernel;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'cameraNear' ].value = this.camera.near;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.downSampleResX, this.downSampleResY );
|
|
|
+ // this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
|
|
|
+ // this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
|
|
|
|
|
|
|
|
|
// hbao
|
|
@@ -248,7 +250,7 @@ class SSRPass extends Pass {
|
|
|
fragmentShader: SSAODepthShader.fragmentShader,
|
|
|
blending: NoBlending
|
|
|
})
|
|
|
- this.ssaoDepthMaterial.uniforms[ 'tDepth' ] = this.ssaoRenderTarget.texture;
|
|
|
+ this.ssaoDepthMaterial.uniforms[ 'tDepth' ] = this.aoRenderTarget.texture;
|
|
|
// material for rendering the content of a render target
|
|
|
|
|
|
this.copyMaterial = new ShaderMaterial( {
|
|
@@ -339,19 +341,19 @@ class SSRPass extends Pass {
|
|
|
|
|
|
|
|
|
//render SSAO
|
|
|
- if(this.ssao) {
|
|
|
- this.ssaoMaterial.uniforms[ 'kernelRadius' ].value = this.kernelRadius;
|
|
|
- this.ssaoMaterial.uniforms[ 'minDistance' ].value = this.minDistance;
|
|
|
- this.ssaoMaterial.uniforms[ 'maxDistance' ].value = 0.5;
|
|
|
- this.ssaoMaterial.uniforms[ 'power'].value = this.power;
|
|
|
- this.ssaoMaterial.uniforms[ 'rangeStrength'].value = this.rangeStrength;
|
|
|
- this.ssaoMaterial.uniforms[ 'depthBiasValue'].value = this.depthBiasValue;
|
|
|
- this.ssaoMaterial.uniforms[ 'uframe' ].value = this.frame;
|
|
|
- this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
|
|
|
- this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
|
|
|
-
|
|
|
- this.renderPass( renderer, this.ssaoMaterial, this.ssaoRenderTarget );
|
|
|
- }
|
|
|
+ // if(this.ssao) {
|
|
|
+ // this.ssaoMaterial.uniforms[ 'kernelRadius' ].value = this.kernelRadius;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'minDistance' ].value = this.minDistance;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'maxDistance' ].value = 0.5;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'power'].value = this.power;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'rangeStrength'].value = this.rangeStrength;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'depthBiasValue'].value = this.depthBiasValue;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'uframe' ].value = this.frame;
|
|
|
+ // this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
|
|
|
+ // this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
|
|
|
+
|
|
|
+ // this.renderPass( renderer, this.ssaoMaterial, this.aoRenderTarget );
|
|
|
+ // }
|
|
|
|
|
|
if(this.hbao) {
|
|
|
this.hbaoMaterial.uniforms[ 'power' ].value = this.hbaoPower;
|
|
@@ -363,7 +365,7 @@ class SSRPass extends Pass {
|
|
|
this.hbaoMaterial.uniforms[ 'cameraFar' ].value = this.camera.far;
|
|
|
this.hbaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
|
|
|
this.hbaoMaterial.uniforms[ 'cameraProjectionMatrixInverse' ].value.copy( this.camera.projectionMatrixInverse );
|
|
|
- this.renderPass( renderer, this.hbaoMaterial, this.ssaoRenderTarget );
|
|
|
+ this.renderPass( renderer, this.hbaoMaterial, this.aoRenderTarget );
|
|
|
}
|
|
|
|
|
|
|
|
@@ -384,7 +386,7 @@ class SSRPass extends Pass {
|
|
|
}
|
|
|
|
|
|
if (this.ssao || this.hbao) {
|
|
|
- this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.ssaoRenderTarget.texture;
|
|
|
+ this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.aoRenderTarget.texture;
|
|
|
this.copyMaterial.blending = NormalBlending;
|
|
|
this.renderPass( renderer, this.copyMaterial, this.renderToScreen ? null : writeBuffer );
|
|
|
}
|
|
@@ -406,7 +408,7 @@ class SSRPass extends Pass {
|
|
|
break;
|
|
|
|
|
|
case SSRPass.OUTPUT.SSAO:
|
|
|
- this.ssaoDepthMaterial.uniforms[ 'tDepth' ].value = this.ssaoRenderTarget.texture;
|
|
|
+ this.ssaoDepthMaterial.uniforms[ 'tDepth' ].value = this.aoRenderTarget.texture;
|
|
|
this.copyMaterial.blending = NoBlending;
|
|
|
this.renderPass( renderer, this.ssaoDepthMaterial, this.renderToScreen ? null : writeBuffer );
|
|
|
|
|
@@ -545,14 +547,14 @@ class SSRPass extends Pass {
|
|
|
|
|
|
this.metalnessRenderTarget.dispose();
|
|
|
this.ssrRenderTarget.dispose();
|
|
|
- this.ssaoRenderTarget.dispose();
|
|
|
+ this.aoRenderTarget.dispose();
|
|
|
this.historyRenderTarget.dispose();
|
|
|
|
|
|
|
|
|
// dispose materials
|
|
|
|
|
|
this.ssrMaterial.dispose();
|
|
|
- this.ssaoMaterial.dispose();
|
|
|
+ // this.ssaoMaterial.dispose();
|
|
|
this.hbaoMaterial.dispose();
|
|
|
this.ssaoDepthMaterial.dispose();
|
|
|
this.copyMaterial.dispose();
|
|
@@ -573,7 +575,7 @@ class SSRPass extends Pass {
|
|
|
// this.ssrMaterial.needsUpdate = true;
|
|
|
this.metalnessRenderTarget.setSize( width, height );
|
|
|
this.ssrRenderTarget.setSize( this.downSampleResX, this.downSampleResY );
|
|
|
- this.ssaoRenderTarget.setSize( this.downSampleResX, this.downSampleResY );
|
|
|
+ this.aoRenderTarget.setSize( this.downSampleResX, this.downSampleResY );
|
|
|
this.historyRenderTarget.setSize( this.downSampleResX, this.downSampleResY );
|
|
|
|
|
|
|
|
@@ -581,9 +583,9 @@ class SSRPass extends Pass {
|
|
|
this.ssrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
|
|
|
this.ssrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
|
|
|
|
|
|
- this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.downSampleResX, this.downSampleResY );
|
|
|
- this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
|
|
|
- this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
|
|
|
+ // this.ssaoMaterial.uniforms[ 'resolution' ].value.set( this.downSampleResX, this.downSampleResY );
|
|
|
+ // this.ssaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
|
|
|
+ // this.ssaoMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
|
|
|
|
|
|
this.hbaoMaterial.uniforms[ 'resolution' ].value.set( this.downSampleResX, this.downSampleResY );
|
|
|
this.hbaoMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
|