Files
nexus/wiki/sources/godot-shader-developer.md
2026-04-26 12:02:53 +08:00

4.0 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-04-26

Source File

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 参数必须附带 hinthint_rangesource_colorhint_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 ShaderGodot 2D/UI 着色器类型,使用 shader_type canvas_item,通过 TEXTUREUVCOLOR 内置变量操作精灵和 UI 效果
  • Spatial ShaderGodot 3D 世界着色器类型,使用 shader_type spatial,通过 ALBEDOMETALLICROUGHNESSNORMAL_MAP 输出变量控制 PBR 材质
  • VisualShaderGodot 图形化着色器编辑器,将 GLSL 节点化支持艺术家快速搭建材质变体Group 和 Comment 节点用于组织复杂图
  • CompositorEffectGodot 4 Forward+ 渲染器的全屏后处理扩展点,通过 GDScript extends CompositorEffect 实现自定义后处理 Pass
  • Forward+ RendererGodot 4 高端渲染器,支持 DEPTH_TEXTURESCREEN_TEXTURENORMAL_ROUGHNESS_TEXTURE 全部特性
  • Mobile RendererGodot 4 中端渲染器,避免 discard 使用,优先 Alpha Scissor纹理采样预算严格
  • Compatibility RendererGodot 4 最广泛支持渲染器,无 compute shader、无 DEPTH_TEXTURE canvas 采样、无 HDR 纹理

Key Entities

  • GodotJuan Linietsky 和 Ariel Manzur 主导的开源游戏引擎Godot 4 引入了 Forward+ 渲染器和重构的着色语言
  • GLSLOpenGL 着色语言Godot 着色语言基于 GLSL 但有自己的内置变量和 APItexture() vs texture2D()

Connections

Contradictions

  • 无已知冲突内容。