Logo Td Glsl Vertex

Td Glsl Vertex

Cộng đồng
rheadsh
td-glsl-vertex

Write GLSL vertex shaders for TouchDesigner's GLSL MAT operator. Use whenever creating 3D materials, vertex displacement, geometry deformation, mesh animation, instancing effects, custom surface normals, or any shader that needs to manipulate vertex data in 3D space. Also covers the complete vertex + pixel shader pair for GLSL MAT. Trigger when the user mentions GLSL MAT, vertex shader, vertex displacement, mesh deformation, instancing in TouchDesigner, 3D material writing, surface normals in GLSL, or wants to create a custom material for a SOP/geometry node.

Tổng quan

Nhà phát hànhrheadsh
Kho mãaudiovisual-production-skills
Tên kỹ năngtd-glsl-vertex
Sao
45
Bản fork
2
Tệp đi kèm
7
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 7 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được rheadsh công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Td Glsl Vertex trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/rheadsh/audiovisual-production-skills/tree/main/td-glsl-vertex
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/rheadsh/audiovisual-production-skills.git /tmp/audiovisual-production-skills
mkdir -p .claude/skills
cp -r /tmp/audiovisual-production-skills/td-glsl-vertex .claude/skills/td-glsl-vertex
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Td Glsl Vertex trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Td Glsl Vertex ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Td Glsl Vertex với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

TouchDesigner GLSL MAT — Vertex Shader Writing

Write vertex and pixel shaders for TouchDesigner's GLSL MAT operator (not GLSL TOP). GLSL MAT applies to 3D geometry and requires both a vertex shader and a pixel shader in separate DATs.

Quick Start — Minimal GLSL MAT

Vertex Shader DAT (e.g. glsl_vert):

glsl
// Minimum viable vertex shader
out vec3 vWorldPos;   // Custom varying to pixel shader
out vec3 vNormal;

void main() {
    // 1. Deform: applies instancing, skinning → world space
    vec4 worldPos = TDDeform(P);

    // 2. Project: world → clip space
    gl_Position = TDWorldToProj(worldPos);

    // 3. Pass data to pixel shader
    vWorldPos = worldPos.xyz;
    vNormal   = normalize((uTDMats[TDCameraIndex()].worldForNormals * N).xyz);
}

Pixel Shader DAT (e.g. glsl_frag):

glsl
// Input varyings from vertex shader
in vec3 vWorldPos;
in vec3 vNormal;

layout(location = 0) out vec4 fragColor;

void main() {
    vec3 color = vNormal * 0.5 + 0.5;  // Visualize normals
    fragColor = TDOutputSwizzle(vec4(color, 1.0));
}

GLSL MAT Setup:

  • Load Page → Vertex Shader: point to your vertex DAT
  • Load Page → Pixel Shader: point to your pixel DAT

Critical Rules

  1. Never declare the TD-provided vertex attributes — P, N, uv[0], Cd, T — they are auto-injected
  2. Never declare default varyings — vUV, vP, vN, vColor — TD provides these if you don't supply a custom vertex shader
  3. Always call TDDeform(P) before TDWorldToProj() — skipping it breaks instancing and skinning
  4. Always match varyings: every out in the vertex shader needs an in in the pixel shader with the same name and type
  5. No #version directive — TouchDesigner injects it automatically
  6. Pixel shader output uses layout(location = 0) out vec4 fragColor; (with layout qualifier, unlike GLSL TOP)

Auto-Provided Vertex Attributes (DO NOT Declare)

glsl
P       // vec3  — vertex position in object/local space
N       // vec3  — vertex normal in object space
uv[0]   // vec4  — texture coordinate layer 0 (uv[1], uv[2]... for additional layers)
Cd      // vec4  — vertex color (RGBA)
T       // vec4  — tangent vector (for normal mapping)

These are injected by TD at compile time. Declaring them yourself causes errors.


Core Vertex Functions

glsl
// Transform local position → world space (applies instancing + skinning)
vec4 TDDeform(vec3 pos)
vec4 TDDeform(vec4 pos)

// Transform world/view space → clip space (NDC for gl_Position)
vec4 TDWorldToProj(vec4 worldPos)
vec4 TDWorldToProj(vec3 worldPos)

// Per-instance unique ID (use for per-instance variation)
int TDInstanceID()

// Camera index (for multi-camera / stereo rendering)
int TDCameraIndex()

The standard transform chain: gl_Position = TDWorldToProj(TDDeform(P));


Key Uniform Structs

