shader-programming-glsl
하는 일
이 가이드는 GLSL이라는 특별한 언어로 게임과 웹사이트의 시각 효과를 만드는 방법을 가르칩니다. 그래픽이 보기 좋고 빠르게 실행되도록 만드는 방법을 보여 줍니다.
사용하는 경우
- ✓게임이나 웹사이트에 맞춤 시각 효과를 만들 때.
- ✓화면에 그래픽이 나타나는 속도를 최적화할 때.
- ✓이미지에 블러나 글로우 같은 효과를 추가할 때.
스킬 링크
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/shader-programming-glsl/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“GLSL을 사용해서 3D 객체에 빛나는 효과를 어떻게 만드나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
GLSL은 그래픽 카드(GPU)에 직접 지시를 내리는 데 사용됩니다. 두 가지 주요 부분이 있습니다. 하나는 모양을 정의하는 버텍스 셰이더이고, 다른 하나는 화면의 작은 점 하나하나의 색을 정의하는 프래그먼트 셰이더입니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Shader Programming GLSL
Overview
A comprehensive guide to writing GPU shaders using GLSL (OpenGL Shading Language). Learn syntax, uniforms, varying variables, and key mathematical concepts like swizzling and vector operations for visual effects.
When to Use This Skill
- Use when creating custom visual effects in WebGL, Three.js, or game engines.
- Use when optimizing graphics rendering performance.
- Use when implementing post-processing effects (blur, bloom, color correction).
- Use when procedurally generating textures or geometry on the GPU.
Step-by-Step Guide
1. Structure: Vertex vs. Fragment
Understand the pipeline:
- Vertex Shader: Transforms 3D coordinates to 2D screen space (
gl_Position). - Fragment Shader: Colors individual pixels (
gl_FragColor).
// Vertex Shader (basic)
attribute vec3 position;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
// Fragment Shader (basic)
uniform vec3 color;
void main() {
gl_FragColor = vec4(color, 1.0);
}
2. Uniforms and Varyings
uniform: Data constant for all vertices/fragments (passed from CPU).varying: Data interpolated from vertex to fragment shader.
// Passing UV coordinates
varying vec2 vUv;
// In Vertex Shader
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
// In Fragment Shader
void main() {
// Gradient based on UV
gl_FragColor = vec4(vUv.x, vUv.y, 1.0, 1.0);
}
3. Swizzling & Vector Math
Access vector components freely: vec4 color = vec4(1.0, 0.5, 0.0, 1.0);
color.rgb->vec3(1.0, 0.5, 0.0)color.zyx->vec3(0.0, 0.5, 1.0)(reordering)
Examples
Example 1: Simple Raymarching (SDF Sphere)
float sdSphere(vec3 p, float s) {
return length(p) - s;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec3 ro = vec3(0.0, 0.0, -3.0); // Ray Origin
vec3 rd = normalize(vec3(uv, 1.0)); // Ray Direction
float t = 0.0;
for(int i = 0; i < 64; i++) {
vec3 p = ro + rd * t;
float d = sdSphere(p, 1.0); // Sphere radius 1.0
if(d < 0.001) break;
t += d;
}
vec3 col = vec3(0.0);
if(t < 10.0) {
vec3 p = ro + rd * t;
vec3 normal = normalize(p);
col = normal * 0.5 + 0.5; // Color by normal
}
fragColor = vec4(col, 1.0);
}
Best Practices
- ✅ Do: Use
mix()for linear interpolation instead of manual math. - ✅ Do: Use
step()andsmoothstep()for thresholding and soft edges (avoidifbranches). - ✅ Do: Pack data into vectors (
vec4) to minimize memory access. - ❌ Don't: Use heavy branching (
if-else) inside loops if possible; it hurts GPU parallelism. - ❌ Don't: Calculate constant values inside the shader; pre-calculate them on the CPU (uniforms).
Troubleshooting
Problem: Shader compiles but screen is black.
Solution: Check if gl_Position.w is correct (usually 1.0). Check if uniforms are actually being set from the host application. Verify UV coordinates are within [0, 1].
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
자주 묻는 질문
「uniforms」와 「varyings」란 무엇인가요?
「uniforms」는 모든 객체에 대해 변하지 않는 정보로, 예를 들어 전체 색상 같은 것입니다. 「varyings」는 한 지점에서 다른 지점으로 변하는 정보로, 예를 들어 질감의 세부 사항 같은 것입니다.
셰이더 안에서 「if」 문을 쓰지 말아야 하는 이유는 무엇인가요?
「if」를 쓰면 그래픽 카드가 많은 것을 동시에 처리하는 방식 때문에 느려질 수 있습니다. 대신 GPU에 더 빠른 다른 함수를 사용하는 것이 좋습니다.
셰이더는 컴파일되는데 화면이 검게 나옵니다. 무엇이 잘못되었을까요?
좌표가 맞는지 확인하고, 셰이더로 보내는 정보(유니폼)가 메인 프로그램에서 제대로 설정되고 있는지 확인해 보세요.
상세 정보
작성자의 원본 설명
Expert guide for writing efficient GLSL shaders (Vertex/Fragment) for web and game engines, covering syntax, uniforms, and common effects.
인기도
- GitHub 스타
- 48k
- 순위
- #5769
- 라이선스
- MIT
- 업데이트
- 2026. 10. 15.
댓글
- …
이 저장소의 다른 스킬
00-andruia-consultant
48k에이전트가 AI 프로젝트를 시작하거나 개선할 수 있도록 코드를 분석하고 스페인어로 실행 계획을 세워 줍니다.
007
48k에이전트가 보안 감사와 위협 모델링을 수행해 공격과 취약점으로부터 프로젝트를 보호하도록 돕습니다.
10-andruia-skill-smith
48k에이전트가 AI 도구의 작동 방식을 정의하고 문서를 쓰며 구조를 검증하도록 돕습니다.
20-andruia-niche-intelligence
48k에이전트가 신뢰할 수 있는 자료를 바탕으로 특정 산업의 맥락, 규칙, 사용 패턴, 위험을 정리한 요약을 만들도록 돕습니다.