mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 13:59:19 +02:00
fog range slider
This commit is contained in:
@@ -78,7 +78,7 @@ struct global_settings {
|
|||||||
bool bLiveTraction{ true };
|
bool bLiveTraction{ true };
|
||||||
float Overcast{ 0.1f }; // NOTE: all this weather stuff should be moved elsewhere
|
float Overcast{ 0.1f }; // NOTE: all this weather stuff should be moved elsewhere
|
||||||
glm::vec3 FogColor = { 0.6f, 0.7f, 0.8f };
|
glm::vec3 FogColor = { 0.6f, 0.7f, 0.8f };
|
||||||
double fFogEnd{ 7500 };
|
float fFogEnd{ 7500 };
|
||||||
std::string Season{}; // season of the year, based on simulation date
|
std::string Season{}; // season of the year, based on simulation date
|
||||||
std::string Weather{ "cloudy:" }; // current weather
|
std::string Weather{ "cloudy:" }; // current weather
|
||||||
bool FullPhysics{ true }; // full calculations performed for each simulation step
|
bool FullPhysics{ true }; // full calculations performed for each simulation step
|
||||||
|
|||||||
@@ -543,6 +543,12 @@ debug_panel::render() {
|
|||||||
render_section( "Vehicle AI", m_ailines );
|
render_section( "Vehicle AI", m_ailines );
|
||||||
render_section( "Vehicle Scan Table", m_scantablelines );
|
render_section( "Vehicle Scan Table", m_scantablelines );
|
||||||
if( true == render_section( "Scenario", m_scenariolines ) ) {
|
if( true == render_section( "Scenario", m_scenariolines ) ) {
|
||||||
|
// fog slider
|
||||||
|
auto fogrange = std::log( Global.fFogEnd );
|
||||||
|
if( ImGui::SliderFloat(
|
||||||
|
( to_string( std::exp( fogrange ), 0 ) + " m###fogend" ).c_str(), &fogrange, std::log( 10.0f ), std::log( 25000.0f ), "Fog distance" ) ) {
|
||||||
|
Global.fFogEnd = clamp( std::exp( fogrange ), 10.0f, 25000.0f );
|
||||||
|
}
|
||||||
// cloud cover slider
|
// cloud cover slider
|
||||||
if( ImGui::SliderFloat(
|
if( ImGui::SliderFloat(
|
||||||
( to_string(Global.Overcast, 2 ) + " (" + Global.Weather + ")###overcast" ).c_str(), &Global.Overcast, 0.0f, 2.0f, "Cloud cover" ) ) {
|
( to_string(Global.Overcast, 2 ) + " (" + Global.Weather + ")###overcast" ).c_str(), &Global.Overcast, 0.0f, 2.0f, "Cloud cover" ) ) {
|
||||||
|
|||||||
@@ -1498,7 +1498,7 @@ bool opengl33_renderer::Render(world_environment *Environment)
|
|||||||
|
|
||||||
auto const &modelview = OpenGLMatrices.data(GL_MODELVIEW);
|
auto const &modelview = OpenGLMatrices.data(GL_MODELVIEW);
|
||||||
|
|
||||||
auto const fogfactor{clamp<float>(Global.fFogEnd / 2000.f, 0.f, 1.f)}; // stronger fog reduces opacity of the celestial bodies
|
auto const fogfactor{clamp(Global.fFogEnd / 2000.f, 0.f, 1.f)}; // stronger fog reduces opacity of the celestial bodies
|
||||||
float const duskfactor = 1.0f - clamp(std::abs(Environment->m_sun.getAngle()), 0.0f, 12.0f) / 12.0f;
|
float const duskfactor = 1.0f - clamp(std::abs(Environment->m_sun.getAngle()), 0.0f, 12.0f) / 12.0f;
|
||||||
glm::vec3 suncolor = interpolate(glm::vec3(255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f), glm::vec3(235.0f / 255.0f, 140.0f / 255.0f, 36.0f / 255.0f), duskfactor);
|
glm::vec3 suncolor = interpolate(glm::vec3(255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f), glm::vec3(235.0f / 255.0f, 140.0f / 255.0f, 36.0f / 255.0f), duskfactor);
|
||||||
|
|
||||||
@@ -3634,7 +3634,7 @@ void opengl33_renderer::Render_Alpha(TSubModel *Submodel)
|
|||||||
if (Global.Overcast > 1.0f)
|
if (Global.Overcast > 1.0f)
|
||||||
{
|
{
|
||||||
// fake fog halo
|
// fake fog halo
|
||||||
float const fogfactor{interpolate(2.f, 1.f, clamp<float>(Global.fFogEnd / 2000, 0.f, 1.f)) * std::max(1.f, Global.Overcast)};
|
float const fogfactor{interpolate(2.f, 1.f, clamp(Global.fFogEnd / 2000, 0.f, 1.f)) * std::max(1.f, Global.Overcast)};
|
||||||
model_ubs.param[1].x = pointsize * resolutionratio * fogfactor * 3.0f;
|
model_ubs.param[1].x = pointsize * resolutionratio * fogfactor * 3.0f;
|
||||||
model_ubs.param[0] = glm::vec4(glm::vec3(lightcolor), Submodel->fVisible * std::min(1.f, lightlevel) * 0.5f);
|
model_ubs.param[0] = glm::vec4(glm::vec3(lightcolor), Submodel->fVisible * std::min(1.f, lightlevel) * 0.5f);
|
||||||
|
|
||||||
|
|||||||
@@ -1523,7 +1523,7 @@ opengl_renderer::Render( world_environment *Environment ) {
|
|||||||
|
|
||||||
auto const &modelview = OpenGLMatrices.data( GL_MODELVIEW );
|
auto const &modelview = OpenGLMatrices.data( GL_MODELVIEW );
|
||||||
|
|
||||||
auto const fogfactor { clamp<float>( Global.fFogEnd / 2000.f, 0.f, 1.f ) }; // closer/denser fog reduces opacity of the celestial bodies
|
auto const fogfactor { clamp( Global.fFogEnd / 2000.f, 0.f, 1.f ) }; // closer/denser fog reduces opacity of the celestial bodies
|
||||||
float const duskfactor = 1.0f - clamp( std::abs( Environment->m_sun.getAngle() ), 0.0f, 12.0f ) / 12.0f;
|
float const duskfactor = 1.0f - clamp( std::abs( Environment->m_sun.getAngle() ), 0.0f, 12.0f ) / 12.0f;
|
||||||
glm::vec3 suncolor = interpolate(
|
glm::vec3 suncolor = interpolate(
|
||||||
glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ),
|
glm::vec3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ),
|
||||||
@@ -2758,7 +2758,7 @@ opengl_renderer::Render( TSubModel *Submodel ) {
|
|||||||
float const fogfactor {
|
float const fogfactor {
|
||||||
interpolate(
|
interpolate(
|
||||||
2.f, 1.f,
|
2.f, 1.f,
|
||||||
clamp<float>( Global.fFogEnd / 2000, 0.f, 1.f ) )
|
clamp( Global.fFogEnd / 2000, 0.f, 1.f ) )
|
||||||
* std::max( 1.f, Global.Overcast ) };
|
* std::max( 1.f, Global.Overcast ) };
|
||||||
|
|
||||||
::glPointSize( pointsize * resolutionratio * fogfactor );
|
::glPointSize( pointsize * resolutionratio * fogfactor );
|
||||||
|
|||||||
Reference in New Issue
Block a user