Skip to content
tobspr edited this page Apr 18, 2016 · 26 revisions

The render pipeline supports various types of lights.

Creating Lights

In Python

To create a light, you have to import the light classes. You can do this by doing from rpcore import SpotLight After doing that, you should create an instance of your light and set the light properties:

from rpcore import PointLight
my_light = PointLight()
# set desired properties, see below
self.render_pipeline.add_light(my_light)

In Blender

To create lights in blender, just use blenders builtin lamps. E.g. hit space, then enter Add lamp, then select Point for example. You should see a Physically Based Shading Properties panel if you installed the BAM exporter.

Notice: Make sure you call render_pipeline.prepare_scene(my_model) after loading your scene, so that the render pipeline is aware of your lights.

Light types

There are several light types in the Pipeline. All lights share some properties (explanation see below):

light.pos
light.color
light.energy
light.ies_profile
light.casts_shadows
light.shadow_map_resolution
light.near_plane

# Convenience functions:
light.set_color_from_temperature(temperature_in_kelvin)

To get or set properties, just modify them like you would do with a regular python object, for example:

light.near_plane = 2.0
light.color = (0.2, 0.6, 1.0)
light.casts_shadows = True
light.position += Vec3(0, 0, 1)
...

Light position

The light position specifies the lights position in world space. (TODO: Add support for lights attached to node paths).

Light color

The light color controls the appearance of the light. A value of (1.0, 1.0, 1.0) means plain white. The color will be normalized. In order to controll the brightness of your lights, see lumens.

You can also set a color from a given color temperature in Kelvin, which is more physically correct. You should see the 04-Lights sample for detailed information. Kelvin usually ranges from 2,000 to 20,000, whereas lower values produce more reddish colors:

Energy

The energy of the light control its brightness. It is typically in the range 0.5 - 2000.0, and heavily depends on the environment.

IES Profile

See [IES Profiles](IES Profiles).

Shadows

To enable shadows on the light, use light.casts_shadows = True. You can control the resolution of the shadow map with light.shadow_map_resolution = resolution. To avoid artifacts from objects which are very close to the light, you can set the near plane with light.near_plane = near_plane. This behaves like on a regular camera lens.

Light Types

PointLight

This is a radial light positioned at a point. Point Lights have an additional radius and inner radius property, which can be set with:

point_light.radius
point_light.inner_radius

The radius controls the maximum distance in world space, which the light affects. The inner radius controls the size of the light, for point lights this is 0.0, but if you want to have area spherical lights, set this to a value greater than zero.

SpotLight

This is a light with a direction and angle, behaving like a camera, or a flashlight. The radius controls the maximum distance after which the influence of the light gets zero. The direction is the forward vector of the light. The FoV just behaves like the FoV on a camera. You can set the properties with:

spot_light.radius
spot_light.fov
spot_light.direction

# Helper functions for setting the direction:
spot_light.look_at(Vec3 position)
spot_light.look_at(float x, float y, float z)

More light types will follow