17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-26 02:12:27 +01:00

feat(track): rails and ballast blended into those of the tracks joined, where their textures differ

This commit is contained in:
2026-10-21 22:34:57 +02:00
parent 407a555803
commit c5a894a674
19 changed files with 721 additions and 14 deletions

View File

@@ -2850,6 +2850,16 @@ material_handle opengl46_renderer::Tinted_Material(material_handle const Materia
return m_materials.create_tinted(Material, Colour);
}
material_handle opengl46_renderer::Blend_Material(material_handle const Material, std::array<material_handle, 3> const &Others, bool const Grain)
{
return m_materials.create_blend(Material, Others, Grain);
}
bool opengl46_renderer::Blendable_Material(material_handle const Material)
{
return m_materials.blendable(Material);
}
std::shared_ptr<gl::program> opengl46_renderer::Fetch_Shader(const std::string &name)
{
auto it = m_shaders.find(name);
@@ -6611,13 +6621,13 @@ void opengl46_renderer::Render(scene::basic_cell::path_sequence::const_iterator
// track with light level of its own is drawn on its own
flush_batch();
setup_environment_light(track->eEnvironment);
Bind_Material(track->m_material1);
Bind_Material(track->m_blendmaterial1 != null_handle ? track->m_blendmaterial1 : track->m_material1);
draw(std::begin(track->Geometry1), std::end(track->Geometry1));
// restore default lighting
setup_environment_light();
break;
}
if (false == begin_batch(track->m_material1))
if (false == begin_batch(track->m_blendmaterial1 != null_handle ? track->m_blendmaterial1 : track->m_material1))
{
// the track is drawn with the call of its predecessor
--m_renderpass.draw_stats.drawcalls;
@@ -6680,13 +6690,13 @@ void opengl46_renderer::Render(scene::basic_cell::path_sequence::const_iterator
{
flush_batch();
setup_environment_light(track->eEnvironment);
Bind_Material(track->m_material2);
Bind_Material(track->m_blendmaterial2 != null_handle ? track->m_blendmaterial2 : track->m_material2);
draw(std::begin(track->Geometry2), std::end(track->Geometry2));
// restore default lighting
setup_environment_light();
break;
}
begin_batch(track->m_material2);
begin_batch(track->m_blendmaterial2 != null_handle ? track->m_blendmaterial2 : track->m_material2);
m_pathbatch.insert(std::end(m_pathbatch), std::begin(track->Geometry2), std::end(track->Geometry2));
break;
}
@@ -6747,13 +6757,13 @@ void opengl46_renderer::Render(scene::basic_cell::path_sequence::const_iterator
{
flush_batch();
setup_environment_light(track->eEnvironment);
Bind_Material(track->SwitchExtension->m_material3);
Bind_Material(track->m_blendmaterial3 != null_handle ? track->m_blendmaterial3 : track->SwitchExtension->m_material3);
draw(track->SwitchExtension->Geometry3);
// restore default lighting
setup_environment_light();
break;
}
begin_batch(track->SwitchExtension->m_material3);
begin_batch(track->m_blendmaterial3 != null_handle ? track->m_blendmaterial3 : track->SwitchExtension->m_material3);
m_pathbatch.emplace_back(track->SwitchExtension->Geometry3);
break;
}

View File

@@ -101,6 +101,10 @@ class opengl46_renderer : public gfx_renderer {
Matte_Material( material_handle const Material ) override;
material_handle
Tinted_Material( material_handle const Material, glm::vec3 const &Colour ) override;
material_handle
Blend_Material( material_handle const Material, std::array<material_handle, 3> const &Others, bool const Grain ) override;
bool
Blendable_Material( material_handle const Material ) override;
void
Bind_Material( material_handle const Material, TSubModel const *sm = nullptr, lighting_data const *lighting = nullptr ) override;
IMaterial const *

View File

@@ -111,6 +111,11 @@ public:
// the same material with its highlights damped, for faces which aren't polished like the surfaces they are cut from. backends which can't make one give back the material itself
virtual auto Matte_Material( material_handle const Material ) -> material_handle { return Material; }
virtual auto Tinted_Material( material_handle const Material, glm::vec3 const &Colour ) -> material_handle { return Material; }
// the material of a track blending its texture with those of up to three others (null: none) by the weights in y, z and w of the user data
// of the vertices, the others as grains with Grain (world/TrackBlend.h). backends which can't make one give back the material itself
virtual auto Blend_Material( material_handle const Material, std::array<material_handle, 3> const &Others, bool const Grain ) -> material_handle { return Material; }
// whether a material can be blended so
virtual auto Blendable_Material( material_handle const Material ) -> bool { return false; }
// heightmap terrain: material of a chunk blending the materials of up to 8 layers by their weights.
// Weights: (Samples + 1)^2 values per layer, planar, rows of growing z, the weights of a sample adding up to 255; null with a single layer.
// Placement: corner of the chunk (x, z) in the texture coordinates of its mesh, and the size of the chunk.