Skip to content

Commit

Permalink
Setting: maxDistance configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
gonnavis committed Mar 21, 2021
1 parent 76fac3e commit 3042bc5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/jsm/postprocessing/SSRrPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var SSRrPass = function ( { renderer, scene, camera, width, height, selects, enc
// this.output = 1;

this.ior = SSRrShader.uniforms.ior.value;
this.maxDistance = SSRrShader.uniforms.maxDistance.value;
this.surfDist = SSRrShader.uniforms.surfDist.value;

this.encoding = encoding;
Expand Down Expand Up @@ -290,6 +291,7 @@ SSRrPass.prototype = Object.assign( Object.create( Pass.prototype ), {
// render SSRr

this.ssrrMaterial.uniforms[ 'ior' ].value = this.ior;
this.ssrrMaterial.uniforms[ 'maxDistance' ].value = this.maxDistance;
this.ssrrMaterial.uniforms[ 'surfDist' ].value = this.surfDist;
this.ssrrMaterial.uniforms[ 'tSpecular' ].value = this.specularRenderTarget.texture;
this.renderPass( renderer, this.ssrrMaterial, this.ssrrRenderTarget );
Expand Down
3 changes: 2 additions & 1 deletion examples/jsm/shaders/SSRrShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var SSRrShader = {
"cameraInverseProjectionMatrix": { value: new Matrix4() },
"ior": { value: 1.03 },
"cameraRange": { value: 0 },
"maxDistance": { value: 180 },
"surfDist": { value: .007 },

},
Expand Down Expand Up @@ -61,6 +62,7 @@ var SSRrShader = {
uniform float ior;
uniform mat4 cameraProjectionMatrix;
uniform mat4 cameraInverseProjectionMatrix;
uniform float maxDistance;
uniform float surfDist;
#include <packing>
float pointToLineDistance(vec3 x0, vec3 x1, vec3 x2) {
Expand Down Expand Up @@ -141,7 +143,6 @@ var SSRrShader = {
vec3 viewRefractDir=refract(viewIncidentDir,viewNormalSelects,1./ior);
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/refract.xhtml
float maxDistance=100.;
vec3 d1viewPosition=viewPosition+viewRefractDir*maxDistance;
#ifdef PERSPECTIVE_CAMERA
if(d1viewPosition.z>-cameraNear){
Expand Down
Binary file modified examples/screenshots/webgl_postprocessing_ssrr.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion examples/webgl_postprocessing_ssrr.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@
});
ssrrPass.surfDist = 0.1;
folder.add( ssrrPass, 'surfDist' ).min( 0 ).max( .3 ).step( .001 );
folder.open()
ssrrPass.maxDistance = 15;
folder.add( ssrrPass, 'maxDistance' ).min( 0 ).max( 20 ).step( .001 )
// folder.open()
// gui.close()

}
Expand Down

0 comments on commit 3042bc5

Please sign in to comment.