diff --git a/game/engines/default/engine/Entity.lua b/game/engines/default/engine/Entity.lua index 741095c4f3ca9e03b5d0d400d14358c8de134236..ed9bb3c97f2a5fff32846db89198ee231c763402 100644 --- a/game/engines/default/engine/Entity.lua +++ b/game/engines/default/engine/Entity.lua @@ -29,7 +29,7 @@ local next_uid = 1 local entities_load_functions = {} _M.__mo_final_repo = {} -_M._no_save_fields = {} +_M._no_save_fields = { _shader = true } _M.__position_aware = false -- Subclasses can change it to know where they are on the map -- Setup the uids & MO repository as a weak value table, when the entities are no more used anywhere else they disappear from there too @@ -327,7 +327,10 @@ function _M:makeMapObject(tiles, idx) -- Setup shader if tiles.use_images and core.shader.active() and self.shader then local shad = Shader.new(self.shader, self.shader_args) - if shad.shad then self._mo:shader(shad.shad) end + if shad.shad then + self._mo:shader(shad.shad) + self._shader = shad + end end self._mo, self.z, last_mo = self:alterMakeMapObject(tiles, self._mo, self.z, last_mo) diff --git a/game/engines/default/engine/Shader.lua b/game/engines/default/engine/Shader.lua index c1f4e800bffae841228fea80e0d15a9381156f8d..7581bfd468d5ee54952f77fd212826ad6327b0b4 100644 --- a/game/engines/default/engine/Shader.lua +++ b/game/engines/default/engine/Shader.lua @@ -25,6 +25,7 @@ module(..., package.seeall, class.make) _M.verts = {} _M.frags = {} +_M.progsperm = {} _M.progs = {} _M.progsreset = {} @@ -151,7 +152,7 @@ function _M:loaded() if _M.progs[self.totalname] and not _M.progsreset[self.totalname] then -- print("[SHADER] using cached shader "..self.totalname) self.shad = _M.progs[self.totalname].shad - _M.progs[self.totalname].dieat = os.time() + 120 + _M.progs[self.totalname].dieat = os.time() + 2 else -- print("[SHADER] Loading from /data/gfx/shaders/"..self.name..".lua") local f, err = loadfile("/data/gfx/shaders/"..self.name..".lua") @@ -172,18 +173,21 @@ function _M:loaded() -- print("[SHADER] Loaded shader with totalname", self.totalname) if not _M.progs[self.totalname] then - _M.progs[self.totalname] = {shad=self:createProgram(def), dieat=def.resetargs and (os.time() + 3) or (os.time() + 120)} + _M.progs[self.totalname] = {shad=self:createProgram(def), dieat=def.resetargs and (os.time() + 3) or (os.time() + 2)} _M.progsreset[self.totalname] = def.resetargs else - _M.progs[self.totalname].dieat = def.resetargs and (os.time() + 3) or (os.time() + 120) + _M.progs[self.totalname].dieat = def.resetargs and (os.time() + 3) or (os.time() + 2) end + self.shad = _M.progs[self.totalname].shad if self.shad then for k, v in pairs(def.args) do self:setUniform(k, v) end end + + if def.permanent then _M.progsperm[self.totalname] = self.shad end end if self.shad and _M.progsreset[self.totalname] then diff --git a/game/modules/tome/data/gfx/shaders/full_fbo.lua b/game/modules/tome/data/gfx/shaders/full_fbo.lua index f58cb5f67fa6649515404ad36eb3df7a9c84673d..76db2c441f5fe06e7246c97ad0d9cd597ddefd6c 100644 --- a/game/modules/tome/data/gfx/shaders/full_fbo.lua +++ b/game/modules/tome/data/gfx/shaders/full_fbo.lua @@ -25,4 +25,5 @@ return { noisevol = { texture = 1 }, }, clone = false, + permanent = true, } diff --git a/game/modules/tome/data/gfx/shaders/main_fbo.lua b/game/modules/tome/data/gfx/shaders/main_fbo.lua index 727bbe093de1c92622848989f19ab622e9493437..5d15f72ad7a08d1e5f505ff8cc5668e8451fc9aa 100644 --- a/game/modules/tome/data/gfx/shaders/main_fbo.lua +++ b/game/modules/tome/data/gfx/shaders/main_fbo.lua @@ -25,4 +25,5 @@ return { noisevol = { texture = 1 }, }, clone = false, + permanent = true, } diff --git a/game/modules/tome/data/gfx/shaders/objectsoutline.lua b/game/modules/tome/data/gfx/shaders/objectsoutline.lua index 4fc329d9ced9c2171d4314b95cdd01dbdbb8a8b3..20a07d3c06ae782da2a88fe619cc11e9a0c14bfa 100644 --- a/game/modules/tome/data/gfx/shaders/objectsoutline.lua +++ b/game/modules/tome/data/gfx/shaders/objectsoutline.lua @@ -28,4 +28,5 @@ return { outlineColor = outlineColor or {0, 1, 0.5, 0.4}, }, clone = false, + permanent = true, } diff --git a/game/modules/tome/data/gfx/shaders/resources.lua b/game/modules/tome/data/gfx/shaders/resources.lua index 24fee413d3d7ffa511991b15331a3edb337768ad..e1047c907547b3d9ab61d5675724b1ac1abbed71 100644 --- a/game/modules/tome/data/gfx/shaders/resources.lua +++ b/game/modules/tome/data/gfx/shaders/resources.lua @@ -28,4 +28,5 @@ return { amp = amp or 0.2, }, clone = false, + permanent = true, } diff --git a/game/modules/tome/data/gfx/shaders/resources2.lua b/game/modules/tome/data/gfx/shaders/resources2.lua index 7bf542d96f91a06932d0613b86eeb57f16a9147d..48721d4e0c076bc949100ba3d04fdd1b9e963855 100644 --- a/game/modules/tome/data/gfx/shaders/resources2.lua +++ b/game/modules/tome/data/gfx/shaders/resources2.lua @@ -30,4 +30,5 @@ return { amp = amp or 0.2, }, clone = false, + permanent = true, } diff --git a/game/modules/tome/data/gfx/shaders/textoutline.lua b/game/modules/tome/data/gfx/shaders/textoutline.lua index d8697b80fe96df728c8660d6a6a375c9f7ec5500..a25e54e0247c19d454f170f9992bad96ac3d7966 100644 --- a/game/modules/tome/data/gfx/shaders/textoutline.lua +++ b/game/modules/tome/data/gfx/shaders/textoutline.lua @@ -28,4 +28,5 @@ return { outlineColor = outlineColor or {0, 0, 0, 1}, }, clone = false, + permanent = true, }