Various small tweaks to make things smoother

This commit is contained in:
Simon 2020-10-10 19:51:03 +01:00
parent a30446ff59
commit d50c947e37
5 changed files with 73 additions and 36 deletions

View file

@ -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"/>

View file

@ -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, "" );
@ -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;
}
}
}

View file

@ -172,6 +172,7 @@ public:
static idCVar com_showAngles;
static idCVar com_showTics;
static idCVar com_skipTics;
static idCVar com_minTics;
static idCVar com_fixedTic;
static idCVar com_showDemo;

View file

@ -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);
@ -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();
}
@ -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 {
@ -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();
}

View file

@ -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
@ -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;
static bool first = true;
static float defaultProjection[16];
if (first) {
memset(defaultProjection, 0, 16 * sizeof(float));
first = false;
}
//0 is ortho projection matrix
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[ORTHO_PROJECTION], orthoProjectionMatrix);
//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));
//1 is unadjusted projection matrix
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[NORMAL_PROJECTION], backEnd.viewDef->projectionMatrix);
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;
//2 is weapon depth hack projection
float projection[16];
RB_ComputeProjection(true, 0.0, projection);
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[WEAPON_PROJECTION], projection);
//0 is ortho projection matrix
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[ORTHO_PROJECTION],
orthoProjectionMatrix);
//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);
}
//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);