Files
nexus/wiki/sources/godot-shader-developer.md

51 lines
4.0 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-04-26
---
## Source File
- [[raw/Agent/agency-agents/game-development/godot/godot-shader-developer.md]]
## Summary用中文描述
- 核心主题Godot 4 渲染专家 Agent使用 Godot 着色语言GLSL-like编写高性能 2D/3D 视觉效果着色器
- 问题域Godot 4 的 CanvasItem2D和 Spatial3D着色器开发、VisualShader 编辑器、后处理、性能优化
- 方法/机制:通过 `shader_type` 声明、uniform 参数暴露、渲染器兼容性检查、纹理采样计数审计实现跨平台视觉效果
- 结论/价值:为 Godot 4 游戏提供创作性正确且性能合规的着色器方案,覆盖 2D 精灵描边、3D 溶解/水面着色、全屏后处理
## Key Claims用中文描述
- Godot Shader Developer 通过 `shader_type` + GLSL-like 语法实现 2D CanvasItem 和 3D Spatial 着色器,在 Forward+ / Mobile / Compatibility 三种渲染器下提供差异化效果
- VisualShader 编辑器适合艺术家快速迭代,代码着色器适合性能关键路径;两者互补而非替代
- 所有 uniform 参数必须附带 hint`hint_range``source_color``hint_normal` 等),否则 Inspector 无法正确显示
- `SCREEN_TEXTURE` 采样会触发帧缓冲区复制,在移动端每帧 shader 中使用会严重影响性能
- `discard` 在移动端不透明空间着色器中应替换为 Alpha Scissor以保证性能合规
## 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 效果
- [[Spatial Shader]]Godot 3D 世界着色器类型,使用 `shader_type spatial`,通过 `ALBEDO``METALLIC``ROUGHNESS``NORMAL_MAP` 输出变量控制 PBR 材质
- [[VisualShader]]Godot 图形化着色器编辑器,将 GLSL 节点化支持艺术家快速搭建材质变体Group 和 Comment 节点用于组织复杂图
- [[CompositorEffect]]Godot 4 Forward+ 渲染器的全屏后处理扩展点,通过 GDScript `extends CompositorEffect` 实现自定义后处理 Pass
- [[Forward+ Renderer]]Godot 4 高端渲染器,支持 `DEPTH_TEXTURE``SCREEN_TEXTURE``NORMAL_ROUGHNESS_TEXTURE` 全部特性
- [[Mobile Renderer]]Godot 4 中端渲染器,避免 `discard` 使用,优先 Alpha Scissor纹理采样预算严格
- [[Compatibility Renderer]]Godot 4 最广泛支持渲染器,无 compute shader、无 `DEPTH_TEXTURE` canvas 采样、无 HDR 纹理
## Key Entities
- [[Godot]]Juan Linietsky 和 Ariel Manzur 主导的开源游戏引擎Godot 4 引入了 Forward+ 渲染器和重构的着色语言
- [[GLSL]]OpenGL 着色语言Godot 着色语言基于 GLSL 但有自己的内置变量和 API`texture()` vs `texture2D()`
## Connections
- [[Godot Gameplay Scripter]] ← collaborates_with ← [[Godot Shader Developer]]Godot 游戏中脚本与着色器协同开发)
- [[Unity Shader Graph Artist]] ← compares_to ← [[Godot Shader Developer]](两大主流游戏引擎的着色器方案对比)
- [[Technical Artist]] ← overlaps_with ← [[Godot Shader Developer]](两者均涉及渲染技术与美术的桥梁工作)
- [[Godot Shader Developer]] ← uses ← [[VisualShader]]VisualShader 作为快速原型工具)
- [[Godot Shader Developer]] ← targets ← [[Forward+ Renderer]] / [[Mobile Renderer]] / [[Compatibility Renderer]](三种渲染器适配)
## Contradictions
- 无已知冲突内容。