Christian Clavet Posted July 9, 2017 Share Posted July 9, 2017 Hi! Is there a method (preferably LUA if possible) to enable/disable some of the post-process shaders that are used in a map. I don't seem to find something that is related to that in documentation. I would like to use that so that in the settings menu, I could offer a way to disable/enable "FX's" to keep game performance on lower end hardware... Quote Link to comment Share on other sites More sharing options...
gamecreator Posted July 9, 2017 Share Posted July 9, 2017 You can use the camera functions like AddPostEffect and ClearPostEffects. I don't code Lua but it should work there too.https://www.leadwerks.com/learn.php?page=API-Reference_Object_Entity_Camera Quote Link to comment Share on other sites More sharing options...
Christian Clavet Posted July 9, 2017 Author Share Posted July 9, 2017 Thanks. Exactly what I was looking for! Quote Link to comment Share on other sites More sharing options...
Russell Posted February 21, 2020 Share Posted February 21, 2020 On 7/9/2017 at 7:28 PM, Christian Clavet said: Thanks. Exactly what I was looking for! I'm new in LUA, im trying to do this. Any tip i can follow to code ENABLE/DISABLE Shaders. I'm trying enable/disable WOBBLE.SHADER when i go out of water or underwater. I have readed gamecreator link about entity camera: On 7/9/2017 at 7:25 PM, gamecreator said: You can use the camera functions like AddPostEffect and ClearPostEffects. I don't code Lua but it should work there too. https://www.leadwerks.com/learn.php?page=API-Reference_Object_Entity_Camera And i tried encoding myself script with AddPostEffect command, but i don't know how use it. Any tip or code example to see the sintax??? Thank you very much. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 22, 2020 Share Posted February 22, 2020 It would be like camera:AddPostEffect("Shaders/PostEffects/nameofshader.shader") 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...
Russell Posted February 22, 2020 Share Posted February 22, 2020 1 hour ago, Josh said: It would be like camera:AddPostEffect("Shaders/PostEffects/nameofshader.shader") Thanks for your answer Josh. But my problem is how encode that line in a Script. If I write that command in my own script appears error of nil value. My case using the flowgraph is this: I've got a box (called Trigger_EnableDisableWobble) with texture Trigger, with Physics Trigger and Script collision trigger.lua. How and where can I encode the line addposteffect when our character touches the trigger to add that shader? Thanks for help. Quote Link to comment Share on other sites More sharing options...
Josh Posted February 22, 2020 Share Posted February 22, 2020 Well, you need a variable where your camera is. What script is in this? Can you post some of your code? 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...
Russell Posted February 22, 2020 Share Posted February 22, 2020 3 hours ago, Josh said: Well, you need a variable where your camera is. What script is in this? Can you post some of your code? I don't have any camera on the map. Only de FPSPlayer.prefab of our character. This is my code for CollisionTrigger... Is the default of Leadwerks... function Script:Start() self.enabled=true end function Script:Collision(entity, position, normal, speed) if self.enabled then self.component:CallOutputs("Collision") end end function Script:Enable()--in if self.enabled==false then self.enabled=true --self:CallOutputs("Enable") end end function Script:Disable()--in if self.enabled then self.enabled=false --self:CallOutputs("Disable") end end Any hint of how encode camera:AddPostEffect line??? I have tried this: function Script:Collision(entity, position, normal, speed) if self.enabled then self.component:CallOutputs("Collision") self.camera:AddPostEffect("Shaders/PostEffects/wobble.shader") end end And in have tried this too in the same script: function Script:Render(camera, context, buffer, depthtexture, diffusetexture, normaltexture) camera:AddPostEffect("Shaders/PostEffects/wobble.shader") end It doesn't work... I don't know how encode this... Quote Link to comment Share on other sites More sharing options...
Josh Posted February 23, 2020 Share Posted February 23, 2020 Without having tried it, I think you need something like this: function Script:Collision(entity, position, normal, speed) if self.enabled then if entity.script ~= nil then if entity.script.camera ~= nil then entity.script.camera:AddPostEffect("Shaders/PostEffects/wobble.shader") self.enabled = false end end end end 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...
Russell Posted February 23, 2020 Share Posted February 23, 2020 2 hours ago, Josh said: Without having tried it, I think you need something like this: function Script:Collision(entity, position, normal, speed) if self.enabled then if entity.script ~= nil then if entity.script.camera ~= nil then entity.script.camera:AddPostEffect("Shaders/PostEffects/wobble.shader") self.enabled = false end end end end I will say something that many people will tell you in the forum: "I love you Josh!! I love you buddy!!" It works!! Thank you very much!! You have saved my day 1 Quote Link to comment Share on other sites More sharing options...
Russell Posted February 23, 2020 Share Posted February 23, 2020 3 hours ago, Josh said: Without having tried it, I think you need something like this: function Script:Collision(entity, position, normal, speed) if self.enabled then if entity.script ~= nil then if entity.script.camera ~= nil then entity.script.camera:AddPostEffect("Shaders/PostEffects/wobble.shader") self.enabled = false end end end end I have now 2 collisions scripts differents for the Water area. One for ENABLE (thanks @Josh) wobble.shader effect, and another one for DISABLE it with ClearPostEffects() This is the result: Many thanks team!! Im very newbie with LUA, and sometimes one simple line of code takes me a long time to achieve my objetive. 2 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.