|
@@ -66,8 +66,10 @@ class BokehPass extends Pass {
|
|
|
|
|
|
|
|
|
// DownSample
|
|
|
- this.DownSampleRenderTarget = new WebGLRenderTarget(this.downSampleResX, this.downSampleResY, {
|
|
|
- type: HalfFloatType
|
|
|
+ this.DownSampleRenderTarget = new WebGLRenderTarget(this.width, this.height, {
|
|
|
+ type: HalfFloatType,
|
|
|
+ minFilter: NearestFilter,
|
|
|
+ magFilter: NearestFilter,
|
|
|
});
|
|
|
|
|
|
this.DownSampleMaterial = new ShaderMaterial( {
|
|
@@ -82,7 +84,7 @@ class BokehPass extends Pass {
|
|
|
|
|
|
// bokeh
|
|
|
this.BokehRenderTarget = new WebGLRenderTarget(this.downSampleResX, this.downSampleResY, {
|
|
|
- type: HalfFloatType
|
|
|
+ type: HalfFloatType,
|
|
|
});
|
|
|
|
|
|
this.BokehMaterial = new ShaderMaterial( {
|
|
@@ -96,7 +98,7 @@ class BokehPass extends Pass {
|
|
|
|
|
|
// filter
|
|
|
this.FilterRenderTarget = new WebGLRenderTarget(this.downSampleResX, this.downSampleResY, {
|
|
|
- type: HalfFloatType
|
|
|
+ type: HalfFloatType,
|
|
|
});
|
|
|
|
|
|
this.FileterMaterial = new ShaderMaterial( {
|
|
@@ -109,7 +111,7 @@ class BokehPass extends Pass {
|
|
|
|
|
|
// Scatter
|
|
|
this.ScatterRenderTarget = new WebGLRenderTarget(this.downSampleResX, this.downSampleResY, {
|
|
|
- type: HalfFloatType
|
|
|
+ type: HalfFloatType,
|
|
|
});
|
|
|
|
|
|
this.ScatterMaterial = new ShaderMaterial( {
|
|
@@ -141,11 +143,13 @@ class BokehPass extends Pass {
|
|
|
|
|
|
this.originalClearColor = new Color();
|
|
|
this.tempColor = new Color();
|
|
|
-
|
|
|
+ console.log(this.DownSampleRenderTarget)
|
|
|
}
|
|
|
|
|
|
|
|
|
render( renderer, writeBuffer, readBuffer, deltaTime, maskActive, GBuffer ) {
|
|
|
+ this.maxblur = this.bokehRadius * this.height * 0.001;
|
|
|
+
|
|
|
// render DofCoC
|
|
|
this.DofCoCMaterial.uniforms[ 'tDepth' ].value = GBuffer.depthTexture;
|
|
|
this.DofCoCMaterial.uniforms[ 'focus' ].value.copy(this.focus);
|
|
@@ -160,7 +164,7 @@ class BokehPass extends Pass {
|
|
|
// render downSample
|
|
|
this.DownSampleMaterial.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
|
|
|
this.DownSampleMaterial.uniforms[ 'tCoC' ].value = this.DofCoCRenderTarget.texture;
|
|
|
- this.DownSampleMaterial.uniforms[ 'bokehRadius' ].value = this.bokehRadius;
|
|
|
+ this.DownSampleMaterial.uniforms[ 'bokehRadius' ].value = this.maxblur;
|
|
|
this.renderPass( renderer, this.DownSampleMaterial, this.DownSampleRenderTarget);
|
|
|
|
|
|
|
|
@@ -170,9 +174,8 @@ class BokehPass extends Pass {
|
|
|
this.BokehMaterial.needsUpdate = true;
|
|
|
}
|
|
|
this.BokehMaterial.uniforms[ 'tDiffuse' ].value = this.DownSampleRenderTarget.texture;
|
|
|
- this.BokehMaterial.uniforms[ 'bokehRadius' ].value = this.bokehRadius;
|
|
|
+ this.BokehMaterial.uniforms[ 'bokehRadius' ].value = this.maxblur;
|
|
|
this.BokehMaterial.uniforms[ 'uframe' ].value = this.frame;
|
|
|
- this.BokehMaterial.uniforms[ 'maxblur' ].value = this.maxblur;
|
|
|
this.BokehMaterial.uniforms[ 'bladeCount' ].value = this.bladeCount;
|
|
|
this.renderPass( renderer, this.BokehMaterial, this.BokehRenderTarget);
|
|
|
|
|
@@ -193,7 +196,7 @@ class BokehPass extends Pass {
|
|
|
this.BlendMaterial.uniforms[ 'tCoC' ].value = this.DofCoCRenderTarget.texture;
|
|
|
this.BlendMaterial.uniforms[ 'tDown' ].value = this.DownSampleRenderTarget.texture;
|
|
|
this.BlendMaterial.uniforms[ 'tDof' ].value = this.ScatterRenderTarget.texture;
|
|
|
- this.BlendMaterial.uniforms[ 'bokehRadius' ].value = this.bokehRadius;
|
|
|
+ this.BlendMaterial.uniforms[ 'bokehRadius' ].value = this.maxblur;
|
|
|
this.renderPass( renderer, this.BlendMaterial, writeBuffer);
|
|
|
|
|
|
// this.copyMaterial.uniforms[ 'tDiffuse' ].value = this.FilterRenderTarget.texture;
|
|
@@ -253,14 +256,15 @@ class BokehPass extends Pass {
|
|
|
this.downSampleResX = width * this.downSampleFactor;
|
|
|
this.downSampleResY = height * this.downSampleFactor;
|
|
|
|
|
|
+
|
|
|
this.DofCoCRenderTarget.setSize( width, height );
|
|
|
- this.DownSampleRenderTarget.setSize( this.downSampleResX, this.downSampleResY );
|
|
|
+ this.DownSampleRenderTarget.setSize( width, height );
|
|
|
this.BokehRenderTarget.setSize( this.downSampleResX, this.downSampleResY );
|
|
|
this.FilterRenderTarget.setSize( this.downSampleResX, this.downSampleResY );
|
|
|
this.ScatterRenderTarget.setSize( this.downSampleResX, this.downSampleResY );
|
|
|
|
|
|
- this.DownSampleMaterial.uniforms[ 'resolution' ].value.set(width, height);
|
|
|
- this.BokehMaterial.uniforms[ 'resolution' ].value.set( this.downSampleResX, this.downSampleResY );
|
|
|
+ this.DownSampleMaterial.uniforms[ 'resolution' ].value.set( width, height );
|
|
|
+ this.BokehMaterial.uniforms[ 'resolution' ].value.set( width, height );
|
|
|
this.FileterMaterial.uniforms[ 'resolution' ].value.set( this.downSampleResX, this.downSampleResY );
|
|
|
this.ScatterMaterial.uniforms[ 'resolution' ].value.set( this.downSampleResX, this.downSampleResY );
|
|
|
this.BlendMaterial.uniforms[ 'resolution' ].value.set(width, height);
|