EnvLight

Overview

EnvLight is one of Moonray’s two light types that model a light source at infinity, and was designed to make it easy to represent illumination by the sky or similar distant distributed sources which benefit from having a user-defined texture assigned.

When a texture is applied using the texture attribute, the light’s local z-axis is used to define the poles of the sphere, with the texture u-coordinate determining the longitude and the v-coordinate the latitude.

If the sample_upper_hemisphere_only attribute is set to true, only the hemisphere centered around the positive local z-axis emits light.


Attribute Reference

Map attributes

contrast

Rgb
default: [ 1, 1, 1 ]

Per-channel contrast used in color-correcting the light's texture, if one is present. The operation mimics Nuke's ColorCorrect node's contrast function:
For input > 0, output = 0.18 * pow(inputCompnent/0.18, contrast).
For input <= 0, output = 0.18 * input * pow(1/0.18, contrast).

gain

Rgb
default: [ 1, 1, 1 ]

Per-channel gain used in tandem with a per-channel offset for color-correcting the light's texture, if one is present. This is achieved by applying the following formula for each channel:
output = input * gain + offset

gamma

Rgb
default: [ 1, 1, 1 ]

Per-channel gamma used in color-correcting the light's texture, if one is present. This is achieved by applying the following formula for each channel:
For input > 0, output = pow(input, gamma)
For input <= 0, output = input

offset

Rgb
default: [ 0, 0, 0 ]

Per-channel offset used in tandem with a per-channel gain for color-correcting the light's texture, if one is present. This is achieved by applying the following formula for each channel:
output = input * gain + offset

sample_upper_hemisphere_only

Bool
default: False

Set this to true if you want the EnvLight to illuminate from only the "upper" hemisphere, defined as the hemisphere centered around the light's positive local z-axis direction.

saturation

Rgb
default: [ 1, 1, 1 ]

Per-channel saturation used in color-correcting the light's texture, if one is present. This is achieved by applying the following formula for each channel:
output = lerp(luminance(inputRGB), input, saturation).

temperature

Vec3f
default: [ 0, 0, 0 ]

