From 943e05462dee1e9c4a0962d328e1780ff2779071 Mon Sep 17 00:00:00 2001 From: tmj-fstate Date: Wed, 25 Dec 2019 19:42:50 +0100 Subject: [PATCH] build 191224. opengl 3.3 renderer material glossiness support, minor bug fixes --- DynObj.cpp | 2 +- Train.cpp | 2 +- Train.h | 2 +- drivermode.cpp | 1 - gl/shader.cpp | 3 ++- gl/shader.h | 3 ++- material.cpp | 7 +++++++ material.h | 2 ++ opengl33renderer.cpp | 36 +++++++++++++++++++++++++++++------- openglrenderer.cpp | 2 +- version.h | 4 ++-- 11 files changed, 48 insertions(+), 16 deletions(-) diff --git a/DynObj.cpp b/DynObj.cpp index 3236a519..ad49e5cd 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -4212,7 +4212,7 @@ void TDynamicObject::RenderSounds() { clamp( MoverParameters->Vel / 40.0, 0.0, 1.0 ) ) - + ( MyTrack->eType == tt_Switch ? 0.25 : 0.0 ); + * ( MyTrack->eType == tt_Switch ? 100.0 : 1.0 ); } else { volume = 0; diff --git a/Train.cpp b/Train.cpp index 6af695ba..24cc858c 100644 --- a/Train.cpp +++ b/Train.cpp @@ -432,7 +432,7 @@ TTrain::TTrain() { { for ( int j = 0; j < 3; ++j ) fPress[i][j] = 0.0; - bBrakes[i][0] = bBrakes[i][1] = 0.0; + bBrakes[i][0] = bBrakes[i][1] = false; } } diff --git a/Train.h b/Train.h index eb7c5a97..0fb6b9df 100644 --- a/Train.h +++ b/Train.h @@ -741,7 +741,7 @@ private: public: float fPress[20][3]; // cisnienia dla wszystkich czlonow - float bBrakes[20][2]; // zalaczenie i dzialanie hamulcow + bool bBrakes[20][2]; // zalaczenie i dzialanie hamulcow static std::vector const fPress_labels; float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych float fDieselParams[9][10]; // parametry dla silnikow asynchronicznych diff --git a/drivermode.cpp b/drivermode.cpp index 574bcb8f..15d87e43 100644 --- a/drivermode.cpp +++ b/drivermode.cpp @@ -1169,7 +1169,6 @@ driver_mode::ChangeDynamic() { if( false == driver->AIControllFlag ) // tylko jeśli ręcznie prowadzony { occupied->LimPipePress = occupied->PipePress; - occupied->CabOccupied = occupied->CabActive; occupied->CabActivisation( true ); // załączenie rozrządu (wirtualne kabiny) vehicle->MechInside = true; vehicle->Controller = Humandriver; diff --git a/gl/shader.cpp b/gl/shader.cpp index f4d7f3c7..462cb959 100644 --- a/gl/shader.cpp +++ b/gl/shader.cpp @@ -69,7 +69,8 @@ std::unordered_map gl::shader::defaultp { "one", defaultparam_e::one }, { "ambient", defaultparam_e::ambient }, { "diffuse", defaultparam_e::diffuse }, - { "specular", defaultparam_e::specular } + { "specular", defaultparam_e::specular }, + { "glossiness", defaultparam_e::glossiness } }; void gl::shader::process_source(std::string &str) diff --git a/gl/shader.h b/gl/shader.h index 0430d450..154229a1 100644 --- a/gl/shader.h +++ b/gl/shader.h @@ -44,7 +44,8 @@ namespace gl one, ambient, diffuse, - specular + specular, + glossiness }; struct param_entry diff --git a/material.cpp b/material.cpp index 0b6eb8f2..2b2fae30 100644 --- a/material.cpp +++ b/material.cpp @@ -267,6 +267,13 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c selfillum = std::stof(value); //m7t: handle exception m_selfillum_priority = Priority; } + else if (key == "glossiness:" && + Priority > m_glossiness_priority) + { + std::string value = deserialize_random_set( Input ); + glossiness = std::stof(value); //m7t: handle exception + m_glossiness_priority = Priority; + } else if( key == "size:" ) { Input.getTokens( 2 ); Input diff --git a/material.h b/material.h index 008707c1..cf6a44ce 100644 --- a/material.h +++ b/material.h @@ -26,6 +26,7 @@ struct opengl_material { std::shared_ptr shader; float opacity = std::numeric_limits::quiet_NaN(); float selfillum = std::numeric_limits::quiet_NaN(); + float glossiness { 10.f }; std::string name; glm::vec2 size { -1.f, -1.f }; // 'physical' size of bound texture, in meters @@ -55,6 +56,7 @@ private: int m_shader_priority = -1; int m_opacity_priority = -1; int m_selfillum_priority = -1; + int m_glossiness_priority = -1; struct parse_info_s { diff --git a/opengl33renderer.cpp b/opengl33renderer.cpp index 368da47b..8623db99 100644 --- a/opengl33renderer.cpp +++ b/opengl33renderer.cpp @@ -220,6 +220,7 @@ bool opengl33_renderer::Init(GLFWwindow *Window) m_depth_pointer_fb = std::make_unique(); m_depth_pointer_fb->attach(*m_depth_pointer_rb, GL_DEPTH_ATTACHMENT); + m_depth_pointer_fb->setup_drawing(0); if( !m_depth_pointer_fb->is_complete() ) { ErrorLog( "depth pointer framebuffer setup failed" ); @@ -1699,16 +1700,37 @@ void opengl33_renderer::Bind_Material(material_handle const Material, TSubModel glm::vec4 src(1.0f); + // submodel-based parameters if (sm) { - if (entry.defaultparam == gl::shader::defaultparam_e::ambient) - src = sm->f4Ambient; - else if (entry.defaultparam == gl::shader::defaultparam_e::diffuse) - src = sm->f4Diffuse; -// src = glm::vec4( glm::pow( glm::vec3( sm->f4Diffuse ), gammacorrection ), sm->f4Diffuse.a ); - else if (entry.defaultparam == gl::shader::defaultparam_e::specular) - src = sm->f4Specular; + switch( entry.defaultparam ) { + case gl::shader::defaultparam_e::ambient: { + src = sm->f4Ambient; + break; + } + case gl::shader::defaultparam_e::diffuse: { + src = sm->f4Diffuse; +// src = glm::vec4( glm::pow( glm::vec3( sm->f4Diffuse ), gammacorrection ), sm->f4Diffuse.a ); + break; + } + case gl::shader::defaultparam_e::specular: { + src = sm->f4Specular;// *( sm->Opacity > 0.f ? m_specularopaquescalefactor : m_speculartranslucentscalefactor ); + break; + } + default: { + break; + } + } } + // material-based parameters + switch( entry.defaultparam ) { + case gl::shader::defaultparam_e::glossiness: { + src = glm::vec4( material.glossiness ); + } + default: { + break; + } + } for (size_t j = 0; j < entry.size; j++) model_ubs.param[entry.location][entry.offset + j] = src[j]; diff --git a/openglrenderer.cpp b/openglrenderer.cpp index 5e585989..1d1ccac2 100644 --- a/openglrenderer.cpp +++ b/openglrenderer.cpp @@ -4217,7 +4217,7 @@ opengl_renderer::Init_caps() { WriteLog( "using multisampling x" + std::to_string( 1 << Global.iMultisampling ) ); } - WriteLog( "main window size: " + std::to_string( Global.gfx_framebuffer_width ) + "x" + std::to_string( Global.gfx_framebuffer_height ) ); + WriteLog( "main window size: " + std::to_string( Global.iWindowWidth ) + "x" + std::to_string( Global.iWindowHeight ) ); return true; } diff --git a/version.h b/version.h index 9c75d1a5..fd5923f2 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 19 -#define VERSION_MINOR 1214 -#define VERSION_REVISION 0 +#define VERSION_MINOR 1224 +#define VERSION_REVISION 1