diff --git a/core/client/include/pragma/rendering/shaders/world/c_shader_textured.hpp b/core/client/include/pragma/rendering/shaders/world/c_shader_textured.hpp index e23afcac7..f4e6bb3d2 100644 --- a/core/client/include/pragma/rendering/shaders/world/c_shader_textured.hpp +++ b/core/client/include/pragma/rendering/shaders/world/c_shader_textured.hpp @@ -191,7 +191,7 @@ namespace pragma { virtual bool IsUsingLightmaps() const override { return true; } bool IsDepthPrepassEnabled() const; void SetDepthPrepassEnabled(bool enabled) { m_depthPrepassEnabled = enabled; } - static std::shared_ptr GetTexture(const std::string &texName); + static std::shared_ptr GetTexture(const std::string &texName, bool load = false); protected: using ShaderEntity::RecordDraw; GameShaderSpecializationConstantFlag GetStaticSpecializationConstantFlags(GameShaderSpecialization specialization) const; diff --git a/core/client/src/lua/c_luaclass.cpp b/core/client/src/lua/c_luaclass.cpp index 383c1018e..b82d5c90d 100644 --- a/core/client/src/lua/c_luaclass.cpp +++ b/core/client/src/lua/c_luaclass.cpp @@ -110,7 +110,15 @@ static void reload_textures(CMaterial &mat) static luabind::object shader_mat_value_to_lua_object(lua_State *l, const pragma::rendering::shader_material::PropertyValue &val) { - return std::visit([l](const auto &val) { return luabind::object {l, val}; }, val); + return std::visit( + [l](const auto &val) { + using T = util::base_type; + if constexpr(std::is_same_v) + return luabind::object {l, static_cast(val)}; + else + return luabind::object {l, val}; + }, + val); } void ClientState::RegisterSharedLuaClasses(Lua::Interface &lua, bool bGUI) @@ -224,11 +232,12 @@ void ClientState::RegisterSharedLuaClasses(Lua::Interface &lua, bool bGUI) if(db == nullptr) return; auto shaderInfo = c_engine->GetShaderManager().PreRegisterShader(shader); + static_cast(mat).ClearDescriptorSets(); mat.Initialize(shaderInfo, db); + mat.SetUserData2(nullptr); mat.SetLoaded(true); - auto shaderHandler = static_cast(client->GetMaterialManager()).GetShaderHandler(); - if(shaderHandler) - shaderHandler(&mat); + mat.UpdateTextures(true); + c_game->ReloadMaterialShader(static_cast(&mat)); })); materialClassDef.def( "GetPrimaryShader", +[](lua_State *l, ::Material &mat) -> luabind::object { @@ -546,6 +555,7 @@ void ClientState::RegisterSharedLuaClasses(Lua::Interface &lua, bool bGUI) defShaderTextured3D.add_static_constant("PUSH_CONSTANTS_SIZE", sizeof(pragma::ShaderGameWorldLightingPass::PushConstants)); defShaderTextured3D.add_static_constant("PUSH_CONSTANTS_USER_DATA_OFFSET", sizeof(pragma::ShaderGameWorldLightingPass::PushConstants)); defShaderTextured3D.def("GetShaderMaterial", &pragma::ShaderGameWorldLightingPass::GetShaderMaterial); + defShaderTextured3D.def("GetShaderMaterialName", &pragma::ShaderGameWorldLightingPass::GetShaderMaterialName); modShader[defShaderTextured3D]; auto defShaderGlow = luabind::class_>("Glow");