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

52 lines
5.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Godot Shader Developer Agent Personality"
type: source
tags: [Godot, Shader, Game Development, GLSL, Visual Effects]
date: 2026-05-01
---
## Source File
- [[raw/Agent/agency-agents/game-development/godot/godot-shader-developer.md]]
## 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 参数必须附带 hint`hint_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 Shader]]Godot 2D/UI 着色器类型,使用 `shader_type canvas_item`,通过 `TEXTURE``UV``COLOR` 内置变量操作精灵和 UI 效果;不支持 `DEPTH_TEXTURE`
- [[Spatial Shader]]Godot 3D 世界着色器类型,使用 `shader_type spatial`,通过 `ALBEDO``METALLIC``ROUGHNESS``NORMAL_MAP` 输出变量控制 PBR 材质;这些是输出变量而非输入
- [[VisualShader]]Godot 图形化着色器编辑器,将 GLSL 节点化支持艺术家快速搭建材质变体Comment 节点用于组织复杂图;`uniform` 必须设置 hint
- [[CompositorEffect]]Godot 4 Forward+ 渲染器的全屏后处理扩展点,通过 GDScript `extends CompositorEffect` + RenderingDevice 实现自定义后处理 Pass
- [[Forward+ Renderer]]Godot 4 高端渲染器,全特性支持——`DEPTH_TEXTURE``SCREEN_TEXTURE``NORMAL_ROUGHNESS_TEXTURE`、compute shader
- [[Mobile Renderer]]Godot 4 中端渲染器,避免 `discard` 使用不透明空间着色器(优先 Alpha Scissor纹理采样预算严格每片元 ≤ 6 次)
- [[Compatibility Renderer]]Godot 4 最广泛支持渲染器,无 compute shader、无 `DEPTH_TEXTURE` canvas 采样、无 HDR 纹理;限制最多
- [[RenderingDevice]]Godot 4 底层 GPU API用于 dispatch compute shaderForward+ 渲染器下)进行 GPU 侧纹理生成和数据处理
## Key Entities
- [[Godot]]Juan Linietsky 和 Ariel Manzur 主导的开源游戏引擎Godot 4 引入了 Forward+ 渲染器和重构的着色语言(基于 GLSL 但有 Godot 特有内置变量)
- [[GLSL]]OpenGL 着色语言Godot 着色语言基于 GLSL`texture()` 函数签名与原始 GLSL `texture2D()` 不同Godot 3 用 `texture2D()`Godot 4 用 `texture()`
## Connections
- [[Godot Gameplay Scripter]] ← collaborates_with ← [[Godot Shader Developer]]Godot 游戏中脚本逻辑与视觉效果着色器协同开发,构成完整 Godot 4 游戏开发栈)
- [[Unity Shader Graph Artist]] ← compares_to ← [[Godot Shader Developer]]两大主流游戏引擎的着色器方案对比Unity 用 Shader GraphGodot 用 VisualShader + 代码着色器,均追求艺术友好与性能控制的平衡)
- [[Technical Artist]] ← overlaps_with ← [[Godot Shader Developer]](两者均涉及渲染技术与美术的桥梁工作)
- [[Godot Shader Developer]] ← uses ← [[VisualShader]]VisualShader 作为快速原型工具,代码着色器用于性能关键路径)
- [[Godot Shader Developer]] ← targets ← [[Forward+ Renderer]] / [[Mobile Renderer]] / [[Compatibility Renderer]](三种渲染器分级适配)
## Contradictions
- 无已知冲突内容。该源页面与 [[Unity Shader Graph Artist]] 在着色器工具选型上仅有描述性差异Graph vs Code不存在事实性矛盾。