Skillpedia
برمجة عامة6.6k · #13805

shader-programming

ما الذي تفعله

تشرح هذه المهارة عمل المظللات وكيفية بناء التأثيرات البصرية الشائعة بها. وهي لمطوري الألعاب والفنيين التقنيين الذين يريدون تأثيرات مثل التلاشي والحدود أو الإضاءة الحافية.

متى تستخدمها

  • ✓عندما تريد تأثيرًا بصريًا مثل التلاشي أو الحدود أو الإضاءة الحافية على صورة أو نموذج.
  • ✓عندما تحتاج إلى فهم إحداثيات UV أو أنظمة الإحداثيات أو مرحلتي الرؤوس والبكسلات.
  • ✓عندما تريد نقل مظلل بين GLSL وHLSL أو بين المحركات.

رابط المهارة

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/disciplines/shader-programming/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/disciplines/shader-programming/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“هل يمكنك كتابة مظلل يُذيب شخصيتي من الأطراف ويضيف حدًا فاتحًا حولها؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يشرح الوكيل أي مرحلة تقوم بأي عمل، ثم يكتب مظللًا للبكسلات يستعمل إحداثيات UV وقيمة ضوضاء لإخفاء البكسلات تدريجيًا. ويضيف الحد بأخذ عينات من البكسلات المجاورة، باستعمال GLSL مع ما يعادله في HLSL.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Shader programming (cross-engine)

Shaders are small programs that run per vertex and per pixel on the GPU. The concepts — the pipeline, coordinate spaces, UVs, and how common effects are built — port across engines; only the language dialect and built-in variable names change. This skill teaches those portable fundamentals in GLSL with HLSL equivalents; use godot-shaders (or Unity/Unreal material docs) for the exact engine syntax and built-ins.

When to use

  • Use to understand or write vertex/fragment shaders and to reason about UVs, coordinate spaces, and the GPU pipeline.
  • Use to build common effects: tint/recolor, scrolling textures, dissolve, outlines, fresnel/rim light, vignette, color grading.
  • Use to translate a shader concept between GLSL and HLSL, or between engines.

When not to use: for an engine's exact shader language and built-ins, use godot-shaders (Godot shading language) or the engine's material docs. For full particle VFX systems, see unreal-niagara. For post-process stacks, defer to the engine's renderer settings.

Core workflow

  1. Know which stage you're in. The vertex shader transforms each vertex into clip space and passes data (UVs, normals) onward; the fragment/pixel shader runs per rasterized pixel and outputs a color. Most game effects live in the fragment stage.
  2. Track coordinate spaces. Positions move model → world → view → clip space; normals belong in world or view space. Mixing spaces is the most common bug.
  3. Drive effects with UVs and time. UVs are 0..1 texture coordinates; offset, scale, or distort them, and animate with a time uniform.
  4. Work per pixel, branch-light. Prefer mix, step, smoothstep, and clamp over if where possible; GPUs run pixels in lockstep, so a branch whose condition differs between neighbouring pixels runs both sides. A branch on a uniform (same for the whole draw) is cheap.
  5. Pass data via uniforms (constant per draw) and varyings (interpolated vertex→fragment). Keep texture samples few; they dominate cost.
  6. Validate source before visual testing when the tools are already available. For GLSL, run glslangValidator path/to/shader.frag with the matching stage suffix; for WGSL, run naga path/to/shader.wgsl. Check Godot .gdshader files by opening the project in Godot, which has no standalone validator for them.
  7. Verify visually and on target hardware. Shaders that look right on desktop can break on mobile (precision, missing features). Test where it ships.

Patterns

GLSL fragment snippets for desktop #version 330 (each passes glslangValidator with that header; close to Godot's canvas_item/spatial shaders). For GLSL ES 3.00 — WebGL2, three.js ShaderMaterial, PixiJS filters — add precision highp float; and set uniform defaults from code: ES rejects uniform float edge = 0.05; with "cannot initialize this type of qualifier" (Godot's shading language accepts it). See references/effects.md for the HLSL equivalents and the full outline/fresnel/vignette shaders.

1. Fragment basics: sample, tint, and combine

// Per-pixel: read the texture at this UV, multiply by a color (tint), keep alpha.
uniform sampler2D tex;
uniform vec4 tint;          // e.g. (1,0,0,1) reddens; multiply is non-destructive
in vec2 uv;                 // interpolated 0..1 texture coordinate (a "varying")
out vec4 frag;
void main() {
    vec4 c = texture(tex, uv);   // HLSL: tex.Sample(samp, uv)
    frag = c * tint;             // component-wise multiply tints without clipping
}

2. Scrolling UVs (animated texture) — frame-rate independent

// Add time * speed to the UV to scroll. fract() wraps it into 0..1 so it tiles.
uniform sampler2D tex;
uniform float time;          // seconds, supplied by the engine
uniform vec2 scroll_speed;   // UV units per second, e.g. (0.1, 0.0)
in vec2 uv;
out vec4 frag;
void main() {
    vec2 scrolled = fract(uv + scroll_speed * time);  // HLSL: frac(...)
    frag = texture(tex, scrolled);
}
// Drive with a real time uniform, not a per-frame accumulator, so speed is stable.

3. Dissolve (threshold a noise map, glow the edge)

// Hide pixels where noise < threshold; tint a thin band at the boundary.
uniform sampler2D tex;
uniform sampler2D noise_tex;     // grayscale noise, 0..1
uniform float amount;            // 0 = fully visible, 1 = fully dissolved
uniform float edg
الأسئلة الشائعة

ما الفرق بين مظلل الرؤوس ومظلل البكسلات؟

مرحلة الرؤوس تضع كل رأس على الشاشة، أما مرحلة البكسلات فتحدد لون كل بكسل.

هل تغطي صيغة مظللات Godot؟

تحيل المهارة إلى مهارة مظللات Godot للصيغة الدقيقة والأسماء المدمجة.

هل تغطي تأثيرات الجسيمات؟

أنظمة الجسيمات الكاملة خارج هذه المهارة، وتنتمي إلى إرشادات Unreal Niagara.

التفاصيل

الوصف الأصلي من المؤلف

Write game shaders from cross-engine fundamentals — the vertex→fragment pipeline, coordinate spaces, UV math, and common 2D/3D effects (tint, UV scroll, dissolve, outline, fresnel rim, vignette) in GLSL with HLSL equivalents. Use when the user mentions shaders, fragment/pixel shader, vertex shader, UV, GLSL, HLSL, or effects like dissolve, outline, or rim light.

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

الشعبية

نجوم GitHub
6.6k
الترتيب
#13805
الترخيص
Apache-2.0
آخر تحديث
28‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة