godot-3d-essentials
它能做什么
该技能指导在 Godot 中搭建基础 3D 场景,包括摄像机、灯光、环境和材质。适合开始制作 3D 关卡,或修复渲染出来是黑色、看起来很平淡的场景的 Godot 开发者。
适用场景
- ✓当你开始在 Godot 中制作 3D 场景,需要摄像机和灯光时。
- ✓当 Godot 3D 场景渲染为黑色或缺少环境光时。
- ✓当你想用网格地图搭建基于瓦片的 3D 关卡时。
技能链接
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-3d-essentials/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我正在 Godot 4.7 中开始制作一个 3D 关卡。你能设置摄像机、太阳光、天空,以及一个立方体上的基础材质吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会放置 Camera3D 并将其设为当前摄像机,添加方向光,并设置带有天空和环境光的 WorldEnvironment。然后它会为网格分配材质,并在适当的地方用网格地图搭建关卡。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Godot 3D Essentials (4.x)
Assemble a working 3D scene: transforms, camera, lights, environment/post, materials, and
GridMap blockouts. Targets Godot 4.7.
When to use
- Use when starting or fixing a 3D scene: positioning a
Camera3D, adding lights, setting up aWorldEnvironment(sky, ambient, tonemap, glow/SSAO), assigning materials, or building levels withGridMap.
When not to use: writing spatial shaders → godot-shaders; 3D physics bodies and
raycasts → godot-physics; character animation blending → godot-animation; full FPS
template → the fps-shooter genre skill.
Core workflow
- Everything 3D is a
Node3Dwith aTransform3D(position, rotation basis, scale). Move withglobal_position, rotate withrotate_y(angle)orlook_at(target). - Add a
Camera3D. Mark itcurrent(or callmake_current()); setfov,near,far. Parent it to a rig/pivot for orbit or follow cameras. - Light the scene. A
DirectionalLight3Dis the sun;OmniLight3D/SpotLight3Dare local;AreaLight3D(4.7+) is a rectangular panel light that costs more than omni/spot. Enable shadows per light. Without lights and ambient, surfaces render black. - Add a
WorldEnvironmentwith anEnvironmentresource: background (sky/color), ambient light, tonemap, and post (glow, SSAO, fog, adjustments). - Give meshes materials (
StandardMaterial3Dor aShaderMaterial) onMeshInstance3D. - Block out levels with
GridMap, which placesMeshLibraryitems on a 3D grid (the 3D analog of a tilemap).
Patterns
1. A follow camera (third-person, smoothed)
extends Camera3D
@export var target: Node3D
@export var offset := Vector3(0, 4, 8)
@export var smooth := 6.0
func _physics_process(delta: float) -> void:
if target == null:
return
var desired := target.global_position + offset
global_position = global_position.lerp(desired, smooth * delta) # smooth follow
look_at(target.global_position, Vector3.UP) # face the target
2. Sun + environment in code
func _ready() -> void:
var sun := DirectionalLight3D.new()
sun.rotation_degrees = Vector3(-45, -30, 0)
sun.shadow_enabled = true
add_child(sun)
var we := WorldEnvironment.new()
var env := Environment.new()
env.background_mode = Environment.BG_SKY
env.sky = Sky.new()
env.sky.sky_material = ProceduralSkyMaterial.new()
env.ambient_light_source = Environment.AMBIENT_SOURCE_SKY
env.tonemap_mode = Environment.TONE_MAPPER_FILMIC
env.glow_enabled = true
we.environment = env
add_child(we)
3. Assign a StandardMaterial3D from code
func tint_mesh(mesh: MeshInstance3D, color: Color) -> void:
var mat := StandardMaterial3D.new()
mat.albedo_color = color
mat.metallic = 0.0
mat.roughness = 0.6
mat.emission_enabled = true
mat.emission = color * 0.3
mesh.material_override = mat # overrides the mesh's surface materials
4. Place tiles into a GridMap
@onready var grid: GridMap = $GridMap # cell_size + mesh_library set in the editor
func build_floor(width: int, depth: int, item_id: int) -> void:
for x in width:
for z in depth:
# set_cell_item(Vector3i cell, int item, orientation = 0)
grid.set_cell_item(Vector3i(x, 0, z), item_id)
Pitfalls
- Scene renders black → no lights and no ambient. Add a
DirectionalLight3Dand/or aWorldEnvironmentwith ambient/sky. New scenes have neither by default. - No camera / wrong camera. If nothing shows, no
Camera3Discurrent. Setcurrent = trueormake_current(); only one camera renders per viewport. - Confusing local vs global transforms.
position/rotationare relative to the parent;global_position/global_transformare world space. Mixing them under a rotated parent gives surprising results.look_atuses global coordinates. - Scaling physics/lights. Non-uniform
scaleon aNode3Ddistorts child collisions and lights; prefer scaling the mesh asset or using uniform scale. look_atdoes nothing and prints an error → the target equals the node's position, theupvector is parallel to the look direction (e.g. looking straight down withVector3.UP), or the node is not in the tree yet. Keep an offset, pass a differentup, or uselook_at_from_position()before the nod
常见问题
为什么我的 3D 场景是黑的?
该技能指出,表面需要光源和环境光,否则会渲染为黑色。
什么是 AreaLight3D?
该技能提到,它是 Godot 4.7 中的矩形面板光源,比全向光或聚光灯的开销更大。
它涵盖 3D 物理吗?
不涵盖。3D 物理刚体和射线检测由 Godot 物理技能涵盖。
详情
作者的原始描述
Set up a Godot 4.7 3D scene: Node3D transforms, Camera3D, lighting (DirectionalLight3D/OmniLight3D), WorldEnvironment for sky/ambient/tonemap/post, MeshInstance3D materials, and GridMap for tile-based 3D levels. Use when building a 3D scene in a Godot project, placing cameras/lights, configuring environment and post-processing, or working with Node3D/.tscn 3D content and GridMap.
热度
- GitHub 星标
- 6.6k
- 排名
- #13817
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/28
评论
- …