Skip to content
tobspr edited this page Jan 9, 2016 · 26 revisions

Creating and adding Lights

To create a light, you have to import the light classes. You can do this by doing from RenderPipeline import SpotLight or if you are in the same directory: from render_pipeline_importer import SpotLight.

After doing that, you should create an instance of your light and set the desired properties (see below):

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

Light types

There are several light types in the Pipeline. All lights share some properties:

light.position
light.color
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. Notice you can use colors way over 1.0, for example (7.0,6.0,6.5).

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