mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-24 21:11:03 +00:00
Added missing shaders and comfort vignette drawing
This commit is contained in:
parent
1597349f9d
commit
6b40649ef5
2 changed files with 84 additions and 0 deletions
|
@ -4062,6 +4062,80 @@ static void CG_DrawZoomBorders( void )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
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
|
||||
|
@ -4173,6 +4247,8 @@ static void CG_Draw2D( void )
|
|||
// don't draw any status if dead
|
||||
if ( cg.snap->ps.stats[STAT_HEALTH] > 0 )
|
||||
{
|
||||
CG_DrawVignette();
|
||||
|
||||
if ( !(cent->gent && cent->gent->s.eFlags & (EF_LOCKED_TO_WEAPON )))//|EF_IN_ATST
|
||||
{
|
||||
//CG_DrawIconBackground();
|
||||
|
|
|
@ -1436,6 +1436,14 @@ static void CG_RegisterGraphics( void ) {
|
|||
|
||||
cgs.media.boltShader = cgi_R_RegisterShader( "gfx/misc/blueLine" );
|
||||
|
||||
cgs.media.reticleShader = cgi_R_RegisterShader( "gfx/weapon/scope" );
|
||||
|
||||
cgs.media.vignetteShader = cgi_R_RegisterShaderNoMip( "gfx/vignette" );
|
||||
|
||||
cgs.media.iconMoveSpeed[0] = cgi_R_RegisterShaderNoMip( "gfx/icon_comfortable" );
|
||||
cgs.media.iconMoveSpeed[1] = cgi_R_RegisterShaderNoMip( "gfx/icon_full" );
|
||||
cgs.media.iconMoveSpeed[2] = cgi_R_RegisterShaderNoMip( "gfx/icon_walk" );
|
||||
|
||||
// FIXME: do these conditionally
|
||||
cgi_R_RegisterShader( "gfx/2d/workingCamera" );
|
||||
cgi_R_RegisterShader( "gfx/2d/brokenCamera" );
|
||||
|
|
Loading…
Reference in a new issue