Toggle & Timeout
- Roxxtar
- Topic Author
I'm trying to set certain effects to run on a one-off basis by granting them toggle keys that attach to in-game actions, then have the effect time out after a set amount of milliseconds. For example, when a player presses the number 5 key to cast a spell, the toggle key for Heat Haze in GemFX will also be attached to the number 5 key (0x50) and the Heat Haze will enable. I already have this part handled.
What I don't know how to do is add a timeout to the effect toggle so it automatically expires after a set amount of time (1-2 seconds) so the Heat Haze effect runs in-union with the in game spell, then times out without the player needing to press the toggle button again.
I also don't know how to set these effects to be off by default (so they don't automatically run after compilation, only on the toggle press). When I set them to off in the .fx files, the toggle keys do not work to force them to "kick on".
Lastly, and this one may not even be possible at all... is there any way to make an effect run only for the duration of a key press? For example, setting the toggle to spacebar and the effect only remains active while the spacebar is held down - for as long as it is held - and then goes off once it is released?
I'm looking for the most simplistic method to do this that will work universally with all (or at least most) of the effects in the Framework.
Is all/any/some of this possible? If so could someone give me an example of coding that would make such magic happen? Thanks!
Please Log in or Create an account to join the conversation.
- Ioxa
uniform bool keydown < source = "key"; keycode = 0x20; toggle = false; >;
> True if specified keycode (in this case the spacebar) is pressed and
false otherwise. If toggle is true the value stays true until the key
is pressed a second time.
technique tech1 < enabled = true; > { ... }
> Enable (or disable if false) this technique by default.
technique tech2 < timeout = 1000; > { ... }
> Auto-toggle this technique off 1000 milliseconds after it was enabled.
Please Log in or Create an account to join the conversation.
- Roxxtar
- Topic Author
Let's say I wanted to make your Gauss Blur kick on when the spacebar was held down, then expire after spacebar is released, how would one do that?
I cracked open the gaussian.h file and have no clue where would be the proper place to put the codes without mucking things up. I found this line:
technique Gaussian_Tech <bool enabled = RFX_Start_Enabled; int toggle = Gaussian_ToggleKey; >
Is that the right place for all of this? And would changing it to this:
uniform bool keydown < source = "key"; keycode = 0x20; toggle = false; >;
technique Gaussian_Tech < enabled = false; >
Achieve the desired result?
Please Log in or Create an account to join the conversation.
- Ioxa
uniform bool keydown < source = "key"; keycode = 0x20; toggle = false; >;
technique Gaussian_Tech <bool enabled = keydown; >
technique Gaussian_Tech <bool enabled = false; int toggle = 0x20; timeout = 1000; >
Please Log in or Create an account to join the conversation.
- Martigen
Please Log in or Create an account to join the conversation.
- Roxxtar
- Topic Author
www.nexusmods.com/witcher3/mods/206
I haven't implemented these spell effects yet, but thanks to Ioxa's help I've already managed to get an extreme version of the Heat Wave effect to blast in when you cast the Igni spell... and it looks INCREDIBLE! Next I'm working on Aard which will have a heavy Gauss Blur and Motion Blur chime in when it's cast to simulate a sort of "wind blast" effect. After I'm done with all of the spells, I'm going to release the next version of the preset.
Please Log in or Create an account to join the conversation.
- Ganossa
Please Log in or Create an account to join the conversation.
- Roxxtar
- Topic Author
On a side note, although the timeout is working perfectly, I'm still not able to get the "keydown" to work. It seems like ReShade doesn't want anything but true/false to be placed after <bool enabled=. It's kicking out a yellow error in reference to the exactly place in the line where the "k" in keydown is when using this:
uniform bool keydown < source = "key"; keycode = 0x20; toggle = false; >;
technique Gaussian_Tech <bool enabled = keydown; >
So as of right now I'm still not able to make effects activate for the duration of a key hold, then expire upon release.
Any idea on how to get that working?
Please Log in or Create an account to join the conversation.
- Roxxtar
- Topic Author
Until you implement timeout control into the config files, is it alright for me to upload the altered .h files with the new version of my mod? I'm not 100% sure if uploading those to the Nexus is against your terms or not... I just know that the terms are designed to direct users here for the Framework download as they should be.
As usual I'll of course be leaving out everything else for the users to download here, only include the necessary files for the preset to operate properly, so the mod wouldn't work at all unless they follow my links here to download the Framework.
Just covering my bases, I'm really exciting about this next release because of these "one-off" effect additions I'm making
Please Log in or Create an account to join the conversation.
- Ganossa
Before adding them into every relevant post processing pass, I would first discuss with Crosire whether it is possible to add them as a technique attribute.
Regarding your mod, I will add that timeout field to all relevant shader with the next update so I would appreciate if you could wait that long
Please Log in or Create an account to join the conversation.
- crosire
The technique timeout starts counting as soon as a toggle event was recieved (so when the key is pressed), so it doesn't count in if the user is still holding down the key (as you noticed). On the other hand, uniform variables are for use in shaders, to enable something inside the shader code depending on key status. There is no timeout option for those yet though, could add that if it's needed.
Please Log in or Create an account to join the conversation.
- Ganossa
If the shader is activated and I press the toggle key it will deactivate and after defined time activate again
If the shader is deactivated and I press the toggle key it will activate and after defined time deactivate again
However,
If the shader is activated/deactivated and I press the toggle key twice before the timer ran out, it will swap the timeout result
This might be intended or not intended but maybe worth mentioning
(at least it means the timeout value is no solution for Roxxtar's idea)
Please Log in or Create an account to join the conversation.
- crosire
Yes, that is intended. The technique timeout toggles the technique to the opposite state once it ran out.LuciferHawk wrote: This might be intended or not intended but maybe worth mentioning
Please Log in or Create an account to join the conversation.
- Roxxtar
- Topic Author
To elaborate, I've noticed that if you cast the Igni spell with the Heat Haze I've attached to it, the effect becomes enabled and the timeout timer begins. That is what is intended. However, if you cast the spell again before the timer runs out (and auto-disables the effect on it's own) it will switch the effect to a state where it believes that it is still enabled, and you must double press the toggle key to activate it again.
Luckily, the spells in TW3 deplete your stamina upon each use, so I've been setting the timeouts to run for the same amount of time (or less) as the stamina regeneration. This obviously isn't ideal for all games, but in my case works just fine to prevent the double press issue.
You guys are the experts, but my assumption for a possible fix is some type of "block" to prevent the toggle keys from being used while the timeout for that specific key is currently running.
Please Log in or Create an account to join the conversation.
- Ganossa
Please Log in or Create an account to join the conversation.
- Roxxtar
- Topic Author
Can I add the necessary timeout #define lines to the config files myself, thus navigating around the need to edit the .h files at all? That way, I could upload the latest version of my preset without any violation to the terms and conditions and show everyone how these really cool timeout effects really work.
I'd have no problem doing the leg work by adding them all, then you'd be able to use my edited config files as a reference while compiling the next ReShade release without wasting time on the timeout #define lines yourselves, leaving more time for the complex stuff only you guys know how to do. Win win.
If so, would the line be something like this?
#define MotionFocus_timeout 2000 //[undef] //-
... and does a setting of zero disable the timeout?
#define MotionFocus_timeout 0 //[undef] //- Auto-toggle this technique off after it was enabled. Set to 0 to disable timeout.
Please Log in or Create an account to join the conversation.
- Ganossa
1. A value from 0 does not (yet) mean that timeout is disables but the opposite. (We either need precompiler commands or a quick discussion with Crosire which I would prefer)
2. Downwards compatibility has to be considered but would also introduce an immense clutter and additional compile time.
I only want to be careful about this addition though I understand of course that you want to release something new.
You can promote it of course with youtube videos or similar for the time being.
Please Log in or Create an account to join the conversation.
- crosire
I wouldn't make ReShade disable the timeout if a value of zero is found. It should be disabled if no timeout is specified at all. It can be done like this though (which does exactly that, but using the preprocessor):LuciferHawk wrote: 1. A value from 0 does not (yet) mean that timeout is disables but the opposite. (We either need precompiler commands or a quick discussion with Crosire which I would prefer)
technique MyTechnique <
#if MotionFocus_timeout != 0
timeout = MotionFocus_timeout
#endif
> {
...
}
Please Log in or Create an account to join the conversation.
- Ganossa
My concerne however would be that for a general solution I would constantly have that compiler overhead for almost every technique while the 0 value would actually never be useful (it only disables the set toggle key - maybe thats actually useful for someone?). Though I can completly understand if you think that such a border case implementation is not fitting in the overall design.
Please Log in or Create an account to join the conversation.
- Ganossa
TilftShift from CustomFX Suite
All shader in GemFX Suite
HeatHaze and FishEye in McFX Suite
Explosion and CA in SweetFX Suite
Since there is a little compiler overhead I decided to "only" add it to the effects/shader that make most sense (there is still plenty of combinations possible). I hope you are okay with that.
Thanks to Crosire now also with blocked toggle for the timeout.
--it is included in the upcoming update
Please Log in or Create an account to join the conversation.