Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when implementing shaders — Godot shader language, visual shaders, common visual recipes, and post-processing effects
.claude/skills/jame581-shader-basics/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 63% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 73% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 14% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 61% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 46% | 0% |
All examples target Godot 4.3+ with no deprecated APIs.
> Related skills: animation-system for shader-driven effects like hit flash, godot-optimization for shader performance considerations, camera-system for post-processing camera effects, 2d-essentials for 2D lighting, pixel-art shaders, and CanvasTexture normal maps, 3d-essentials for spatial shaders and environment materials, particles-vfx for custom particle shaders, tween-animation for animating shader parameters at runtime.
| Shader Type | Applied To | Use For | |------------------|--------------------------|--------------------------------------------------| | canvas_item | 2D nodes (Sprite2D, Control, etc.) | 2D effects — outlines, dissolve, color swap | | spatial | 3D meshes (MeshInstance3D) | 3D materials — water, terrain, toon shading | | particles | GPUParticles2D/3D | Custom particle behavior | | sky | WorldEnvironment | Procedural sky rendering | | fog | FogVolume | Volumetric fog effects |
Shader (.gdshader) → The code (GLSL-like language)
ShaderMaterial → Instance of a shader with specific uniform values
CanvasItemMaterial / StandardMaterial3D → Built-in materials (no code needed)Multiple nodes can share the same Shader but have different ShaderMaterial instances with different uniform values (e.g., same dissolve shader but different dissolve progress per enemy).
.gdshader file in the built-in editorOr create a .gdshader file directly in the FileSystem dock.
Godot uses a GLSL ES 3.0-like language with Godot-specific additions.
glslshader_type canvas_item; void fragment() { // COLOR is the output pixel color // TEXTURE is the sprite's texture // UV is the texture coordinate (0,0 top-left to 1,1 bottom-right) vec4 tex = texture(TEXTURE, UV); COLOR = tex; }
glslshader_type spatial; void fragment() { // ALBEDO is the base color (vec3) ALBEDO = vec3(0.8, 0.2, 0.2); }
| Variable | Type | Description | |------------|--------|---------------------------------------| | UV | vec2 | Texture coordinates | | COLOR | vec4 | Output color (set this in fragment()) | | TEXTURE | sampler2D | The node's texture | | VERTEX | vec2 | Vertex position (in vertex()) | | TIME | float| Elapsed time in seconds | | SCREEN_UV| vec2 | Screen-space UV (for screen effects) |
> SCREEN_TEXTURE was removed in Godot 4.0. To read the screen, declare a uniform: uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
| Variable | Type | Description | |-------------|--------|---------------------------------------| | ALBEDO | vec3 | Base surface color | | METALLIC | float| Metallic value (0.0–1.0) | | ROUGHNESS | float| Roughness value (0.0–1.0) | | NORMAL | vec3 | Surface normal (for normal mapping) | | EMISSION | vec3 | Emissive color | | ALPHA | float| Transparency (enable in render mode) | | VERTEX | vec3 | Vertex position (in vertex()) |
Uniforms expose shader values to the Inspector and code.
glslshader_type canvas_item; uniform float speed : hint_range(0.0, 10.0, 0.1) = 1.0; uniform vec4 tint_color : source_color = vec4(1.0, 1.0, 1.0, 1.0); uniform sampler2D noise_texture : filter_linear_mipmap; void fragment() { vec4 tex = texture(TEXTURE, UV); COLOR = tex * tint_color; }
| Hint | Type | Description | |-----------------------------|--------------|-------------------------------------| | hint_range(min, max, step) | float/int | Slider in Inspector | | source_color | vec4 | Color picker in Inspector | | filter_linear_mipmap | sampler2D | Texture filtering mode | | repeat_enable | sampler2D | Allow texture tiling | | hint_normal | sampler2D | Treat as normal map |
gdscriptvar mat: ShaderMaterial = $Sprite2D.material mat.set_shader_parameter("speed", 2.0) mat.set_shader_parameter("tint_color", Color.RED)
csharpvar mat = GetNode<Sprite2D>("Sprite2D").Material as ShaderMaterial; mat.SetShaderParameter("speed", 2.0f); mat.SetShaderParameter("tint_color", Colors.Red);
The canvas_item recipes most projects need: dissolve (noise + edge glow), outline (sample neighbors, expand alpha), flash-white (uniform-driven hit effect), color swap (palette shift), scrolling UV (water/lava/clouds), wave distortion.
> See references/2d-shader-recipes.md for complete shader code for all six recipes.
Spatial-shader recipes: toon/cel shading (banded NdotL), rim lighting / Fresnel (1 - NdotV), simple water surface (UV scroll + normal-map blend + Fresnel).
> See references/3d-shader-recipes.md for the full shader source for each recipe.
Visual shaders provide a node-based graph editor — no code required.
| Use Visual Shaders When | Use Code Shaders When | |--------------------------------|------------------------------------| | Prototyping effects quickly | Complex math or branching logic | | Artists need to tweak values | Need precise control over every line | | Learning shader concepts | Performance-critical shaders | | Simple effects (color adjust, UV scroll) | Loops or advanced techniques |
| Node | Purpose | |---------------------|--------------------------------------| | Texture2D | Sample a texture | | ColorConstant | Solid color value | | VectorOp | Math operations on vectors | | ScalarOp | Math operations on floats | | Mix | Lerp between two values | | Step / SmoothStep | Threshold / smooth threshold | | Time | Current time (for animation) | | UV | Texture coordinates | | Input (custom) | Expose a uniform to Inspector |
> Visual shaders compile to the same GPU code as written shaders. There is no performance difference.
> Godot 4.7+: Two new spatial Input nodes — in_shadow_pass (vertex/fragment; maps to the IN_SHADOW_PASS built-in, true when the shader is being rendered in a shadow mapping pass — render objects differently in shadow maps than in the regular pass) and specular_amount (light(); maps to SPECULAR_AMOUNT — 2.0 × light_specular for OmniLight3D/SpotLight3D, 1.0 for DirectionalLight3D).
> ⚠️ Changed in Godot 4.7: The LinearToSRGB visual shader node no longer clamps its output to [0.0, 1.0] when using the Forward+ or Mobile renderer — HDR values above 1.0 now pass through. Graphs that relied on the implicit clamp produce different output; add an explicit Clamp node to restore the old behavior. See the 4.7 migration guide.
The standard pattern: full-rect ColorRect with a canvas_item shader on top of the gameplay canvas. For 3D, use a WorldEnvironment Adjustment, Glow, or custom shader. For chained effects, render the world to a SubViewport then sample its texture in a final shader pass.
> See references/post-processing.md for the ColorRect overlay pattern, vignette + CRT/scanline shader source, the SubViewport pipeline, and WorldEnvironment 3D post-processing notes.
CompositorEffect runs custom render passes within Godot's render pipeline (post-tonemap or pre-tonemap). Use when ColorRect overlays aren't enough — multi-pass effects, depth-aware effects, custom AO/SSR variants. Heavier setup than a screen-space shader; reach for it only when needed.
> See references/compositor-effects.md for setup, a custom CompositorEffect GDScript example, and built-in Compositor use cases.
Render modes go on the first line after shader_type and control how the shader interacts with the rendering pipeline.
glslshader_type canvas_item; render_mode unshaded; // Ignore all lighting render_mode light_only; // Only visible where lit render_mode blend_add; // Additive blending (glow, fire) render_mode blend_mix; // Standard alpha blending (default) render_mode blend_premul_alpha; // Pre-multiplied alpha
glslshader_type spatial; render_mode unshaded; // No lighting calculations render_mode cull_disabled; // Render both sides of faces render_mode depth_draw_always; // Always write to depth buffer render_mode specular_toon; // Toon specular model render_mode diffuse_toon; // Toon diffuse model render_mode blend_add; // Additive blending
Godot 4.5 exposes stencil write/read in spatial and canvas_item shaders via stencil_write_mode, stencil_read_mode, stencil_value, etc. across all rendering backends. Enables portals, X-ray vision, outline masks, and holes-in-geometry effects that previously required compositor-level work.
> See references/stencil-buffer.md for render-mode reference and the X-ray vision portal worked example.
Sub-pixel Morphological Antialiasing (SMAA 1x) is a built-in post-processing AA mode added in Godot 4.5. It produces sharper, more temporally stable results than FXAA and is less costly than MSAA for deferred-heavy scenes.
SMAA can be combined with MSAA (for geometry edge aliasing) or used standalone. It does not require any shader code changes.
| AA Mode | Sharpness | GPU cost | Ghosting | |---------|-----------|----------|----------| | Disabled | N/A | None | None | | FXAA | Low (blurry) | Very low | Low | | SMAA | High | Low | Very low | | TAA | Medium (slight blur) | Medium | Possible | | MSAA 4x | High | High | None |
> When to use SMAA: Prefer SMAA over FXAA for most desktop projects — it delivers noticeably sharper text and thin edges with a similar performance profile. Combine SMAA + MSAA 2x for best quality at moderate cost.
This is an editor/export setting only — no runtime API is needed.
The Shader Baker pre-compiles all project shaders for the target platform at export time, eliminating the stutter players experience the first time a new material renders in-game — especially severe on macOS/Apple Silicon (Metal) and Windows (D3D12), where shader translation is expensive. Enable it per export preset for release builds; leave it off for development builds to keep exports fast. It operates at the Godot export pipeline level — see the export-pipeline skill for export preset configuration.
> See references/shader-baker.md for enabling steps and the with/without comparison.
| Symptom | Cause | Fix | |-------------------------------------|----------------------------------------------------|------------------------------------------------------------------| | Shader has no visible effect | Material not assigned or shader not saved | Check node's Material property in Inspector | | Transparent parts render as black | Alpha not handled in shader | Set COLOR.a = tex.a; and use appropriate blend mode | | Uniform doesn't appear in Inspector | Typo in uniform name or wrong type | Re-save the shader; check for compilation errors | | Texture appears stretched/tiled | Missing repeat_enable or wrong UV scale | Add repeat_enable hint to sampler2D uniform | | Shader works in editor but not in game | Screen texture uniform needs backbuffer | Use hint_screen_texture on a sampler2D uniform (Godot 4.x) | | Performance drops with many shaders | Each unique shader = draw call break | Share ShaderMaterial instances; use uniforms for variation | | Screen-space UV is wrong | SCREEN_UV not available in some contexts | Ensure the node is rendered in the correct viewport | | Visual shader node missing | Node was renamed or removed in newer Godot version | Check Godot docs for the current node name |
> ⚠️ Changed in Godot 4.7: textureQueryLod() is available only in the fragment shader, and Godot 4.7 enforces this with a compile error — shaders calling it from vertex() stop compiling after upgrading. Move the call into fragment(). See GH-118962.
canvas_item for 2D, spatial for 3D)hint_range, source_color, filter_linear_mipmap)TEXTURE is sampled in canvas_item shaders (otherwise sprite content is lost)COLOR.a correctly and use blend_mix render mode_processhint_screen_texture on a sampler2D uniform (Godot 4.x approach)| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 11,451 | 10,043 | -12% | 1 | 1 | 0% | 2,065 | 5,894 | +185% | 0 | 0 | — |
case-02 | fail→pass | 19,932 | 7,280 | -63% | 1 | 1 | 0% | 3,176 | 5,182 | +63% | 0 | 0 | — |
case-03 | fail→pass | 22,461 | 12,243 | -45% | 1 | 1 | 0% | 3,509 | 6,069 | +73% | 0 | 0 | — |
case-09 | fail→fail | 13,248 | 12,851 | -3% | 1 | 1 | 0% | 2,098 | 6,099 | +191% | 0 | 0 | — |
case-04 | pass→pass | 10,351 | 7,128 | -31% | 1 | 1 | 0% | 1,833 | 5,247 | +186% | 0 | 0 | — |
case-05 | pass→pass | 4,963 | 3,898 | -21% | 1 | 1 | 0% | 806 | 4,573 | +467% | 0 | 0 | — |
case-06 | pass→pass | 16,759 | 15,271 | -9% | 1 | 1 | 0% | 2,515 | 6,215 | +147% | 0 | 0 | — |
case-07 | fail→pass | 26,083 | 6,163 | -76% | 1 | 1 | 0% | 4,351 | 4,978 | +14% | 0 | 0 | — |
case-08 | pass→pass | 16,388 | 11,324 | -31% | 1 | 1 | 0% | 2,499 | 5,743 | +130% | 0 | 0 | — |
case-10 | fail→pass | 19,612 | 6,338 | -68% | 1 | 1 | 0% | 3,200 | 5,164 | +61% | 0 | 0 | — |
case-11 | pass→pass | 4,871 | 4,354 | -11% | 1 | 1 | 0% | 780 | 4,625 | +493% | 0 | 0 | — |
case-12 | pass→pass | 13,348 | 10,895 | -18% | 1 | 1 | 0% | 2,305 | 5,949 | +158% | 0 | 0 | — |
case-13 | pass→pass | 15,824 | 9,966 | -37% | 1 | 1 | 0% | 2,821 | 5,610 | +99% | 0 | 0 | — |
case-19 | pass→pass | 10,871 | 11,811 | +9% | 1 | 1 | 0% | 1,765 | 6,120 | +247% | 0 | 0 | — |
case-14 | pass→pass | 4,459 | 3,881 | -13% | 1 | 1 | 0% | 765 | 4,594 | +501% | 0 | 0 | — |
case-15 | pass→pass | 4,526 | 4,585 | +1% | 1 | 1 | 0% | 734 | 4,662 | +535% | 0 | 0 | — |
case-16 | fail→pass | 20,701 | 4,764 | -77% | 1 | 1 | 0% | 3,279 | 4,775 | +46% | 0 | 0 | — |
case-17 | fail→pass | 12,154 | 6,677 | -45% | 1 | 1 | 0% | 1,780 | 4,865 | +173% | 0 | 0 | — |
case-18 | pass→pass | 6,021 | 3,302 | -45% | 1 | 1 | 0% | 1,003 | 4,503 | +349% | 0 | 0 | — |
case-20 | pass→pass | 14,659 | 11,688 | -20% | 1 | 1 | 0% | 2,769 | 6,079 | +120% | 0 | 0 | — |
case-21 | pass→pass | 8,127 | 7,598 | -7% | 1 | 1 | 0% | 1,272 | 5,230 | +311% | 0 | 0 | — |
case-22 | pass→pass | 12,123 | 9,077 | -25% | 1 | 1 | 0% | 1,933 | 5,353 | +177% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +27 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.