Fixes FPS issue and hopefully "warping"

To fix warping I have:
1. Created a symmetrically sized render target, wish I'd done this in
the first place! it takes a bit of the guess work out of one of the
projection matrices (for the timewarp layer) which may have been the
cause of the "warping"
2. Added a very rudimentary neck model..
basically just translate the eyes forwards a little so when you spin
your head they aren;t rotating around a central axis between the eyes,
but in more of a neck position. The positional tracking should have been
handling this, but maybe it wasn;t quite enough
This commit is contained in:
Simon committed 2019-08-05 17:10:05 +01:00
1 parent ba2fb98942
commit 8296398e38
4 files changed
+84 -102

No files matched your search

@@ -77,12 +77,11 @@ PFNEGLSIGNALSYNCKHRPROC eglSignalSyncKHR;
PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR;
#endif
//Let's go to the maximum!
int CPU_LEVEL = 2;
int GPU_LEVEL = 3;
int NUM_MULTI_SAMPLES = 1;
float SS_MULTIPLIER = 1.2f;
float SS_MULTIPLIER = 1.5f;
vec2_t cylinderSize = {1280, 720};
@@ -98,7 +97,6 @@ float degrees(float rad) {
struct arg_dbl *ss;
struct arg_int *cpu;
struct arg_int *gpu;
struct arg_dbl *msaa;
struct arg_end *end;
char **argv;
@@ -129,10 +127,6 @@ LAMBDA1VR Stuff
================================================================================
*/
//All the functionality we link to in the DarkPlaces Quake implementation
static bool xash_initialised = false;
typedef void (*pfnChangeGame)( const char *progname );
extern int Host_Main( int argc, const char **argv, const char *progname, int bChangeGame, pfnChangeGame func );
@@ -147,9 +141,6 @@ void L1VR_exit(int exitCode)
runStatus = exitCode;
}
float horizFOV;
float vertFOV;
static void UnEscapeQuotes( char *arg )
{
char *last = NULL;
@@ -659,8 +650,8 @@ void ovrRenderer_Create( int width, int height, ovrRenderer * renderer, const ov
{
renderer->NumBuffers = VRAPI_FRAME_LAYER_EYE_MAX;
horizFOV = vrapi_GetSystemPropertyInt( java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X);
vertFOV = vrapi_GetSystemPropertyInt( java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y);
//Now using a symmetrical render target, based on the horizontal FOV
vrFOV = vrapi_GetSystemPropertyInt( java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X);
// Create the render Textures.
for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ )
@@ -674,9 +665,7 @@ void ovrRenderer_Create( int width, int height, ovrRenderer * renderer, const ov
// Setup the projection matrix.
renderer->ProjectionMatrix = ovrMatrix4f_CreateProjectionFov(
horizFOV,
vertFOV,
0.0f, 0.0f, 1.0f, 0.0f );
vrFOV, vrFOV, 0.0f, 0.0f, 1.0f, 0.0f );
}
@@ -862,8 +851,8 @@ void RenderFrame( ovrRenderer * renderer, const ovrJava * java,
GL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
GL(glDisable(GL_SCISSOR_TEST));
//Now do the drawing for this eye
Cvar_Set("vr_stereo_side", eye == 0 ? "0" : "1");
//Now do the drawing for this eye - Force the set as it is a "read only" cvar
Cvar_Set2("vr_stereo_side", eye == 0 ? "0" : "1", true);
Host_Frame();
}
@@ -1361,15 +1350,15 @@ void VR_Init()
//Create Cvars
vr_snapturn_angle = Cvar_Get( "vr_snapturn_angle", "45", CVAR_ARCHIVE, "Sets the angle for snap-turn, set to < 10.0 to enable smooth turning" );
vr_reloadtimeoutms = Cvar_Get( "vr_reloadtimeoutms", "200", CVAR_ARCHIVE, "How quickly the grip trigger needs to be release to initiate a reload" );
vr_positional_factor = Cvar_Get( "vr_positional_factor", "1800", CVAR_READ_ONLY, "Arbitrary number that makes positional tracking work" );
vr_positional_factor = Cvar_Get( "vr_positional_factor", "2600", CVAR_READ_ONLY, "Arbitrary number that makes positional tracking work" );
vr_walkdirection = Cvar_Get( "vr_walkdirection", "0", CVAR_ARCHIVE, "1 - Use HMD for direction, 0 - Use off-hand controller for direction" );
vr_weapon_pitchadjust = Cvar_Get( "vr_weapon_pitchadjust", "-20.0", CVAR_ARCHIVE, "gun pitch angle adjust" );
vr_weapon_recoil = Cvar_Get( "vr_weapon_recoil", "0", CVAR_ARCHIVE, "Enables weapon recoil in VR, default is disabled, warning could make you sick" );
vr_lasersight = Cvar_Get( "vr_lasersight", "0", CVAR_ARCHIVE, "Enables laser-sight" );
vr_fov = Cvar_Get( "vr_fov", "108.5", CVAR_ARCHIVE, "FOV for Lambda1VR" );
vr_fov = Cvar_Get( "vr_fov", "108", CVAR_ARCHIVE, "FOV for Lambda1VR" );
//Not to be changed by users, as it will be overwritten anyway
vr_stereo_side = Cvar_Get( "vr_stereo_side", "0", CVAR_RENDERINFO, "Eye being drawn" );
vr_stereo_side = Cvar_Get( "vr_stereo_side", "0", CVAR_READ_ONLY, "Eye being drawn" );
}
void * AppThreadFunction( void * parm )
@@ -1384,6 +1373,8 @@ void * AppThreadFunction( void * parm )
// Note that AttachCurrentThread will reset the thread name.
prctl( PR_SET_NAME, (long)"OVR::Main", 0, 0, 0 );
xash_initialised = false;
const ovrInitParms initParms = vrapi_DefaultInitParms( &java );
int32_t initResult = vrapi_Initialize( &initParms );
if ( initResult != VRAPI_INITIALIZE_SUCCESS )
@@ -1399,8 +1390,9 @@ void * AppThreadFunction( void * parm )
// This app will handle android gamepad events itself.
vrapi_SetPropertyInt( &appState.Java, VRAPI_EAT_NATIVE_GAMEPAD_EVENTS, 0 );
//Using a symmetrical render target
m_width=vrapi_GetSystemPropertyInt( &java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_WIDTH ) * SS_MULTIPLIER;
m_height=vrapi_GetSystemPropertyInt( &java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_HEIGHT ) * SS_MULTIPLIER;
m_height=m_width;
ovrEgl_CreateContext( &appState.Egl, NULL );
@@ -1597,19 +1589,11 @@ void * AppThreadFunction( void * parm )
layer.Textures[eye].ColorSwapChain = frameBuffer->ColorTextureSwapChain;
layer.Textures[eye].SwapChainIndex = frameBuffer->TextureSwapChainIndex;
#define OCULUS_QUEST
#ifdef OCULUS_QUEST
ovrMatrix4f projectionMatrix;
projectionMatrix = ovrMatrix4f_CreateProjectionFov(horizFOV+1.0f, vertFOV+4.0f,
0.0f, 0.0f, 0.1f,
0.0f);
projectionMatrix = ovrMatrix4f_CreateProjectionFov(vrFOV, vrFOV,
0.0f, 0.0f, 0.1f, 0.0f);
layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection(&projectionMatrix);
#else
//Gear VR
layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection( &tracking.Eye[eye].ProjectionMatrix );
#endif
layer.Textures[eye].TextureRect.x = 0;
layer.Textures[eye].TextureRect.y = 0;
@@ -1767,7 +1751,6 @@ JNIEXPORT jlong JNICALL Java_com_drbeef_lambda1vr_GLES3JNILib_onCreate( JNIEnv *
ss = arg_dbl0("s", "supersampling", "<double>", "super sampling value (e.g. 1.0)"),
cpu = arg_int0("c", "cpu", "<int>", "CPU perf index 1-3 (default: 2)"),
gpu = arg_int0("g", "gpu", "<int>", "GPU perf index 1-3 (default: 3)"),
msaa = arg_dbl0("m", "msaa", "<int>", "msaa value 1-4 (default 1)"), // Don't think this actually works
end = arg_end(20)
};
@@ -1805,11 +1788,6 @@ JNIEXPORT jlong JNICALL Java_com_drbeef_lambda1vr_GLES3JNILib_onCreate( JNIEnv *
{
GPU_LEVEL = gpu->ival[0];
}
if (msaa->count > 0 && msaa->dval[0] > 0 && msaa->dval[0] < 5)
{
NUM_MULTI_SAMPLES = msaa->dval[0];
}
}
initialize_gl4es();
@@ -0,0 +1,57 @@
#include <xash3d_types.h>
#include <VrApi_Ext.h>
#include <VrApi_Input.h>
#include <android/log.h>
#define LOG_TAG "Lambda1VR"
#ifndef NDEBUG
#define DEBUG 1
#endif
#define ALOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ )
#if DEBUG
#define ALOGV(...) __android_log_print( ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__ )
#else
#define ALOGV(...)
#endif
#define PITCH 0
#define YAW 1
#define ROLL 2
bool xash_initialised;
float playerHeight;
float playerYaw;
bool showingScreenLayer;
float vrFOV;
vec3_t worldPosition;
vec3_t hmdPosition;
vec3_t hmdorientation;
vec3_t positionDeltaThisFrame;
vec3_t weaponangles;
vec3_t weaponoffset;
vec3_t weaponvelocity;
vec3_t flashlightangles;
vec3_t flashlightoffset;
float radians(float deg);
float degrees(float rad);
bool isMultiplayer();
double GetTimeInMilliSeconds();
float length(float x, float y);
float nonLinearFilter(float in);
bool between(float min, float val, float max);
void rotateAboutOrigin(float v1, float v2, float rotation, vec2_t out);
void QuatToYawPitchRoll(ovrQuatf q, vec3_t out);
bool useScreenLayer();
+10 -63
View File
@@ -1,55 +1,5 @@
#include <xash3d_types.h>
#include <VrApi_Ext.h>
#include <VrApi_Input.h>
#include <android/log.h>
#define LOG_TAG "Lambda1VR"
#ifndef NDEBUG
#define DEBUG 1
#endif
#define ALOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ )
#if DEBUG
#define ALOGV(...) __android_log_print( ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__ )
#else
#define ALOGV(...)
#endif
#define PITCH 0
#define YAW 1
#define ROLL 2
float playerHeight;
float playerYaw;
bool showingScreenLayer;
vec3_t worldPosition;
vec3_t hmdPosition;
vec3_t hmdorientation;
vec3_t positionDeltaThisFrame;
vec3_t weaponangles;
vec3_t weaponoffset;
vec3_t weaponvelocity;
vec3_t flashlightangles;
vec3_t flashlightoffset;
float radians(float deg);
float degrees(float rad);
float remote_movementSideways;
float remote_movementForward;
float positional_movementSideways;
float positional_movementForward;
float snapTurn;
#include "VrCommon.h"
ovrInputStateTrackedRemote leftTrackedRemoteState_old;
ovrInputStateTrackedRemote leftTrackedRemoteState_new;
@@ -61,19 +11,16 @@ ovrInputStateTrackedRemote rightTrackedRemoteState_new;
ovrTracking rightRemoteTracking_old;
ovrTracking rightRemoteTracking_new;
float remote_movementSideways;
float remote_movementForward;
float positional_movementSideways;
float positional_movementForward;
float snapTurn;
void sendButtonAction(const char* action, long buttonDown);
void sendButtonActionSimple(const char* action);
void HandleInput_Right( ovrMobile * Ovr, double displayTime );
void HandleInput_Left( ovrMobile * Ovr, double displayTime );
bool isMultiplayer();
double GetTimeInMilliSeconds();
void sendButtonAction(const char* action, long buttonDown);
float length(float x, float y);
float nonLinearFilter(float in);
void sendButtonActionSimple(const char* action);
bool between(float min, float val, float max);
void rotateAboutOrigin(float v1, float v2, float rotation, vec2_t out);
void QuatToYawPitchRoll(ovrQuatf q, vec3_t out);
bool useScreenLayer();
void handleTrackedControllerButton(ovrInputStateTrackedRemote * trackedRemoteState, ovrInputStateTrackedRemote * prevTrackedRemoteState, uint32_t button, int key);
@@ -665,7 +665,7 @@ static void R_SetupModelviewMatrix( const ref_params_t *fd, matrix4x4 m )
Matrix4x4_ConcatTranslate( m, 0, vr_worldscale->value * (0.065f / 2.0f) * ((vr_stereo_side->integer - 0.5f) * 2.0f), 0 );
//Move eyes forward 3cm - super rudimentary neck model lol
Matrix4x4_ConcatTranslate( m, vr_worldscale->value * -0.03f, 0, 0 );
Matrix4x4_ConcatTranslate( m, vr_worldscale->value * -0.025f, 0, 0 );
Matrix4x4_ConcatRotate( m, -fd->viewangles[ROLL], 1, 0, 0 );
Matrix4x4_ConcatRotate( m, -fd->viewangles[PITCH], 0, 1, 0 );