Generating 3D Desktop Wallpapers

• April 05, 2021

Tired of always seeing the same desktop wallpaper, in March of 2020 I set out to program a way to see a new desktop wallpaper every time I looked. I soon discovered how I could use Blender, a 3D graphics engine, with a scripting API to create 3D renderings using only Python.

Using Blender, I attempted to automate the process of creating visually appealing background images. The idea was to use an automated process to create several similar, yet unique images to use in a slideshow as my desktop wallpaper. By using a slideshow of similar images, I was able to create a desktop wallpaper that changed enough to seem new but didn't change so severely as to be a visual distraction.

I soon settled for a design of cubes floating and casting shadows over a three-colour gradient.


An example output image

The 3D structure was fairly straightforward. First, I created a plane with a three-colour gradient using linear interpolation (AKA lerp) for my background. I then generated a variable number of cubes in random positions with colours matching their position over the background gradient. The cubes were placed with a minimum distance between them so there would be no 3D-overlap. The scene was then rendered and ready to be used as a desktop wallpaper.

This process was then repeated a number of times, each time with a new set of cube positions. The images could then be displayed as a slideshow.


Notice the minimum distance between cubes

Having a wallpaper change between two similar images prevents significant visual distraction

Furthermore, the scene was completely customizable with easily adjustable variables controlling gradient colours, number and size of cubes, minimum space between cubes, output resolution, and output image compression.

The settings I used:

# RGB Colors for gradient
COLOR_1 = (78/255, 220/255, 77/255, 1)    # Left
COLOR_2 = (231/255, 55/255, 82/255, 1)    # Middle
COLOR_3 = (50/255, 107/255, 222/255, 1)    # Right

RENDER_COUNT = 150    # Total number of image generations
MAX_CUBE_COUNT = 60     # Total number of cubes
MAX_ITERATIONS = 2500    # Max iterations for cube generation loop
BUFFER = 0.25    # Buffer size around cube
SIZE = 0.8    # Size of cube

# Screen resolution and resolution quality
bpy.context.scene.render.resolution_x = 1920
bpy.context.scene.render.resolution_y = 1080
bpy.context.scene.render.resolution_percentage = 60

Using different colours

More cubes

The source code for this project as well as many rendered images can be found on my Github page.

Content Tags