Welcome, Guest.
Username: Password: Remember me

TOPIC: technique & uniform bool toggle

technique & uniform bool toggle 1 year 2 months ago #1

ver 1.0.0
when technique toggle and uniform bool toggle set to same key,

uniform bool test < source = "key"; keycode = VK_F2; toggle = true; > = false;
technique Test < enabled = false; toggle = VK_F2;>
{....}

the uniform bool behave like this: (both default at true)

technique: T F T F
bool return T T F F

set bool to default at false only flips the return.
also the same result with togglectrl = true;
Last Edit: 1 year 2 months ago by kingeric1992.
The administrator has disabled public write access.

technique & uniform bool toggle 1 year 2 months ago #2

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2457
  • Thank you received: 1393
That's an unfortunate side-effect of how the uniforms are updated currently. All techniques share the same uniform values, but they are updates not once per frame, but once per technique. If a technique is disabled however, the update is skipped (for that technique).
Let's say we have two techniques. Now the following happens:
uniform bool test < source = "key"; keycode = VK_F2; toggle = true; > = true;
technique t1 < enabled = true; toggle = VK_F2; > { ... }
technique t2 < enabled = true; > { ... }
F2 is pressed ->
	RENDER t1 [DISABLED]
		--> SKIP
	RENDER t2
		--> UPDATE --> test = !test --> false
F2 is pressed ->
	RENDER t1 [ENABLED]
		--> UPDATE --> test = !test --> true
	RENDER t2
		--> UPDATE --> test = !test --> false
F2 is pressed ->
	RENDER t1 [DISABLED]
		--> SKIP
	RENDER t2
		--> UPDATE --> test = !test --> true
F2 is pressed ->
	RENDER t1 [ENABLED]
		--> UPDATE --> test = !test --> false
	RENDER t2
		--> UPDATE --> test = !test --> true
I hope that visualizes the problem.

To fix this I could move the uniform update code to only happen once per frame. This would mean all timers are only updates once per frame too and not between techniques. That might be a problem, but it might as well be not. Performance would sure benefit from this.
Cheers, crosire =)
Last Edit: 1 year 2 months ago by crosire.
The administrator has disabled public write access.

technique & uniform bool toggle 1 year 2 months ago #3

Thanks,
I was able to bypass the problem by isolating the problematic passes to separated technique with toggle key.

And I think it would be more intuitive if uniforms updates per frame,
keeping the timer update per technique might be useful if someone wishes to utilize the delta time, but it would also mess up syncing between techniques.

Anyway, it is good to know about reshade standards.
The administrator has disabled public write access.

technique & uniform bool toggle 1 year 2 months ago #4

btw, there is a another minor issue with the timer.
when shaders recompile, default true technique with small timer will fail to turn on as if it is default as false.
Not a big deal though, tuning up the timer can fix the issue.
The administrator has disabled public write access.