Skip to content

Commit

Permalink
Various small tweaks to make things smoother
Browse files Browse the repository at this point in the history
  • Loading branch information
DrBeef committed Oct 10, 2020
1 parent a30446f commit d50c947
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Projects/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.doom3quest"
android:versionCode="13"
android:versionName="0.1.0" android:installLocation="auto" >
android:versionCode="14"
android:versionName="0.1.1" android:installLocation="auto" >

<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ If you have questions concerning this license or the applicable additional terms

idCVar idSessionLocal::com_showAngles( "com_showAngles", "0", CVAR_SYSTEM | CVAR_BOOL, "" );
idCVar idSessionLocal::com_minTics( "com_minTics", "1", CVAR_SYSTEM, "" );
idCVar idSessionLocal::com_showTics( "com_showTics", "0", CVAR_SYSTEM | CVAR_BOOL, "" );
idCVar idSessionLocal::com_showTics( "com_showTics", "1", CVAR_SYSTEM | CVAR_BOOL, "" );
idCVar idSessionLocal::com_skipTics( "com_skipTics", "1", CVAR_SYSTEM | CVAR_BOOL | CVAR_ARCHIVE, "Skip all missed tics and only use one tick per frame" );
idCVar idSessionLocal::com_fixedTic( "com_fixedTic", "0", CVAR_SYSTEM | CVAR_INTEGER | CVAR_ARCHIVE, "", -1, 10 );
idCVar idSessionLocal::com_showDemo( "com_showDemo", "0", CVAR_SYSTEM | CVAR_BOOL, "" );
idCVar idSessionLocal::com_skipGameDraw( "com_skipGameDraw", "0", CVAR_SYSTEM | CVAR_BOOL, "" );
Expand Down Expand Up @@ -2723,21 +2724,30 @@ void idSessionLocal::Frame() {
// create client commands, which will be sent directly
// to the game
if ( com_showTics.GetBool() ) {
common->Printf( "%i ", latchedTicNumber - lastGameTic );
common->Printf( " Tics to run: %i ", latchedTicNumber - lastGameTic );
}

int gameTicsToRun = latchedTicNumber - lastGameTic;

int i;
for ( i = 0 ; i < gameTicsToRun ; i++ ) {
for ( i = 0 ; i < gameTicsToRun ; i++ )
{
RunGameTic();
if ( !mapSpawned ) {
// exited game play
break;
}

if ( syncNextGameFrame ) {
// long game frame, so break out and continue executing as if there was no hitch
break;
}

//Bit of a hack to smooth things out - needs proper testing
if ( com_skipTics.GetBool() && gameTicsToRun > 1 ) {
syncNextGameFrame = true;
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class idSessionLocal : public idSession {

static idCVar com_showAngles;
static idCVar com_showTics;
static idCVar com_skipTics;
static idCVar com_minTics;
static idCVar com_fixedTic;
static idCVar com_showDemo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,12 @@ void idPlayerView::DoubleVision( idUserInterface *hud, const renderView_t *view,
shift = fabs( shift );

// if double vision, render to a texture
renderSystem->DirectFrameBufferStart();
renderSystem->CropRenderSize( 512, 256, true );
SingleView( hud, view );
renderSystem->CaptureRenderToImage( "_scratch" );
renderSystem->UnCrop();
renderSystem->DirectFrameBufferEnd();

// carry red tint if in berserk mode
idVec4 color(1, 1, 1, 1);
Expand All @@ -611,12 +613,14 @@ idPlayerView::BerserkVision
===================
*/
void idPlayerView::BerserkVision( idUserInterface *hud, const renderView_t *view ) {
renderSystem->DirectFrameBufferStart();
renderSystem->CropRenderSize( 512, 256, true );
SingleView( hud, view );
renderSystem->CaptureRenderToImage( "_scratch" );
renderSystem->UnCrop();
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
renderSystem->DrawStretchPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, 1, 0, dvMaterial );
renderSystem->DirectFrameBufferEnd();
}


Expand Down Expand Up @@ -712,11 +716,13 @@ void idPlayerView::InfluenceVision( idUserInterface *hud, const renderView_t *vi
}
}
if ( player->GetInfluenceMaterial() ) {
renderSystem->DirectFrameBufferStart();
SingleView( hud, view );
renderSystem->CaptureRenderToImage( "_currentRender" );
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, pct );
renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, player->GetInfluenceMaterial() );
} else if ( player->GetInfluenceEntity() == NULL ) {
renderSystem->DirectFrameBufferEnd();
} else if ( player->GetInfluenceEntity() == NULL ) {
SingleView( hud, view );
return;
} else {
Expand All @@ -733,17 +739,17 @@ idPlayerView::RenderPlayerView
void idPlayerView::RenderPlayerView( idUserInterface *hud ) {
const renderView_t *view = player->GetRenderView();

if (g_skipViewEffects.GetBool()) {
if (g_skipViewEffects.GetBool()) {
SingleView( hud, view );
} else {
if (player->GetInfluenceMaterial() || player->GetInfluenceEntity()) {
InfluenceVision( hud, view );
InfluenceVision( hud, view );
} else if (gameLocal.time < dvFinishTime) {
DoubleVision( hud, view, dvFinishTime - gameLocal.time );
DoubleVision( hud, view, dvFinishTime - gameLocal.time );
} else if (player->PowerUpActive(BERSERK)) {
BerserkVision( hud, view );
BerserkVision( hud, view );
} else {
SingleView( hud, view );
SingleView( hud, view );
}
ScreenFade();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ shaderProgram_t stencilShadowShader;
#define NORMAL_PROJECTION 1
#define WEAPON_PROJECTION 2
#define DEPTH_HACK_PROJECTION 3
#define NUM_DEPTH_HACK_PROJECTIONS 20
#define NUM_DEPTH_HACK_PROJECTIONS 50
GLuint viewMatricesBuffer;

bool projectionMatricesSet = false;
GLuint projectionMatricesBuffer[DEPTH_HACK_PROJECTION + NUM_DEPTH_HACK_PROJECTIONS];

#define ATTR_VERTEX 0 // Don't change this, as WebGL require the vertex attrib 0 to be always bound
Expand Down Expand Up @@ -2611,34 +2613,52 @@ void RB_GLSL_PrepareShaders(void) {
//Set up the buffers that won't change this frame
GL_ViewMatricesUniformBuffer(backEnd.viewDef->worldSpace.viewMatrix);

float orthoProjectionMatrix[16];
memset(orthoProjectionMatrix, 0, sizeof(orthoProjectionMatrix));
orthoProjectionMatrix[0] = 2.0f / 640.0f;
orthoProjectionMatrix[5] = -2.0f / 480.0f;
orthoProjectionMatrix[10] = -2.0f / 1.0f;
orthoProjectionMatrix[12] = -1.0f;
orthoProjectionMatrix[13] = 1.0f;
orthoProjectionMatrix[14] = -1.0f;
orthoProjectionMatrix[15] = 1.0f;

//0 is ortho projection matrix
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[ORTHO_PROJECTION], orthoProjectionMatrix);

//1 is unadjusted projection matrix
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[NORMAL_PROJECTION], backEnd.viewDef->projectionMatrix);

//2 is weapon depth hack projection
float projection[16];
RB_ComputeProjection(true, 0.0, projection);
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[WEAPON_PROJECTION], projection);

//3+ ore model depth hack projections
for (int i = 0; i < NUM_DEPTH_HACK_PROJECTIONS; ++i)
{
float depthHack = (float)(i+1) / float(NUM_DEPTH_HACK_PROJECTIONS);
RB_ComputeProjection(false, depthHack, projection);
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[DEPTH_HACK_PROJECTION + i], projection);
}
static bool first = true;
static float defaultProjection[16];
if (first) {
memset(defaultProjection, 0, 16 * sizeof(float));
first = false;
}

//We only need to do the following if the default projection changes
if (memcmp(defaultProjection, backEnd.viewDef->projectionMatrix, 16 * sizeof(float)) != 0)
{
//Take a copy of the default projection
memcpy(defaultProjection, backEnd.viewDef->projectionMatrix, 16 * sizeof(float));

float orthoProjectionMatrix[16];
memset(orthoProjectionMatrix, 0, sizeof(orthoProjectionMatrix));
orthoProjectionMatrix[0] = 2.0f / 640.0f;
orthoProjectionMatrix[5] = -2.0f / 480.0f;
orthoProjectionMatrix[10] = -2.0f / 1.0f;
orthoProjectionMatrix[12] = -1.0f;
orthoProjectionMatrix[13] = 1.0f;
orthoProjectionMatrix[14] = -1.0f;
orthoProjectionMatrix[15] = 1.0f;

//0 is ortho projection matrix
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[ORTHO_PROJECTION],
orthoProjectionMatrix);

//1 is unadjusted projection matrix
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[NORMAL_PROJECTION],
backEnd.viewDef->projectionMatrix);

//2 is weapon depth hack projection
float projection[16];
RB_ComputeProjection(true, 0.0, projection);
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[WEAPON_PROJECTION], projection);

//3+ ore model depth hack projections
for (int i = 0; i < NUM_DEPTH_HACK_PROJECTIONS; ++i) {
float depthHack = (float) (i + 1) / float(NUM_DEPTH_HACK_PROJECTIONS);
RB_ComputeProjection(false, depthHack, projection);
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[DEPTH_HACK_PROJECTION + i],
projection);
}

projectionMatricesSet = true;
}

// Always enable the vertex, color and texcoord attributes arrays
GL_EnableVertexAttribArray(ATTR_VERTEX);
Expand Down

0 comments on commit d50c947

Please sign in to comment.