Sub topic 3
Solid-Colour Materials, Scene Building and Rendering
This chapter assumes you have Blender 4.x installed, can add and move objects in Object Mode, and know what vertices, edges and faces are. It finishes the scene from the earlier chapters: a ground plane, a tree, a rock, a light and a camera, then a rendered image.
Solid-colour materials
A material is a set of surface settings, such as colour and shininess, that Blender applies to an object. A solid-colour material uses one flat colour and no textures. This suits the low-poly style because it keeps each face readable.
Each material has a Base Color in its Principled BSDF node and a viewport colour (diffuse_color). Set both so the solid viewport matches the render.
Building the scene: ground, trees and rocks
Add the ground with a plane, the tree with a six-sided trunk and cone, and the rock with a low-subdivision icosphere. Give each object its own material.
import bpy
import math
def make_material(name, rgba):
mat = bpy.data.materials.new(name=name)
mat.use_nodes = True
mat.node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = rgba
mat.diffuse_color = rgba
return mat
# Ground
bpy.ops.mesh.primitive_plane_add(size=12, location=(0, 0, 0))
ground = bpy.context.active_object
ground.name = "Ground"
ground.data.materials.append(make_material("Grass", (0.35, 0.55, 0.2, 1.0)))
# Tree trunk and foliage
bpy.ops.mesh.primitive_cylinder_add(vertices=6, radius=0.2, depth=1.0, location=(3, 0, 0.5))
trunk = bpy.context.active_object
trunk.name = "Trunk"
trunk.data.materials.append(make_material("Bark", (0.36, 0.22, 0.1, 1.0)))
bpy.ops.mesh.primitive_cone_add(vertices=6, radius1=1.0, radius2=0.0, depth=2.0, location=(3, 0, 2.0))
foliage = bpy.context.active_object
foliage.name = "Foliage"
foliage.data.materials.append(make_material("Leaf", (0.1, 0.5, 0.15, 1.0)))
# Rock
bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=1, radius=0.6, location=(-2, 1, 0.3))
rock = bpy.context.active_object
rock.name = "Rock"
rock.data.materials.append(make_material("Stone", (0.45, 0.45, 0.48, 1.0)))
# Sun light
bpy.ops.object.light_add(type='SUN', location=(4, -4, 6))
bpy.context.active_object.data.energy = 3.0
# Camera aimed at the scene
bpy.ops.object.camera_add(location=(7, -7, 5), rotation=(math.radians(63), 0, math.radians(45)))
cam = bpy.context.active_object
bpy.context.scene.camera = cam
# Render and save
bpy.context.scene.render.filepath = "/tmp/lowpoly_scene.png"
bpy.ops.render.render(write_still=True)Lighting and camera
A Sun light gives parallel rays and even shadows, which suits a small scene. The camera's rotation sets its angle. Tilt the X value to look down at the scene, and rotate Z to turn it toward the objects.
Rendering and saving
Rendering writes the image to the path in render.filepath. Choose a folder that exists on your system. On Windows, use a path such as C:/Temp/lowpoly_scene.png.
Optional: building the scene with Python
The script above does every step in one run. It uses bpy.ops calls, which add objects at the current cursor and make each new object active. To rerun the script, delete the old objects first or start a new file.
Exercise
In the script, what does bpy.context.active_object refer to right after bpy.ops.mesh.primitive_plane_add runs, and why does the script store it in a variable?
Show answer
It refers to the newly added plane. The script stores it so it can rename the object and assign a material. Later bpy.ops calls create new objects and change the active object, so the variable keeps the reference to the plane.