Files
nexus/wiki/sources/godot-shader-developer.md
2026-05-03 05:42:12 +08:00

5.1 KiB
Raw Blame History

title, type, tags, date
title type tags date
Godot Shader Developer Agent Personality source
Godot
Shader
Game Development
GLSL
Visual Effects
2026-05-01

Source File

Summary用中文描述

  • 核心主题Godot 4 渲染效果专家 AI Agent精通 Godot 着色语言GLSL-like、VisualShader 编辑器、CanvasItem 和 Spatial 着色器、后处理与性能优化
  • 问题域2DCanvasItem和 3DSpatial视觉效果着色器开发、渲染器分级兼容、移动端性能合规
  • 方法/机制:通过 shader_type 声明 + uniform hint 系统 + 渲染器分级适配Forward+ / Mobile / Compatibility+ 纹理采样性能审计实现跨平台视觉效果
  • 结论/价值:为 Godot 4 游戏提供创作性、正确性与性能意识三合一的着色器方案,核心交付物涵盖 2D 精灵描边、3D Dissolve 溶解、3D 水面、全屏后处理及着色器性能审计清单

Key Claims用中文描述

  • Godot Shader Developer 通过 shader_type 声明canvas_item / spatial / particles / sky明确着色器上下文使用 Godot 内置变量TEXTURE / UV / COLOR / ALBEDO而非原始 GLSL 等价物
  • VisualShader 编辑器适合艺术家快速迭代,代码着色器适合性能关键路径;两者互补而非替代
  • 所有 uniform 参数必须附带 hinthint_range / source_color / hint_normal 等),否则 Inspector 无法正确显示颜色选择器和范围滑块
  • SCREEN_TEXTURE 采样会触发帧缓冲区复制,在移动端每帧 shader 中使用会严重影响性能,应有文档化性能理由
  • discard 在移动端不透明空间着色器中应替换为 Alpha Scissor以保证性能合规Compatibility 渲染器完全不支持 compute shader 和 DEPTH_TEXTURE canvas 采样

Key Quotes

"MANDATORY: Godot's shading language is not raw GLSL — use Godot built-ins (TEXTURE, UV, COLOR, FRAGCOORD) not GLSL equivalents" — Godot 4 着色语言核心规范 "8 texture samples in this fragment is 4 over mobile budget — here's a 4-sample version that looks 90% as good" — 移动端纹理采样性能审计原则 "Use VisualShader for effects artists need to extend — use code shaders for performance-critical or complex logic" — 工具选型原则

Key Concepts

  • CanvasItem ShaderGodot 2D/UI 着色器类型,使用 shader_type canvas_item,通过 TEXTUREUVCOLOR 内置变量操作精灵和 UI 效果;不支持 DEPTH_TEXTURE
  • Spatial ShaderGodot 3D 世界着色器类型,使用 shader_type spatial,通过 ALBEDOMETALLICROUGHNESSNORMAL_MAP 输出变量控制 PBR 材质;这些是输出变量而非输入
  • VisualShaderGodot 图形化着色器编辑器,将 GLSL 节点化支持艺术家快速搭建材质变体Comment 节点用于组织复杂图;uniform 必须设置 hint
  • CompositorEffectGodot 4 Forward+ 渲染器的全屏后处理扩展点,通过 GDScript extends CompositorEffect + RenderingDevice 实现自定义后处理 Pass
  • Forward+ RendererGodot 4 高端渲染器,全特性支持——DEPTH_TEXTURESCREEN_TEXTURENORMAL_ROUGHNESS_TEXTURE、compute shader
  • Mobile RendererGodot 4 中端渲染器,避免 discard 使用不透明空间着色器(优先 Alpha Scissor纹理采样预算严格每片元 ≤ 6 次)
  • Compatibility RendererGodot 4 最广泛支持渲染器,无 compute shader、无 DEPTH_TEXTURE canvas 采样、无 HDR 纹理;限制最多
  • RenderingDeviceGodot 4 底层 GPU API用于 dispatch compute shaderForward+ 渲染器下)进行 GPU 侧纹理生成和数据处理

Key Entities

  • GodotJuan Linietsky 和 Ariel Manzur 主导的开源游戏引擎Godot 4 引入了 Forward+ 渲染器和重构的着色语言(基于 GLSL 但有 Godot 特有内置变量)
  • GLSLOpenGL 着色语言Godot 着色语言基于 GLSLtexture() 函数签名与原始 GLSL texture2D() 不同Godot 3 用 texture2D()Godot 4 用 texture()

Connections

Contradictions

  • 无已知冲突内容。该源页面与 Unity Shader Graph Artist 在着色器工具选型上仅有描述性差异Graph vs Code不存在事实性矛盾。