technique & uniform bool toggle

  • kingeric1992
  • Topic Author
More
8 years 6 months ago - 8 years 6 months ago #1 by kingeric1992 technique & uniform bool toggle was created by kingeric1992
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: 8 years 6 months ago by kingeric1992.

Please Log in or Create an account to join the conversation.

  • crosire
More
8 years 6 months ago - 8 years 6 months ago #2 by crosire Replied by crosire on topic technique & uniform bool toggle
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.
Last edit: 8 years 6 months ago by crosire.

Please Log in or Create an account to join the conversation.

  • kingeric1992
  • Topic Author
More
8 years 6 months ago #3 by kingeric1992 Replied by kingeric1992 on topic technique & uniform bool toggle
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.

Please Log in or Create an account to join the conversation.

  • kingeric1992
  • Topic Author
More
8 years 6 months ago #4 by kingeric1992 Replied by kingeric1992 on topic technique & uniform bool toggle
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.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.