As immersive designers and TouchDesigner developers, it’s important to always be looking for ways to streamline our workflow and improve our skills. In our last ChatGPT post, we explored some of the ways that ChatGPT, a programming helper and learning tool, can be useful for those working in these fields. In this post, we’ll delve even deeper and look at even more examples of how ChatGPT can help immersive designers and TouchDesigner developers.
Regex: Simplifying the Convoluted and Cryptic
I don’t think I’ve met anyone who enjoys building regex expressions. They’re often convoluted, cryptic, and unintuitive, making them a daunting task for many of us. That’s where ChatGPT comes in. ChatGPT can help you generate regex expressions using Python, making the process a lot easier and more intuitive.
But ChatGPT’s usefulness doesn’t stop there. It can also help explain regex expressions that you find in other people’s code, breaking down the often confusing syntax and making it easier to understand. This can be especially useful when working on a team or using pre-built tools, as it allows you to more easily understand and modify code written by others.
Let’s take a look at two examples. First, let’s get ChatGPT to explain an expression. I found this one randomly online:
re.sub(r'\d+', '', my_str)
What it do?? Well let’s ask ChatGPT without giving it any further context other than asking for an explanation:
This is fantastic. Not only does it give us a detailed explanation of how the expression is built, what it does, and even gives us an example of how it would work on a string!
What about generating a regex expression that removes all special characters from a string? I’ll ask ChatGPT:
Honestly, I’ve learned more about regex writing this post than I have in my whole career up to now!
GLSL: Streamlining Custom Node and Module Development
GLSL is an extremely powerful language for building custom nodes and modules for yourself in TouchDesigner and Unreal Engine. However, it can be hard to approach if you’ve never coded before, as it requires a working knowledge of C. This can be a significant barrier to entry for those new to coding, but ChatGPT can help.
ChatGPT is very capable of generating boilerplate code in GLSL, making it easier to get started with custom node and module development. It can also help fill in tricky gaps or explain how to approach specific problems in the context of GLSL, making it a valuable resource for both experienced and new developers.
Let’s take a look at a few examples. Let’s start by asking ChatGPT how to do a common action that can be a little bit tricky for new developers, which is doing an over composite with alpha:
This response is great because firstly it explains how you would approach this in steps and breaks down the formula for you. After that it explains the main formula and follows up with a generic GLSL fragment shader (pixel shader). So you could just take the formula and paste that into your code and fill in the variables, or you could even reference the longer example.
Get Our 7 Core TouchDesigner Templates, FREE
We’re making our 7 core project file templates available – for free.
These templates shed light into the most useful and sometimes obtuse features of TouchDesigner.
They’re designed to be immediately applicable for the complete TouchDesigner beginner, while also providing inspiration for the advanced user.
Reading Code: Making Sense of Long Extensions and Pieces of Code
There are many times in our careers as immersive designers and developers where we’ll be brought onto a project or working with pre-built tools that are full of long extensions or pieces of code that can be tough to wrap our heads around. In these situations, ChatGPT can be an invaluable resource.
By taking Python code and explaining it in plain English, ChatGPT makes it much easier to understand what the code is doing and how it fits into the overall project. This can save a significant amount of time and frustration, and can help accelerate our progress as we work on new projects.
Here’s a few fun examples I encountered recently and had to figure out without ChatGPT. First is I saw this code in a GLSL shader and had no idea what it was for. I can copy and paste that function into ChatGPT and it explains is a signed distance function (SDF) that basically calculates if something is inside a range or outside of a range (basically is something inside this box or not):
Let me tell you, that’s a lot easier and faster than what I had to go through to figure out what was going on. How about a Python example?
A recent project I was working on had a lot of dictionaries and dictionary manipulation happening that was dense on first read. So I can toss one of these functions into ChatGPT and see what it does:
Brilliaaaannnnttttt! This would have taken me a while to sit down and work through myself. Not only does ChatGPT explain whats going on and the concepts, but it also shows me a quick example of how it would work. What more could I ask for?
As we’ve seen, ChatGPT is an immensely powerful tool for both experienced and new immersive designers and developers. From code completion to code explanations, it has the potential to significantly streamline our workflow and accelerate our careers. Whether you’re just starting out or have been working in these fields for years, ChatGPT is worth exploring and incorporating into your toolkit.