Andy90 Posted September 30, 2023 Share Posted September 30, 2023 Hello, i want to ask how i can remove a single post effect from the camera with lua. I was looking in the documentation but there is only a function to remove all. Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted September 30, 2023 Solution Share Posted September 30, 2023 Remove all and add the ones you want back in. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Andy90 Posted September 30, 2023 Author Share Posted September 30, 2023 oh ok so in this case i write an effect manager script. I will share it tomorrow here if anyone else needs it. Quote Link to comment Share on other sites More sharing options...
Andy90 Posted September 30, 2023 Author Share Posted September 30, 2023 Here is my effect manager script. It's really simple to use. Just create a pivot in your map and add the script. Then assign your camera to the script. Script.effects = {} Script.camera = nil --Entity "Camera"; function Script:Start() self:AddEffect("bloom", "Shaders/PostEffects/bloom.lua", true) self:AddEffect("ssao", "Shaders/PostEffects/ssao.shader", true) self:AddEffect("godrays", "Shaders/PostEffects/godrays.lua", true) self:AddEffect("grayscale", "Shaders/PostEffects/grayscale.shader", false) self:BuildEffectChain() end --Adds a new effect to the effect chain function Script:AddEffect(name, file, enabled) local effect = { name = name, file = file, enabled = enabled } table.insert(self.effects, effect) if enabled then self:BuildEffectChain() end return #self.effects + 1 end --Disables the effect at position n function Script:DisableEffect(index) if self.effects[index].enabled == true then self.effects[index].enabled = false self:BuildEffectChain() end end --Enables the effect at position n function Script:EnableEffect(index) if self.effects[index].enabled == false then self.effects[index].enabled = true self:BuildEffectChain() end end --Returns the effect index with the given name function Script:GetEffectIndex(name) for i, item in ipairs(self.effects) do if item.name == name then return i end end end --Returns the effect with the given name (untested) function Script:GetEffect(name) local effectIndex = self:GetEffectIndex(name); return self.effects[effectIndex]; end -- Rebuils the effect chain function Script:BuildEffectChain() self.camera:ClearPostEffects() for i, item in ipairs(self.effects) do if item.enabled then self.camera:AddPostEffect(item.file) end end end You can call the functions from the script when you assign the pivot as the entity. For example: and use local effectIndex = self.effectManager.script:GetEffectIndex("grayscale"); self.effectManager.script:DisableEffect(effectIndex); 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.