godot-shaders
gamedev-skills/awesome-gamedev-agent-skills
Write Godot 4.7 shaders (2D canvas_item and 3D spatial) with uniforms, TIME animation, and screen-reading.
What is godot-shaders?
This skill covers authoring .gdshader files in Godot 4.7's Shading Language for both 2D and 3D visual effects. Use it when writing fragment/vertex shader code, creating effects like dissolve or rim lighting, or porting Godot 3.x shaders to 4.x syntax.
- Write canvas_item shaders for 2D effects (outline, dissolve, flash, water) and spatial shaders for 3D surfaces (rim light, toon, scrolling UV)
- Expose uniforms with hints (source_color, hint_range) for Inspector editing and correct color management
- Animate effects using TIME and UV coordinates, and sample textures with texture() function
- Read screen content via hint_screen_texture for post-processing effects
- Attach shaders to nodes via ShaderMaterial and set uniform values from GDScript at runtime
- Handle vertex displacement and custom lighting via vertex() and light() functions
How to install godot-shaders
npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill godot-shaders- Godot 4.7 installed
- Basic understanding of shader concepts (fragment/vertex functions, UV coordinates)
- A .gdshader file or ShaderMaterial node to attach the shader to
How to use godot-shaders
- 1.Choose your shader type: canvas_item for 2D or spatial for 3D on the first line
- 2.Create a ShaderMaterial, assign your .gdshader file, and attach it to the node's material property
- 3.Write a fragment() function to set output (COLOR for 2D, ALBEDO/EMISSION/ALPHA for 3D)
- 4.Define uniform variables with appropriate hints (source_color for colors, hint_range for numeric ranges)
- 5.Use TIME for animation and texture() to sample textures; add vertex() or light() functions if needed
- 6.Set uniform values from GDScript using material.set_shader_parameter("name", value)
Use cases
- Create a 2D sprite with scrolling texture and tint control via uniforms
- Implement a dissolve effect using a noise texture threshold to fade out geometry
- Add emissive rim lighting to a 3D character that glows at grazing angles
- Build a screen-space blur post-effect by sampling the screen texture with offsets
- Port a Godot 3.x shader to 4.x by updating SCREEN_TEXTURE to hint_screen_texture and hint_color to source_color
- Game developers building 2D or 3D visual effects in Godot 4.7
- Technical artists porting shaders from Godot 3.x to 4.x
- Developers implementing post-processing effects or custom material looks
godot-shaders FAQ
canvas_item shaders are for 2D (Sprite2D, TextureRect) and write to COLOR; spatial shaders are for 3D materials and write to ALBEDO, EMISSION, ALPHA, and other 3D-specific outputs.
Replace SCREEN_TEXTURE with a uniform sampler2D declared with hint_screen_texture; change hint_color and hint_albedo to source_color; keep hint_range unchanged; update any removed built-ins by checking the shading language reference.
Color uniforms must use the source_color hint (e.g., uniform vec4 my_color : source_color;) so Godot applies correct sRGB conversion; without it, the value is treated as raw linear and appears incorrect.
Add : repeat_enable to the sampler uniform declaration (e.g., uniform sampler2D tex : repeat_enable;) so sampling outside [0,1] UV wraps instead of clamping.
Yes, discard removes a pixel, but it is costly on some hardware and breaks early-Z optimization; prefer setting ALPHA or COLOR.a to 0.0 when possible for better performance.
Full instructions (SKILL.md)
Source of truth, from gamedev-skills/awesome-gamedev-agent-skills.
name: godot-shaders description: > Write Godot 4.7 shaders in the Godot Shading Language: canvas_item shaders for 2D and spatial shaders for 3D, with vertex/fragment functions, uniforms (source_color, hint_range), TIME/UV animation, and screen-reading via hint_screen_texture. Use when authoring .gdshader files, writing fragment/vertex code, making 2D/3D visual effects, or porting 3.x shaders (SCREEN_TEXTURE, hint_color) to 4.x.
Godot Shaders (4.x)
Write canvas_item (2D) and spatial (3D) shaders in the Godot Shading Language, animate
with TIME/UV, expose uniforms, and read the screen. Targets Godot 4.7.
When to use
- Use when writing
.gdshadercode or aShaderMaterial: 2D effects (outline, dissolve, flash, water), 3D surface shaders (rim light, toon, scrolling UV), or screen-space post effects.
When not to use: the cross-engine concepts of shading (UVs, vertex/fragment
theory) → shader-programming; particles/VFX nodes → general 3D; non-shader visuals.
Core workflow
- Pick the shader type on the first line:
shader_type canvas_item;for 2D (Sprite2D, TextureRect, anythingCanvasItem) orshader_type spatial;for 3D materials. (particles,sky,fogalso exist.) - Attach via a
ShaderMaterial. Create aShaderMaterial, assign your.gdshader, and put it on the node'smaterial. Uniforms appear in the Inspector. - Write
fragment()to set the output:COLOR(2D) orALBEDO/EMISSION/ALPHA(3D). Optionallyvertex()to move geometry andlight()for custom lighting. - Expose tunables as
uniforms with hints (source_color,hint_range) so they are editable and correctly color-managed. - Animate with the built-in
TIMEand sample textures withtexture(tex, UV). - Set uniforms from code with
material.set_shader_parameter("name", value).
Patterns
1. 2D (canvas_item): tint + scrolling UV
shader_type canvas_item;
uniform vec4 tint : source_color = vec4(1.0); // source_color = sRGB-correct color
uniform float scroll_speed : hint_range(0.0, 2.0) = 0.3;
void fragment() {
vec2 uv = UV;
uv.x += TIME * scroll_speed; // scroll horizontally over time
COLOR = texture(TEXTURE, uv) * tint; // TEXTURE = the node's texture
}
2. 2D dissolve using a noise threshold
shader_type canvas_item;
uniform sampler2D noise : repeat_enable; // a NoiseTexture2D
uniform float amount : hint_range(0.0, 1.0) = 0.0;
void fragment() {
vec4 tex = texture(TEXTURE, UV);
float n = texture(noise, UV).r;
if (n < amount) {
discard; // cut the pixel away
}
COLOR = tex;
}
3. 3D (spatial): emissive rim light
shader_type spatial;
uniform vec4 base_color : source_color = vec4(0.2, 0.5, 1.0, 1.0);
uniform vec3 rim_color : source_color = vec3(0.6, 0.8, 1.0);
uniform float rim_power : hint_range(0.5, 8.0) = 3.0;
void fragment() {
ALBEDO = base_color.rgb;
// VIEW and NORMAL are view-space built-ins; rim is strong at grazing angles.
float rim = pow(1.0 - dot(NORMAL, VIEW), rim_power);
EMISSION = rim_color * rim;
}
4. Screen-reading post effect (4.x hint, not SCREEN_TEXTURE)
shader_type canvas_item;
// 4.x: declare the screen as a uniform with hint_screen_texture.
uniform sampler2D screen_tex : hint_screen_texture, filter_linear_mipmap;
uniform float blur : hint_range(0.0, 4.0) = 1.0;
void fragment() {
vec2 px = SCREEN_PIXEL_SIZE * blur;
vec4 c = texture(screen_tex, SCREEN_UV);
c += texture(screen_tex, SCREEN_UV + vec2(px.x, 0.0));
c += texture(screen_tex, SCREEN_UV - vec2(px.x, 0.0));
COLOR = c / 3.0;
}
Set a uniform from GDScript:
$Sprite2D.material.set_shader_parameter("amount", 0.7)
Pitfalls
- 3.x → 4.x renames.
SCREEN_TEXTUREis removed — declareuniform sampler2D x : hint_screen_texture;and sample withSCREEN_UV. Color hintshint_color→source_color;hint_albedo/hint_white→source_color;hint_rangestays. Depth/normal usehint_depth_texture/hint_normal_roughness_texture. - Wrong output variable. In
canvas_itemwriteCOLOR; inspatialwriteALBEDO(andEMISSION,ALPHA,ROUGHNESS,METALLIC). WritingCOLORin a spatial shader does nothing. - Color uniforms without
source_colorare treated as raw linear values and look wrong (washed/dark) because Godot won't sRGB-convert them. - Transparency needs opt-in (3D). For
ALPHA < 1.0to blend, add a render mode or set the material transparency; otherwise it's opaque/cut. - Sampling outside [0,1] UV without
repeat_enableclamps. Add: repeat_enableto the sampler uniform for tiling/scroll. TIMEis seconds since start and keeps growing — wrap withfract()/mod()for periodic effects to avoid precision drift.discardis costly on some hardware and breaks early-Z; prefer settingALPHA/COLOR.awhen you can.
References
- For built-in variables per shader type, render modes,
varying, customlight(),vertex()displacement, and the visual shader graph, readreferences/shading-language.md.
Related skills
shader-programming— engine-agnostic shader concepts (GLSL/HLSL).godot-3d-essentials— materials, environment, and where spatial shaders live.godot-ui-control— applying shaders to UI for effects.
Related skills
More from gamedev-skills/awesome-gamedev-agent-skills and the wider catalog.

godot-signals-groups
Decouple Godot 4.x gameplay with signals and node groups instead of hard-coded references.

godot-tilemap
Build and edit tile-based 2D levels in Godot 4.7 with TileMapLayer, collision, terrains, and runtime cell manipulation.

godot-ui-control
Build responsive Godot 4.7 UIs with Control nodes, Containers, Themes, and keyboard/gamepad focus.

input-systems
Design game input as named actions with rebinding, multi-device support, deadzones, and feel features like buffering and coyote time.

itch-publish
Publish and update game builds on itch.io using butler CLI with efficient delta uploads.

level-design
Design playable levels through blockout-to-playable workflow: metrics, pacing, gating, and encounter design.