

How to create a Camera in Blender using Python You can find more information in the Blender documentation: There are more types of light source, like for example a SPOT and an AREA. In this case, the intensity of the light source is not measured in watts, but instead, its measured in watts per meter squared, but the property name is still called energy: =200Įven though we are using the same energy value as the POINT light source, the SUN light source is much more powerful. If you want a more powerful light, similar to the sun, instead of creating a light as of type POINT, we create a light as type SUN: light_data = ('light', type='SUN') To control the power of the light source, we set the intensity in watts: =200.0 The light source is of type POINT, which is similar to artificial light. To see how powerful this light source is in Blender, we can render it:Īs you can see our light source is not that powerful. Let’s change its location: light.location = (3, 4, -5)
#Blender 3d render code#
The code above creates a light source, but where is it?īy default, the light source is in the origin, so it’s inside the cube! To create a light source: light_data = ('light', type='POINT') Without a light source, when rendering in Blender, everything will be dark. In order to render a scene, we need a light source. There is definitely value in learning how to use this function for more complex meshes of your own design. You can always do it the hard way, by specifying the vertices and faces of the cube using the from_pydata function. To create a cube there is more than one way of doing it. I know that Blender already comes with a default cube, but since we want to learn Blender, better delete it, and create our own cube, right? To be able to use the Blender Python API you always need to import the bpy python library: import bpy Creating a cube the hard way And Then click New Importing bpy Python package

The first thing to do is to open Blender and click on the scripting tab. Then I will show you how you can rotate a virtual camera around a cube and use it to render from 3D to 2D from different viewpoints using the Blender API. We will create a simple scene with a plane, a cube, texture, a light source, and a camera. In this article, I will show you how you can create a scene in Blender, using the Python 2.93 Blender API.
