shader-programming-glsl
Helps write efficient GLSL shaders for games and the web. Explains syntax and common effects to create amazing visuals.
What it does
This guide teaches how to create visual effects for games and websites using a special language called GLSL. It shows how to make graphics look good and run fast.
When to use it
- ✓Creating custom visual effects in games or websites.
- ✓Optimizing how fast graphics appear on screen.
- ✓Adding effects like blur or glow to images.
Example of what to ask your AI
“How do I create a glowing effect on a 3D object using GLSL?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
GLSL is used to give direct instructions to the graphics card (GPU). It has two main parts: one that defines the shape (vertex shader) and another that defines the color of each tiny dot on the screen (fragment shader).
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill shader-programming-glslOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/shader-programming-glsl/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from 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.
FAQ
What are 'uniforms' and 'varyings'?
'Uniforms' are pieces of information that don't change for all objects, like the overall color. 'Varyings' are pieces of information that change from one point to another, like texture details.
Why shouldn't I use 'if' statements inside shaders?
Using 'if' can slow down the graphics card because it processes many things at once. It's better to use other functions that are faster for the GPU.
My shader compiles, but the screen is black. What could be wrong?
Check if the coordinates are correct and if the information you're sending to the shader (uniforms) is being set up properly by the main program.
Details
Original description by the author
Expert guide for writing efficient GLSL shaders (Vertex/Fragment) for web and game engines, covering syntax, uniforms, and common effects.
Popularity
- GitHub stars
- 48k
- Ranking position
- #4155
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
benchmark-optimization-loop
Has your agent improve something's speed in a measured way. It tests multiple versions and chooses the fastest one that still works correctly.
affaan-m/ECC
change-impact
Helps your agent analyze the impact of code changes before making them. It compares the planned vs. actual results afterward, covering paths, data, tests, and documentation. Useful for risky or system-wide changes.
affaan-m/ECC
click-path-audit
Lets your agent trace all user buttons and interactions to find bugs. It finds issues where functions seem to work alone but fail together. Useful when bugs persist even after debugging.
affaan-m/ECC