Skip to content

GLSL Creator

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.

  • No additional Python packages required
  • Requires a valid OpenAI API key configured in the ChatTD operator
  • Up to three TOP inputs (optional):
    • Used as textures within the generated GLSL shader
    • Controlled by Use Input 0, Use Input 1, and Use Input 2 parameters
  • GLSL TOP: Rendered result of the generated or loaded GLSL shader
Current GLSL Project (Currentsave) 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
Select Project (Selectproject) op('glsl_creator').par.Selectproject Pulse

Opens a file dialog to select a project folder, updating the Current GLSL Project parameter.

Default:
None
Active Call (Activecall) op('glsl_creator').par.Activecall Toggle

Indicates whether a shader generation or improvement process is currently active. Prevents concurrent AI calls.

Default:
0
GLSL Monitor Header
CPU Cook Time (Cpucooktime) op('glsl_creator').par.Cpucooktime String

Displays the CPU cook time of the GLSL TOP.

Default:
0.067 ms
GPU Cook Time (Gpucooktime) op('glsl_creator').par.Gpucooktime String

Displays the GPU cook time of the GLSL TOP.

Default:
0.06 ms
Show Average Cook (Average) op('glsl_creator').par.Average Toggle

Toggles the display of average cook times.

Default:
1
Op Error (Operror) op('glsl_creator').par.Operror Toggle

Indicates whether the GLSL TOP has encountered a compilation error.

Default:
0
Heavycookcheck (Heavycookcheck) op('glsl_creator').par.Heavycookcheck Pulse

Forces the GLSL TOP to cook, useful for debugging.

Default:
None
Edit GLSL Code External (Editcodeexternal) op('glsl_creator').par.Editcodeexternal Pulse

Opens the GLSL code in an external text editor.

Default:
None
Open GLSL Code DAT (Editshadercode) op('glsl_creator').par.Editshadercode Pulse

Opens the GLSL code in a TouchDesigner Text DAT viewer.

Default:
None
Generate Shader (Generateshader) op('glsl_creator').par.Generateshader Pulse

Initiates the AI-powered shader generation process based on the Shader Prompt.

Default:
None
Shader Prompt (Shaderprompt) 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 Header
Max Tokens (Maxtokens) 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
Max Total Attempts (Maxattempts) op('glsl_creator').par.Maxattempts Integer

The maximum number of attempts to generate a shader from the initial prompt.

Default:
3
Max Fix Attempts (Maxfixattempts) op('glsl_creator').par.Maxfixattempts Integer

The maximum number of attempts to fix a shader that has compilation errors.

Default:
3
Current Attempt (Currentattempt) op('glsl_creator').par.Currentattempt Integer

The current attempt number for shader generation.

Default:
0
Current Uniform Attempt (Currentuniformattempt) op('glsl_creator').par.Currentuniformattempt Integer

The current attempt number for uniform setup.

Default:
1
Checkresults (Checkresults) 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
Auto Check (Autocheck) op('glsl_creator').par.Autocheck Toggle

Automatically checks the shader compilation results after each generation or fix attempt.

Default:
1
Auto Apply (Autoapply) op('glsl_creator').par.Autoapply Toggle

Automatically applies the generated shader code to the GLSL TOP if the compilation is successful.

Default:
1
Improvement Note (Improvenote) op('glsl_creator').par.Improvenote String

A text note describing the desired improvements to the current shader.

Default:
it should include a grid !!!!
Include Shader Still (Improveshaderimage) op('glsl_creator').par.Improveshaderimage Toggle

Includes a still of the current shader as context for the AI during the improvement process.

Default:
1
Difference Level (Differencelevel) 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
Improve Shader (Improveshader) op('glsl_creator').par.Improveshader Pulse

Initiates the AI-powered shader improvement process based on the Improvement Note.

Default:
None
Time (Time) op('glsl_creator').par.Time Float

The current time, passed as a uniform to the GLSL shader.

Default:
39084.13333333333
Color (Color) op('glsl_creator').par.Color RGBA

The color, passed as a uniform to the GLSL shader.

Default:
0,0.65,1,1
Mouse UV (Mouseuv) op('glsl_creator').par.Mouseuv UV

The mouse UV coordinates, passed as a uniform to the GLSL shader.

Default:
0,0
Output Resolution (Outputresolution) op('glsl_creator').par.Outputresolution Menu

Determines the output resolution of the GLSL TOP.

Default:
useinput
Options:
useinput: Use Input Resolution, half: Half Resolution, quarter: Quarter Resolution, custom: Custom Resolution
Resolution (Resolution) op('glsl_creator').par.Resolution XY

The custom resolution values used when Output Resolution is set to custom.

Default:
1280,1280
True Resolution (Trueres) op('glsl_creator').par.Trueres XY

