Layers, Nodes, Code Programming - Blending Mode in Video/Photo Editor
This article is a simple explanation of sometimes confusing terminology which is often used in Blender and many other video or photo editors. Certain operations in computers can be defined by programming a code in a specific programming language such as Python, C++ or Java. They can also be represented visually by connecting nodes (Node-based programming) representing operations such as in Compositor or Material Editor in Blender, Visual Scripting in Graph Editor in Unity, or in Blueprint Editor in Unreal Engine. And when talking about video or image editing, there are also layers which can be used to combine imagery together. Below is a simple example of producing exactly the same thing in Blender but in different ways. The task is simple: take two different pictures and compose them over each other with additive blending mode, which means that the pixels are simply added together.
First, it is necessary to load the images to Blender, for example, int the Compositor or Image Editor and to create the resulting image of the same size. The code was run in the Script Editor. Here is the used Python script:
import bpy firstImage = bpy.data.images.get("japanFushimi.jpg").pixels[:] secondImage = bpy.data.images.get("japanTori.jpg").pixels[:] resultImage = bpy.data.images.get("Untitled") # We copy the pixels because the access will be faster resultPixels = list(resultImage.pixels) # Every pixel consists of four values Red, Green, Blue, and Alpha (Transparency) rgbaSize = 4 # Here we assume that all three images are of the same size width = resultImage.size[0] * rgbaSize height = resultImage.size[1] for y in range(1,height): for x in range (1,width): # The image is linear array so we transform the XY to 1D coordinate index = width * y + x # This is the main addition operation for each pixel resultPixels[index] = firstImage[index] + secondImage[index] # Putting back the edited pixels in the resulting image resultImage.pixels[:] = resultPixels resultImage.update()
The goal of this article is to demonstrate what are blending modes, what is the difference between layer or tracks and nodes or graphs, what is the difference between nodes and code programming and how are all these features supported in Blender. This article is a simple practical demonstration of these things.
Published:Keywords: Blender, cinematography, computer science, image composition
#blender #gameengine #nodes #videoediting #imageediting
Privacy Terms