Skip to content

Commit

Permalink
Reorganize graphics settings, add 4096 shadows
Browse files Browse the repository at this point in the history
- Add 4096 resolution shadows. This helps noticeably in some places to reduce shadow aliasing, nonetheless, for most users, the significant performance hit will not be worth the small quality gains.
- Add an 8th graphics preset, with max resolution shadows.
- Enable Light Shaft (God Rays) only on level 5, instead of level 4
- Enable SSAO only on level 7 instead of level 6
- Changed the location of specific settings in the custom settings dialog, to group the blur options at the end and to have less performance-intensive options towards the top. The options activated on each preset level are now 'connected'.
- Remove the text saying the game needs to be restarted to apply new settings - the player doesn't need to manually restart the game, STK takes care of it when needed
- Remove unused variables and fix typo
  • Loading branch information
Alayan-stk-2 committed Jan 24, 2025
1 parent b180a49 commit 70c2ba0
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 59 deletions.
60 changes: 28 additions & 32 deletions data/gui/dialogs/custom_video_settings.stkgui
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div layout="horizontal-row" proportion="1" height="fit">
<label text="Shadows" I18N="Video settings"/>
<spacer width="10" height="10"/>
<gauge id="shadows" min_value="0" max_value="3" proportion="1"/>
<gauge id="shadows" min_value="0" max_value="4" proportion="1"/>
</div>
</div>

Expand All @@ -39,17 +39,17 @@
<spacer width="70" height="10"/>

<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="bloom"/>
<checkbox id="mlaa"/>
<spacer width="10" height="10"/>
<label text="Bloom" I18N="Video settings"/>
<label text="Anti-aliasing" I18N="Video settings"/>
</div>

<spacer height="4" width="10" />

<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="lightshaft"/>
<checkbox id="lightscattering"/>
<spacer width="10" height="10"/>
<label text="Light shaft (God rays)" I18N="Video settings"/>
<label text="Light Scattering" I18N="Video settings"/>
</div>
</div>

Expand All @@ -59,69 +59,69 @@
<spacer width="70" height="10"/>

<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="ssao"/>
<checkbox id="glow"/>
<spacer width="10" height="10"/>
<label text="Ambient occlusion" I18N="Video settings"/>
<label text="Glow (Outlines)" I18N="Video settings"/>
</div>

<spacer height="4" width="10" />

<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="dof"/>
<checkbox id="lightshaft"/>
<spacer width="10" height="10"/>
<label text="Depth of field" I18N="Video settings"/>
<label text="Light shaft (God rays)" I18N="Video settings"/>
</div>
</div>

<spacer height="4" width="10" />

<div layout="horizontal-row" width="100%" proportion="1">
<spacer width="70" height="10"/>

<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="glow"/>
<checkbox id="ibl"/>
<spacer width="10" height="10"/>
<label text="Glow (Outlines)" I18N="Video settings"/>
<label text="Image-based lighting" I18N="Video settings"/>
</div>

<spacer height="4" width="10" />

<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="mlaa"/>
<checkbox id="bloom"/>
<spacer width="10" height="10"/>
<label text="Anti-aliasing" I18N="Video settings"/>
<label text="Bloom" I18N="Video settings"/>
</div>
</div>

<spacer height="4" width="10" />

<div layout="horizontal-row" width="100%" proportion="1">
<spacer width="70" height="10"/>

<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="motionblur"/>
<spacer width="10" height="10"/>
<label text="Motion blur" I18N="Video settings"/>
</div>

<spacer height="4" width="10" />

<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="ibl"/>
<checkbox id="ssao"/>
<spacer width="10" height="10"/>
<label text="Image-based lighting" I18N="Video settings"/>
<label text="Ambient occlusion" I18N="Video settings"/>
</div>
</div>

<spacer height="4" width="10" />

<div layout="horizontal-row" width="100%" proportion="1">
<spacer width="70" height="10"/>

<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="lightscattering"/>
<checkbox id="motionblur"/>
<spacer width="10" height="10"/>
<label text="Light Scattering" I18N="Video settings"/>
<label text="Motion blur" I18N="Video settings"/>
</div>

