GLSL MAT
Summary
The GLSL MAT allows you to write or import custom materials into TouchDesigner. When there are compile errors in a GLSL shader, a blue/red checkerboard error shader will be displayed.
For more information on writing a shader, see Write a GLSL Material, and the GLSL Category.
Parameters - Load Page
glslversion
- ⊞ - Pick what version of GLSL to compile the shader with.
- 1.20
glsl120
-
- 3.30
glsl330
-
- 4.00
glsl400
-
- 4.10
glsl410
-
- 4.20
glsl420
-
- 4.30
glsl430
-
- 4.40
glsl440
-
- 4.50
glsl450
-
- 4.60
glsl460
-
predat
- Use this DAT to place preprocessor directives at the start of your shader, such as #extension. This is required since these need to be the first lines in the shader, and TouchDesigner will be adding code to the start of your shader to declare uniforms/functions which would appear before #extension directives located in the main shader.
vdat
- Path to the DAT that holds the vertex shader code.
pdat
- Path to the DAT that holds the pixel shader code.
loaduniformnames
- This will read all the declared (and used) uniforms in the compiled GLSL shader, and fill in the various name fields for the uniform parameters.
clearuniformnames
- This will clear all of the name fields for the uniform parameters.
gdat
- Path to the DAT that holds the geometry shader code.
inherit
- This Material will inherit all of the Textures and Uniforms from the GLSL Material referenced in this parameter.
lightingspace
- ⊞ - Allows lighting space switch from the current default World Space to legacy Camera Space which was used for TouchDesigner 088.
- World Space
worldspace
-
- Camera Space (Legacy 088 shaders)
cameraspace
-
inprim
- ⊞ - The type of geometry that will be inputed into the Geometry Shader.
- Points
points
-
- Lines
lines
-
- Triangles
triangles
-
outprim
- ⊞ - The type of geometry that the Geometry Shader will output.
- Points
points
-
- Line Strip
linestrip
-
- Triangle Strip
tristrip
-
numout
- The maximum number of vertices the Geometry Shader will output.
twocolor
- Enables support for two-sided coloring. When this is enabled the Vertex and/or Geometry shader can write to gl_FrontColor, gl_BackColor, gl_FrontSecondaryColor and gl_BackSecondaryColor and the correct color will be placed into gl_Color and gl_SecondaryColor in the Pixel shader depending on if the primitive's front face or back face is facing the camera. When this is disabled the values placed into gl_FrontColor and gl_FrontSecondaryColor are passed to gl_Color and gl_SecondaryColor regardless of which side of the primitive is facing the camera.
Parameters - Attributes Page
attr
- A sequence of attributes that should be made accesible in the shader. In the past these would be manually declared inside the shader, but to add support for POP based workflows, they need to be setup via these parameters instead. You can access the shaders using TDAttrib_<attribName>()
.
attr0name
- The name to give the attribute.
attr0type
- ⊞ - The type, both vector size as well as if it's a float, double (d), integer (i), or unsigned integer (u).
- float
float
-
- vec2
vec2
-
- vec3
vec3
-
- vec4
vec4
-
- double
double
-
- dvec2
dvec2
-
- dvec3
dvec3
-
- dvec4
dvec4
-
- int
int
-
- ivec2
ivec2
-
- ivec3
ivec3
-
- ivec4
ivec4
-
- uint
uint
-
- uvec2
uvec2
-
- uvec3
uvec3
-
- uvec4
uvec4
-
attr0size
- The size of the array. Currently a Size == 1 means it's not an array.
Parameters - Samplers Page
sampler
- Sequence of samplers for use in the shader
sampler0name
- This is the sampler name that the GLSL program will use to sample from this TOP. The samplers need to be declared at the same dimentions as the TOP (sampler2D for a 2D TOP, sampler3D for 3D TOP).
sampler0top
- ⊞ - This is the TOP that will be referenced by the above sampler name above it.
Exposed by the + Button, texture sampling parameters:
Refer to the Texture Sampling Parameters article for more information on the parameters exposed by pressing the + button. The parameter prefix for each of the parameters is top[digit].
sampler0extendu
- ⊞ -
- Hold
hold
-
- Zero
zero
-
- Repeat
repeat
-
- Mirror
mirror
-
sampler0extendv
- ⊞ -
- Hold
hold
-
- Zero
zero
-
- Repeat
repeat
-
- Mirror
mirror
-
sampler0extendw
- ⊞ -
- Hold
hold
-
- Zero
zero
-
- Repeat
repeat
-
- Mirror
mirror
-
sampler0filter
- ⊞ -
- Nearest
nearest
-
- Linear
linear
-
- Mipmap Linear
mipmaplinear
-
sampler0anisotropy
- ⊞ -
- Off
off
-
- 2x
2x
-
- 4x
4x
-
- 8x
8x
-
- 16x
16x
-
Parameters - Vectors Page
vec
- Sequence of vectors to be used as uniforms
vec0name
- The name of the vector.
vec0value
- ⊞ - The value to assign to the uniform. If the uniform is a float the first entry of the four is used, if the uniform is a vec2 the first two entries are used, etc.
- Value
vec0valuex
-
- Value
vec0valuey
-
- Value
vec0valuez
-
- Value
vec0valuew
-
Parameters - Arrays Page
CHOP Uniforms allow you to send CHOP channel data into a GLSL shader as an array. Depending on the array type used, the number of values you can send into the shader may be limited. If you are using Uniform Arrays, you can use the Built-In variable $SYS_GFX_GLSL_MAX_UNIFORMS to get an idea of how many values you can pass to the shader. Current GPUs are vec4 based for uniform arrays, so the maximum array size is $SYS_GFX_GLSL_MAX_UNIFORMS / 4. Other uniforms will take away from this maximum. If you are using Texture Buffers the maximum array size is far bigger, $SYS_GFX_MAX_TEXTURE_BUFFER_SIZE will tell you the max for this. The max for texture buffer is per texture buffer, and having multiple texture buffers does not take away from the max for each array.
array
- Sequence of arrays to be used as uniforms
array
- Sequence of arrays to be used as uniforms
Parameters - Matrices Page
Relative Xforms are matrices that will transform points and vectors from one space to another space.
matrix
- Sequence of matrices to be used as uniforms
matrix0name
- The name of the uniform. The uniform should be declared as a mat4.
matrix0value
- The value to assign the matrix. For valid ways to specify this, see the Matrix Parameters article.
rel
- A sequence of relative transforms. The transform is the relative transform one Object COMP to another.
rel0name
- The name of the uniform. The uniform should be declared as a mat4.
rel0from
- Transform from this COMPs world transform.
rel0to
- Transform to this COMPs world transform.
Parameters - Constants Page
Specialization Constants can optionally have their values assigned here.
const
- Sequence of constant uniforms.
const0name
- The constant name, as declared in the shader.
const0value
- The value to give the constant.
Parameters - Deform Page
Refer to the Deform Article for more information on doing deforms in TouchDesigner.
dodeform
- Enables deforms on this material.
deformdata
- ⊞ - Specifies where the deform bone data will be obtained.
- From a SOP
sop
-
- From another MAT
mat
-
- From a DeformIn MAT
deformin
-
targetsop
- Specifies the SOP that contains the deform capture attributes.
pcaptpath
- Specifies the name of the pCaptPath attribute to use. When your geometry has been put through a Bone Group SOP, the attributes will be split into names like pCaptPath0, pCaptPath1. You can only render 1 bone group at a time, so this should match the group you are rendering with this material.
pcaptdata
- Much like pCaptPath Attrib.
skelrootpath
- Specifies the path to the COMP where the root of the skeleton is located.
mat
- When obtaining deform data from a MAT or a Deform In MAT, this is where that MAT is specified.
Parameters - Common Page
Blending
Blending is summing the color value of the pixel being drawn and the pixel currently present in the Color-Buffer. Blending is typically used to simulate Transparency.
The blending equation is:
Final Pixel Value = (Source Blend * Source Color) + (Dest Blend * Destination Color)
blending
- This toggle enables and disables blending. However see the wiki article Transparency.
blendop
- ⊞ -
- Add
add
-
- Subtract
subtract
-
- Reverse Subtract
revsubtract
-
- Minimum
minimum
-
- Maximum
maximum
-
srcblend
- ⊞ - This value is multiplied by the color value of the pixel that is being written to the Color-Buffer (also know as the Source Color).
- Zero
zero
-
- Dest Color
dcol
-
- One Minus Dest Color
omdcol
-
- Source Alpha
sa
-
- One Minus Source Alpha
omsa
-
- Dest Alpha
da
-
- One Minus Dest Alpha
omda
-
- Source Alpha Saturate
sas
-
- One
one
-
- Constant Color
constantcol
-
- One Minus Constant Color
omconstantcol
-
- Constant Alpha
constanta
-
- One Minus Constant Alpha
omconstanta
-
destblend
- ⊞ - This value is multiplied by the color value of the pixel currently in the Color-Buffer (also known as the Destination Color).
- One
one
-
- Src Color
scol
-
- One Minus Src Color
omscol
-
- Source Alpha
sa
-
- One Minus Source Alpha
omsa
-
- Dest Alpha
da
-
- One Minus Dest Alpha
omda
-
- Zero
zero
-
- Dest Color
dcol
-
- One Minus Dest Color
omdcol
-
- Source Alpha Saturate
sas
-
- Constant Color
constantcol
-
- One Minus Constant Color
omconstantcol
-
- Constant Alpha
constanta
-
- One Minus Constant Alpha
omconstanta
-
separatealphafunc
- This toggle enables and disables separate blending options for the alpha values.
blendopa
- ⊞ -
- Add
add
-
- Subtract
subtract
-
- Reverse Subtract
revsubtract
-
- Minimum
minimum
-
- Maximum
maximum
-
srcblenda
- ⊞ - This value is multiplied by the alpha value of the pixel that is being written to the Color-Buffer (also know as the Source Alpha).
- Zero
zero
-
- Dest Color
dcol
-
- One Minus Dest Color
omdcol
-
- Source Alpha
sa
-
- One Minus Source Alpha
omsa
-
- Dest Alpha
da
-
- One Minus Dest Alpha
omda
-
- Source Alpha Saturate
sas
-
- One
one
-
- Constant Color
constantcol
-
- One Minus Constant Color
omconstantcol
-
- Constant Alpha
constanta
-
- One Minus Constant Alpha
omconstanta
-
destblenda
- ⊞ - This value is multiplied by the alpha value of the pixel currently in the Color-Buffer (also known as the Destination Alpha).
- One
one
-
- Src Color
scol
-
- One Minus Src Color
omscol
-
- Source Alpha
sa
-
- One Minus Source Alpha
omsa
-
- Dest Alpha
da
-
- One Minus Dest Alpha
omda
-
- Zero
zero
-
- Dest Color
dcol
-
- One Minus Dest Color
omdcol
-
- Source Alpha Saturate
sas
-
- Constant Color
constantcol
-
- One Minus Constant Color
omconstantcol
-
- Constant Alpha
constanta
-
- One Minus Constant Alpha
omconstanta
-
blendconstant
- ⊞ -
- Blend Constant Color
blendconstantr
-
- Blend Constant Color
blendconstantg
-
- Blend Constant Color
blendconstantb
-
blendconstanta
-
legacyalphabehavior
-
postmultalpha
- Multiplies the color by alpha after all other operations have taken place.
pointcolorpremult
- ⊞ -
- Already Pre-Multiplied By Alpha
alreadypremult
-
- Pre-Multiply By Alpha in Shader
premultinshader
-
depthtest
- Enables and disables the Depth-Test. If the depth-test is disabled, depths values aren't written to the Depth-Buffer.
depthfunc
- ⊞ - The depth value of the pixel being drawn is compared to the depth value currently in the depth-buffer using this function. If the test passes then the pixel is drawn to the Frame-Buffer. If the test fails the pixel is discarded and no changes are made to the Frame-Buffer.
- Less Than
less
-
- Less Than or Equal
lessorequal
-
- Equal
equal
-
- Greater Than
greater
-
- Greater Than or Equal
greaterorequal
-
- Not Equal
notequal
-
- Always
always
-
Depth Test
Depth-Testing is comparing the depth value of the pixel being drawn with the pixel currently in the Frame-Buffer. A pixel that is determined to be in-front of the pixel currently in the Frame-Buffer will be drawn over it. Pixels that are determined to be behind the pixel currently in the Frame-Buffer will not be drawn. Depth-Testing allows geometry in a 3D scene to occlude geometry behind it, and be occluded by geometry in-front of it regardless of the order the geometry was drawn.
For a more detailed description of Depth-Testing, refer to the Depth-Test article.
depthwriting
- If Write Depth Values is on, pixels that pass the depth-test will write their depth value to the Depth-Buffer. If this isn't on then no changes will be made to the Depth-Buffer, regardless of if the pixels drawn pass or fail the depth-test.
alphatest
- This enables or disables the pixel alpha test.
alphafunc
- ⊞ - This menu works in conjunction with the Alpha Threshold parameter below in determining which pixels to keep based on their alpha value.
- Less Than
less
-
- Less Than or Equal
lessorequal
-
- Greater Than
greater
-
- Greater Than or Equal
greaterorequal
-
alphathreshold
- This value is what the pixel's alpha is compared to to determine if the pixel should be drawn. Pixels with alpha greater than the Alpha Threshold will be drawn. Pixels with alpha less than or equal to the Alpha Threshold will not be drawn.
wireframe
- ⊞ - Enables and disables wire-frame rendering with the option of OpenGL Tesselated or Topology based wireframes.
- Off
off
-
- OpenGL Tesselated Wire Frame
tesselated
-
- Topology Wire Frame
topology
-
Alpha Test
Alpha-testing allows you to choose to draw or not draw a pixel based on its alpha value.
wirewidth
- This value is the width that the wires will be. This value is in pixels.
cullface
- ⊞ - Selects which faces to render.
- Use Render Setting
userender
- Use the render settings found in the Render or Render Pass TOP.
- Neither
neither
- Do not cull any faces, render everything.
- Back Faces
backfaces
- Cull back faces, render front faces.
- Front Faces
frontfaces
- Cull front faces, render back faces.
- Both Faces
bothfaces
- Cull both faces, render nothing.
polygonoffset
- Turns on the polygon offset feature.
polygonoffsetfactor
-
polygonoffsetunits
-
Wire Frame
The wire-frame feature will render the geometry as wire-frame, using the actual primitive type used in the render. What this means is surfaces like Metaballs, NURBs and Beziers will become a wire-frame of the triangles/triangle-strips used to render them (since these types of primitives can't be natively rendered in OpenGL).
Cull Face
The cull face parameter will cull faces from the render output. This can be used as an optimization or sometimes to remove artifacts. See Back-Face Culling for more infomation.
Polygon Depth Offset
This feature pushes the polygons back into space a tiny fraction. This is useful when you are rendering two polygons directly on-top of each other and are experiencing Z-Fighting. Refer to Polygon Depth Offset for more information. This is also an important feature when doing shadows.
Info CHOP Channels
Extra Information for the GLSL MAT can be accessed via an Info CHOP.
Common MAT Info Channels
Common Operator Info Channels
- total_cooks - Number of times the operator has cooked since the process started.
- cook_time - Duration of the last cook in milliseconds.
- cook_frame - Frame number when this operator was last cooked relative to the component timeline.
- cook_abs_frame - Frame number when this operator was last cooked relative to the absolute time.
- cook_start_time - Time in milliseconds at which the operator started cooking in the frame it was cooked.
- cook_end_time - Time in milliseconds at which the operator finished cooking in the frame it was cooked.
- cooked_this_frame - 1 if operator was cooked this frame.
- warnings - Number of warnings in this operator if any.
- errors - Number of errors in this operator if any.
TouchDesigner Build: