I have written a little snippet that lets importing shaders from ShaderToy. It creates a set of 3 files: frag, vert and j3md which can be used on your textures right away! The frag file is the port of the original shader from the website, the vert file is a simple placeholder, and the j3md is a simple template which gives the dynamic access to the fragment shader. ShaderToy features only fragment shaders (as of now), so the importer only takes care of that. The resulting material is ready for use, although, IRL, surely, you’ll get to customizations.
run from command line with “java -jar sti.jar [params]”. There is only 1 set of params and all of them are required. Them are:
- the name of the resulting material, i.e. MyMaterial
- the EXISTING path where to place the material, i.e. D:/temp
- the local path which will be specified in the j3md file and which is usually relative to the assets folder, i.e. Materials/ShaderToy
- the ShaderToy shader id, i.e. Msf3D7
- true or false, whether the shader will be used as a screen filter or as a texture for an object.
My example call I used for testing:
java -jar sti.jar B E:/temp "material" Msf3D7 false
The example shader that worked for me: https://www.shadertoy.com/view/Msf3D7 (note the shader id at the end)
- If you don’t see a correct shader result, try setting Resolution to Vector3f(1,1,1);
- Explore the resulting j3md to see what parameters you can set. Actually, they are verbatim translation from those of ShaderToy.
- Animated shaders require to specify the GlobalTime parameter on every frame. It must be a float. If you just add your tpfs up, it should do.
Here is the link for the alpha version:
So this is alpha, nothing fancy, but I plan to improve it at least as long as it goes hand-in-hand with my current project and I am satisfied with it.
Any feedback is appreciated. Bug reports are very welcome.