jit.gl.light Reference

Place a light source in a 3D scene

jit.gl.light

Description

Contains the properties needed to define a light source in OpenGL. These include light type (directional, point and spot), light color, attenuation, and spot angle and falloff. In addition a position (for point and spot) and orientation (for directional and spot) can be defined for a virtual light in 3D space.

Examples

Discussion

Multiple jit.gl.light objects can be added to a scene, up to a maximum that is specific to your graphics card.
The actual appearance of 3D objects is a combination of the material properties of that object, and the color values of the jit.gl.light objects in the scene. The possible color values are ambient, diffuse and specular. For more information, see chapter 5 of the OpenGl Redbook. This object requires one argument: the name of a drawing context. A named drawing context is a named instance of a jit.window, jit.pwindow, or jit.matrix object that has an instance of the jit.gl.render object associated with it. Additionally it can reference the name of a jit.gl.node sub-context. This value may also be set via the OB3D drawto attribute. If no argument is present, the object is implicitly added to the first valid drawing context or sub-context found in the current patch or by searching up the patcher hierarchy.

Attributes

ambient [4 floats]

The color and opacity of the ambient light component in the form red green blue opacity (default = 0. 0. 0. 1. (opaque black)) All values should be in the range 0.-1.

atten_const [float]

The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation. The attenuation parameters determine how the light source diminishes with distance.

atten_linear [float]

The linear factor in the attenuation formula: 1 means attenuate evenly over the distance. The attenuation parameters determine how the light source diminishes with distance.

atten_quad [float]

The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula. The attenuation parameters determine how the light source diminishes with distance.

diffuse [4 floats]

The color and opacity of the diffuse light component in the form red green blue opacity (default = 1. 1. 1. 1. (opaque white)) All values should be in the range 0.-1.

direction [3 floats]

Sets the direction the light points. Only applies to directional and spot lights.

lookat [3 floats]

One way to set the orientation. The light will orient so that it's local Z points to the 3D position provided. (default = 0 0 0)

shadowblur [float]7.0.0

Shadow blur amount (default = 0.2). Indicates the width of a gaussian blur performed on the shadow output texture.

shadowquality [symbol]7.0.0

Shadow texture quality (default = med). Setting this value affects the dim and type of the internal jit.gl.texture shadow target.

Possible values:

'lo' ( type=float16, dim=512 )
'med-lo' ( type=float16, dim=1024 )
'med' ( type=float32, dim=1024 )
'med-hi' ( type=float32, dim=2048 )
'hi' ( type=float32, dim=4096 )

shadowrange [float]7.0.0

Shadow range value (default = 50.0). For directional lights, this represents the the maximum distance a shadow-caster can be from shadow-receiver. For spot/point lights the maximum range a light will affect other objects. Setting this as low as possible in the scene generally gives better shadow results.

shadows [int]7.0.0

Enable shadow casting from this light (default = 0).

shadowtexoutname [symbol]7.0.0

g/s(get)

The internal shadow texture output name.

specular [4 floats]

Color and opacity of specular light component (default = 1. 1. 1. 1. (opaque white)) The first three floats in the range 0.-1. specify the RGB components of the specular light color. The fourth float (also in the range 0.-1.) specifies opacity.

spot_angle [float]

Defines the cone angle for spot type lights (default = 90)

spot_falloff [float]

Defines the rate of falloff of the light from the center, to the edges of the cone (default = 0). Only applies to spot type lights.

type [symbol]

Light type

Possible values:

'point'
'directional'
'spot'

viewproj_matrix [symbol]7.0.0

g/s(get)

Shadow camera current view-projection matrix

Common Box Attributes

OB3D Attributes

Messages

sendoutput

Send the shadow output texture a message

OB3D Messages

See Also

Name Description
Working with OpenGL Working with OpenGL
jit.gl.render
jit.gl.sketch
jit.gl.material