Comfort Vignette (@MuadDib)

+ haptic intensity menu control
This commit is contained in:
Simon 2022-11-25 18:01:08 +00:00
parent 0d3d244157
commit b942a64fc2
12 changed files with 1196 additions and 805 deletions

View file

@ -818,6 +818,11 @@ void updateHMDOrientation()
{ {
VectorCopy(vr.weaponangles, vr.weaponangles_first); VectorCopy(vr.weaponangles, vr.weaponangles_first);
} }
// View yaw delta
float clientview_yaw = vr.clientviewangles[YAW] - vr.hmdorientation[YAW];
vr.clientview_yaw_delta = vr.clientview_yaw_last - clientview_yaw;
vr.clientview_yaw_last = clientview_yaw;
} }
void setHMDPosition( float x, float y, float z ) void setHMDPosition( float x, float y, float z )
@ -1345,6 +1350,7 @@ void JKVR_Init()
vr_irl_crouch_to_stand_ratio = Cvar_Get ("vr_irl_crouch_to_stand_ratio", "0.65", CVAR_ARCHIVE); vr_irl_crouch_to_stand_ratio = Cvar_Get ("vr_irl_crouch_to_stand_ratio", "0.65", CVAR_ARCHIVE);
vr_saber_block_debounce_time = Cvar_Get ("vr_saber_block_debounce_time", "200", CVAR_ARCHIVE); vr_saber_block_debounce_time = Cvar_Get ("vr_saber_block_debounce_time", "200", CVAR_ARCHIVE);
vr_haptic_intensity = Cvar_Get ("vr_haptic_intensity", "1.0", CVAR_ARCHIVE); vr_haptic_intensity = Cvar_Get ("vr_haptic_intensity", "1.0", CVAR_ARCHIVE);
vr_comfort_vignette = Cvar_Get ("vr_comfort_vignette", "0.0", CVAR_ARCHIVE);
cvar_t *expanded_menu_enabled = Cvar_Get ("expanded_menu_enabled", "0", CVAR_ARCHIVE); cvar_t *expanded_menu_enabled = Cvar_Get ("expanded_menu_enabled", "0", CVAR_ARCHIVE);
if (FS_FileExists("expanded_menu.pk3")) { if (FS_FileExists("expanded_menu.pk3")) {

View file

@ -44,6 +44,8 @@ typedef struct {
vec3_t clientviewangles; //orientation in the client - we use this in the cgame vec3_t clientviewangles; //orientation in the client - we use this in the cgame
float snapTurn; // how much turn has been applied to the yaw by joystick float snapTurn; // how much turn has been applied to the yaw by joystick
float clientview_yaw_last; // Don't use this, it is just for calculating delta!
float clientview_yaw_delta;
vec3_t weaponposition; vec3_t weaponposition;
vec3_t weaponoffset; vec3_t weaponoffset;

View file

@ -18,4 +18,5 @@ extern cvar_t *vr_irl_crouch_enabled;
extern cvar_t *vr_irl_crouch_to_stand_ratio; extern cvar_t *vr_irl_crouch_to_stand_ratio;
extern cvar_t *vr_saber_block_debounce_time; extern cvar_t *vr_saber_block_debounce_time;
extern cvar_t *vr_haptic_intensity; extern cvar_t *vr_haptic_intensity;
extern cvar_t *vr_comfort_vignette;

View file

@ -38,6 +38,7 @@ cvar_t *vr_irl_crouch_enabled;
cvar_t *vr_irl_crouch_to_stand_ratio; cvar_t *vr_irl_crouch_to_stand_ratio;
cvar_t *vr_saber_block_debounce_time; cvar_t *vr_saber_block_debounce_time;
cvar_t *vr_haptic_intensity; cvar_t *vr_haptic_intensity;
cvar_t *vr_comfort_vignette;
ovrInputStateTrackedRemote leftTrackedRemoteState_old; ovrInputStateTrackedRemote leftTrackedRemoteState_old;
ovrInputStateTrackedRemote leftTrackedRemoteState_new; ovrInputStateTrackedRemote leftTrackedRemoteState_new;

View file

@ -2571,6 +2571,82 @@ static void CG_DrawZoomBorders( void )
CG_FillRect( 0, 480 - 80, 640, bar_height, modulate ); CG_FillRect( 0, 480 - 80, 640, bar_height, modulate );
} }
/*
==============
CG_DrawVignette
==============
*/
float currentComfortVignetteValue = 0.0f;
float filteredViewYawDelta = 0.0f;
static void CG_DrawVignette( void )
{
playerState_t *ps;
ps = &cg.snap->ps;
cvar_t *vr_comfort_vignette = gi.cvar("vr_comfort_vignette", "0.0", CVAR_ARCHIVE); // defined in VrCvars.h
if (vr_comfort_vignette->value <= 0.0f || vr_comfort_vignette->value > 1.0f || !cg.zoomMode == 0)
{
return;
}
bool isMoving = VectorLength(cg.predicted_player_state.velocity) > 30.0;
// When player is in the air, apply vignette (to prevent throbbing on top of jump)
bool isInAir = ps->groundEntityNum == ENTITYNUM_NONE;
cvar_t *vr_turn_mode = gi.cvar("vr_turn_mode", "0", CVAR_ARCHIVE); // defined in VrCvars.h
// Apply only for smooth turn
bool isTurning = (vr_turn_mode->integer == 2 || (vr_turn_mode->integer == 1 && vr->third_person));
if (isTurning) {
float yawDelta = fabsf(vr->clientview_yaw_delta);
if (yawDelta > 180)
{
yawDelta = fabs(yawDelta - 360);
}
filteredViewYawDelta = filteredViewYawDelta * 0.75f + yawDelta * 0.25f;
isTurning = filteredViewYawDelta > 1;
}
if (isMoving || isInAir || isTurning)
{
if (currentComfortVignetteValue < vr_comfort_vignette->value)
{
currentComfortVignetteValue += vr_comfort_vignette->value * 0.05;
if (currentComfortVignetteValue > 1.0f)
currentComfortVignetteValue = 1.0f;
}
} else{
if (currentComfortVignetteValue > 0.0f)
currentComfortVignetteValue -= vr_comfort_vignette->value * 0.05;
}
if (currentComfortVignetteValue > 0.0f && currentComfortVignetteValue <= 1.0f)
{
int screenWidth = 640; //cg.refdef.width;
int screenHeight = 480; //cg.refdef.height;
int x = (int)(0 + currentComfortVignetteValue * screenWidth / 3.5f);
int w = (int)(screenWidth - 2 * x);
int y = (int)(0 + currentComfortVignetteValue * screenHeight / 3.5f);
int h = (int)(screenHeight - 2 * y);
vec4_t black = {0.0, 0.0, 0.0, 1};
cgi_R_SetColor( black );
// sides
cgi_R_DrawStretchPic( 0, 0, x, screenHeight, 0, 0, 1, 1, cgs.media.whiteShader );
cgi_R_DrawStretchPic( screenWidth - x, 0, x, screenHeight, 0, 0, 1, 1, cgs.media.whiteShader );
// top/bottom
cgi_R_DrawStretchPic( x, 0, screenWidth - x, y, 0, 0, 1, 1, cgs.media.whiteShader );
cgi_R_DrawStretchPic( x, screenHeight - y, screenWidth - x, y, 0, 0, 1, 1, cgs.media.whiteShader );
// vignette
cgi_R_DrawStretchPic( x, y, w, h, 0, 0, 1, 1, cgs.media.vignetteShader );
cgi_R_SetColor( NULL );
}
}
/* /*
================= =================
CG_Draw2D CG_Draw2D
@ -2662,6 +2738,8 @@ static void CG_Draw2D( void )
// don't draw any status if dead // don't draw any status if dead
if ( cg.snap->ps.stats[STAT_HEALTH] > 0 ) if ( cg.snap->ps.stats[STAT_HEALTH] > 0 )
{ {
CG_DrawVignette();
if ( !(cent->gent && cent->gent->s.eFlags & (EF_LOCKED_TO_WEAPON |EF_IN_ATST))) if ( !(cent->gent && cent->gent->s.eFlags & (EF_LOCKED_TO_WEAPON |EF_IN_ATST)))
{ {
CG_DrawIconBackground(); CG_DrawIconBackground();

View file

@ -1313,6 +1313,8 @@ static void CG_RegisterGraphics( void ) {
cgs.media.reticleShader = cgi_R_RegisterShader( "gfx/weapon/scope" ); cgs.media.reticleShader = cgi_R_RegisterShader( "gfx/weapon/scope" );
cgs.media.vignetteShader = cgi_R_RegisterShaderNoMip( "gfx/vignette" );
// FIXME: do these conditionally // FIXME: do these conditionally
cgi_R_RegisterShader( "gfx/2d/workingCamera" ); cgi_R_RegisterShader( "gfx/2d/workingCamera" );

View file

@ -151,6 +151,8 @@ typedef struct {
qhandle_t reticleShader; qhandle_t reticleShader;
qhandle_t vignetteShader;
// Disruptor zoom graphics // Disruptor zoom graphics
qhandle_t disruptorMask; qhandle_t disruptorMask;
qhandle_t disruptorInsert; qhandle_t disruptorInsert;

Binary file not shown.

Binary file not shown.

View file

@ -3,16 +3,16 @@ CONFIG W:\bin\striped.cfg
ID 100 ID 100
REFERENCE MENUS_VR REFERENCE MENUS_VR
DESCRIPTION "VR Menu Localizations" DESCRIPTION "VR Menu Localizations"
COUNT 119 COUNT 123
INDEX 0 INDEX 0
{ {
REFERENCE COMMON_CONTROLS_ITEM REFERENCE COMMON_CONTROLS_ITEM
TEXT_LANGUAGE1 "OBSOLETE Common" TEXT_LANGUAGE1 "Common"
} }
INDEX 1 INDEX 1
{ {
REFERENCE COMMON_CONTROLS_DESC REFERENCE COMMON_CONTROLS_DESC
TEXT_LANGUAGE1 "OBSOLETE Common controls configuration." TEXT_LANGUAGE1 "Common controls configuration."
} }
INDEX 2 INDEX 2
{ {
@ -37,7 +37,7 @@ INDEX 5
INDEX 6 INDEX 6
{ {
REFERENCE COMFORT_CONTROLS_DESC REFERENCE COMFORT_CONTROLS_DESC
TEXT_LANGUAGE1 "Configure common controls and comfort options." TEXT_LANGUAGE1 "Configure comfort options."
} }
INDEX 7 INDEX 7
{ {
@ -599,3 +599,23 @@ INDEX 118
REFERENCE AUTO_USE_BACTA_DESC REFERENCE AUTO_USE_BACTA_DESC
TEXT_LANGUAGE1 "When enabled, automatically uses bacta canister before dying." TEXT_LANGUAGE1 "When enabled, automatically uses bacta canister before dying."
} }
INDEX 119
{
REFERENCE HAPTIC_INTENSITY_ITEM
TEXT_LANGUAGE1 "Haptic Intensity:"
}
INDEX 120
{
REFERENCE HAPTIC_INTENSITY_DESC
TEXT_LANGUAGE1 "Adjust intensity of haptic feedback."
}
INDEX 121
{
REFERENCE COMFORT_VIGNETTE_ITEM
TEXT_LANGUAGE1 "Comfort Vignette:"
}
INDEX 122
{
REFERENCE COMFORT_VIGNETTE_DESC
TEXT_LANGUAGE1 "Adjust size of comfort vignette."
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff