flixel-addons icon indicating copy to clipboard operation
flixel-addons copied to clipboard

FlxHotReloadShader?

Open Geokureli opened this issue 2 years ago • 3 comments

Now that #399 was added, how hard would it be tie a shader to its original .frag asset, and check for changes to create a new shader instance and update utilizing sprites?

This would only exist on debug

Geokureli avatar Aug 17 '23 23:08 Geokureli

That would be a kinda hard task to do. I am not a pro at how shaders works in OpenFL, but that would require to reload and recompile the shader program frequently. I'd recommend just letting the developers doing their own way on reloading shaders, by having 2 variables that should be set to both fragment/vertex source file path, and a reload function that reloads and recompile the shader program.

Sword352 avatar Aug 21 '23 17:08 Sword352

That would be a kinda hard task to do. I am not a pro at how shaders works in OpenFL, but that would require to reload and recompile the shader program frequently.

the bulk of that work is done due to FlxRuntimeShader, also:

  1. the frequency to me is not an issue, it's whenever you save the .frag file, not everytime you type into whatever editor you're using
  2. My intended purpose for this is debugging, where any performance issues of switching shaders constantly is traded off for the convenience of rapid prototyping.

I do think there's plenty of ways to approach this, I plan on making my own, and if it seems generic and useful enough than its worth considering adding it to flixel-addons. otherwise it can be listed in External Tools

Geokureli avatar Aug 21 '23 19:08 Geokureli

Lime has a FileWatcher class (https://github.com/openfl/lime/blob/develop/src/lime/system/FileWatcher.hx), which could be of use for this

UncertainProd avatar Sep 04 '23 18:09 UncertainProd