Make shader time always count from zero #6903
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your PR, what does it fix/add?
At the moment, a shader's
time
uniform is initially set to whatever the current value ofm_tGlobalTimer
is. This means that any shaders that are enabled after hyprland starts have no way of knowing how long it has been since they were enabled (this only applies to the user defined screen shader as far as I can tell).This PR fixes this by storing the initial time and setting the
time
uniform totime - initialTime
, so a shader's firsttime
value is zero (and then counts up normally from there).Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)
This only sets the initial time value for the screen shader (everything else defaulting to zero), as I assume nothing else actually needs it. This does mean the initial time could just be stored outside of the
CShader
, but it's easier this way.It means that whenever the config is edited and the user has a screen shader active it will reset the screen shader's time back to zero instead of continuing roughly from where they were. If this is a problem then it could instead just expose an
initial_time
uniform to the shader but the only thing you could possibly do with it is justfloat timer = time-initial_time;
so I think it's best not to, for ease of use. (the first commit does it this way)Is it ready for merging, or does it need work?
Should be ready to merge, it works fine on my machine.