Merge pull request #88 from petr666/VrApi

Configurable supersampling, added 120hz option, small cosmetic change (VrApi)
This commit is contained in:
Simon 2022-09-30 18:39:11 +01:00 committed by GitHub
commit 1d81801087
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 187 additions and 43 deletions

View file

@ -2824,7 +2824,7 @@ void CG_DrawActive( void ) {
// clear around the rendered view if sized down
CG_TileClear();
if(!vr->weapon_zoomed)
if(!vr->weapon_zoomed && !vr->virtual_screen)
CG_DrawCrosshair3D();
// offset vieworg appropriately if we're doing stereo separation
@ -2892,7 +2892,7 @@ void CG_DrawActive( void ) {
}
//Now draw the HUD shader in the world
if (trap_Cvar_VariableValue("vr_hudDrawStatus") != 2.0f)
if (trap_Cvar_VariableValue("vr_hudDrawStatus") != 2.0f && !vr->weapon_zoomed && !vr->virtual_screen)
{
refEntity_t ent;
trace_t trace;
@ -2955,7 +2955,7 @@ void CG_DrawActive( void ) {
//Now draw the screen 2D stuff
CG_DrawScreen2D();
if (!vr->weapon_zoomed)
if (!vr->weapon_zoomed && !vr->virtual_screen)
{
cg.drawingHUD = qtrue;

View file

@ -1728,8 +1728,8 @@ void CG_AddViewWeapon( playerState_t *ps ) {
return;
}
if (vr->weapon_zoomed) {
return; // do not draw weapon model with enabled weapon scope
if (vr->weapon_zoomed || vr->virtual_screen) {
return; // do not draw weapon model with enabled weapon scope or when in menu
}
cent = &cg.predictedPlayerEntity; // &cg_entities[cg.snap->ps.clientNum];

View file

@ -249,10 +249,12 @@ GRAPHICS OPTIONS MENU
#define ID_PLAYERSHADOW 109
#define ID_GAMMA 110
#define ID_HIGHQUALITYSKY 111
#define ID_SUPERSAMPLING 112
#define NUM_REFRESHRATE 4
#define NUM_REFRESHRATE 5
#define NUM_SHADOWS 3
#define NUM_RAILGUN 2
#define NUM_SUPERSAMPLING 6
typedef struct {
menuframework_s menu;
@ -276,6 +278,7 @@ typedef struct {
menulist_s playershadow;
menuslider_s gamma;
menuradiobutton_s highqualitysky;
menulist_s supersampling;
menubitmap_s apply;
menubitmap_s back;
@ -292,6 +295,7 @@ typedef struct
int playershadow;
float gamma;
int highqualitysky;
float supersampling;
} InitialVideoOptions_s;
static InitialVideoOptions_s s_ivo;
@ -313,6 +317,7 @@ static void GraphicsOptions_GetInitialVideo( void )
s_ivo.playershadow = s_graphicsoptions.playershadow.curvalue;
s_ivo.gamma = s_graphicsoptions.gamma.curvalue;
s_ivo.highqualitysky = s_graphicsoptions.highqualitysky.curvalue;
s_ivo.supersampling = s_graphicsoptions.supersampling.curvalue;
}
/*
@ -401,6 +406,9 @@ static void GraphicsOptions_Event( void* ptr, int event ) {
case 3:
refresh = 90;
break;
case 4:
refresh = 120;
break;
}
trap_Cvar_SetValue("vr_refreshrate", refresh);
}
@ -452,6 +460,32 @@ static void GraphicsOptions_Event( void* ptr, int event ) {
trap_Cvar_SetValue( "r_fastsky", !s_graphicsoptions.highqualitysky.curvalue );
break;
case ID_SUPERSAMPLING: {
float supersampling;
switch (s_graphicsoptions.supersampling.curvalue) {
case 0:
supersampling = 0.8;
break;
case 1:
supersampling = 0.9;
break;
case 2:
supersampling = 1.0;
break;
case 3:
supersampling = 1.1;
break;
case 4:
supersampling = 1.2;
break;
case 5:
supersampling = 1.3;
break;
}
trap_Cvar_SetValue("vr_superSampling", supersampling);
}
break;
case ID_DRIVERINFO:
UI_DriverInfo_Menu();
break;
@ -542,6 +576,12 @@ static void GraphicsOptions_SetMenuItems( void )
case 90:
s_graphicsoptions.refreshrate.curvalue = 3;
break;
case 120:
s_graphicsoptions.refreshrate.curvalue = 4;
break;
default:
s_graphicsoptions.refreshrate.curvalue = 1;
break;
}
switch ( (int) trap_Cvar_VariableValue( "cg_shadows" ) )
@ -570,6 +610,23 @@ static void GraphicsOptions_SetMenuItems( void )
break;
}
float superSampling = trap_Cvar_VariableValue( "vr_superSampling" );
if (superSampling == 0.8f) {
s_graphicsoptions.supersampling.curvalue = 0;
} else if (superSampling == 0.9f) {
s_graphicsoptions.supersampling.curvalue = 1;
} else if (superSampling == 1.0f) {
s_graphicsoptions.supersampling.curvalue = 2;
} else if (superSampling == 1.1f) {
s_graphicsoptions.supersampling.curvalue = 3;
} else if (superSampling == 1.2f) {
s_graphicsoptions.supersampling.curvalue = 4;
} else if (superSampling == 1.3f) {
s_graphicsoptions.supersampling.curvalue = 5;
} else {
s_graphicsoptions.supersampling.curvalue = 3;
}
s_graphicsoptions.lighting.curvalue = trap_Cvar_VariableValue( "r_vertexLight" ) != 0;
s_graphicsoptions.railgun.curvalue = trap_Cvar_VariableValue( "cg_oldRail" );
s_graphicsoptions.gamma.curvalue = trap_Cvar_VariableValue( "r_gamma" );
@ -602,9 +659,10 @@ void GraphicsOptions_MenuInit( void )
static const char *s_refreshrate[] =
{
"60",
"72 (Recommended)",
"72",
"80",
"90",
"120",
NULL
};
@ -623,6 +681,17 @@ void GraphicsOptions_MenuInit( void )
NULL
};
static const char *s_supersampling[] =
{
"0.8",
"0.9",
"1.0",
"1.1",
"1.2",
"1.3",
NULL
};
int y;
// zero set all our globals
@ -687,7 +756,7 @@ void GraphicsOptions_MenuInit( void )
s_graphicsoptions.network.style = UI_RIGHT;
s_graphicsoptions.network.color = color_red;
y = 254 - 5 * (BIGCHAR_HEIGHT + 2);
y = 254 - 6 * (BIGCHAR_HEIGHT + 2);
// references "vr_refreshrate"
s_graphicsoptions.refreshrate.generic.type = MTYPE_SPINCONTROL;
@ -701,6 +770,18 @@ void GraphicsOptions_MenuInit( void )
s_graphicsoptions.refreshrate.numitems = NUM_REFRESHRATE;
y += BIGCHAR_HEIGHT+2;
// references "vr_superSampling"
s_graphicsoptions.supersampling.generic.type = MTYPE_SPINCONTROL;
s_graphicsoptions.supersampling.generic.name = "Supersampling:";
s_graphicsoptions.supersampling.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_graphicsoptions.supersampling.generic.x = 400;
s_graphicsoptions.supersampling.generic.y = y;
s_graphicsoptions.supersampling.itemnames = s_supersampling;
s_graphicsoptions.supersampling.generic.callback = GraphicsOptions_Event;
s_graphicsoptions.supersampling.generic.id = ID_SUPERSAMPLING;
s_graphicsoptions.supersampling.numitems = NUM_SUPERSAMPLING;
y += BIGCHAR_HEIGHT+2;
// references "r_gamma"
s_graphicsoptions.gamma.generic.type = MTYPE_SLIDER;
s_graphicsoptions.gamma.generic.name = "Brightness:";
@ -828,6 +909,7 @@ void GraphicsOptions_MenuInit( void )
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.network );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.refreshrate );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.supersampling );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.railgun );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.gamma );
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.lighting );

View file

@ -31,6 +31,7 @@ cvar_t *vr_weaponPitch = NULL;
cvar_t *vr_twoHandedWeapons = NULL;
cvar_t *vr_showItemInHand = NULL;
cvar_t *vr_refreshrate = NULL;
cvar_t *vr_superSampling = NULL;
cvar_t *vr_weaponScope = NULL;
cvar_t *vr_rollWhenHit = NULL;
cvar_t *vr_hudYOffset = NULL;
@ -76,6 +77,7 @@ void VR_InitCvars( void )
vr_twoHandedWeapons = Cvar_Get ("vr_twoHandedWeapons", "1", CVAR_ARCHIVE);
vr_showItemInHand = Cvar_Get ("vr_showItemInHand", "1", CVAR_ARCHIVE);
vr_refreshrate = Cvar_Get ("vr_refreshrate", "72", CVAR_ARCHIVE);
vr_superSampling = Cvar_Get ("vr_superSampling", "1.1", CVAR_ARCHIVE);
vr_weaponScope = Cvar_Get ("vr_weaponScope", "1", CVAR_ARCHIVE);
vr_rollWhenHit = Cvar_Get ("vr_rollWhenHit", "0", CVAR_ARCHIVE);
vr_hudYOffset = Cvar_Get ("vr_hudYOffset", "0", CVAR_ARCHIVE);

View file

@ -63,6 +63,8 @@ typedef struct {
int *menuCursorX;
int *menuCursorY;
qboolean menuLeftHanded;
float superSampling;
} vr_clientinfo_t;
#endif //vr_clientinfo_h

View file

@ -30,10 +30,16 @@
#include <GLES3/gl32.h>
#endif
#define SUPER_SAMPLE 1.15f
#define DEFAULT_SUPER_SAMPLING 1.1f
extern vr_clientinfo_t vr;
int menuResWidth = 0.0f;
int menuResHeight = 0.0f;
int gameResWidth = 0.0f;
int gameResHeight = 0.0f;
qboolean fullscreenMode = qfalse;
void APIENTRY VR_GLDebugLog(GLenum source, GLenum type, GLuint id,
GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
{
@ -66,13 +72,29 @@ void APIENTRY VR_GLDebugLog(GLenum source, GLenum type, GLuint id,
void VR_GetResolution(engine_t* engine, int *pWidth, int *pHeight)
{
static int width = 0;
static int height = 0;
float superSampling = 0.0f;
float configuredSuperSampling = Cvar_VariableValue("vr_superSampling");
if (vr.superSampling == 0.0f || configuredSuperSampling != vr.superSampling) {
vr.superSampling = configuredSuperSampling;
if (vr.superSampling != 0.0f) {
Cbuf_AddText( "vid_restart\n" );
}
}
if (vr.superSampling == 0.0f) {
superSampling = DEFAULT_SUPER_SAMPLING;
} else {
superSampling = vr.superSampling;
}
if (engine)
{
*pWidth = width = vrapi_GetSystemPropertyInt(&engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_WIDTH) * SUPER_SAMPLE;
*pHeight = height = vrapi_GetSystemPropertyInt(&engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_HEIGHT) * SUPER_SAMPLE;
menuResWidth = vrapi_GetSystemPropertyInt(&engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_WIDTH) * DEFAULT_SUPER_SAMPLING;
menuResHeight = vrapi_GetSystemPropertyInt(&engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_HEIGHT) * DEFAULT_SUPER_SAMPLING;
*pWidth = gameResWidth = vrapi_GetSystemPropertyInt(&engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_WIDTH) * superSampling;
*pHeight = gameResHeight = vrapi_GetSystemPropertyInt(&engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_HEIGHT) * superSampling;
vr.fov_x = vrapi_GetSystemPropertyInt( &engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X);
vr.fov_y = vrapi_GetSystemPropertyInt( &engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y);
@ -80,8 +102,8 @@ void VR_GetResolution(engine_t* engine, int *pWidth, int *pHeight)
else
{
//use cached values
*pWidth = width;
*pHeight = height;
*pWidth = gameResWidth;
*pHeight = gameResHeight;
}
}
@ -148,7 +170,7 @@ void VR_InitRenderer( engine_t* engine ) {
}
void VR_DestroyRenderer( engine_t* engine ) {
for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye)
//for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye)
{
if (engine->framebuffers.swapchainLength > 0) {
glDeleteFramebuffers(engine->framebuffers.swapchainLength,
@ -312,18 +334,17 @@ void VR_DrawFrame( engine_t* engine ) {
const ovrMatrix4f monoVRMatrix = ovrMatrix4f_CreateProjectionFov(
30.0f, 30.0f, 0.0f, 0.0f, 1.0f, 0.0f );
int eyeW, eyeH;
VR_GetResolution(engine, &eyeW, &eyeH);
if (VR_useScreenLayer() ||
(cl.snap.ps.pm_flags & PMF_FOLLOW && vr.follow_mode == VRFM_FIRSTPERSON))
{
fullscreenMode = qtrue;
static ovrLayer_Union2 cylinderLayer;
memset( &cylinderLayer, 0, sizeof( ovrLayer_Union2 ) );
// Add a simple cylindrical layer
cylinderLayer.Cylinder =
BuildCylinderLayer(engine, eyeW, eyeW * 0.75f, &engine->tracking, radians(vr.menuYaw) );
BuildCylinderLayer(engine, menuResWidth, menuResWidth * 0.75f, &engine->tracking, radians(vr.menuYaw) );
const ovrLayerHeader2* layers[] = {
&cylinderLayer.Header
@ -341,7 +362,7 @@ void VR_DrawFrame( engine_t* engine ) {
re.SetVRHeadsetParms(&projectionMatrix, &monoVRMatrix,
engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex]);
VR_ClearFrameBuffer(engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex], eyeW, eyeH);
VR_ClearFrameBuffer(engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex], menuResWidth, menuResHeight);
Com_Frame();
@ -359,6 +380,11 @@ void VR_DrawFrame( engine_t* engine ) {
}
else
{
if (fullscreenMode) {
VR_ReInitRenderer();
fullscreenMode = qfalse;
}
vr.menuYaw = vr.hmdorientation[YAW];
ovrLayerProjection2 layer = vrapi_DefaultLayerProjection2();
@ -375,7 +401,7 @@ void VR_DrawFrame( engine_t* engine ) {
}
layer.Header.Flags |= VRAPI_FRAME_LAYER_FLAG_CHROMATIC_ABERRATION_CORRECTION;
VR_ClearFrameBuffer(engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex], eyeW, eyeH);
VR_ClearFrameBuffer(engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex], gameResWidth, gameResHeight);
re.SetVRHeadsetParms(&projectionMatrix, &monoVRMatrix,
engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex]);

View file

@ -184,7 +184,7 @@ itemDef {
type ITEM_TYPE_MULTI
text "Refresh Rate:"
cvar "vr_refreshrate"
cvarFloatList { "60" 60 "72 (Recommended)" 72 "80" 80 "90" 90 }
cvarFloatList { "60" 60 "72" 72 "80" 80 "90" 90 "120" 120 }
rect 0 50 306 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
@ -194,13 +194,29 @@ itemDef {
visible 0
}
itemDef {
name graphics
group grpSystem
type ITEM_TYPE_MULTI
text "Supersampling:"
cvar "vr_superSampling"
cvarFloatList { "0.8" 0.8 "0.9" 0.9 "1.0" 1.0 "1.1" 1.1 "1.2" 1.2 "1.3" 1.3 }
rect 0 70 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
textaligny 17
textscale .25
forecolor 1 1 1 1
visible 0
}
itemDef {
name graphics
group grpSystem
type ITEM_TYPE_SLIDER
text "Brightness:"
cvarfloat "r_gamma" 0.05 0.8 1.2
rect 0 70 256 20
rect 0 90 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
textaligny 17
@ -216,7 +232,7 @@ itemDef {
text "Railgun Effect:"
cvar "cg_oldRail"
cvarFloatList { "Q2 Style" 0 "Q3 Style" 1 }
rect 0 90 256 20
rect 0 110 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
textaligny 17
@ -232,7 +248,7 @@ itemDef {
text "Lighting:"
cvar "r_vertexlight"
cvarFloatList { "Lightmap (High)" 0 "Vertex (Low)" 1 }
rect 0 110 256 20
rect 0 130 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
textaligny 17
@ -249,7 +265,7 @@ itemDef {
text "Opponent Shadows:"
cvar "cg_shadows"
cvarFloatList { "None" 0 "Low" 1 "High" 3 }
rect 0 130 306 20
rect 0 150 306 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
textaligny 17
@ -265,7 +281,7 @@ itemDef {
text "Player Shadow:"
cvar "cg_playerShadow"
cvarFloatList { "None" 0 "Low" 1 "High" 3 }
rect 0 150 306 20
rect 0 170 306 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
textaligny 17
@ -281,7 +297,7 @@ itemDef {
text "Geometric Detail:"
cvar "r_lodbias"
cvarFloatList { "High" -1 "Medium" 1 "Low" 2 }
rect 0 170 256 20
rect 0 190 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
textaligny 17
@ -298,7 +314,7 @@ itemDef {
text "Texture Detail:"
cvar "r_picmip"
cvarFloatList { "Low" 2 "Normal" 1 "High" 0 }
rect 0 190 256 20
rect 0 210 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
textaligny 17
@ -314,7 +330,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Compress Textures:"
cvar "r_ext_compressed_textures"
rect 0 210 256 20
rect 0 230 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
textaligny 17
@ -330,7 +346,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Low Quality Sky:"
cvar "r_fastsky"
rect 0 230 256 20
rect 0 250 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 133
textaligny 17

View file

@ -87,7 +87,7 @@ itemDef {
type ITEM_TYPE_MULTI
text "Refresh Rate:"
cvar "vr_refreshrate"
cvarFloatList { "60" 60 "72 (Recommended)" 72 "80" 80 "90" 90 }
cvarFloatList { "60" 60 "72" 72 "80" 80 "90" 90 "120" 120 }
rect 99 42 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
@ -97,13 +97,29 @@ itemDef {
visible 0
}
itemDef {
name graphics
group grpSystem
type ITEM_TYPE_MULTI
text "Supersampling:"
cvar "vr_superSampling"
cvarFloatList { "0.8" 0.8 "0.9" 0.9 "1.0" 1.0 "1.1" 1.1 "1.2" 1.2 "1.3" 1.3 }
rect 99 67 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
textscale .333
forecolor 1 1 1 1
visible 0
}
itemDef {
name graphics
group grpSystem
type ITEM_TYPE_SLIDER
text "Brightness:"
cvarfloat "r_gamma" 0.05 0.8 1.2
rect 99 67 256 20
rect 99 92 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -119,7 +135,7 @@ itemDef {
text "Railgun Effect:"
cvar "cg_oldRail"
cvarFloatList { "Q2 Style" 0 "Q3 Style" 1 }
rect 99 92 256 20
rect 99 117 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -135,7 +151,7 @@ itemDef {
text "Lighting:"
cvar "r_vertexlight"
cvarFloatList { "Lightmap (High)" 0 "Vertex (Low)" 1 }
rect 99 117 256 20
rect 99 142 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -152,7 +168,7 @@ itemDef {
text "Opponent Shadows:"
cvar "cg_shadows"
cvarFloatList { "None" 0 "Low" 1 "High" 3 }
rect 99 142 256 20
rect 99 167 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -168,7 +184,7 @@ itemDef {
text "Player Shadow:"
cvar "cg_playerShadow"
cvarFloatList { "None" 0 "Low" 1 "High" 3 }
rect 99 167 256 20
rect 99 192 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -184,7 +200,7 @@ itemDef {
text "Geometric Detail:"
cvar "r_lodbias"
cvarFloatList { "High" -1 "Medium" 1 "Low" 2 }
rect 99 192 256 20
rect 99 217 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -201,7 +217,7 @@ itemDef {
text "Texture Detail:"
cvar "r_picmip"
cvarFloatList { "Low" 2 "Normal" 1 "High" 0 }
rect 99 217 256 20
rect 99 242 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -217,7 +233,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Compress Textures:"
cvar "r_ext_compressed_textures"
rect 99 242 256 20
rect 99 267 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20
@ -233,7 +249,7 @@ itemDef {
type ITEM_TYPE_YESNO
text "Low Quality Sky:"
cvar "r_fastsky"
rect 99 267 256 20
rect 99 292 256 20
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 20