Light

DSL supports four types of lights. There are PointLight, RectangleLight, Sunlight, IESspotLight.

Attributes

AttributeTypeDescription
lightTypestrPointLight, RectangleLight, SunLight, IESspotLight
energyfloatThe intensity of light.
colordictThe color of light. The format is {x": 3.4734852, "y": 6.955175, "z": 6.3826585}. It is the normalized rgb multipled by the energy.

Access the attributes of light

example DSL:

class ReadLightDsl(EntityProcessor):
    def process(self):
        # loop all lights
        for light in self.shader.world.lights:
            position = light.position

Function

FunctionDescription
set_attr({attr_name}, **kwargs)modify light attributes. **kwargs is used for attributes of dictionary type, such as position, etc.
_tune_temp(delta)Random adjust color temperature. (delta: weight for tuned color temperature) (1 - delta) * orig + delta * tuned
tune_random(ratio)Random light intensity. 50% probability attenuates according to ratio, 50% probability is uniformly sampled from the interval [0.1, 0.3] to get the attenuation coefficient.
tune_intensity(ratio)Set brightness attenutation. (ratio: brightness adjustment multiple)

Modify the lighting attributes directly

example DSL:

class SetLightDsl(EntityProcessor):
    def process(self):
        for light in self.shader.world.lights:
            # set light attr
            light.set_attr('position', x=100, y=0, z=1000)

The overall light intensity adjustment of the scene

There are two built-in function of EntityProcessor which can tune intensity of all lights.

FunctionDescription
tune_brightness__all_lights(ratio)adjust the brightness of all lights in the scene(ratio: brightness adjustment multiple)
tune_brightness__sunlight(ratio)adjust the multiple of natural light and turn off other light sources. (ratio: brightness adjustment multiple)

Example of use:

class TuneLights(EntityProcessor):
    def process(self, *args, **kwargs):
        self.tune_brightness__all_lights(0.8)

Domain randomization - Light Sampler

Example DSL:

class LightsSampler(EntityProcessor):
    def process(self, *args, **kwargs):
        for light in self.shader.world.lights:
            # Adjust the color temperature randomly
            light._tune_temp(1)
            # Adjust the light intensity randomly
            light.tune_random(0.5)
            # Use lower light intensity
            light.tune_intensity(0.8)

light_sampler