matthewwachter / td-shadertoy

MIT License
73 stars 8 forks source link

td-shadertoy

Built in TouchDesigner version - 2023.11340

td-shadertoy.toe is a collection of TouchDesigner components that can be used to convert and browse Shadertoy shaders via the Shadertoy API.

WARNING

YOU CANNOT USE A SHADER COMMERCIALLY WITHOUT PERMISSION FROM THE AUTHOR

If you wish to use a Shadertoy shader in a commercial environment, you must contact the original author of the shader and obtain permission. The shadertoyConverter component has a button to Open Site which will open the shader on the Shadertoy website where you will find the author's contact information. Usually the author will include the license information as a comment in the shader's code.

shadertoyConverter

Screenshot1

Screenshot3

shadertoyBrowser

Screenshot4

Screenshot2

Converting from Shadertoy to TouchDesigner

Below you will find exmples of several differences between the way shaders are written in Shadertoy and TouchDesigner. These differences need to be addressed in order to compile the shader code in TouchDesigner. This is done automatically when the shadertoyConverter component loads a shader.

uniform vec3      iResolution;           // viewport resolution (in pixels)
uniform float     iTime;                 // shader playback time (in seconds)
uniform float     iTimeDelta;            // render time (in seconds)
uniform int       iFrame;                // shader playback frame
uniform float     iChannelTime[4];       // channel playback time (in seconds)
uniform vec4      iMouse;                // mouse pixel coords. xy: current (if MLB down), zw: click
uniform vec4      iDate;                 // (year, month, day, time in seconds)
uniform float     iSampleRate;           // sound sample rate (i.e., 44100)
layout (location = 0) out vec4 TDColor;
void main()
{
    mainImage(TDColor, vUV.st*iResolution.xy);
}
if ctype == 'cubemap':
    code = code.replace('iChannel' + str(channel), 'sTDCubeInputs[' + str(channel) + ']')
    code = code.replace('iChannelResolution[' + str(channel) + ']', 'vec2(uTDCubeInfos[' + str(channel) + '].res.zw)')
else:
    code = code.replace('iChannel' + str(channel), 'sTD2DInputs[' + str(channel) + ']')
code += textwrap.dedent('''
#include <../common>
''')

Known Issues

Links

matthewwachter.com

Shadertoy

Shadertoy API Documentation