Zum Inhalt springen
Skillpedia
Allgemeines Programmieren6.6k · #13828

godot-shaders

Was er macht

Dieser Skill bringt dem Agenten bei, Shader-Code zu schreiben, der das Aussehen von Dingen in Godot verändert, etwa leuchtende Kanten oder animierte Oberflächen. Er ist für Grafiker und Entwickler gedacht, die visuelle Effekte hinzufügen.

Wann du ihn nutzt

  • ✓Wenn du einen visuellen Effekt wie Umriss, Auflösen oder Aufblitzen auf einem Godot-Sprite willst.
  • ✓Wenn du einen 3D-Oberflächeneffekt brauchst, etwa Randlicht, einen Cartoon-Look oder eine bewegte Textur.
  • ✓Wenn du einen älteren Godot-3-Shader in die Godot-4-Syntax übersetzt.

Link zum Skill

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-shaders/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-shaders/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Gib meinem Figuren-Sprite in meinem Godot-Spiel ein weißes Aufblitzen, wenn es getroffen wird.”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Der Skill zeigt, wie du das Shader-Programm schreibst, es über ein Material anbindest, Einstellungen freigibst, die die Grafik im Inspektor ändern kann, und den Effekt über die Zeit animierst.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

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 .gdshader code or a ShaderMaterial: 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

  1. Pick the shader type on the first line: shader_type canvas_item; for 2D (Sprite2D, TextureRect, anything CanvasItem) or shader_type spatial; for 3D materials. (particles, sky, fog also exist.)
  2. Attach via a ShaderMaterial. Create a ShaderMaterial, assign your .gdshader, and put it on the node's material. Uniforms appear in the Inspector.
  3. Write fragment() to set the output: COLOR (2D) or ALBEDO/EMISSION/ALPHA (3D). Optionally vertex() to move geometry and light() for custom lighting.
  4. Expose tunables as uniforms with hints (source_color, hint_range) so they are editable and correctly color-managed.
  5. Animate with the built-in TIME and sample textures with texture(tex, UV).
  6. 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_TEXTURE is removed — declare uniform sampler2D x : hint_screen_texture; and sample with SCREEN_UV. Color hints hint_color/hint_albedo→source_color; hint_white/hint_black→ hint_default_white/hint_default_black; hint_range stays. Depth/normal use hint_depth_texture / hint_normal_roughness_texture.
  • Wrong output variable. In canvas_item write COLOR; in spatial write ALBEDO (and EMISSION, ALPHA, ROUGHNESS, METALLIC). Writing COLOR in a spatial shader does nothing.
  • Color uniforms without source_color are treated as raw linear values and look wrong (washed/dark) because Godot won't sRGB-convert them.
  • Object drawn in the wrong order, casts no shadow, or skips SSAO (3D) → the spatial shader reads or writes ALPHA, which moves the whole material to the transparent pipeline even if the value is always 1.0. Don't touch ALPHA in opaque shaders; for hard cut-outs also set ALPHA_SCISSOR_THRESHOLD (alpha-scissor stays in the opaque pass).
Häufige Fragen

Brauche ich Shader-Kenntnisse?

Grundkenntnisse helfen, aber der Skill erklärt die Godot-Teile Schritt für Schritt.

Ist das für 2D oder 3D?

Für beides. Der Skill deckt 2D-Canvas-Shader und 3D-Spatial-Shader ab.

Deckt er Partikeleffekte ab?

Eher nicht. Partikel-Nodes sind ein eigenes Thema, daher konzentriert sich dieser Skill auf Shader-Code.

Details

Originalbeschreibung des Autors

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.

repo: gamedev-skills/awesome-gamedev-agent-skills

Beliebtheit

GitHub-Sterne
6.6k
Platz im Ranking
#13828
Lizenz
Apache-2.0
Aktualisiert
28.10.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills