mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-20 19:29:18 +02:00
build 191224. opengl 3.3 renderer material glossiness support, minor bug fixes
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
Train.h
2
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<std::string> const fPress_labels;
|
||||
float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych
|
||||
float fDieselParams[9][10]; // parametry dla silnikow asynchronicznych
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -69,7 +69,8 @@ std::unordered_map<std::string, gl::shader::defaultparam_e> 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)
|
||||
|
||||
@@ -44,7 +44,8 @@ namespace gl
|
||||
one,
|
||||
ambient,
|
||||
diffuse,
|
||||
specular
|
||||
specular,
|
||||
glossiness
|
||||
};
|
||||
|
||||
struct param_entry
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -26,6 +26,7 @@ struct opengl_material {
|
||||
std::shared_ptr<gl::program> shader;
|
||||
float opacity = std::numeric_limits<float>::quiet_NaN();
|
||||
float selfillum = std::numeric_limits<float>::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
|
||||
{
|
||||
|
||||
@@ -220,6 +220,7 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
|
||||
|
||||
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->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];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user