<spacer height="4" width="10" />

<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="dof"/>
<spacer width="10" height="10"/>
<label text="Depth of field" I18N="Video settings"/>
</div>
</div>

Expand Down Expand Up @@ -167,11 +167,7 @@
<gauge id="geometry_detail" min_value="0" max_value="5" width="50%" />
</div>

<spacer height="10" width="10" />

<label text="* Restart STK to apply new settings" width="100%" text_align="center" I18N="Video settings"/>

<spacer height="4" width="10"/>
<spacer height="10" width="10"/>

<buttonbar id="buttons" height="15%" width="30%" align="center">
<icon-button id="cancel" width="128" height="128" icon="gui/icons/red_x.png"
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/irr_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ void IrrDriver::initDevice()

if (UserConfigParams::m_shadows_resolution != 0 &&
(UserConfigParams::m_shadows_resolution < 512 ||
UserConfigParams::m_shadows_resolution > 2048))
UserConfigParams::m_shadows_resolution > 4096))
{
Log::warn("irr_driver",
"Invalid value for UserConfigParams::m_shadows_resolution : %i",
Expand Down
14 changes: 4 additions & 10 deletions src/graphics/shadow_matrices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,9 @@ static std::vector<vector3df> getFrustrumVertex(const scene::SViewFrustum &frust
* and 1.
* \param transform a transform matrix.
* \param pointsInside a vector of point in 3d space.
* \param size returns the size (width, height) of shadowmap coverage
*/
core::matrix4 ShadowMatrices::getTighestFitOrthoProj(const core::matrix4 &transform,
const std::vector<vector3df> &pointsInside,
std::pair<float, float> &size)
core::matrix4 ShadowMatrices::getTightestFitOrthoProj(const core::matrix4 &transform,
const std::vector<vector3df> &pointsInside)
{
float xmin = std::numeric_limits<float>::infinity();
float xmax = -std::numeric_limits<float>::infinity();
Expand All @@ -173,9 +171,6 @@ core::matrix4 ShadowMatrices::getTighestFitOrthoProj(const core::matrix4 &transf
float up = ymin;
float down = ymax;

size.first = right - left;
size.second = down - up;

core::matrix4 tmp_matrix;
// Prevent Matrix without extend
if (left == right || up == down)
Expand All @@ -184,7 +179,7 @@ core::matrix4 ShadowMatrices::getTighestFitOrthoProj(const core::matrix4 &transf
down, up,
zmin - 100, zmax);
return tmp_matrix;
} // getTighestFitOrthoProj
} // getTightestFitOrthoProj

// ----------------------------------------------------------------------------
/** Generate View, Projection, Inverse View, Inverse Projection, ViewProjection
Expand Down Expand Up @@ -280,8 +275,7 @@ void ShadowMatrices::computeMatrixesAndCameras(scene::ICameraSceneNode *const ca
memcpy(m_shadows_cam[i], tmp, 24 * sizeof(float));

std::vector<vector3df> vectors = getFrustrumVertex(*frustrum);
tmp_matrix = getTighestFitOrthoProj(sun_cam_view_matrix, vectors,
m_shadow_scales[i]);
tmp_matrix = getTightestFitOrthoProj(sun_cam_view_matrix, vectors);


m_shadow_cam_nodes[i]->setProjectionMatrix(tmp_matrix, true);
Expand Down
11 changes: 2 additions & 9 deletions src/graphics/shadow_matrices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ class ShadowMatrices
std::vector<core::matrix4> m_sun_ortho_matrices;
scene::ICameraSceneNode *m_sun_cam;
scene::ICameraSceneNode *m_shadow_cam_nodes[4];
std::pair<float, float> m_shadow_scales[4];
core::matrix4 m_rsm_matrix;
bool m_rsm_matrix_initialized;
float m_shadows_cam[4][24];
bool m_rsm_map_available;
float m_mat_ubo[16 * 9 + 2];

core::matrix4 getTighestFitOrthoProj(const core::matrix4 &transform,
const std::vector<core::vector3df> &pointsInside,
std::pair<float, float> &size);
core::matrix4 getTightestFitOrthoProj(const core::matrix4 &transform,
const std::vector<core::vector3df> &pointsInside);
void renderWireFrameFrustrum(float *tmp, unsigned i);
public:

Expand Down Expand Up @@ -84,11 +82,6 @@ class ShadowMatrices
return m_sun_ortho_matrices;
}
// ------------------------------------------------------------------------
const std::pair<float, float>* getShadowScales() const
{
return m_shadow_scales;
}
// ------------------------------------------------------------------------
const float* getMatricesData() const { return m_mat_ubo; }

}; // class ShadowMatrices
Expand Down
7 changes: 5 additions & 2 deletions src/states_screens/dialogs/custom_video_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ void CustomVideoSettingsDialog::beforeAddingWidgets()
shadows->addLabel(_("Low")); // 1
shadows->addLabel(_("Medium")); // 2
shadows->addLabel(_("High")); // 3
shadows->setValue(UserConfigParams::m_shadows_resolution == 2048 ? 3 :
shadows->addLabel(_("Very High")); // 4
shadows->setValue(UserConfigParams::m_shadows_resolution == 4096 ? 4 :
UserConfigParams::m_shadows_resolution == 2048 ? 3 :
UserConfigParams::m_shadows_resolution == 1024 ? 2 :
UserConfigParams::m_shadows_resolution == 512 ? 1 : 0);

Expand Down Expand Up @@ -161,7 +163,8 @@ GUIEngine::EventPropagation CustomVideoSettingsDialog::processEvent(const std::s
UserConfigParams::m_shadows_resolution =
getWidget<SpinnerWidget>("shadows")->getValue() == 1 ? 512 :
getWidget<SpinnerWidget>("shadows")->getValue() == 2 ? 1024 :
getWidget<SpinnerWidget>("shadows")->getValue() == 3 ? 2048 : 0;
getWidget<SpinnerWidget>("shadows")->getValue() == 3 ? 2048 :
getWidget<SpinnerWidget>("shadows")->getValue() == 4 ? 4096 : 0;
}
else
{
Expand Down
18 changes: 13 additions & 5 deletions src/states_screens/options/options_screen_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void OptionsScreenVideo::initPresets()

m_presets.push_back // Level 4
({
true /* light */, 0 /* shadow */, false /* bloom */, true /* lightshaft */,
true /* light */, 0 /* shadow */, false /* bloom */, false /* lightshaft */,
true /* glow */, true /* mlaa */, false /* ssao */, true /* light scatter */,
true /* animatedCharacters */, 2 /* particles */, 2 /* image_quality */,
false /* degraded IBL */, 3 /* Geometry Detail */
Expand All @@ -81,7 +81,7 @@ void OptionsScreenVideo::initPresets()
m_presets.push_back // Level 6
({
true /* light */, 1024 /* shadow */, true /* bloom */, true /* lightshaft */,
true /* glow */, true /* mlaa */, true /* ssao */, true /* light scatter */,
true /* glow */, true /* mlaa */, false /* ssao */, true /* light scatter */,
true /* animatedCharacters */, 2 /* particles */, 3 /* image_quality */,
false /* degraded IBL */, 4 /* Geometry Detail */
});
Expand All @@ -94,17 +94,25 @@ void OptionsScreenVideo::initPresets()
false /* degraded IBL */, 5 /* Geometry Detail */
});

m_blur_presets.push_back
m_presets.push_back // Level 8
({
true /* light */, 4096 /* shadow */, true /* bloom */, true /* lightshaft */,
true /* glow */, true /* mlaa */, true /* ssao */, true /* light scatter */,
true /* animatedCharacters */, 2 /* particles */, 3 /* image_quality */,
false /* degraded IBL */, 5 /* Geometry Detail */
});

m_blur_presets.push_back // Level 0
({
false /* motionblur */, false /* depth of field */
});

m_blur_presets.push_back
m_blur_presets.push_back // Level 1
({
true /* motionblur */, false /* depth of field */
});

m_blur_presets.push_back
m_blur_presets.push_back // Level 2
({
true /* motionblur */, true /* depth of field */
});
Expand Down

0 comments on commit 70c2ba0

Please sign in to comment.