Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/js/loaders/FBXLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3594,7 +3594,7 @@

function isFbxFormatBinary( buffer ) {

const CORRECT = 'Kaydara FBX Binary \0';
const CORRECT = 'Kaydara\u0020FBX\u0020Binary\u0020\u0020\0';
return buffer.byteLength >= CORRECT.length && CORRECT === convertArrayBufferToString( buffer, 0, CORRECT.length );

}
Expand Down
79 changes: 41 additions & 38 deletions examples/js/shaders/SSRShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,45 +204,48 @@
float viewReflectRayZ=viewPosition.z+s*(d1viewPosition.z-viewPosition.z);
#endif

if(viewReflectRayZ>vZ) continue;

bool hit;
#ifdef INFINITE_THICK
hit=true;
#else
float away=pointToLineDistance(vP,viewPosition,d1viewPosition);

float minThickness;
vec2 xyNeighbor=xy;
xyNeighbor.x+=1.;
vec2 uvNeighbor=xyNeighbor/resolution;
vec3 vPNeighbor=getViewPosition(uvNeighbor,d,cW);
minThickness=vPNeighbor.x-vP.x;
minThickness*=3.;
float tk=max(minThickness,thickness);

hit=away<=tk;
#endif

if(hit){
vec3 vN=getViewNormal( uv );
if(dot(viewReflectDir,vN)>=0.) continue;
float distance=pointPlaneDistance(vP,viewPosition,viewNormal);
if(distance>maxDistance) break;
float op=opacity;
#ifdef DISTANCE_ATTENUATION
float ratio=1.-(distance/maxDistance);
float attenuation=ratio*ratio;
op=opacity*attenuation;
#endif
#ifdef FRESNEL
float fresnelCoe=(dot(viewIncidentDir,viewReflectDir)+1.)/2.;
op*=fresnelCoe;
// if(viewReflectRayZ>vZ) continue; // will cause "npm run make-screenshot webgl_postprocessing_ssr" high probability hang.
// https://github.com/mrdoob/three.js/pull/21539#issuecomment-821061164
if(viewReflectRayZ<=vZ){

bool hit;
#ifdef INFINITE_THICK
hit=true;
#else
float away=pointToLineDistance(vP,viewPosition,d1viewPosition);

float minThickness;
vec2 xyNeighbor=xy;
xyNeighbor.x+=1.;
vec2 uvNeighbor=xyNeighbor/resolution;
vec3 vPNeighbor=getViewPosition(uvNeighbor,d,cW);
minThickness=vPNeighbor.x-vP.x;
minThickness*=3.;
float tk=max(minThickness,thickness);

hit=away<=tk;
#endif
vec4 reflectColor=texture2D(tDiffuse,uv);
gl_FragColor.xyz=reflectColor.xyz;
gl_FragColor.a=op;
break;

if(hit){
vec3 vN=getViewNormal( uv );
if(dot(viewReflectDir,vN)>=0.) continue;
float distance=pointPlaneDistance(vP,viewPosition,viewNormal);
if(distance>maxDistance) break;
float op=opacity;
#ifdef DISTANCE_ATTENUATION
float ratio=1.-(distance/maxDistance);
float attenuation=ratio*ratio;
op=opacity*attenuation;
#endif
#ifdef FRESNEL
float fresnelCoe=(dot(viewIncidentDir,viewReflectDir)+1.)/2.;
op*=fresnelCoe;
#endif
vec4 reflectColor=texture2D(tDiffuse,uv);
gl_FragColor.xyz=reflectColor.xyz;
gl_FragColor.a=op;
break;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/loaders/FBXLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3892,7 +3892,7 @@ class FBXTree {

function isFbxFormatBinary( buffer ) {

const CORRECT = 'Kaydara FBX Binary \0';
const CORRECT = 'Kaydara\u0020FBX\u0020Binary\u0020\u0020\0';

return buffer.byteLength >= CORRECT.length && CORRECT === convertArrayBufferToString( buffer, 0, CORRECT.length );

Expand Down