Color temperature using Nuke-style T/M/I settings (T = temperature, M = magenta/green, I = intensity). This is achieved as follows:
The 3-channel temperature is interpreted as the vector (T,M,I). The followiong scale values are then applied to the RGB components:
outputR = inputR * (pow(2,I) + M/3 - T/2)
outputG = inputG * (pow(2,I) - 2*M/3
outputB = inputB * (pow(2,I) + M/3 + T/2)

texture

String filename
default:

File name of the texture applied to the light. If set to the empty string, no texture is applied. Any file format supported by OpenImageIO can be used. The texture is used in 2 ways - for looking up the texture value at the intersection point when a ray hits the light, and for building a lookup-table-based auxilliary data structure used for distributing light samples over the texture.

texture_border_color

Rgb
default: [ 1, 1, 1 ]

RGB value used when a texture lookup occurs outside the texture.

texture_coverage

Vec2f
default: [ 1, 1 ]

Texture scales in the u and v-directions.

texture_mirror_u

Bool
default: False

Whether to mirror the texture in the u-direction. If set to false, the texture is repeated in the u-direction.

texture_mirror_v

Bool
default: False

Whether to mirror the texture in the v-direction. If set to false, the texture is repeated in the v-direction.

texture_reps_u

Float
default: 1.0

Number of times texture repeats in u over the scaled texture space.

texture_reps_v

Float
default: 1.0

Number of times texture repeats in v over the scaled texture space.

texture_rotation

Float
default: 0.0

Clockwise rotation angle in degrees.

texture_translation

Vec2f
default: [ 0, 0 ]

Translation of the texture in (u,v)-space, in units of the texture size. For example, a translation of (0.25, 0.5) will translate the texture one-quarter of its width in the u-direction and one-half of its height in the v-direction.

Properties attributes

color

Rgb
default: [ 1, 1, 1 ]

The light's RGB values.
These are combined multiplicatively with the intensity and other attributes in determining the light's 3-channel radiance.

exposure

Float
default: 0.0

The light's exposure value.
This value provides an alternative to the intensity value as a mechanism for controlling the light's overall brightness, and is inspired by the corresponding photographic term but is generalised to apply independently to each light. To calculate its effect, pow(2, exposure) is combined multiplicatively with the color and other attributes in determining the light's 3-channel radiance.

intensity

Float
default: 1.0

The light's intensity.
This is combined multiplicatively with the color and other attributes in determining the light's 3-channel radiance.

label

String
default:

Label used in light aov expressions.

max_shadow_distance

Float
default: 0.0

The distance from the light beyond which a light-receiving surface will no longer receive shadows cast from that light.
Note that the distance is thresholded for each occlusion ray cast for this light, it is possible for a receiving point to lie at an intermediate distance such that some parts of the light are closer than the threshold distance and other parts beyond it, in which case the point will appearto be in partial shadow.

mb

Bool
default: False

Whether motion-blur is active for this light. When set to true, the scene's illumination will correctly account for any blur() applied to the light's transformation matrix.

on

Bool
default: True

Whether the light is switched on.

presence_shadows

Int enum
  0 = “force off”
  1 = “force on”
  2 = “use default” (default)

Switch this attribute on for shadows cast from this light to correctly respect presence values. When off, surfaces with a material with presence less than 1.0 will cast opaque shadows from this light. This is an optimization - when the attribute is off, occlusion rays (fast) are used for testing for shadows. When it is on, regular rays (slower) are used, and the material's presence is evaluated to determine how much shadowing should occur. When set to "use default" it reads from the value of SceneVariable enable_presence_shadows.

ray_termination

Bool
default: False

Whether the light is used for ray termination color. Ray termination color is used for filling in falsely dark areas where ray paths have been terminated too early by the depth controls. Such a ray path immediately exits to any ray termination light(s) present in the light set being applied to the lobe, ignoring occlusion by scene geometry. Any light can either be a regular light or a ray termination light (but not both). Thus they can be freely assigned to light sets, which provides a mechanism for applying specific ray termination lights to specific materials, parts or objects. Ray termination color is only applied to non-hair transmission lobes.

texture_filter

Int enum
  0 = “nearest neighbor” (default)
  1 = “bilinear”
  2 = “nearest neighbor with nearest mip”
  3 = “bilinear with nearest mip”

The filtering mode to apply to the texture. Nearest neighbor is the cheapest filtering mode but produces a blocky result. Switch linear filtering on for a smoother result. Additionally, mip-mapping can be switched on with either nearest neighbor or linear filtering.

visible_in_camera

Int enum
  0 = “force off”
  1 = “force on”
  2 = “use default” (default)

Whether the light is directly visible in the scene's active camera. When set to "use default" it reads from the value of SceneVariable lights_visible_in_camera.

Visibility Flags attributes

visible_diffuse_reflection

Bool
default: True

Whether the light is visible in diffuse reflection.

visible_diffuse_transmission

Bool
default: True

Whether the light is visible in diffuse transmission.

visible_glossy_reflection

Bool
default: True

Whether the light is visible in glossy reflection.

visible_glossy_transmission

Bool
default: True

Whether the light is visible in glossy transmission (refraction).

visible_mirror_reflection

Bool
default: True

Whether the light is visible in miror reflection.

visible_mirror_transmission

Bool
default: True

Whether the light is visible in miror transmission (refraction).

General attributes

light_filters

SceneObject Vector
default: {}

Vector of LightFilters associated with the light.

node_xform

Mat4d blurrable
default: [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ]

The 4x4 matrix describing the transformation from local space to world space.


Examples

EnvLight("/lights/env") {
    ["node_xform"] = Mat4(-0.459297, 0, 0.888282, 0, 0.742928, 0.548173, 0.38414, 0, -0.486933, 0.836364, -0.251775, 0, 0, 0, 0, 1),
    ["intensity"] = 2.0,
    ["color"] = Rgb(0.5, 0.8, 1.0),
    ["sample_upper_hemisphere_only"] = false,
    ["texture"] = "/path/texture.exr",
}