glsl
// Transformation matrices — indexed by camera (use TDCameraIndex())
struct TDMatrix {
    mat4 world;              // Object → world
    mat4 worldCam;           // Object → camera
    mat4 cam;                // World → camera (view matrix)
    mat4 proj;               // Camera → clip (projection)
    mat4 worldCamProj;       // Combined MVP
    mat3 worldForNormals;    // Inverse-transpose for normal transform
    mat3 worldCamForNormals; // Normal matrix in camera space
};
uniform TDMatrix uTDMats[TD_NUM_CAMERAS];

Transform normals correctly:

glsl
// ❌ Wrong — does not handle non-uniform scale
vec3 worldNormal = mat3(uTDMats[0].world) * N;

// ✅ Correct — uses inverse-transpose
vec3 worldNormal = normalize(uTDMats[TDCameraIndex()].worldForNormals * N);

Varyings — Passing Data Vertex → Pixel

Declare out in vertex, matching in in pixel:

glsl
// Vertex shader
out vec2  vTexCoord;   // UV coordinates
out vec3  vWorldNorm;  // World-space normal
out vec4  vVertColor;  // Vertex color passthrough
out float vDisplace;   // Any scalar

// Pixel shader (must match exactly)
in vec2  vTexCoord;
in vec3  vWorldNorm;
in vec4  vVertColor;
in float vDisplace;

The GPU interpolates these values across each triangle — what arrives in the pixel shader is a smooth blend across the surface.

See reference/VARYINGS.md for full patterns.


Instancing

When Render TOP has instancing enabled, each instance gets a unique TDInstanceID(). You can sample per-instance data from a CHOP or texture:

glsl
uniform sampler2D uInstanceData;  // CHOP/texture with per-instance values
uniform int uInstanceCount;

void main() {
    int id = TDInstanceID();

    // Sample per-instance position offset from texture row
    float u = (float(id) + 0.5) / float(uInstanceCount);
    vec4 offset = texture(uInstanceData, vec2(u, 0.5));

    vec4 worldPos = TDDeform(P + offset.xyz);
    gl_Position   = TDWorldToProj(worldPos);
    ...
}

Common Patterns

See reference/VERTEX-API.md for the complete function reference.

Vertex Displacement

glsl
uniform float uDisplaceAmount;
uniform float uTime;

void main() {
    // Displace along local normal
    float noise = TDSimplexNoise(vec3(P * 2.0 + uTime * 0.5));
    vec3 displaced = P + N * noise * uDisplaceAmount;

    gl_Position = TDWorldToProj(TDDeform(displaced));
}

Wave Deformation

glsl
uniform float uFrequency;
uniform float uAmplitude;
uniform float uTime;

void main() {
    vec3 pos = P;
    pos.y += sin(pos.x * uFrequency + uTime) * uAmplitude;
    pos.y += sin(pos.z * uFrequency * 0.7 + uTime * 1.3) * uAmplitude * 0.5;

    gl_Position = TDWorldToProj(TDDeform(pos));
}

Response Format

When writing a GLSL MAT shader, always provide:

  1. Vertex Shader — complete GLSL code with comments
  2. Pixel Shader — complete GLSL code, matching all varyings
  3. TouchDesigner Setup:
    • Load Page: which DAT goes in Vertex Shader / Pixel Shader fields
    • Uniforms: parameter page, name, type, value or expression
    • Render setup notes if instancing or lighting is involved

Common Errors

ErrorCauseFix
'P' : redefinitionDeclared P in shaderRemove your declaration — TD provides it
Black / no geometryForgot TDDeform()Use TDDeform(P) before TDWorldToProj()
Varyings mismatchName/type differs between stagesVerify out ↔ in names and types match exactly
Instancing brokenManual position, no TDDeformAlways route through TDDeform()
Normal flippingWrong normal transformUse worldForNormals matrix, not world
layout errorMissing layout(location=0)Pixel output must be layout(location = 0) out vec4 fragColor;

Additional Resources

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Td Glsl Vertex làm được gì?

Write GLSL vertex shaders for TouchDesigner's GLSL MAT operator. Use whenever creating 3D materials, vertex displacement, geometry deformation, mesh animation, instancing effects, custom surface normals, or any shader that needs to manipulate vertex data in 3D space. Also covers the complete vertex + pixel shader pair for GLSL MAT. Trigger when the user mentions GLSL MAT, vertex shader, vertex displacement, mesh deformation, instancing in TouchDesigner, 3D material writing, surface normals in GLSL, or wants to create a custom material for a SOP/geometry node.

Vì sao nên dùng Td Glsl Vertex trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Td Glsl Vertex là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Td Glsl Vertex trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/rheadsh/audiovisual-production-skills/tree/main/td-glsl-vertex. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Td Glsl Vertex?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Td Glsl Vertex với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Td Glsl Vertex với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Td Glsl Vertex có miễn phí không?

Có. Kỹ năng này được rheadsh phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