mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 18:38:24 +02:00
Fixing the stereo issue
This commit is contained in:
parent
4fe67bfbf1
commit
b90e0cfd89
3 changed files with 39 additions and 40 deletions
|
@ -218,7 +218,7 @@ vec3 getTapLocationClamped(int sampleNumber, float spinAngle, float outerRadius,
|
||||||
tap.xy = tapPos - pixelPos;
|
tap.xy = tapPos - pixelPos;
|
||||||
tap.z = length(tap.xy);
|
tap.z = length(tap.xy);
|
||||||
tap.z = 0;
|
tap.z = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tap;
|
return tap;
|
||||||
}
|
}
|
||||||
|
@ -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 ssP = ivec2(tap.xy) + ssC;
|
||||||
ivec2 ssPFull = ivec2(ssP.x + side.y, ssP.y);
|
ivec2 ssPFull = ivec2(ssP.x + side.y, ssP.y);
|
||||||
|
|
||||||
|
|
||||||
vec2 tapUV = (vec2(ssP) + vec2(0.5)) / imageSize;
|
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;
|
vec3 P;
|
||||||
P.xy = tapUV;
|
P.xy = tapUV;
|
||||||
P.z = -texture(pyramidMap, tapUV).x;
|
P.z = -texture(pyramidMap, fetchUV).x;
|
||||||
|
|
||||||
return P;
|
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());
|
int mipLevel = evalMipFromRadius(tap.z * doFetchMips());
|
||||||
|
|
||||||
ivec2 ssP = ivec2(tap.xy) + ssC;
|
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));
|
ivec2 mipP = clamp(ssPFull >> mipLevel, ivec2(0), mipSize - ivec2(1));
|
||||||
|
|
||||||
// vec2 tapUV = (vec2(ssP) + vec2(0.5)) / imageSize;
|
vec2 tapUV = (vec2(ssP) + vec2(0.5)) / imageSize;
|
||||||
vec2 tapUV = (vec2(mipP) + vec2(0.5)) / vec2(mipSize);
|
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;
|
vec3 P;
|
||||||
P.xy = tapUV;
|
P.xy = tapUV;
|
||||||
P.z = -texelFetch(pyramidMap, mipP, mipLevel).x;
|
// P.z = -texelFetch(pyramidMap, mipP, mipLevel).x;
|
||||||
// P.z = -textureLod(pyramidMap, tapUV, float(mipLevel)).x;
|
P.z = -textureLod(pyramidMap, fetchUV, float(mipLevel)).x;
|
||||||
|
|
||||||
return P;
|
return P;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,13 +36,13 @@ out vec4 outFragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec2 imageSize = getSideImageSize(getResolutionLevel());
|
vec2 imageSize = getSideImageSize(getResolutionLevel());
|
||||||
|
|
||||||
// In debug adjust the correct frag pixel based on base resolution
|
// In debug adjust the correct frag pixel based on base resolution
|
||||||
vec2 fragCoord = gl_FragCoord.xy;
|
vec2 fragCoord = gl_FragCoord.xy;
|
||||||
if (getResolutionLevel() > 0) {
|
if (getResolutionLevel() > 0) {
|
||||||
fragCoord /= float (1 << getResolutionLevel());
|
fragCoord /= float (1 << getResolutionLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pixel Debugged
|
// Pixel Debugged
|
||||||
vec2 cursorUV = getDebugCursorTexcoord();
|
vec2 cursorUV = getDebugCursorTexcoord();
|
||||||
vec2 cursorPixelPos = cursorUV * imageSize;
|
vec2 cursorPixelPos = cursorUV * imageSize;
|
||||||
|
@ -73,7 +73,7 @@ void main(void) {
|
||||||
|
|
||||||
// Let's make noise
|
// Let's make noise
|
||||||
//float randomPatternRotationAngle = getAngleDithering(ssC);
|
//float randomPatternRotationAngle = getAngleDithering(ssC);
|
||||||
vec3 wCp = (getViewInverse() * vec4(Cp, 1.0)).xyz;
|
vec3 wCp = (getViewInverse() * vec4(Cp, 1.0)).xyz;
|
||||||
float randomPatternRotationAngle = getAngleDitheringWorldPos(wCp);
|
float randomPatternRotationAngle = getAngleDitheringWorldPos(wCp);
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,9 +93,9 @@ void main(void) {
|
||||||
keepedMip = evalMipFromRadius(tap.z * doFetchMips());
|
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);
|
vec3 Q = evalEyePositionFromZeye(side.x, tapUVZ.z, tapUVZ.xy);
|
||||||
|
|
||||||
sum += float(tap.z > 0.0) * evalAO(Cp, Cn, Q);
|
sum += float(tap.z > 0.0) * evalAO(Cp, Cn, Q);
|
||||||
}
|
}
|
||||||
|
@ -116,20 +116,6 @@ void main(void) {
|
||||||
|
|
||||||
outFragColor = vec4(packOcclusionDepth(A, CSZToDephtKey(Cp.z)), 1.0);
|
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) )) {
|
if ((dot(fragToCursor,fragToCursor) < (100.0 * keepTapRadius * keepTapRadius) )) {
|
||||||
// outFragColor = vec4(vec3(A), 1.0);
|
// outFragColor = vec4(vec3(A), 1.0);
|
||||||
outFragColor = vec4(vec3(A), 1.0);
|
outFragColor = vec4(vec3(A), 1.0);
|
||||||
|
|
|
@ -23,7 +23,7 @@ void main(void) {
|
||||||
vec2 imageSize = getSideImageSize(getResolutionLevel());
|
vec2 imageSize = getSideImageSize(getResolutionLevel());
|
||||||
|
|
||||||
// Pixel being shaded
|
// Pixel being shaded
|
||||||
vec2 fragCoord = gl_FragCoord.xy;
|
vec2 fragCoord = gl_FragCoord.xy;
|
||||||
ivec2 ssC = ivec2(fragCoord.xy);
|
ivec2 ssC = ivec2(fragCoord.xy);
|
||||||
|
|
||||||
// Fetch the z under the pixel (stereo or not)
|
// Fetch the z under the pixel (stereo or not)
|
||||||
|
@ -44,8 +44,8 @@ void main(void) {
|
||||||
float ssDiskRadius = evalDiskRadius(Cp.z, imageSize);
|
float ssDiskRadius = evalDiskRadius(Cp.z, imageSize);
|
||||||
|
|
||||||
// Let's make noise
|
// Let's make noise
|
||||||
// float randomPatternRotationAngle = getAngleDithering(ssC);
|
//float randomPatternRotationAngle = getAngleDithering(ssC);
|
||||||
vec3 wCp = (getViewInverse() * vec4(Cp, 1.0)).xyz;
|
vec3 wCp = (getViewInverse() * vec4(Cp, 1.0)).xyz;
|
||||||
float randomPatternRotationAngle = getAngleDitheringWorldPos(wCp);
|
float randomPatternRotationAngle = getAngleDitheringWorldPos(wCp);
|
||||||
|
|
||||||
// Accumulate the Obscurance for each samples
|
// Accumulate the Obscurance for each samples
|
||||||
|
@ -53,9 +53,9 @@ void main(void) {
|
||||||
for (int i = 0; i < getNumSamples(); ++i) {
|
for (int i = 0; i < getNumSamples(); ++i) {
|
||||||
vec3 tap = getTapLocationClamped(i, randomPatternRotationAngle, ssDiskRadius, ssC, imageSize);
|
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);
|
vec3 Q = evalEyePositionFromZeye(side.x, tapUVZ.z, tapUVZ.xy);
|
||||||
|
|
||||||
sum += float(tap.z > 0.0) * evalAO(Cp, Cn, Q);
|
sum += float(tap.z > 0.0) * evalAO(Cp, Cn, Q);
|
||||||
}
|
}
|
||||||
|
@ -74,4 +74,13 @@ void main(void) {
|
||||||
!>
|
!>
|
||||||
|
|
||||||
outFragColor = vec4(packOcclusionDepth(A, CSZToDephtKey(Cp.z)), 1.0);
|
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);
|
||||||
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue