GLSL Creator
Overview
Section titled “Overview”The GLSL Creator LOP is a powerful tool for generating, editing, and managing GLSL shaders directly within TouchDesigner. It leverages AI to assist in shader creation based on text prompts, automatically applying and saving shaders, and providing tools for debugging and refinement. This operator simplifies the shader development workflow, making it accessible to users with varying levels of GLSL expertise.
Requirements
Section titled “Requirements”- No additional Python packages required
- Requires a valid OpenAI API key configured in the ChatTD operator
Input/Output
Section titled “Input/Output”Inputs
Section titled “Inputs”- Up to three TOP inputs (optional):
- Used as textures within the generated GLSL shader
- Controlled by
Use Input 0
,Use Input 1
, andUse Input 2
parameters
Outputs
Section titled “Outputs”- GLSL TOP: Rendered result of the generated or loaded GLSL shader
Parameters
Section titled “Parameters”GLSL Creator
Section titled “GLSL Creator”op('glsl_creator').par.Currentsave
Folder Specifies the current project folder for saving and loading shaders. This is a relative path within the Save Folder specified on the Config page.
- Default:
glsl_creator1
op('glsl_creator').par.Selectproject
Pulse Opens a file dialog to select a project folder, updating the Current GLSL Project parameter.
- Default:
None
op('glsl_creator').par.Activecall
Toggle Indicates whether a shader generation or improvement process is currently active. Prevents concurrent AI calls.
- Default:
0
op('glsl_creator').par.Cpucooktime
String Displays the CPU cook time of the GLSL TOP.
- Default:
0.067 ms
op('glsl_creator').par.Gpucooktime
String Displays the GPU cook time of the GLSL TOP.
- Default:
0.06 ms
op('glsl_creator').par.Average
Toggle Toggles the display of average cook times.
- Default:
1
op('glsl_creator').par.Operror
Toggle Indicates whether the GLSL TOP has encountered a compilation error.
- Default:
0
op('glsl_creator').par.Heavycookcheck
Pulse Forces the GLSL TOP to cook, useful for debugging.
- Default:
None
op('glsl_creator').par.Editcodeexternal
Pulse Opens the GLSL code in an external text editor.
- Default:
None
op('glsl_creator').par.Editshadercode
Pulse Opens the GLSL code in a TouchDesigner Text DAT viewer.
- Default:
None
op('glsl_creator').par.Generateshader
Pulse Initiates the AI-powered shader generation process based on the Shader Prompt.
- Default:
None
op('glsl_creator').par.Shaderprompt
String The text prompt used to guide the AI in generating the GLSL shader.
- Default:
create a grid based complex projection mapping pattern. make it neon and fancy and animating
Agent Constraints
Section titled “Agent Constraints”op('glsl_creator').par.Maxtokens
Integer The maximum number of tokens used by the AI during shader generation. Higher values allow for more complex shaders but may increase processing time and API costs.
- Default:
2000
op('glsl_creator').par.Maxattempts
Integer The maximum number of attempts to generate a shader from the initial prompt.
- Default:
3
op('glsl_creator').par.Maxfixattempts
Integer The maximum number of attempts to fix a shader that has compilation errors.
- Default:
3
op('glsl_creator').par.Currentattempt
Integer The current attempt number for shader generation.
- Default:
0
op('glsl_creator').par.Currentuniformattempt
Integer The current attempt number for uniform setup.
- Default:
1
op('glsl_creator').par.Checkresults
Pulse Manually checks the results of the shader compilation and applies the shader if Auto Apply is enabled.
- Default:
None
op('glsl_creator').par.Autocheck
Toggle Automatically checks the shader compilation results after each generation or fix attempt.
- Default:
1
op('glsl_creator').par.Autoapply
Toggle Automatically applies the generated shader code to the GLSL TOP if the compilation is successful.
- Default:
1
Improve Shader
Section titled “Improve Shader”op('glsl_creator').par.Improvenote
String A text note describing the desired improvements to the current shader.
- Default:
it should include a grid !!!!
op('glsl_creator').par.Improveshaderimage
Toggle Includes a still of the current shader as context for the AI during the improvement process.
- Default:
1
op('glsl_creator').par.Differencelevel
Float Controls the level of change during shader improvement. Lower values result in subtle refinements, while higher values allow for more radical transformations.
- Default:
0.7289999723434448
op('glsl_creator').par.Improveshader
Pulse Initiates the AI-powered shader improvement process based on the Improvement Note.
- Default:
None
GLSL Setup
Section titled “GLSL Setup”op('glsl_creator').par.Time
Float The current time, passed as a uniform to the GLSL shader.
- Default:
39084.13333333333
op('glsl_creator').par.Color
RGBA The color, passed as a uniform to the GLSL shader.
- Default:
0,0.65,1,1
op('glsl_creator').par.Mouseuv
UV The mouse UV coordinates, passed as a uniform to the GLSL shader.
- Default:
0,0
op('glsl_creator').par.Resolution
XY The custom resolution values used when Output Resolution is set to custom.
- Default:
1280,1280
op('glsl_creator').par.Trueres
XY Displays the actual resolution of the GLSL TOP.
- Default:
1280,1280
op('glsl_creator').par.Useinput0
Toggle Enables or disables the use of the first input TOP as a texture in the GLSL shader.
- Default:
0
op('glsl_creator').par.Useinput1
Toggle Enables or disables the use of the second input TOP as a texture in the GLSL shader.
- Default:
0
op('glsl_creator').par.Useinput2
Toggle Enables or disables the use of the third input TOP as a texture in the GLSL shader.
- Default:
0
Vector Parameters
Section titled “Vector Parameters”op('glsl_creator').par.Vec
Sequence A sequence of vector parameters that can be passed as uniforms to the GLSL shader.
- Default:
None
op('glsl_creator').par.Vec0name
String The name of the vector uniform.
- Default:
gridDensity
op('glsl_creator').par.Vec0value
XYZW The values of the vector uniform.
- Default:
1,1,1,1
op('glsl_creator').par.Vecsync
Pulse Synchronizes the vector parameters between the GLSL Creator and the GLSL TOP.
- Default:
None
Config
Section titled “Config”op('glsl_creator').par.Saveshader
Pulse Saves the current shader code and metadata to a new version folder within the project.
- Default:
None
op('glsl_creator').par.Loadshader
Pulse Loads the selected shader version from the project folder.
- Default:
None
op('glsl_creator').par.Autoload
Toggle Automatically loads the selected shader version when the Load Version parameter is changed.
- Default:
1
op('glsl_creator').par.Savefolder
Folder Specifies the base folder for saving and loading shader projects.
- Default:
D:/TD-tox/LOPS_tox/INSTALLvenv/glsl_creator
op('glsl_creator').par.Chattd
OP Specifies the path to the ChatTD operator, which handles communication with the AI API.
- Default:
/dot_lops/ChatTD
op('glsl_creator').par.Showbuiltin
Toggle Toggles the display of built-in parameters in the parameter dialog.
- Default:
0
op('glsl_creator').par.Popups
Toggle Enables or disables helpful pop-up messages about the operator.
- Default:
1
op('glsl_creator').par.Clearlog
Pulse Clears the log.
- Default:
None
op('glsl_creator').par.Converttotext
Toggle Converts the log output to text format.
- Default:
0
op('glsl_creator').par.Reverse
Toggle Reverses the order of log messages.
- Default:
1
op('glsl_creator').par.Bypass
Toggle Bypasses the GLSL Creator operator.
- Default:
0
op('glsl_creator').par.Version
String The version number of the GLSL Creator operator.
- Default:
1.0.0
op('glsl_creator').par.Lastupdated
String The date the operator was last updated.
- Default:
2024-11-09
op('glsl_creator').par.Creator
String The creator of the operator.
- Default:
dotsimulate
op('glsl_creator').par.Website
String The creator's website.
- Default:
https://dotsimulate.com
Performance Considerations
Section titled “Performance Considerations”- Shader complexity directly impacts GPU cook time. Optimize shader code for efficiency.
- High
Max Tokens
values can increase AI processing time. - Using input textures increases GPU memory usage.
Usage Examples
Section titled “Usage Examples”Generating a New Shader
Section titled “Generating a New Shader”# Set up shader generationop('glsl_creator').par.Shaderprompt = "create a swirling nebula effect"op('glsl_creator').par.Maxtokens = 2000op('glsl_creator').par.Autoapply = 1
# Generate shaderop('glsl_creator').par.Generateshader.pulse()
# Check for errorsif op('glsl_creator').par.Operror: # Try to fix the shader op('glsl_creator').par.Improvenote = "fix compilation errors" op('glsl_creator').par.Improveshader.pulse()
Improving an Existing Shader
Section titled “Improving an Existing Shader”# Load existing shaderop('glsl_creator').par.Loadversion = "version_1740466694"op('glsl_creator').par.Loadshader.pulse()
# Set up improvementop('glsl_creator').par.Improvenote = "add more vibrant colors"op('glsl_creator').par.Differencelevel = 0.5op('glsl_creator').par.Improveshaderimage = 1
# Improve shaderop('glsl_creator').par.Improveshader.pulse()
Using Input Textures
Section titled “Using Input Textures”# Enable input texturesop('glsl_creator').par.Useinput0 = 1op('glsl_creator').par.Useinput1 = 1
# Connect input TOPsop('glsl_creator').inputConnectors[0].connect(op('texture1'))op('glsl_creator').inputConnectors[1].connect(op('texture2'))
# Update shader prompt to use inputsop('glsl_creator').par.Shaderprompt = """create a shader that blends two input textures with a swirling effect.use sTD2DInputs[0] and sTD2DInputs[1] for the input textures"""
Managing Vector Uniforms
Section titled “Managing Vector Uniforms”# Set up vector uniformop('glsl_creator').par.Vec0name = "gridDensity"op('glsl_creator').par.Vec0valuex = 10op('glsl_creator').par.Vec0valuey = 10
# Sync vector parametersop('glsl_creator').par.Vecsync.pulse()
# Save shader with uniformsop('glsl_creator').par.Saveshader.pulse()
Common Use Cases
Section titled “Common Use Cases”- Generating custom visual effects for interactive installations
- Creating unique textures and patterns for 3D models
- Developing real-time graphics for live performances
- Prototyping shader ideas quickly using AI assistance
- Debugging and refining existing GLSL shaders