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"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.doom3quest" package="com.drbeef.doom3quest"
android:versionCode="13" android:versionCode="14"
android:versionName="0.1.0" android:installLocation="auto" > android:versionName="0.1.1" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. --> <!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/> <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_showAngles( "com_showAngles", "0", CVAR_SYSTEM | CVAR_BOOL, "" );
idCVar idSessionLocal::com_minTics( "com_minTics", "1", CVAR_SYSTEM, "" ); 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_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_showDemo( "com_showDemo", "0", CVAR_SYSTEM | CVAR_BOOL, "" );
idCVar idSessionLocal::com_skipGameDraw( "com_skipGameDraw", "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 // create client commands, which will be sent directly
// to the game // to the game
if ( com_showTics.GetBool() ) { if ( com_showTics.GetBool() ) {
common->Printf( "%i ", latchedTicNumber - lastGameTic ); common->Printf( " Tics to run: %i ", latchedTicNumber - lastGameTic );
} }
int gameTicsToRun = latchedTicNumber - lastGameTic; int gameTicsToRun = latchedTicNumber - lastGameTic;
int i; int i;
for ( i = 0 ; i < gameTicsToRun ; i++ ) { for ( i = 0 ; i < gameTicsToRun ; i++ )
{
RunGameTic(); RunGameTic();
if ( !mapSpawned ) { if ( !mapSpawned ) {
// exited game play // exited game play
break; break;
} }
if ( syncNextGameFrame ) { if ( syncNextGameFrame ) {
// long game frame, so break out and continue executing as if there was no hitch // long game frame, so break out and continue executing as if there was no hitch
break; 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_showAngles;
static idCVar com_showTics; static idCVar com_showTics;
static idCVar com_skipTics;
static idCVar com_minTics; static idCVar com_minTics;
static idCVar com_fixedTic; static idCVar com_fixedTic;
static idCVar com_showDemo; static idCVar com_showDemo;

View file

@ -587,10 +587,12 @@ void idPlayerView::DoubleVision( idUserInterface *hud, const renderView_t *view,
shift = fabs( shift ); shift = fabs( shift );
// if double vision, render to a texture // if double vision, render to a texture
renderSystem->DirectFrameBufferStart();
renderSystem->CropRenderSize( 512, 256, true ); renderSystem->CropRenderSize( 512, 256, true );
SingleView( hud, view ); SingleView( hud, view );
renderSystem->CaptureRenderToImage( "_scratch" ); renderSystem->CaptureRenderToImage( "_scratch" );
renderSystem->UnCrop(); renderSystem->UnCrop();
renderSystem->DirectFrameBufferEnd();
// carry red tint if in berserk mode // carry red tint if in berserk mode
idVec4 color(1, 1, 1, 1); idVec4 color(1, 1, 1, 1);
@ -611,12 +613,14 @@ idPlayerView::BerserkVision
=================== ===================
*/ */
void idPlayerView::BerserkVision( idUserInterface *hud, const renderView_t *view ) { void idPlayerView::BerserkVision( idUserInterface *hud, const renderView_t *view ) {
renderSystem->DirectFrameBufferStart();
renderSystem->CropRenderSize( 512, 256, true ); renderSystem->CropRenderSize( 512, 256, true );
SingleView( hud, view ); SingleView( hud, view );
renderSystem->CaptureRenderToImage( "_scratch" ); renderSystem->CaptureRenderToImage( "_scratch" );
renderSystem->UnCrop(); renderSystem->UnCrop();
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
renderSystem->DrawStretchPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, 1, 0, dvMaterial ); 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() ) { if ( player->GetInfluenceMaterial() ) {
renderSystem->DirectFrameBufferStart();
SingleView( hud, view ); SingleView( hud, view );
renderSystem->CaptureRenderToImage( "_currentRender" ); renderSystem->CaptureRenderToImage( "_currentRender" );
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, pct ); 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() ); 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 ); SingleView( hud, view );
return; return;
} else { } else {
@ -733,17 +739,17 @@ idPlayerView::RenderPlayerView
void idPlayerView::RenderPlayerView( idUserInterface *hud ) { void idPlayerView::RenderPlayerView( idUserInterface *hud ) {
const renderView_t *view = player->GetRenderView(); const renderView_t *view = player->GetRenderView();
if (g_skipViewEffects.GetBool()) { if (g_skipViewEffects.GetBool()) {
SingleView( hud, view ); SingleView( hud, view );
} else { } else {
if (player->GetInfluenceMaterial() || player->GetInfluenceEntity()) { if (player->GetInfluenceMaterial() || player->GetInfluenceEntity()) {
InfluenceVision( hud, view ); InfluenceVision( hud, view );
} else if (gameLocal.time < dvFinishTime) { } else if (gameLocal.time < dvFinishTime) {
DoubleVision( hud, view, dvFinishTime - gameLocal.time ); DoubleVision( hud, view, dvFinishTime - gameLocal.time );
} else if (player->PowerUpActive(BERSERK)) { } else if (player->PowerUpActive(BERSERK)) {
BerserkVision( hud, view ); BerserkVision( hud, view );
} else { } else {
SingleView( hud, view ); SingleView( hud, view );
} }
ScreenFade(); ScreenFade();
} }

View file

@ -39,8 +39,10 @@ shaderProgram_t stencilShadowShader;
#define NORMAL_PROJECTION 1 #define NORMAL_PROJECTION 1
#define WEAPON_PROJECTION 2 #define WEAPON_PROJECTION 2
#define DEPTH_HACK_PROJECTION 3 #define DEPTH_HACK_PROJECTION 3
#define NUM_DEPTH_HACK_PROJECTIONS 20 #define NUM_DEPTH_HACK_PROJECTIONS 50
GLuint viewMatricesBuffer; GLuint viewMatricesBuffer;
bool projectionMatricesSet = false;
GLuint projectionMatricesBuffer[DEPTH_HACK_PROJECTION + NUM_DEPTH_HACK_PROJECTIONS]; 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 #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 //Set up the buffers that won't change this frame
GL_ViewMatricesUniformBuffer(backEnd.viewDef->worldSpace.viewMatrix); GL_ViewMatricesUniformBuffer(backEnd.viewDef->worldSpace.viewMatrix);
float orthoProjectionMatrix[16]; static bool first = true;
memset(orthoProjectionMatrix, 0, sizeof(orthoProjectionMatrix)); static float defaultProjection[16];
orthoProjectionMatrix[0] = 2.0f / 640.0f; if (first) {
orthoProjectionMatrix[5] = -2.0f / 480.0f; memset(defaultProjection, 0, 16 * sizeof(float));
orthoProjectionMatrix[10] = -2.0f / 1.0f; first = false;
orthoProjectionMatrix[12] = -1.0f; }
orthoProjectionMatrix[13] = 1.0f;
orthoProjectionMatrix[14] = -1.0f;
orthoProjectionMatrix[15] = 1.0f;
//0 is ortho projection matrix //We only need to do the following if the default projection changes
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[ORTHO_PROJECTION], orthoProjectionMatrix); 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 float orthoProjectionMatrix[16];
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[NORMAL_PROJECTION], backEnd.viewDef->projectionMatrix); 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 //0 is ortho projection matrix
float projection[16]; GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[ORTHO_PROJECTION],
RB_ComputeProjection(true, 0.0, projection); orthoProjectionMatrix);
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[WEAPON_PROJECTION], projection);
//3+ ore model depth hack projections //1 is unadjusted projection matrix
for (int i = 0; i < NUM_DEPTH_HACK_PROJECTIONS; ++i) GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[NORMAL_PROJECTION],
{ backEnd.viewDef->projectionMatrix);
float depthHack = (float)(i+1) / float(NUM_DEPTH_HACK_PROJECTIONS);
RB_ComputeProjection(false, depthHack, projection); //2 is weapon depth hack projection
GL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[DEPTH_HACK_PROJECTION + i], 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 // Always enable the vertex, color and texcoord attributes arrays
GL_EnableVertexAttribArray(ATTR_VERTEX); GL_EnableVertexAttribArray(ATTR_VERTEX);