3Dickulus / FragM

Derived from https://github.com/Syntopia/Fragmentarium/
GNU General Public License v3.0
344 stars 30 forks source link

Support exporting to shadertoy #197

Open neozhaoliang opened 1 year ago

neozhaoliang commented 1 year ago

Hi, is it possible for FragM to add shadertoy support? That is, export files like common.frag, BufferA.frag, ..., Image.frag so that one can copy them to the shadertoy UI and view the live result?

3Dickulus commented 1 year ago

This is not high on my priority list right now as I'm not familiar enough with the inner workings of shadertoy and I have a feeling that it would be difficult due to the differences between shadertoy and FragM... however, github member loicvdb has contributed to the Fragmentarium/Examples repo some frags and documentation about importing shadertoy to FragM, https://github.com/loicvdb/VDB-frags allows using shadertoy fragments in FragM.

This might be helpful when trying to figure out how to do it.

FragM has a full ECMA (java) scripting inteface with debugger, the FragM commands available are documented here https://github.com/3Dickulus/FragM/wiki/06.-Scripting . With the above mentioned fragments and some creative scripting one could engineer an export.fqs script and bind it to hotkey F6... press Shift+F6 to open a file dialog to load your script, after that your script will execute when you press F6.

Will keep this issue open, but for right now the only option is that if you want to write shadertoy fragments just use shadertoy.

neozhaoliang commented 1 year ago

Thank you for your reply! The main reason I want to export Shadertoy files is that when I want to share some of my works with non-programmers, they lack the necessary experience to install and operate FragM. Shadertoy would be more convenient for them. However, this is not an urgent need. It would be great if this feature could be added in the future.

3Dickulus commented 1 year ago

Maybe a standalone player for FragM that could play animation settings? a "fragX" program that executes a shader without the main program. I think there's something like that out there already... maybe opensource?

neozhaoliang commented 1 year ago

One issue with using the fragX approach is the portability of GLSL. I have encountered this problem multiple times when using FragM/Fragmentarium, where many shader programs require modifications to the GLSL version for different machines. Even for versions below 120, I had to manually write functions like inverse(mat3). Does it seem Shadertoy is using GLSL es 300? Its compatibility on different platforms is much better.

3Dickulus commented 1 month ago

FragM supports GLSL versions: 100, 110, 120, 130, 140, 150, 300 es, 310 es, 320 es, 330, 400, 410, 420, 430, 440, 450, 460