跳到正文
Skillpedia
通用编程6.6k · #13817

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-3d-essentials/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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 a WorldEnvironment (sky, ambient, tonemap, glow/SSAO), assigning materials, or building levels with GridMap.

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

  1. Everything 3D is a Node3D with a Transform3D (position, rotation basis, scale). Move with global_position, rotate with rotate_y(angle) or look_at(target).
  2. Add a Camera3D. Mark it current (or call make_current()); set fov, near, far. Parent it to a rig/pivot for orbit or follow cameras.
  3. Light the scene. A DirectionalLight3D is the sun; OmniLight3D/SpotLight3D are 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.
  4. Add a WorldEnvironment with an Environment resource: background (sky/color), ambient light, tonemap, and post (glow, SSAO, fog, adjustments).
  5. Give meshes materials (StandardMaterial3D or a ShaderMaterial) on MeshInstance3D.
  6. Block out levels with GridMap, which places MeshLibrary items 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 DirectionalLight3D and/or a WorldEnvironment with ambient/sky. New scenes have neither by default.
  • No camera / wrong camera. If nothing shows, no Camera3D is current. Set current = true or make_current(); only one camera renders per viewport.
  • Confusing local vs global transforms. position/rotation are relative to the parent; global_position/global_transform are world space. Mixing them under a rotated parent gives surprising results. look_at uses global coordinates.
  • Scaling physics/lights. Non-uniform scale on a Node3D distorts child collisions and lights; prefer scaling the mesh asset or using uniform scale.
  • look_at does nothing and prints an error → the target equals the node's position, the up vector is parallel to the look direction (e.g. looking straight down with Vector3.UP), or the node is not in the tree yet. Keep an offset, pass a different up, or use look_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.

repo: gamedev-skills/awesome-gamedev-agent-skills

热度

GitHub 星标
6.6k
排名
#13817
许可证
Apache-2.0
更新时间
2026/10/28

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能