This tutorial introduces MATs (Materials) in TouchDesigner. MATs are an operator family that applies shaders to SOPs (3D geometry objects) for rendering textured surfaces with lighting. Materials are an essential part of any real-time 3D workflow.
Setting Up the Basic Render Pipeline
Before working with materials, you need to set up a basic render pipeline:
- Open the OP Create dialog and add a Camera Component from the Components section
- Add a Rectangle SOP (or other geometry) from Surface Operators
- Right-click on the Rectangle output and add a Geometry Component
- Add a Render TOP to your network
- Drag your Geometry Component onto the Render TOP to set it as the geometry to render
Constant Material
The Constant Material is the simplest material type - it has no lighting model attached to it.
Characteristics
- Whatever color you assign in the Constant Material is exactly what you get in the render
- No shading or lighting effects are applied
- The geometry appears as one flat color
Use Cases
Constant materials are especially useful for:
- Texture mapping - When you want to apply an image directly to geometry without lighting influence
- Projection mapping pipelines - Where you need exact color reproduction
Applying Textures with Constant Material
To apply a texture:
- Add a Movie File In TOP and load your image
- Use a Fit TOP to match the aspect ratio of your geometry (set to “Fit Outside”)
- Add a Null TOP at the end of your texture chain
- Set the Constant Material color to white (so the texture isn’t tinted)
- Connect the Null TOP to the Color Map parameter of the Constant Material
The render will now display exactly what’s in your texture, making this perfect for projection mapping and direct texture application.
Phong Material
The Phong Material includes a lighting model, allowing for realistic shading based on light sources.
Setup Requirements
To use Phong materials effectively:
- Add a Light Component to your network
- Set the Light in your Render TOP’s light parameter
- Apply the Phong Material to your geometry
Lighting Interaction
- Moving the light position (e.g., from positive 10 to negative 10 on an axis) will change how the geometry is shaded
- The material responds to light direction and intensity
Rim Light Parameters
Phong materials include rim light controls:
- Enable Rim Light - Toggle rim lighting on/off
- Rim Color - Specify the color of the rim light effect
- Center - Control where the rim light is centered
- Width - Adjust the width of the rim light effect
These parameters provide additional control over how lighting is applied beyond the basic settings on the first page.
Line Material
The Line Material is a relatively new and powerful material type in TouchDesigner, offering unique visualization capabilities.
Distance-Based Coloring
The Line Material uses a distance function for coloring:
- Near Range/Far Range - Define the distance falloff
- Near Color - Color applied to geometry closer to the camera (e.g., bright orange)
- Far Color - Color applied to geometry farther from the camera (e.g., dark blue)
This creates a gradient effect based on distance from the camera.
Drawing Modes
The Line Material supports multiple drawing modes:
Lines
- Default mode for drawing wireframe-style lines
- Useful for technical visualizations
Points
- Turn off lines and enable points
- Adjust point size for different effects
- Excellent technique for point cloud visualization
Vectors
- Draw vectors based on geometry attributes
- By default, uses the N attribute (normal attribute)
- Displays the direction of surface normals
- Also supports near/far color distance functions
Applications
Line materials are incredibly powerful for:
- Point cloud rendering
- Technical visualizations
- Normal debugging
- Stylized rendering effects
Key Takeaways
- MATs are Material Operators - They apply shaders to 3D geometry for rendering with textures and lighting
- Constant Material - No lighting model, perfect for projection mapping and direct texture application
- Phong Material - Includes lighting model with rim light controls for realistic shading
- Line Material - Versatile material for lines, points, and vectors with distance-based coloring
- Render Pipeline - Always need Camera, Geometry Component, and Render TOP to see materials in action
- Color Map - Use the Color Map parameter to apply textures to materials
Understanding these three material types provides a solid foundation for texturing and shading 3D geometry in TouchDesigner.
本教程介绍TouchDesigner中的MATs(材质)。MATs是一个操作符家族,用于将着色器应用到SOPs(3D几何体对象)上,以渲染带有光照的纹理表面。材质是任何实时3D工作流程的重要组成部分。
设置基本渲染管线
在使用材质之前,您需要设置基本的渲染管线:
- 打开OP创建对话框,从组件部分添加一个Camera Component(摄像机组件)
- 从Surface Operators添加一个Rectangle SOP(矩形SOP)(或其他几何体)
- 右键点击Rectangle输出并添加一个Geometry Component(几何体组件)
- 向网络中添加一个Render TOP
- 将Geometry Component拖到Render TOP上,将其设置为要渲染的几何体
Constant材质
**Constant Material(常量材质)**是最简单的材质类型 - 它没有附加光照模型。
特性
- 您在Constant Material中分配的任何颜色都会精确地呈现在渲染中
- 不应用任何着色或光照效果
- 几何体显示为单一平面颜色
使用场景
Constant材质特别适用于:
- 纹理贴图 - 当您想要将图像直接应用到几何体而不受光照影响时
- 投影映射管线 - 需要精确颜色再现的场景
使用Constant材质应用纹理
要应用纹理:
- 添加一个Movie File In TOP并加载您的图像
- 使用Fit TOP匹配几何体的宽高比(设置为”Fit Outside”)
- 在纹理链末端添加一个Null TOP
- 将Constant Material颜色设置为白色(这样纹理不会被着色)
- 将Null TOP连接到Constant Material的Color Map参数
渲染现在将精确显示纹理中的内容,这使其非常适合投影映射和直接纹理应用。
Phong材质
**Phong Material(Phong材质)**包含光照模型,允许基于光源进行逼真的着色。
设置要求
要有效使用Phong材质:
- 向网络中添加一个Light Component(灯光组件)
- 在Render TOP的light参数中设置灯光
- 将Phong Material应用到您的几何体
光照交互
- 移动灯光位置(例如,在某个轴上从正10移动到负10)将改变几何体的着色方式
- 材质会响应光照方向和强度
边缘光参数
Phong材质包含边缘光控制:
- Enable Rim Light(启用边缘光) - 开启/关闭边缘光
- Rim Color(边缘光颜色) - 指定边缘光效果的颜色
- Center(中心) - 控制边缘光的中心位置
- Width(宽度) - 调整边缘光效果的宽度
这些参数提供了超越第一页基本设置的额外光照控制。
Line材质
**Line Material(线条材质)**是TouchDesigner中相对较新且功能强大的材质类型,提供独特的可视化功能。
基于距离的着色
Line Material使用距离函数进行着色:
- Near Range/Far Range(近距离/远距离范围) - 定义距离衰减
- Near Color(近距离颜色) - 应用于靠近摄像机的几何体的颜色(例如,明亮的橙色)
- Far Color(远距离颜色) - 应用于远离摄像机的几何体的颜色(例如,深蓝色)
这会根据与摄像机的距离创建渐变效果。
绘制模式
Line Material支持多种绘制模式:
线条
- 绘制线框样式线条的默认模式
- 适用于技术可视化
点
- 关闭线条并启用点
- 调整点大小以获得不同效果
- 点云可视化的绝佳技术
向量
- 基于几何体属性绘制向量
- 默认使用N属性(法线属性)
- 显示表面法线的方向
- 也支持近/远颜色距离函数
应用场景
Line材质非常适合:
- 点云渲染
- 技术可视化
- 法线调试
- 风格化渲染效果
关键要点
- MATs是材质操作符 - 它们将着色器应用到3D几何体上,用于带有纹理和光照的渲染
- Constant Material - 无光照模型,非常适合投影映射和直接纹理应用
- Phong Material - 包含带有边缘光控制的光照模型,用于逼真着色
- Line Material - 用于线条、点和向量的多功能材质,具有基于距离的着色
- 渲染管线 - 始终需要Camera、Geometry Component和Render TOP才能看到材质效果
- Color Map - 使用Color Map参数将纹理应用到材质
理解这三种材质类型为在TouchDesigner中对3D几何体进行纹理和着色提供了坚实的基础。