thedivergentai/godot-shaders-basics
Expert Godot shader patterns for batch-safe hitflash, alpha-scissor foliage/dissolve, screenspace postFX, depth reconstruction, triplanar, and instance uniforms — not first-shader tutorials. Trigger on draw-call batching breaks, discard vs depth-prepass, foliage shadows, post-process quads, or world-position FX. Keywords: instance uniform, ALPHA_SCISSOR, hint_screen_texture, hint_depth_texture, global uniform, sampler2DArray, canvas_item, spatial, post-processing.
npx skills add https://github.com/thedivergentai/GD-Agentic-Skills --skill godot-shaders-basics
LinearToSRGB visual-shader node no longer clamps to [0,1] on Mobile/Forward+.get_format() lives on Texture2D base for ImageTexture / PortableCompressedTexture2D.Batching-safe materials, scissor/dissolve, screenspace FX, and depth reconstruction — Official Docs cover first shaders and built-in glossaries.
discard unconditionally for optimization — It prevents the depth prepass from working effectively. A discarded pixel still costs vertex processing; sometimes not rendering the object is better [1].if/else for dynamic states in high-performance shaders — GPUs hate branching. Use mix(), step(), and smoothstep() for mathematical, hardware-optimized selection [5, 21].if (v == 0.5) is unreliable. Use abs(a - b) < epsilon or step().POSITION to vec4(VERTEX, 1.0) for full-screen quads in 4.3+ — Godot 4.3 uses Reversed-Z depth; this will cause clipping. Use POSITION = vec4(VERTEX.xy, 1.0, 1.0) [8, 9].instance uniform. This allows unique values for thousands of nodes while maintaining a single draw call (batching) [10].TIME without a speed multiplier — Fragment speed should be controllable via uniforms to ensure consistency across different gameplay states.hint_source_color for color uniforms — Without it, the engine treats colors as linear math, leading to incorrect gamma and washed-out visuals in the inspector.fragment() that could be in vertex() — vertex() runs once per point; fragment() runs millions of times per frame. Interpolate values via varying instead.#define macros for dynamic runtime toggles — These create new shader permutations, causing massive compilation stutters when first encountered in-game. Use uniforms instead.reflect(dir, normal) on unnormalized vectors causes severe rendering artifacts and incorrect lighting math.fract() — Shifting UVs beyond 0.0-1.0 without repeat wrapping or clamping will sample edge pixels or return black, breaking texture consistency.> MANDATORY for the matching effect. Do NOT Load beginner canvas_item tint recipes or built-in variable glossaries here.
| Goal | Script |
|------|--------|
| Per-enemy hitflash without breaking batches | MANDATORY instance_uniform_hitflash.gdshader |
| Foliage wind + shadows | MANDATORY foliage_wind_sway_expert.gdshader (alpha scissor/hash — not unconditional discard) |
| Dissolve that keeps depth-prepass | MANDATORY dissolve_scissor_expert.gdshader |
| PostFX pixelate / stylize | MANDATORY screenspace_hex_pixelate.gdshader |
| Full-screen quad (Reversed-Z) | MANDATORY screenspace_full_quad.gdshader |
| Depth → world for water/fog | MANDATORY depth_world_reconstruction.gdshader |
| Grass flatten from player | global_grass_flatten.gdshader |
| UV-less cliffs/rocks | triplanar_world_mapping.gdshader |
| Unique textures on instanced meshes | instance_texture_array.gdshader |
| Vertex displacement terrain | noise_terrain_displacement.gdshader |
| Animate uniforms at runtime | shader_parameter_animator.gd |
| VFX port template | vfx_port_shader.gdshader |
Golden path for cutouts/dissolve: ALPHA_SCISSOR / alpha hash (see dissolve + foliage scripts) — not discard for optimization. NEVER list explains why.
Instance-uniform flashes; one material, many unique intensities.
Mask dissolve with ALPHA_SCISSOR for depth-prepass + shadows.
World-space wind sway for foliage batches.
global uniform player interaction flattening grass.
hint_screen_texture stylized postFX.
Reversed-Z-safe full-rect post pass.
hint_depth_texture → world position.
World-axis projection without UVs.
sampler2DArray + instance uniform for unique batched textures.
Vertex noise displacement.
Validated VFX shader template.
Tween/runtime uniform animation without AnimationPlayer.
Pre-warm shader pipelines during loading screens to avoid first-frame stutter.
vertex(); pass via varying.hint_source_color.> LLM-ignorance rule: if a general agent would not know it before reading, it lives here or in scripts/ — never delete, only move.
| Topic | Reference |
|-------|-----------|
| 2D dissolve/wave/outline | 2d-effect-recipes.md |
| 3D toon + vignette | 3d-and-postfx-recipes.md |
| Uniforms / built-ins | uniforms-and-builtins.md |
| Fog, compute, warmup | expert-advanced-patterns.md |
> Progressive disclosure: open Official Documentation links only when researching a specific API;
> load Related Skills when routing work to a peer domain — do not preload the whole lattice.
canvas_item built-ins (UV, COLOR, TEXTURE, SCREEN_UV) for sprites, UI, and 2D post FX.spatial built-ins (ALBEDO, NORMAL, instance uniform, depth/screen textures) for materials and full-screen quads.set_shader_parameter / instance parameter API used by animators and hit-flash batching.hint_screen_texture, and compositing patterns for pixelate/vignette-style FX.VisualShaderNodeCustom extensibility covered in the expert patterns..gdshader assets.ALBEDO/EMISSION/light() output interacts with Forward+, GI, and fog volumes.instance uniform and avoiding unique materials.Take thedivergentai/godot-shaders-basics from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.