Blender (software)

From David's Wiki
\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

Blender is an open-source 3D modelling software.
It can be used for creating 3D models for games, creating 2D/3D animations, and even creating video games.

Getting Started



Direct Download
From chocolatey:

choco install blender

Blender is available on the Snap store

sudo snap install blender --classic


Geometry Nodes

Blender Manual Geometry Nodes

Geometry nodes allow you to procedurally modify the geometry of the object.
Some things it can do include instancing of objects, moving vertices, and arithmetic.
Note that Geometry nodes are available in Blender 2.92+ with some nodes introduced in 2.93 LTS.

See some references:

Materials and Shaders

Blender uses a node system for shader which let you composite different textures and BSDFS.

Bypass BSDF

If you wish to use a raw colors from a texture, bypassing materials altogether, you can directly attach a image texture node output to the material output.
For transparent textures, you will need a transparent BSDF node and a mix node with alpha connected to mix.outputs["Fac"] to achieve transparency.


Rendering and Compositing

Press F12 to render.


  1. In the view layer properties, check Denoising Data
  2. Switch to the compositor layout.
  3. Add a denoise node, under filter.
  4. Attach the denoising normal, denoising albedo, and denoising depth.


Blender Python API

Getting Started

Blender supports scripting as an alternative means of interaction. Most things are available in the bpy module.

See one of the following resources to get started:


vertices = [(-1, -1, 0), (1, -1, 0),
            (-1, 1, 0), (1, 1, 0)]
edges = [(0,1), (1,2), (2,3), (3,0)]
faces = [(0,1,2), (1,2,3)]
uvs = [(0, 0), (1, 0),
       (0, 1), (1, 1)]

# Create a new mesh
new_mesh =
new_mesh.from_pydata(vertices, edges, faces)

# Add UVs
uv_layer =
for face in new_mesh.polygons:
  for vert_idx, loop_idx in zip(face.vertices, face.loop_indices):[loop_idx].uv = uvs[vert_idx]


# Create a new material
my_material ="My New Material")
my_material.use_nodes = True

# Add material to an object


# Add an image
image_bpy ="my_image", width=width, height=height, alpha=(channels==4), float_buffer=False)
image_bpy.pixels = np.flipud(image_np).ravel()
image_tex_node ="ShaderNodeTexImage")
image_tex_node.image = image_bpy['Color'], my_bsdf.inputs['Base Color'])

Saving scripts outside

See using external ide and run external scripts.

By default, everything is stored in the .blend file including your custom scripts. If you want to store your scripts outside or use another IDE, you will need to have the script inside Blender call the script outside:

import bpy
filepath = bpy.path.abspath("//")
exec(compile(open(filepath).read(), filename, 'exec'))


def render_to_file(filepath, width, height):
    # Set device to GPU
    bpy.context.scene.cycles.device = "GPU"
    # Set resolution
    bpy.context.scene.render.resolution_x = width
    bpy.context.scene.render.resolution_y = height
    bpy.context.scene.render.resolution_percentage = 100
    # Set output file path
    bpy.context.scene.render.filepath = filepath
    # Do render

MVP matrices

Example python code

# Model matrix

# View matrix

# Projection matrix
projection_matrix =
     bpy.context.evaluated_depsgraph_get(), x=WIDTH, y=HEIGHT)

Python Modules

To add modules, install them using pip to the scripts/modules directory of your Blender install:

python3.9 -m pip install -t=scripts/modules $MODULE
  • If you installed blender using snap, you will need to create another scripts directory somewhere else.

Compiling Blender


Note that Blender has a github mirror which may be faster to clone.