Node3D
The base spatial node. Every 3D object inherits from Node3D, which provides position, rotation, and scale in 3D space.
position = Vector3(0, 1, -5)
rotation_degrees = Vector3(0, 45, 0)
rotate_y(delta * 1.0) # continuous rotation
look_at(target.global_position, Vector3.UP) # face a target
MeshInstance3D
Renders a 3D mesh. Create primitive meshes in code or import .glb/.gltf models from Blender and other tools.
# Create a mesh from code
var mesh_instance = MeshInstance3D.new()
var box = BoxMesh.new()
box.size = Vector3(1, 1, 1)
mesh_instance.mesh = box
var mat = StandardMaterial3D.new()
mat.albedo_color = Color.FIREBRICK
mesh_instance.set_surface_override_material(0, mat)
add_child(mesh_instance)
Importing .glb/.gltf models:
# Import a 3D model exported from Blender
var scene = preload("res://models/character.glb")
var instance = scene.instantiate()
add_child(instance)
StandardMaterial3D
Godot's PBR material. Controls how surfaces look under lighting with physically-based properties.
| Property |
Range |
Description |
albedo_color |
Color |
Base color / texture |
metallic |
0.0 - 1.0 |
0 = dielectric, 1 = metal |
roughness |
0.0 - 1.0 |
0 = mirror, 1 = matte |
emission |
Color |
Self-illumination (glow) |
normal_enabled |
bool |
Enable normal mapping for surface detail |
transparency |
enum |
ALPHA, ALPHA_SCISSOR, ALPHA_HASH, etc. |
# Full PBR material setup
var mat = StandardMaterial3D.new()
mat.albedo_color = Color(0.8, 0.2, 0.1)
mat.metallic = 0.3
mat.roughness = 0.7
mat.normal_enabled = true
mat.normal_texture = preload("res://textures/brick_normal.png")
mat.emission_enabled = true
mat.emission = Color(1, 0.5, 0)
mat.emission_energy_multiplier = 2.0
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
mat.albedo_color.a = 0.8
Lighting
Three light types cover all common scenarios. Each can cast shadows and be configured for energy, color, and attenuation.
| Light |
Type |
Use Case |
DirectionalLight3D |
Parallel rays |
Sun, moon (infinite distance) |
OmniLight3D |
Point (all directions) |
Bulbs, torches, campfires |
SpotLight3D |
Cone beam |
Flashlights, ceiling fixtures, headlights |
# Directional light (sun)
var sun = DirectionalLight3D.new()
sun.light_energy = 1.2
sun.shadow_enabled = true
sun.rotation_degrees = Vector3(-45, 30, 0)
add_child(sun)
# Omni light (torch)
var torch = OmniLight3D.new()
torch.light_energy = 3.0
torch.light_color = Color(1.0, 0.7, 0.3)
torch.omni_range = 8.0
torch.shadow_enabled = true
add_child(torch)
# Spot light (flashlight)
var flash = SpotLight3D.new()
flash.light_energy = 5.0
flash.spot_range = 20.0
flash.spot_angle = 25.0
flash.shadow_enabled = true
add_child(flash)
WorldEnvironment
Controls the sky, ambient lighting, fog, volumetric effects, and post-processing (glow, SSAO, SSR, tone mapping). Add one to your main scene.
var env = Environment.new()
var sky = Sky.new()
var sky_mat = ProceduralSkyMaterial.new()
sky_mat.sky_top_color = Color(0.1, 0.2, 0.5)
sky.sky_material = sky_mat
env.sky = sky
env.background_mode = Environment.BG_SKY
env.fog_enabled = true
env.glow_enabled = true
$WorldEnvironment.environment = env
CSGShape3D
Constructive Solid Geometry nodes for rapid prototyping. Combine shapes with union, subtraction, and intersection operations.
Prototyping only
CSG shapes have no LOD, no lightmap UV generation, and are more expensive to render than static meshes. Use them for blocking out levels, then replace with proper meshes before shipping.
Camera3D
The viewport camera. Configure FOV, near/far clipping planes, and projection type. The example below implements first-person mouse look.
func _input(event):
if event is InputEventMouseMotion:
rotate_y(-event.relative.x * 0.002)
$Head.rotate_x(-event.relative.y * 0.002)
$Head.rotation.x = clamp($Head.rotation.x, -PI/2, PI/2)
Capture the mouse
Call Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) in _ready() to lock the cursor for FPS controls. Toggle back with MOUSE_MODE_VISIBLE on pause.
GridMap
The 3D equivalent of TileMap. Place 3D mesh tiles in a grid for level building. Uses a MeshLibrary resource.
@onready var grid: GridMap = $GridMap
# Place a cell: position, item_index, orientation
grid.set_cell_item(Vector3i(0, 0, 0), 0)
grid.set_cell_item(Vector3i(1, 0, 0), 0, 4) # rotated
# Convert world position to grid coordinates
var grid_pos = grid.local_to_map(to_local(pos))
ShaderMaterial
Write custom spatial shaders for effects the standard material cannot achieve. Godot's shader language is GLSL-like with built-in engine variables.
# Water wave shader (attach as .gdshader file or inline)
shader_type spatial;
uniform float wave_speed = 1.0;
uniform float wave_height = 0.3;
void vertex() {
VERTEX.y += sin(VERTEX.x * 2.0 + TIME * wave_speed) * wave_height;
}
void fragment() {
ALBEDO = vec3(0.1, 0.4, 0.8);
ROUGHNESS = 0.1;
METALLIC = 0.5;
}
Set shader parameters from GDScript at runtime:
$WaterMesh.material_override.set_shader_parameter("wave_speed", 2.0)