Deep-Fold / PixelPlanets

MIT License
1.05k stars 120 forks source link

Controlling time from game loop instead of shader #1

Open sjml opened 4 years ago

sjml commented 4 years ago

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.