18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-20 10:24:58 +01:00

Merge branch 'master' into feat/renderers-cleanup

This commit is contained in:
2026-11-16 21:44:48 +01:00
264 changed files with 41203 additions and 10041 deletions

View File

@@ -84,6 +84,8 @@ class vulkan14_renderer : public gfx_renderer, public gfx::scene_walk
gfx::vertex_array const &Vertices(gfx::geometry_handle const &Geometry) const override;
gfx::userdata_array const &UserData(gfx::geometry_handle const &Geometry) const override;
int Primitive(gfx::geometry_handle const &Geometry) const override;
// the sleepers and timbers are drawn by the walk of the scene (gfx::scene_walk), as in the opengl renderer
bool Draws_Timbers() const override { return true; }
// materials
material_handle Fetch_Material(std::string const &Filename, bool const Loadnow = true) override;
material_handle Matte_Material(material_handle const Material) override;
@@ -105,6 +107,7 @@ class vulkan14_renderer : public gfx_renderer, public gfx::scene_walk
void Bind_Texture(std::size_t const Unit, texture_handle const Texture) override;
ITexture &Texture(texture_handle const Texture) override;
ITexture const &Texture(texture_handle const Texture) const override;
void Unload_Texture(texture_handle const Texture) override;
// picking
void Pick_Control_Callback(std::function<void(TSubModel const *, glm::vec2 const)> Callback) override;
void Pick_Node_Callback(std::function<void(scene::basic_node *)> Callback) override;
@@ -191,6 +194,7 @@ class vulkan14_renderer : public gfx_renderer, public gfx::scene_walk
void walk_draw(std::vector<gfx::geometrybank_handle>::iterator First, std::vector<gfx::geometrybank_handle>::iterator Last) override;
std::uint32_t walk_instances(glm::mat4 const *Modelviews, std::size_t const Count) override;
void walk_cull_face(bool const Enabled) override;
void walk_decal(bool const Enabled) override;
void walk_glare(bool const Enabled) override;
void walk_glare_draw(TSubModel *Submodel, gfx::geometry_handle const &Geometry) override;
void walk_light_query(TSubModel *Submodel, bool const Begin) override;

View File

@@ -1769,6 +1769,31 @@ void vulkan14_renderer::walk_cull_face(bool const Enabled)
m_draw->cullface = Enabled;
}
void vulkan14_renderer::walk_decal(bool const Enabled)
{
auto &draw{*m_draw};
if ((false == draw.rendering) || (draw.commands == nullptr) || draw.shadows)
{
return;
}
// the depth is reversed (VK_COMPARE_OP_GREATER_OR_EQUAL): a positive bias comes nearer the camera, as glPolygonOffset(2, 8) of
// the opengl renderer (slope 2, constant 8). the depth pass of the scene draws everything a little farther (-1, -1,
// render_scene_depth()), the decal goes as much nearer from there
if (draw.depthpass)
{
if (Enabled)
draw.commands->set_depth_bias(-1.f + 8.f, 0.f, -1.f + 2.f);
else
draw.commands->set_depth_bias(-1.f, 0.f, -1.f);
return;
}
draw.commands->set_depth_bias_enable(Enabled ? VK_TRUE : VK_FALSE);
if (Enabled)
{
draw.commands->set_depth_bias(8.f, 0.f, 2.f);
}
}
void vulkan14_renderer::walk_glare(bool const Enabled)
{
// without the depth test, added to what is there
@@ -2691,3 +2716,13 @@ ITexture const &vulkan14_renderer::Texture(texture_handle const Texture) const
}
return m_context->textures->texture(Texture);
}
void vulkan14_renderer::Unload_Texture(texture_handle const Texture)
{
if ((Texture == null_handle) || !m_context || !m_context->textures)
{
return;
}
// the image goes once the gpu is done with it (vulkan14_texture::release())
m_context->textures->unload(Texture);
}