Fixing the stereo issue

This commit is contained in:
samcake 2016-08-12 19:18:05 -07:00
parent 4fe67bfbf1
commit b90e0cfd89
3 changed files with 39 additions and 40 deletions

View file

@ -244,20 +244,23 @@ int evalMipFromRadius(float radius) {
}
vec3 fetchTapUnfiltered(ivec3 side, ivec2 ssC, vec3 tap, vec2 imageSize) {
vec3 fetchTapUnfiltered(ivec4 side, ivec2 ssC, vec3 tap, vec2 imageSize) {
ivec2 ssP = ivec2(tap.xy) + ssC;
ivec2 ssPFull = ivec2(ssP.x + side.y, ssP.y);
vec2 tapUV = (vec2(ssP) + vec2(0.5)) / imageSize;
vec2 fetchUV = vec2(tapUV.x + side.w * 0.5 * (side.x - tapUV.x), tapUV.y);
vec3 P;
P.xy = tapUV;
P.z = -texture(pyramidMap, tapUV).x;
P.z = -texture(pyramidMap, fetchUV).x;
return P;
}
vec3 fetchTap(ivec3 side, ivec2 ssC, vec3 tap, vec2 imageSize) {
vec3 fetchTap(ivec4 side, ivec2 ssC, vec3 tap, vec2 imageSize) {
int mipLevel = evalMipFromRadius(tap.z * doFetchMips());
ivec2 ssP = ivec2(tap.xy) + ssC;
@ -270,13 +273,14 @@ vec3 fetchTap(ivec3 side, ivec2 ssC, vec3 tap, vec2 imageSize) {
ivec2 mipP = clamp(ssPFull >> mipLevel, ivec2(0), mipSize - ivec2(1));
// vec2 tapUV = (vec2(ssP) + vec2(0.5)) / imageSize;
vec2 tapUV = (vec2(mipP) + vec2(0.5)) / vec2(mipSize);
vec2 tapUV = (vec2(ssP) + vec2(0.5)) / imageSize;
vec2 fetchUV = vec2(tapUV.x + side.w * 0.5 * (side.x - tapUV.x), tapUV.y);
// vec2 tapUV = (vec2(mipP) + vec2(0.5)) / vec2(mipSize);
vec3 P;
P.xy = tapUV;
P.z = -texelFetch(pyramidMap, mipP, mipLevel).x;
// P.z = -textureLod(pyramidMap, tapUV, float(mipLevel)).x;
// P.z = -texelFetch(pyramidMap, mipP, mipLevel).x;
P.z = -textureLod(pyramidMap, fetchUV, float(mipLevel)).x;
return P;
}

View file

@ -93,7 +93,7 @@ void main(void) {
keepedMip = evalMipFromRadius(tap.z * doFetchMips());
}
vec3 tapUVZ = fetchTap(side.xyz, ssC, tap, imageSize);
vec3 tapUVZ = fetchTap(side, ssC, tap, imageSize);
vec3 Q = evalEyePositionFromZeye(side.x, tapUVZ.z, tapUVZ.xy);
@ -116,20 +116,6 @@ void main(void) {
outFragColor = vec4(packOcclusionDepth(A, CSZToDephtKey(Cp.z)), 1.0);
// KEEP IT for Debugging
// Debug Normal: outFragColor = vec4((Cn + vec3(1.0))* 0.5, 1.0);
// Debug Radius outFragColor = vec4(vec3(ssDiskRadius / 100.0), 1.0);
// Debug MaxMiplevel outFragColor = vec4(1.0 - vec3(float(clamp(findMSB(int(ssDiskRadius)) - LOG_MAX_OFFSET, 0, MAX_MIP_LEVEL))/ float(MAX_MIP_LEVEL)), 1.0);
// Debug OffsetPosition
// float ssR;
// vec2 unitOffset = tapLocation(int(getNumSamples() - 1), 0, ssR);
// vec3 Q = getOffsetPosition(side, ssC, unitOffset, ssR * ssDiskRadius);
//outFragColor = vec4(vec3(Q.x / 10.0, Q.y / 2.0, -Q.z/ 3.0), 1.0);
// vec3 v = normalize(Q - Cp);
//outFragColor = vec4((v + vec3(1.0))* 0.5, 1.0);
// outFragColor = vec4((Cn + vec3(1.0))* 0.5, 1.0);
//outFragColor = vec4(vec3(ssDiskRadius / 100.0), 1.0);
if ((dot(fragToCursor,fragToCursor) < (100.0 * keepTapRadius * keepTapRadius) )) {
// outFragColor = vec4(vec3(A), 1.0);
outFragColor = vec4(vec3(A), 1.0);

View file

@ -53,7 +53,7 @@ void main(void) {
for (int i = 0; i < getNumSamples(); ++i) {
vec3 tap = getTapLocationClamped(i, randomPatternRotationAngle, ssDiskRadius, ssC, imageSize);
vec3 tapUVZ = fetchTap(side.xyz, ssC, tap, imageSize);
vec3 tapUVZ = fetchTap(side, ssC, tap, imageSize);
vec3 Q = evalEyePositionFromZeye(side.x, tapUVZ.z, tapUVZ.xy);
@ -74,4 +74,13 @@ void main(void) {
!>
outFragColor = vec4(packOcclusionDepth(A, CSZToDephtKey(Cp.z)), 1.0);
/* {
vec3 tap = getTapLocationClamped(2, randomPatternRotationAngle, ssDiskRadius, ssC, imageSize);
vec3 tapUVZ = fetchTap(side, ssC, tap, imageSize);
vec2 fetchUV = vec2(tapUVZ.x + side.w * 0.5 * (side.x - tapUVZ.x), tapUVZ.y);
vec3 Q = evalEyePositionFromZeye(side.x, tapUVZ.z, tapUVZ.xy);
outFragColor = vec4(fetchUV, 0.0, 1.0);
}*/
}