diff --git a/Assets/RT3script.cs b/Assets/RT3script.cs index 9ff0ff9..39d4d88 100644 --- a/Assets/RT3script.cs +++ b/Assets/RT3script.cs @@ -78,7 +78,7 @@ public class RT3script : MonoBehaviour { for(int i = 0; i < cameraList.Length; i++){ depthCameraList[i].worldToCameraMatrix = cameraList[i].worldToCameraMatrix; - // depthCameraList[i].projectionMatrix = cameraList[i].cameraToWorldMatrix; + depthCameraList[i].projectionMatrix = cameraList[i].projectionMatrix; } } diff --git a/Assets/Website~/index.html b/Assets/Website~/index.html index 9f9c3f1..a863cf8 100644 --- a/Assets/Website~/index.html +++ b/Assets/Website~/index.html @@ -27,7 +27,7 @@ />
- + diff --git a/Assets/Website~/projection.vert.glsl b/Assets/Website~/projection.vert.glsl index 1374390..61db10f 100644 --- a/Assets/Website~/projection.vert.glsl +++ b/Assets/Website~/projection.vert.glsl @@ -18,6 +18,41 @@ varying vec2 vUv; varying vec2 vUv1pxOffset; varying float paintfordiscard; +// mat4 swapHandedness(mat4 sM) { +// return mat4( +// sM[0][0], sM[0][1], sM[0][2], sM[3][0], +// sM[1][0], sM[1][1], sM[1][2], sM[3][1], +// sM[2][0], sM[2][1], sM[2][2], sM[3][2], +// sM[0][3], sM[1][3], sM[2][3], sM[3][3]); +// } +mat4 fuckAroundAndFindOut(mat4 sM) { + // return mat4( + // sM[0][0], sM[1][0], sM[2][0], sM[0][3], + // sM[0][1], sM[1][1], sM[2][1], sM[1][3], + // sM[0][2], sM[1][2], sM[2][2], sM[2][3], + // sM[3][0], sM[3][1], sM[3][2], sM[3][3]); + return mat4( + sM[0][0], sM[0][1], sM[0][2], sM[0][3], + sM[1][0], sM[1][1], sM[1][2], sM[1][3], + sM[2][0], sM[2][1], sM[2][2], sM[2][3], + sM[3][0], sM[3][1], sM[3][2], sM[3][3]); + // return mat4( + // sM[0][0], sM[1][0], sM[0][2], sM[0][3], + // sM[0][1], sM[1][1], sM[1][2], sM[1][3], + // sM[2][0], sM[2][1], sM[2][2], sM[2][3], + // sM[3][0], sM[3][1], sM[3][2], sM[3][3]); + // return mat4( + // sM[0][0], sM[0][1], sM[2][0], sM[0][3], + // sM[1][0], sM[1][1], sM[2][1], sM[1][3], + // sM[0][2], sM[1][2], sM[2][2], sM[2][3], + // sM[3][0], sM[3][1], sM[3][2], sM[3][3]); + // return mat4( + // sM[0][0], sM[0][1], -sM[0][2], sM[0][3], + // sM[1][0], sM[1][1], sM[1][2], sM[1][3], + // -sM[2][0], sM[2][1], sM[2][2], sM[2][3], + // sM[3][0], sM[3][1], sM[3][2], sM[3][3]); + +} void main() { @@ -44,7 +79,7 @@ void main() { float depth = ( color.r + color.g + color.b ) / 3.0; - // Projection code by @kcmic + // (original) Projection code by @kcmic // instead of building a matrix and multiplying by the matrix, math is being done to // guess the projection. @@ -61,12 +96,14 @@ void main() { vec4 pos = vec4( 2.*(position.x / float(width)) - 1., 2.*(position.y / float(height)) - 1., - 2.*depth - 1., + -1., //mix(1., -1., depth), 1.0 ); //vec4 pos2 = pos; - // vec4 pos2 = c2wm * prjm * pos; // order matters here! First undo projection, then undo view, then below model is undone - vec4 pos2 = c2wm * inverse(prjm) * pos; // order matters here! First undo projection, then undo view, then below model is undone + + // First undo projection, then undo view, then below model is undone; flip the Y and Z vectors since WebGL is right handed + vec4 pos2 = fuckAroundAndFindOut(c2wm) * inverse(prjm) * pos; // order matters here! Parentheses do not + pos2.xyz *= boxSize; // pos2 = pos2 * vec4(20000., 20000., 20000., 20000.); // bad idea! the last point needs to be 1 for translation to work // pos2 = pos2 * boxSize;