16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-23 23:49:17 +02:00

build 191224. opengl 3.3 renderer material glossiness support, minor bug fixes

This commit is contained in:
tmj-fstate
2019-12-25 19:42:50 +01:00
parent db49440653
commit 943e05462d
11 changed files with 48 additions and 16 deletions

View File

@@ -4212,7 +4212,7 @@ void TDynamicObject::RenderSounds() {
clamp( clamp(
MoverParameters->Vel / 40.0, MoverParameters->Vel / 40.0,
0.0, 1.0 ) ) 0.0, 1.0 ) )
+ ( MyTrack->eType == tt_Switch ? 0.25 : 0.0 ); * ( MyTrack->eType == tt_Switch ? 100.0 : 1.0 );
} }
else { else {
volume = 0; volume = 0;

View File

@@ -432,7 +432,7 @@ TTrain::TTrain() {
{ {
for ( int j = 0; j < 3; ++j ) for ( int j = 0; j < 3; ++j )
fPress[i][j] = 0.0; fPress[i][j] = 0.0;
bBrakes[i][0] = bBrakes[i][1] = 0.0; bBrakes[i][0] = bBrakes[i][1] = false;
} }
} }

View File

@@ -741,7 +741,7 @@ private:
public: public:
float fPress[20][3]; // cisnienia dla wszystkich czlonow 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<std::string> const fPress_labels; static std::vector<std::string> const fPress_labels;
float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych
float fDieselParams[9][10]; // parametry dla silnikow asynchronicznych float fDieselParams[9][10]; // parametry dla silnikow asynchronicznych

View File

@@ -1169,7 +1169,6 @@ driver_mode::ChangeDynamic() {
if( false == driver->AIControllFlag ) // tylko jeśli ręcznie prowadzony if( false == driver->AIControllFlag ) // tylko jeśli ręcznie prowadzony
{ {
occupied->LimPipePress = occupied->PipePress; occupied->LimPipePress = occupied->PipePress;
occupied->CabOccupied = occupied->CabActive;
occupied->CabActivisation( true ); // załączenie rozrządu (wirtualne kabiny) occupied->CabActivisation( true ); // załączenie rozrządu (wirtualne kabiny)
vehicle->MechInside = true; vehicle->MechInside = true;
vehicle->Controller = Humandriver; vehicle->Controller = Humandriver;

View File

@@ -69,7 +69,8 @@ std::unordered_map<std::string, gl::shader::defaultparam_e> gl::shader::defaultp
{ "one", defaultparam_e::one }, { "one", defaultparam_e::one },
{ "ambient", defaultparam_e::ambient }, { "ambient", defaultparam_e::ambient },
{ "diffuse", defaultparam_e::diffuse }, { "diffuse", defaultparam_e::diffuse },
{ "specular", defaultparam_e::specular } { "specular", defaultparam_e::specular },
{ "glossiness", defaultparam_e::glossiness }
}; };
void gl::shader::process_source(std::string &str) void gl::shader::process_source(std::string &str)

View File

@@ -44,7 +44,8 @@ namespace gl
one, one,
ambient, ambient,
diffuse, diffuse,
specular specular,
glossiness
}; };
struct param_entry struct param_entry

View File

@@ -267,6 +267,13 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c
selfillum = std::stof(value); //m7t: handle exception selfillum = std::stof(value); //m7t: handle exception
m_selfillum_priority = Priority; 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:" ) { else if( key == "size:" ) {
Input.getTokens( 2 ); Input.getTokens( 2 );
Input Input

View File

@@ -26,6 +26,7 @@ struct opengl_material {
std::shared_ptr<gl::program> shader; std::shared_ptr<gl::program> shader;
float opacity = std::numeric_limits<float>::quiet_NaN(); float opacity = std::numeric_limits<float>::quiet_NaN();
float selfillum = std::numeric_limits<float>::quiet_NaN(); float selfillum = std::numeric_limits<float>::quiet_NaN();
float glossiness { 10.f };
std::string name; std::string name;
glm::vec2 size { -1.f, -1.f }; // 'physical' size of bound texture, in meters 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_shader_priority = -1;
int m_opacity_priority = -1; int m_opacity_priority = -1;
int m_selfillum_priority = -1; int m_selfillum_priority = -1;
int m_glossiness_priority = -1;
struct parse_info_s struct parse_info_s
{ {

View File

@@ -220,6 +220,7 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
m_depth_pointer_fb = std::make_unique<gl::framebuffer>(); m_depth_pointer_fb = std::make_unique<gl::framebuffer>();
m_depth_pointer_fb->attach(*m_depth_pointer_rb, GL_DEPTH_ATTACHMENT); 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() ) { if( !m_depth_pointer_fb->is_complete() ) {
ErrorLog( "depth pointer framebuffer setup failed" ); 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); glm::vec4 src(1.0f);
// submodel-based parameters
if (sm) if (sm)
{ {
if (entry.defaultparam == gl::shader::defaultparam_e::ambient) switch( entry.defaultparam ) {
src = sm->f4Ambient; case gl::shader::defaultparam_e::ambient: {
else if (entry.defaultparam == gl::shader::defaultparam_e::diffuse) src = sm->f4Ambient;
src = sm->f4Diffuse; break;
// src = glm::vec4( glm::pow( glm::vec3( sm->f4Diffuse ), gammacorrection ), sm->f4Diffuse.a ); }
else if (entry.defaultparam == gl::shader::defaultparam_e::specular) case gl::shader::defaultparam_e::diffuse: {
src = sm->f4Specular; 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++) for (size_t j = 0; j < entry.size; j++)
model_ubs.param[entry.location][entry.offset + j] = src[j]; model_ubs.param[entry.location][entry.offset + j] = src[j];

View File

@@ -4217,7 +4217,7 @@ opengl_renderer::Init_caps() {
WriteLog( "using multisampling x" + std::to_string( 1 << Global.iMultisampling ) ); 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; return true;
} }

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 19 #define VERSION_MAJOR 19
#define VERSION_MINOR 1214 #define VERSION_MINOR 1224
#define VERSION_REVISION 0 #define VERSION_REVISION 1