Displays the actual resolution of the GLSL TOP.

Default:
1280,1280
Use Input 0 (Useinput0) 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
Use Input 1 (Useinput1) 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
Use Input 2 (Useinput2) 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 (Vec) op('glsl_creator').par.Vec Sequence

A sequence of vector parameters that can be passed as uniforms to the GLSL shader.

Default:
None
Name (Vec0name) op('glsl_creator').par.Vec0name String

The name of the vector uniform.

Default:
gridDensity
Value (Vec0value) op('glsl_creator').par.Vec0value XYZW

The values of the vector uniform.

Default:
1,1,1,1
Vector Block Sync (Vecsync) op('glsl_creator').par.Vecsync Pulse

Synchronizes the vector parameters between the GLSL Creator and the GLSL TOP.

Default:
None
Load Version (Loadversion) op('glsl_creator').par.Loadversion Menu

Selects a specific version of the shader to load from the project folder.

Default:
version_1740466694
Save Shader (Saveshader) op('glsl_creator').par.Saveshader Pulse

Saves the current shader code and metadata to a new version folder within the project.

Default:
None
Load Shader (Loadshader) op('glsl_creator').par.Loadshader Pulse

Loads the selected shader version from the project folder.

Default:
None
Auto Load (Autoload) op('glsl_creator').par.Autoload Toggle

Automatically loads the selected shader version when the Load Version parameter is changed.

Default:
1
Save Folder (Savefolder) 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
Chattd (Chattd) op('glsl_creator').par.Chattd OP

Specifies the path to the ChatTD operator, which handles communication with the AI API.

Default:
/dot_lops/ChatTD
Show Built In Pars (Showbuiltin) op('glsl_creator').par.Showbuiltin Toggle

Toggles the display of built-in parameters in the parameter dialog.

Default:
0
Helper Popups (Popups) op('glsl_creator').par.Popups Toggle

Enables or disables helpful pop-up messages about the operator.

Default:
1
Log Settings [ out4 ] Header
Show Logs (Showlogs) op('glsl_creator').par.Showlogs Menu

Controls the level of detail displayed in the log.

Default:
Basic
Options:
None: No logs, Basic: Basic info, Detailed: Full details
Clear Log (Clearlog) op('glsl_creator').par.Clearlog Pulse

Clears the log.

Default:
None
Convert To Text (Converttotext) op('glsl_creator').par.Converttotext Toggle

Converts the log output to text format.

Default:
0
Reverse Output (Reverse) op('glsl_creator').par.Reverse Toggle

Reverses the order of log messages.

Default:
1
Bypass (Bypass) op('glsl_creator').par.Bypass Toggle

Bypasses the GLSL Creator operator.

Default:
0
Version (Version) op('glsl_creator').par.Version String

The version number of the GLSL Creator operator.

Default:
1.0.0
Last Updated (Lastupdated) op('glsl_creator').par.Lastupdated String

The date the operator was last updated.

Default:
2024-11-09
Creator (Creator) op('glsl_creator').par.Creator String

The creator of the operator.

Default:
dotsimulate
Website (Website) op('glsl_creator').par.Website String

The creator's website.

Default:
https://dotsimulate.com
  • 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.
# Set up shader generation
op('glsl_creator').par.Shaderprompt = "create a swirling nebula effect"
op('glsl_creator').par.Maxtokens = 2000
op('glsl_creator').par.Autoapply = 1
# Generate shader
op('glsl_creator').par.Generateshader.pulse()
# Check for errors
if op('glsl_creator').par.Operror:
# Try to fix the shader
op('glsl_creator').par.Improvenote = "fix compilation errors"
op('glsl_creator').par.Improveshader.pulse()
# Load existing shader
op('glsl_creator').par.Loadversion = "version_1740466694"
op('glsl_creator').par.Loadshader.pulse()
# Set up improvement
op('glsl_creator').par.Improvenote = "add more vibrant colors"
op('glsl_creator').par.Differencelevel = 0.5
op('glsl_creator').par.Improveshaderimage = 1
# Improve shader
op('glsl_creator').par.Improveshader.pulse()
# Enable input textures
op('glsl_creator').par.Useinput0 = 1
op('glsl_creator').par.Useinput1 = 1
# Connect input TOPs
op('glsl_creator').inputConnectors[0].connect(op('texture1'))
op('glsl_creator').inputConnectors[1].connect(op('texture2'))
# Update shader prompt to use inputs
op('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
"""
# Set up vector uniform
op('glsl_creator').par.Vec0name = "gridDensity"
op('glsl_creator').par.Vec0valuex = 10
op('glsl_creator').par.Vec0valuey = 10
# Sync vector parameters
op('glsl_creator').par.Vecsync.pulse()
# Save shader with uniforms
op('glsl_creator').par.Saveshader.pulse()
  • 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