17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-06 06:58:35 +01:00

Add gfx.antialiasing (off, msaax2/x4/x8, taa) with temporal anti-aliasing in the GL 4.6 and Vulkan renderers

This commit is contained in:
2026-10-25 05:17:41 +01:00
parent c48c58776a
commit 252b9373ea
20 changed files with 838 additions and 35 deletions

View File

@@ -368,6 +368,7 @@ bool global_settings::ConfigParseGraphics(cParser& Parser, const std::string& to
{
ParseOne(Parser, iMultisampling, 1, false);
iMultisampling = std::clamp(iMultisampling, 0, 4);
gfx_antialiasing = (iMultisampling > 0 ? antialiasing_mode::msaa : antialiasing_mode::off);
return true;
}
@@ -1898,6 +1899,23 @@ global_settings::ConfigParse_gfx_sky( cParser &Parser, std::string_view const To
std::string level;
Parser >> level;
gfx_fog_quality = ( level == "low" || level == "1" ) ? 1 : ( level == "high" || level == "3" ) ? 3 : ( level == "ultra" || level == "4" ) ? 4 : 2; }
else if( Token == "gfx.antialiasing" ) {
// off, msaax2, msaax4, msaax8 or taa; it sets the multisampling too, the key which used to say it
Parser.getTokens( 1 );
std::string mode;
Parser >> mode;
std::transform( mode.begin(), mode.end(), mode.begin(), []( unsigned char c ) { return static_cast<char>( std::tolower( c ) ); } );
if( mode == "taa" ) {
gfx_antialiasing = antialiasing_mode::taa;
iMultisampling = 0; }
else if( mode == "msaax2" || mode == "msaax4" || mode == "msaax8" || mode == "msaax16" ) {
gfx_antialiasing = antialiasing_mode::msaa;
iMultisampling = ( mode == "msaax2" ) ? 1 : ( mode == "msaax4" ) ? 2 : ( mode == "msaax8" ) ? 3 : 4; }
else if( mode == "off" || mode == "no" || mode == "none" || mode == "0" ) {
gfx_antialiasing = antialiasing_mode::off;
iMultisampling = 0; }
else {
ErrorLog( "Bad config: unknown gfx.antialiasing \"" + mode + "\", expected off, msaax2, msaax4, msaax8 or taa" ); } }
else if( Token == "gfx.fog.range" ) { readvalue( gfx_fog_range, 100.f, 10000.f ); }
else if( Token == "gfx.fog.lights" ) { readvalue( gfx_fog_lights, 0.f, 10.f ); }
else if( Token == "gfx.fog.shadows" ) { readswitch( gfx_fog_shadows ); }
@@ -2033,6 +2051,7 @@ global_settings::export_as_text( std::ostream &Output ) const {
export_as_text( Output, "gfx.reflections.fidelity", reflectiontune.fidelity );
export_as_text( Output, "timespeed", fTimeSpeed );
export_as_text( Output, "multisampling", iMultisampling );
export_as_text( Output, "gfx.antialiasing", std::string{ gfx_antialiasing == antialiasing_mode::taa ? "taa" : ( gfx_antialiasing == antialiasing_mode::off || iMultisampling == 0 ) ? "off" : "msaax" + std::to_string( 1 << iMultisampling ) } );
export_as_text( Output, "latitude", fLatitudeDeg );
export_as_text( Output, "convertmodels", iConvertModels );
export_as_text( Output, "file.binary.terrain", file_binary_terrain );

View File

@@ -179,6 +179,12 @@ struct global_settings {
GLint iMaxTextureSize{ 4096 }; // maksymalny rozmiar tekstury
GLint iMaxCabTextureSize{ 4096 }; // largest allowed texture in vehicle cab
int iMultisampling{ 2 }; // tryb antyaliasingu: 0=brak,1=2px,2=4px,3=8px,4=16px
// gfx.antialiasing: off, msaax2/x4/x8 (the samples go to iMultisampling) or taa (one sample, with the history of the last frames;
// iMultisampling 0). the old key multisampling sets msaa or off. read at the start
enum class antialiasing_mode { off, msaa, taa };
antialiasing_mode gfx_antialiasing{ antialiasing_mode::msaa };
// the temporal anti-aliasing is on: asked for, and the post-processing which does it is there
bool gfx_taa() const { return ( gfx_antialiasing == antialiasing_mode::taa ) && ( false == gfx_skippipeline ); }
float SplineFidelity{ 1.f }; // determines segment size during conversion of splines to geometry
float SleeperDistance{ 250.f }; // max distance (in meters) at which per-track sleeper models are still drawn; 0 disables sleeper rendering entirely
std::string Sleepers3D; // model of the sleepers and switch timbers laid where the simulator makes the ballast; empty: none
@@ -358,6 +364,8 @@ struct global_settings {
// one for each of the last frames, instead of with glBufferSubData. read at the start
bool gfx_bufferstreaming = true;
bool gfx_postfx_motionblur_enabled = true;
// the colour pass writes the velocities of the pixels: for the motion blur, or for the temporal anti-aliasing
bool gfx_motion_vectors() const { return gfx_postfx_motionblur_enabled || gfx_taa(); }
float gfx_postfx_motionblur_shutter = 0.01f;
GLenum gfx_postfx_motionblur_format = GL_RG16F;
GLenum gfx_format_color = GL_RGB16F;