Controlling time from game loop instead of shader #1
+162
−117
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.
As I was integrating this into another project, I noticed it was using a lot more GPU than I had anticipated... at first I thought it was the noise functions, and went down a path of trying to pre-generate a noise texture... eventually I found out that it was the
TIME
variable in the Godot shader language.Apparently using
TIME
causes something the rendering pipeline to overtax the GPU, and at least my modest integrated graphics laptop would start roaring its fans after just 10-20 seconds of running the game.So long as VSync is enabled, driving the animation from the render loop instead of the shader itself avoids this problem and has no impact on visual quality. Admittedly, if you want to turn of VSync for max frames, this won't work for you, but usually those folks might have a much beefier graphics card anyway.
There is a downside, though, in that you actually have to run the game to see the animation; you can't easily watch it from the editor anymore (other than manually scrubbing the shader parameter). I can also appreciate the effort to drive everything from the shader, so if you don't like this for that reason, I totally get it, too. Anyway, do what you will with this -- just thought I would share.