Using ACS scripting to activate/deactivate shaders in game?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
gunrock
Posts: 26
Joined: Sat May 16, 2020 4:19 am

Using ACS scripting to activate/deactivate shaders in game?

Post by gunrock »

I downloaded theviewtopic.php?f=103&t=57352 from the ZDoom forums and thought it would fit nicely in an upcoming horror style mod. However, Is it possible to use ACS scripting to activate this shader when the player enters a room like he is entering a nightmare scene and the old video shader activates only in that room then deactivates when leaving that same room? I dont want the old video shader to play out all through the map. Think of Silent Hill 3, when some parts of the game uses the film grain effect in some scenes to make it more eerie.
User avatar
Cherno
Posts: 1337
Joined: Tue Dec 06, 2016 11:25 am

Re: Using ACS scripting to activate/deactivate shaders in ga

Post by Cherno »

No, but you can use a static ZScript function which can be called from ACS via ScriptCall and in turn can enable or disable the shader.

ACS:

Code: Select all

//make sure the player is the script's activator.
script "ToggleShader" (bool on)
{
    ScriptCall("MyActor", "ToggleShader", on);
}
ZScript:

Code: Select all

class MyActor: Actor
{
     static void ToggleShader(Actor a, bool on)
     {
          if(a && a.player)
          {
               Shader.SetEnabled(a.player,"MyShader",on);
          }
     }
}
Guest

Re: Using ACS scripting to activate/deactivate shaders in ga

Post by Guest »

Forgive me for my ignorance, but I have no idea how to begin to set this up or were to put the zscript code or acs functions in a nice pk3 format structure. Never worked with zscript which makes things more convoluted.
Thanks for your reply Cherno!
Post Reply

Return to “Scripting”