diff --git a/examples/jsm/postprocessing/SSShadowPass.js b/examples/jsm/postprocessing/SSShadowPass.js index 4f1fdb23239591..8c37097ad74024 100644 --- a/examples/jsm/postprocessing/SSShadowPass.js +++ b/examples/jsm/postprocessing/SSShadowPass.js @@ -43,6 +43,7 @@ class SSRrPass extends Pass { this.lightPosition = SSRrShader.uniforms.lightPosition.value; this.maxDistance = SSRrShader.uniforms.maxDistance.value; this.surfDist = SSRrShader.uniforms.surfDist.value; + this.doubleSideCheckStartFrom = SSRrShader.uniforms.doubleSideCheckStartFrom.value; this.encoding = encoding; @@ -229,6 +230,7 @@ class SSRrPass extends Pass { this.ssrrMaterial.uniforms[ 'lightPosition' ].value = this.lightPosition; this.ssrrMaterial.uniforms[ 'maxDistance' ].value = this.maxDistance; this.ssrrMaterial.uniforms[ 'surfDist' ].value = this.surfDist; + this.ssrrMaterial.uniforms[ 'doubleSideCheckStartFrom' ].value = this.doubleSideCheckStartFrom; this.renderPass( renderer, this.ssrrMaterial, this.ssrrRenderTarget ); // output result to screen diff --git a/examples/jsm/shaders/SSShadowShader.js b/examples/jsm/shaders/SSShadowShader.js index 0e9418383d90af..8b27f1f902866b 100644 --- a/examples/jsm/shaders/SSShadowShader.js +++ b/examples/jsm/shaders/SSShadowShader.js @@ -27,6 +27,7 @@ const SSRrShader = { 'cameraRange': { value: 0 }, 'maxDistance': { value: 180 }, 'surfDist': { value: .007 }, + 'doubleSideCheckStartFrom': { value: .01 }, }, @@ -61,6 +62,7 @@ const SSRrShader = { uniform mat4 cameraInverseProjectionMatrix; uniform float maxDistance; uniform float surfDist; + uniform float doubleSideCheckStartFrom; #include float pointToLineDistance(vec3 x0, vec3 x1, vec3 x2) { //x0: point, x1: linePointA, x2: linePointB @@ -173,7 +175,12 @@ const SSRrShader = { gl_FragColor=texture2D(tDiffuse,vUv); if(hit){ vec3 vN=getViewNormal( uv ); - if(dot(viewRefractDir,vN)>=0.) continue; + + // if(dot(viewRefractDir,vN)>=0.) continue; + + if((length(viewPosition-vP)=0.)) continue; + // May not need "doubleSideCheckStartFrom", use "surfDist" or change starting "i" of "for(float i=1.;i { controls.enabled = ! params.autoRotate;