Welcome, Guest.
Username: Password: Remember me

TOPIC: Toggle & Timeout

Toggle & Timeout 1 year 5 months ago #1

  • Roxxtar
  • Roxxtar's Avatar
  • Offline
  • Posts: 15
  • Thank you received: 3
I have a quick question:

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!
Last Edit: 1 year 5 months ago by Roxxtar.
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #2

  • Ioxa
  • Ioxa's Avatar
  • Offline
  • Posts: 267
  • Thank you received: 245
You should download the core version of ReShade and read through the ReShade.fx file. Here are a couple lines from it that might help you out.

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.
The administrator has disabled public write access.
The following user(s) said Thank You: Roxxtar

Toggle & Timeout 1 year 5 months ago #3

  • Roxxtar
  • Roxxtar's Avatar
  • Offline
  • Posts: 15
  • Thank you received: 3
Awesome, that seems to be exactly what I'm looking for. I'm a graphic designer by trade (which is why it's easy for me to manipulate to look of the effects) but don't have much coding experience (which is why implementing this stuff is difficult for me). Is it possible for you to give me an example of where/how to place those codes to achieve what I described above?

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?
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #4

  • Ioxa
  • Ioxa's Avatar
  • Offline
  • Posts: 267
  • Thank you received: 245
I don't have the time to test it right now but I think you would want it to look like this.
uniform bool keydown < source = "key"; keycode = 0x20; toggle = false; >;
technique Gaussian_Tech <bool enabled = keydown; >
And if you want an effect that times out after the key has been pressed, I think it would look like this.
technique Gaussian_Tech <bool enabled = false; int toggle = 0x20; timeout = 1000; >
The administrator has disabled public write access.
The following user(s) said Thank You: Roxxtar

Toggle & Timeout 1 year 5 months ago #5

  • Martigen
  • Martigen's Avatar
  • Offline
  • Posts: 147
  • Thank you received: 35
Wow, just wanted to say great idea. This could really enhance games like Skyrim! It's a lot of work to setup different effects for different in-game spells etc but once it's done anyone can use your profile to get the same. What game are you using this technique for, and will you upload a preset when you're done? :)
The administrator has disabled public write access.
The following user(s) said Thank You: Roxxtar

Toggle & Timeout 1 year 5 months ago #6

  • Roxxtar
  • Roxxtar's Avatar
  • Offline
  • Posts: 15
  • Thank you received: 3
Thanks Martigen! Although I can't take all of the credit, this was actually an idea suggested by the users in my comments section and I'm running with it after we discussed the possibilities. It's my Witcher 3 preset called W3 Evolved - Extreme FX. It already uses the latest framework along with Euda's PPFX merged in for good measure, and takes advantage of far more of ReShade than the other presets available so far (but also has the biggest FPS hit, LOL... that's why I have 3 different performance versions). Check it out here:

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.
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #7

  • Ganossa
  • Ganossa's Avatar
  • Offline
  • 최정장군
  • Posts: 790
  • Thank you received: 838
If you think the timeout field for techniques works properly we can add it as a value to each technique / shader (same as currently done for the toggle key). This way those values can remain in the configuration files.
Last Edit: 1 year 5 months ago by Ganossa.
The administrator has disabled public write access.
The following user(s) said Thank You: Roxxtar

Toggle & Timeout 1 year 5 months ago #8

  • Roxxtar
  • Roxxtar's Avatar
  • Offline
  • Posts: 15
  • Thank you received: 3
Yes, it's definitely working exactly as I expected it to. Just a bit of playing with the time setting so it aligns perfectly with the spell time in the game and boom, incredible effects added on the fly. Having the timeout in the config files would be a great addition in my opinion and open up the possibility for unorthodox and creative use of the effects like what I'm trying to do.

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?
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #9

  • Roxxtar
  • Roxxtar's Avatar
  • Offline
  • Posts: 15
  • Thank you received: 3
Oh, and another thing Lucifer...

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 :)
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #10

  • Ganossa
  • Ganossa's Avatar
  • Offline
  • 최정장군
  • Posts: 790
  • Thank you received: 838
Keydown checks work but not as technique attributes.
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 :)
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #11

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2451
  • Thank you received: 1391
Annotations (the values between "<" and ">") are constants, they cannot change, so it's not possible to refer to another uniform variable there.
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.
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: Ganossa

Toggle & Timeout 1 year 5 months ago #12

  • Ganossa
  • Ganossa's Avatar
  • Offline
  • 최정장군
  • Posts: 790
  • Thank you received: 838
I tried around with timeout and currently the timeout result is not fixed::

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)
Last Edit: 1 year 5 months ago by Ganossa.
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #13

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2451
  • Thank you received: 1391
LuciferHawk wrote:
This might be intended or not intended but maybe worth mentioning :)
Yes, that is intended. The technique timeout toggles the technique to the opposite state once it ran out.
Cheers, crosire =)
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #14

  • Roxxtar
  • Roxxtar's Avatar
  • Offline
  • Posts: 15
  • Thank you received: 3
I believe what Lucifer is referring to is that when you press the toggle key a second time before to the timer runs out, it switches to the opposite state which is technically the current state.

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.
Last Edit: 1 year 5 months ago by Roxxtar.
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #15

  • Ganossa
  • Ganossa's Avatar
  • Offline
  • 최정장군
  • Posts: 790
  • Thank you received: 838
You would not want to block all toggle keys but that specific toggle key which triggered the timeout to not swap/toggle back before it runs out.
Last Edit: 1 year 5 months ago by Ganossa.
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #16

  • Roxxtar
  • Roxxtar's Avatar
  • Offline
  • Posts: 15
  • Thank you received: 3
Just brainstorming:

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.
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #17

  • Ganossa
  • Ganossa's Avatar
  • Offline
  • 최정장군
  • Posts: 790
  • Thank you received: 838
There are a few things that need to be considered:

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.
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #18

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2451
  • Thank you received: 1391
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)
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):
technique MyTechnique <
#if MotionFocus_timeout != 0
timeout = MotionFocus_timeout
#endif
> {
...
}
Cheers, crosire =)
Last Edit: 1 year 5 months ago by crosire.
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #19

  • Ganossa
  • Ganossa's Avatar
  • Offline
  • 최정장군
  • Posts: 790
  • Thank you received: 838
I am fine with anything.
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. :)
Last Edit: 1 year 5 months ago by Ganossa.
The administrator has disabled public write access.

Toggle & Timeout 1 year 5 months ago #20

  • Ganossa
  • Ganossa's Avatar
  • Offline
  • 최정장군
  • Posts: 790
  • Thank you received: 838
Added the timeout feature to the following effects/shader::

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. :side:

--it is included in the upcoming update
The administrator has disabled public write access.
The following user(s) said Thank You: Roxxtar
  • Page:
  • 1
  • 2