#define TD_SHADER_VERT / #define SHADER_FRAG etc

I think it would be nice to able to write vertex/geo/fragment shader code all in one DAT and let the TouchDesigner GLSL compiler insert define statements to figure out what to use. For example, suppose TouchDesigner prepended whatever your vertex shader code is with #define TD_SHADER_VERT and your fragment shader code with #define TD_SHADER_FRAG. Then this could be your single DAT that you put on both the vertex shader and fragment shader.

#if TD_SHADER_VERT void main() { gl_Position = TDWorldToProj(TDDeform(P)); } #endif #if TD_SHADER_FRAG out vec4 fragColor; void main() { fragColor = vec4(1, 0, 0, 1); } #endif

Keeping code in one file has advantages (git depending on your perspective; refactoring), but no one would be forced to write code that uses these define statements.

be still my heart

+1

+1

+1 would use, would recommend to friends

+1

In the meantime, attached is my method of editing as a single DAT. I think this is the functionality we’re asking for?
vertexFrag_singleDAT.toe (4.17 KB)

TD_VERTEX_SHADER, TD_GEOMETRY_SHADER and TD_PIXEL_SHADER will be available in the 2018.40000 series of builds.
Thanks for the suggestion.

Curious to see how that works? The only place I see it in the wiki is in the release notes.
“GLSL TOP, GLSL MAT - Added TD_VERTEX_SHADER, TD_GEOMETRY_SHADER, TD_PIXEL_SHADER. TD_COMPUTE_SHADER defines.”

Thanks!

I’ll document it today for the next build, but basically when compiling a shader one of those #define will be set, depending on what is compiling. So you can #ifdef and #ifndef code that should or shouldn’t be compiled for that shader stage.

+1, great to see this added!

Somehow missed that reply, I see, thanks!