Skip to content

Commit

Permalink
Add new setting values for increased view distances
Browse files Browse the repository at this point in the history
Add 3 new setting values, increasing the distance at which a lower level of detail is used by factors of 1.6, 2.0 and 3.0 (default is 1.25). This allows players for which getting enough FPS is not an issue to reduce pop-in and improve the looks of tracks.

In local testing with a strong CPU and a weak GPU, the performance impact of increasing the view distances is small and well worth it, but this may vary from system to system. More testing is needed on different systems, but this suggests room to increase minimum, default and maximum values in future releases.

This patch also slightly changes the auto-computation of LoD distance, making the transition around a distance of 250 smoother.
  • Loading branch information
Alayan-stk-2 committed Apr 14, 2024
1 parent 31bdb52 commit 6cf094a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion data/gui/dialogs/custom_video_settings.stkgui
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
<div layout="horizontal-row" width="100%" proportion="1">
<label text="Geometry detail" I18N="Video settings" width="40%"/>
<spacer width="10" height="10"/>
<gauge id="geometry_detail" min_value="0" max_value="2" width="50%" />
<gauge id="geometry_detail" min_value="0" max_value="5" width="50%" />
</div>

<spacer height="10" width="10" />
Expand Down
26 changes: 17 additions & 9 deletions src/graphics/lod_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,33 @@ void LODNode::OnRegisterSceneNode()
scene::ISceneNode::OnRegisterSceneNode();
}


/* Each model with LoD has specific distances beyond which it is rendered at a lower
* detail level. This function compute the distances associated with the various
* LoD levels for a given model.
* @param scale The model's scale*/
void LODNode::autoComputeLevel(float scale)
{
m_area *= scale;

// Amount of details based on user's input
float agressivity = 1.0;
if(UserConfigParams::m_geometry_level == 0) agressivity = 1.25;
if(UserConfigParams::m_geometry_level == 1) agressivity = 1.0;
if(UserConfigParams::m_geometry_level == 2) agressivity = 0.75;
if( UserConfigParams::m_geometry_level == 0) agressivity = 1.25;
else if(UserConfigParams::m_geometry_level == 1) agressivity = 1.0;
else if(UserConfigParams::m_geometry_level == 2) agressivity = 0.75;
else if(UserConfigParams::m_geometry_level == 3) agressivity = 1.6;
else if(UserConfigParams::m_geometry_level == 4) agressivity = 2.0;
else if(UserConfigParams::m_geometry_level == 5) agressivity = 3.0;

// First we try to estimate how far away we need to draw
float max_draw = 0.0;
max_draw = sqrtf((0.5 * m_area + 10) * 200) - 10;
// This first formula is equivalent to the one used up to STK 1.4
float max_draw = 10*(sqrtf(m_area + 20) - 1);
// If the draw distance is too big we artificially reduce it
// The formulas are still experimental and improvable.
if(max_draw > 250)
{
max_draw = 250 + (max_draw * 0.06);
}
max_draw = 230 + (max_draw * 0.08);
// This effecte is cumulative
if (max_draw > 500)
max_draw = 200 + (max_draw * 0.6);

max_draw *= agressivity;

Expand Down
19 changes: 16 additions & 3 deletions src/states_screens/dialogs/custom_video_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,21 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
geometry_level->addLabel(_("Very Low"));
//I18N: Geometry level low : few details are displayed
geometry_level->addLabel(_("Low"));
//I18N: Geometry level high : everything is displayed
//I18N: Geometry level medium : everything is displayed, Level-of-Details distances are medium
geometry_level->addLabel(_("Medium"));
//I18N: Geometry level high : everything is displayed, Level-of-Details distances are high
geometry_level->addLabel(_("High"));
//I18N: Geometry level very high : everything is displayed, Level-of-Details distances are very high
geometry_level->addLabel(_("Very High"));
//I18N: Geometry level ultra : everything is displayed, Level-of-Details distances are extremely high
geometry_level->addLabel(_("Ultra"));
// This strange code is needed because a lower geometry level value
// used to be better. The values are now from best to worst: 5, 4, 3, 0, 1, 2.
// This keeps compatibility with 1.X installs.
// FIXME when profile-compatibility is not a concern.
geometry_level->setValue(
UserConfigParams::m_geometry_level == 2 ? 0 :
UserConfigParams::m_geometry_level == 0 ? 2 : 1);
UserConfigParams::m_geometry_level == 0 ? 2 : UserConfigParams::m_geometry_level);

SpinnerWidget* filtering = getWidget<SpinnerWidget>("image_quality");
filtering->addLabel(_("Very Low"));
Expand Down Expand Up @@ -188,7 +198,10 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s

const int val =
getWidget<SpinnerWidget>("geometry_detail")->getValue();
UserConfigParams::m_geometry_level = val == 2 ? 0 : val == 0 ? 2 : 1;
// This strange code is needed because a lower geometry level value
// used to be better. This keeps compatibility with 1.X installs.
UserConfigParams::m_geometry_level = val == 2 ? 0 :
val == 0 ? 2 : val;
int quality = getWidget<SpinnerWidget>("image_quality")->getValue();

user_config->saveConfig();
Expand Down
3 changes: 2 additions & 1 deletion src/tracks/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2357,7 +2357,8 @@ void Track::loadObjects(const XMLNode* root, const std::string& path,
{
int geo_level = 0;
node->get("geometry-level", &geo_level);
if (UserConfigParams::m_geometry_level + geo_level - 2 > 0 &&
if (UserConfigParams::m_geometry_level <= 2 &&
UserConfigParams::m_geometry_level + geo_level - 2 > 0 &&
!NetworkConfig::get()->isNetworking())
continue;
m_track_object_manager->add(*node, parent, model_def_loader, parent_library);
Expand Down

0 comments on commit 6cf094a

Please sign in to comment.