16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 14:49:19 +02:00

build 210509. configurable max draw range factor, moon visualization enhancement, night lighting tweak, minor bug fixes

This commit is contained in:
tmj-fstate
2021-05-10 00:50:54 +02:00
parent 51415ef71f
commit 05d8af139a
13 changed files with 95 additions and 52 deletions

View File

@@ -4185,14 +4185,34 @@ opengl_renderer::Update( double const Deltatime ) {
m_updateaccumulator = 0.0;
m_framerate = 1000.f / ( Timer::subsystem.gfx_total.average() );
// adjust draw ranges etc, based on recent performance
if( Global.targetfps == 0.0f ) {
// automatic adjustment
// adjust draw ranges etc, based on recent performance
// TODO: it doesn't make much sense with vsync
if( Global.targetfps != 0.f ) {
auto const fps_diff = m_framerate - Global.targetfps;
if( fps_diff < -0.5f ) {
Global.fDistanceFactor = std::min( std::max( 1.0f, Global.fDistanceFactor - 0.05f ), Global.gfx_distance_factor_max );
}
else if( fps_diff > 0.5f ) {
Global.fDistanceFactor = std::min( std::min( 3.0f, Global.fDistanceFactor + 0.05f ), Global.gfx_distance_factor_max );
}
}
// legacy framerate parameters
else if( Global.fFpsAverage != 0.f ) {
auto const fps_diff = m_framerate - Global.fFpsAverage;
if( fps_diff < -Global.fFpsDeviation ) {
Global.fDistanceFactor = std::min( std::max( 1.0f, Global.fDistanceFactor - 0.05f ), Global.gfx_distance_factor_max );
}
else if( fps_diff > Global.fFpsDeviation ) {
Global.fDistanceFactor = std::min( std::min( 3.0f, Global.fDistanceFactor + 0.05f ), Global.gfx_distance_factor_max );
}
}
// automatic adjustment
else {
auto const framerate = interpolate( 1000.f / Timer::subsystem.gfx_color.average(), m_framerate, 0.75f );
float targetfactor;
if( framerate > 120.0 ) { targetfactor = 3.00f; }
else if( framerate > 90.0 ) { targetfactor = 1.50f; }
else if( framerate > 60.0 ) { targetfactor = 1.25f; }
if( framerate > 120.f ) { targetfactor = std::min( Global.gfx_distance_factor_max, 3.00f ); }
else if( framerate > 90.f ) { targetfactor = std::min( Global.gfx_distance_factor_max, 1.50f ); }
else if( framerate > 60.f ) { targetfactor = std::min( Global.gfx_distance_factor_max, 1.25f ); }
else { targetfactor = 1.00f; }
if( targetfactor > Global.fDistanceFactor ) {
Global.fDistanceFactor = std::min( targetfactor, Global.fDistanceFactor + 0.05f );
@@ -4201,15 +4221,6 @@ opengl_renderer::Update( double const Deltatime ) {
Global.fDistanceFactor = std::max( targetfactor, Global.fDistanceFactor - 0.05f );
}
}
else {
auto const fps_diff = Global.targetfps - m_framerate;
if( fps_diff > 0.5f ) {
Global.fDistanceFactor = std::max( 1.0f, Global.fDistanceFactor - 0.05f );
}
else if( fps_diff < 1.0f ) {
Global.fDistanceFactor = std::min( 3.0f, Global.fDistanceFactor + 0.05f );
}
}
if( Global.UpdateMaterials ) {
// update resources if there was environmental change