FIx to correctly calculate the mirror projection

- it doesn't work as a proper mirror still though, but it looks way better than it did
This commit is contained in:
Simon 2022-04-27 20:39:59 +01:00
parent d60128cf21
commit bebc85800f
6 changed files with 21 additions and 29 deletions

View file

@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.ioq3quest"
android:installLocation="preferExternal"
android:versionCode="48"
android:versionName="0.31.3">
android:versionCode="49"
android:versionName="0.31.4">
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
<uses-feature android:glEsVersion="0x00030001" />
<!-- <uses-feature android:name="oculus.software.overlay_keyboard" android:required="false"/>-->

View file

@ -391,26 +391,6 @@ void RB_BeginDrawingView (void) {
// we will only draw a sun if there was sky rendered in this view
backEnd.skyRenderedThisView = qfalse;
// clip to the plane of the portal
if ( backEnd.viewParms.isPortal ) {
#if 0
float plane[4];
GLdouble plane2[4];
plane[0] = backEnd.viewParms.portalPlane.normal[0];
plane[1] = backEnd.viewParms.portalPlane.normal[1];
plane[2] = backEnd.viewParms.portalPlane.normal[2];
plane[3] = backEnd.viewParms.portalPlane.dist;
plane2[0] = DotProduct (backEnd.viewParms.or.axis[0], plane);
plane2[1] = DotProduct (backEnd.viewParms.or.axis[1], plane);
plane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane);
plane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3];
#endif
GL_SetModelMatrix( s_flipMatrix );
}
}

View file

@ -68,6 +68,7 @@ typedef enum {
HUDBUFFER_ORTHO_PROJECTION, // Orthographic projection and no stereo view for the HUD buffer
STEREO_ORTHO_PROJECTION, // Orthographic projection with a slight stereo offset per eye for the static hud
VR_PROJECTION,
MIRROR_VR_PROJECTION, // For mirrors etc
MONO_VR_PROJECTION,
PROJECTION_COUNT
@ -226,6 +227,7 @@ static void GLSL_ViewMatricesUniformBuffer(const float eyeView[32], const float
Mat4Translation( translate, viewMatrices + 16 );
}
break;
case MIRROR_VR_PROJECTION:
case VR_PROJECTION:
{
Mat4Copy(eyeView, viewMatrices);
@ -1683,7 +1685,6 @@ void GLSL_ShutdownGPUShaders(void)
qglDeleteBuffers(PROJECTION_COUNT, projectionMatricesBuffer);
}
void GLSL_PrepareUniformBuffers(void)
{
int width, height;
@ -1715,6 +1716,10 @@ void GLSL_PrepareUniformBuffers(void)
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[VR_PROJECTION],
tr.vrParms.projection);
//Mirror VR projection matrix
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[MIRROR_VR_PROJECTION],
tr.vrParms.mirrorProjection);
//Used for drawing models
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[MONO_VR_PROJECTION],
tr.vrParms.monoVRProjection);
@ -1741,6 +1746,11 @@ void GLSL_BindProgram(shaderProgram_t * program)
static GLuint GLSL_CalculateProjection() {
GLuint result = glState.isDrawingHUD ? MONO_VR_PROJECTION : VR_PROJECTION;
if (backEnd.viewParms.isPortal)
{
result = MIRROR_VR_PROJECTION;
}
if (Mat4Compare(&orthoProjectionMatrix, glState.projection))
{
if (glState.isDrawingHUD)

View file

@ -851,6 +851,7 @@ typedef struct {
typedef struct {
qboolean valid;
float projection[16];
float mirrorProjection[16];
float monoVRProjection[16];
int renderBuffer;
int renderBufferOriginal;

View file

@ -783,6 +783,8 @@ void R_SetupProjectionZ(viewParms_t *dest)
float plane2[4];
vec4_t q, c;
Mat4Copy(tr.vrParms.projection, tr.vrParms.mirrorProjection);
// transform portal plane into camera space
plane[0] = dest->portalPlane.normal[0];
plane[1] = dest->portalPlane.normal[1];
@ -803,11 +805,10 @@ void R_SetupProjectionZ(viewParms_t *dest)
VectorScale4(plane2, 2.0f / DotProduct4(plane2, q), c);
dest->projectionMatrix[2] = c[0];
dest->projectionMatrix[6] = c[1];
dest->projectionMatrix[10] = c[2] + 1.0f;
dest->projectionMatrix[14] = c[3];
tr.vrParms.mirrorProjection[2] = c[0];
tr.vrParms.mirrorProjection[6] = c[1];
tr.vrParms.mirrorProjection[10] = c[2] + 1.0f;
tr.vrParms.mirrorProjection[14] = c[3];
}
}

View file

@ -3,7 +3,7 @@
setlocal
set BUILD_TYPE=release
set VERSION=0.31.3-multiview
set VERSION=0.31.4-multiview
@REM Define the following environment variables to sign a release build
@REM set KEYSTORE=