Implementation of comfort vignette

This commit is contained in:
Petr Bartos 2022-03-09 18:58:02 +01:00
parent 3c19d4bf46
commit 48ad5f89d8
8 changed files with 83 additions and 8 deletions

View file

@ -2585,6 +2585,53 @@ static void CG_DrawWeapReticle( void )
}
}
/*
==============
CG_DrawVignette
==============
*/
float currentComfortVignetteValue = 0.0f;
static void CG_DrawVignette( void )
{
float comfortVignetteValue = trap_Cvar_VariableValue( "vr_comfortVignette" );
if (comfortVignetteValue <= 0.0f || comfortVignetteValue > 1.0f)
{
return;
}
if (VectorLength(cg.predictedPlayerState.velocity) > 30.0)
{
if (currentComfortVignetteValue < comfortVignetteValue)
{
currentComfortVignetteValue += comfortVignetteValue * 0.05;
if (currentComfortVignetteValue > 1.0f)
currentComfortVignetteValue = 1.0f;
}
} else{
if (currentComfortVignetteValue > 0.0f)
currentComfortVignetteValue -= comfortVignetteValue * 0.05;
}
if (currentComfortVignetteValue > 0.0f && currentComfortVignetteValue <= 1.0f && !(vr->weapon_zoomed))
{
int x = (int)(0 + currentComfortVignetteValue * cg.refdef.width / 3);
int w = (int)(cg.refdef.width - 2 * x);
int y = (int)(0 + currentComfortVignetteValue * cg.refdef.height / 3);
int h = (int)(cg.refdef.height - 2 * y);
// sides
trap_R_DrawStretchPic( 0, 0, x, cg.refdef.height, 0, 0, 1, 1, cgs.media.maskShader );
trap_R_DrawStretchPic( cg.refdef.width - x, 0, x, cg.refdef.height, 0, 0, 1, 1, cgs.media.maskShader );
// top/bottom
trap_R_DrawStretchPic( x, 0, cg.refdef.width - x, y, 0, 0, 1, 1, cgs.media.maskShader );
trap_R_DrawStretchPic( x, cg.refdef.height - y, cg.refdef.width - x, y, 0, 0, 1, 1, cgs.media.maskShader );
// vignette
trap_R_DrawStretchPic( x, y, w, h, 0, 0, 1, 1, cgs.media.vignetteShader );
}
}
/*
=================
CG_Draw2D
@ -2627,6 +2674,8 @@ static void CG_Draw2D(stereoFrame_t stereoFrame)
// don't draw any status if dead or the scoreboard is being explicitly shown
if ( !cg.showScores && cg.snap->ps.stats[STAT_HEALTH] > 0 ) {
CG_DrawVignette();
#ifdef MISSIONPACK
if ( cg_drawStatus.integer ) {
Menu_PaintAll();

View file

@ -1003,6 +1003,9 @@ typedef struct {
sfxHandle_t wstbimpdSound;
sfxHandle_t wstbactvSound;
// comfort vignette
qhandle_t vignetteShader;
qhandle_t maskShader;
} cgMedia_t;

View file

@ -1051,6 +1051,8 @@ static void CG_RegisterGraphics( void ) {
//Load from pakQ3Q
cgs.media.reticleShader = trap_R_RegisterShader( "gfx/weapon/scope" );
cgs.media.vignetteShader = trap_R_RegisterShader( "gfx/vignette" );
cgs.media.maskShader = trap_R_RegisterShader( "gfx/mask" );
//Used for the weapon selector
cgs.media.smallSphereModel = trap_R_RegisterModel("models/powerups/health/small_sphere.md3");

View file

@ -39,14 +39,15 @@ COMFORT OPTIONS MENU
#define VR_X_POS 360
#define ID_HEIGHTADJUST 127
#define ID_SNAPTURN 128
#define ID_ROLLHIT 129
#define ID_HAPTICINTENSITY 130
#define ID_HUDDEPTH 131
#define ID_HUDYOFFSET 132
#define ID_COMFORTVIGNETTE 127
#define ID_HEIGHTADJUST 128
#define ID_SNAPTURN 129
#define ID_ROLLHIT 130
#define ID_HAPTICINTENSITY 131
#define ID_HUDDEPTH 132
#define ID_HUDYOFFSET 133
#define ID_BACK 133
#define ID_BACK 134
#define NUM_HUDDEPTH 6
@ -58,6 +59,7 @@ typedef struct {
menubitmap_s framel;
menubitmap_s framer;
menuslider_s comfortvignette;
menuslider_s heightadjust;
menulist_s snapturn;
menuradiobutton_s rollhit;
@ -72,6 +74,7 @@ static comfort_t s_comfort;
static void Comfort_SetMenuItems( void ) {
s_comfort.comfortvignette.curvalue = trap_Cvar_VariableValue( "vr_comfortVignette" );
s_comfort.heightadjust.curvalue = trap_Cvar_VariableValue( "vr_heightAdjust" );
s_comfort.snapturn.curvalue = (int)trap_Cvar_VariableValue( "vr_snapturn" ) / 45;
s_comfort.rollhit.curvalue = trap_Cvar_VariableValue( "vr_rollWhenHit" ) != 0;
@ -87,6 +90,10 @@ static void Comfort_MenuEvent( void* ptr, int notification ) {
}
switch( ((menucommon_s*)ptr)->id ) {
case ID_COMFORTVIGNETTE:
trap_Cvar_SetValue( "vr_comfortVignette", s_comfort.comfortvignette.curvalue );
break;
case ID_HEIGHTADJUST:
trap_Cvar_SetValue( "vr_heightAdjust", s_comfort.heightadjust.curvalue );
break;
@ -169,7 +176,18 @@ static void Comfort_MenuInit( void ) {
s_comfort.framer.width = 256;
s_comfort.framer.height = 334;
y = 198;
y = 180;
s_comfort.comfortvignette.generic.type = MTYPE_SLIDER;
s_comfort.comfortvignette.generic.x = VR_X_POS;
s_comfort.comfortvignette.generic.y = y;
s_comfort.comfortvignette.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
s_comfort.comfortvignette.generic.name = "Comfort Vignette:";
s_comfort.comfortvignette.generic.id = ID_COMFORTVIGNETTE;
s_comfort.comfortvignette.generic.callback = Comfort_MenuEvent;
s_comfort.comfortvignette.minvalue = 0.0f;
s_comfort.comfortvignette.maxvalue = 1.0f;
y += BIGCHAR_HEIGHT+2;
s_comfort.heightadjust.generic.type = MTYPE_SLIDER;
s_comfort.heightadjust.generic.x = VR_X_POS;
s_comfort.heightadjust.generic.y = y;
@ -248,6 +266,7 @@ static void Comfort_MenuInit( void ) {
Menu_AddItem( &s_comfort.menu, &s_comfort.framel );
Menu_AddItem( &s_comfort.menu, &s_comfort.framer );
Menu_AddItem( &s_comfort.menu, &s_comfort.comfortvignette );
Menu_AddItem( &s_comfort.menu, &s_comfort.heightadjust );
Menu_AddItem( &s_comfort.menu, &s_comfort.snapturn );
Menu_AddItem( &s_comfort.menu, &s_comfort.rollhit );

View file

@ -35,6 +35,7 @@ cvar_t *vr_hudYOffset = NULL;
cvar_t *vr_sendRollToServer = NULL;
cvar_t *vr_lasersight = NULL;
cvar_t *vr_hapticIntensity = NULL;
cvar_t *vr_comfortVignette = NULL;
engine_t* VR_Init( ovrJava java )
{
@ -71,6 +72,7 @@ void VR_InitCvars( void )
vr_sendRollToServer = Cvar_Get ("vr_sendRollToServer", "1", CVAR_ARCHIVE);
vr_lasersight = Cvar_Get ("vr_lasersight", "0", CVAR_ARCHIVE);
vr_hapticIntensity = Cvar_Get ("vr_hapticIntensity", "1.0", CVAR_ARCHIVE);
vr_comfortVignette = Cvar_Get ("vr_comfortVignette", "0.0", CVAR_ARCHIVE);
// Values are: scale,right,up,forward,pitch,yaw,roll
// VALUES PROVIDED BY SkillFur - Thank-you!

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.