Light COMP

From TouchDesigner 088 Wiki

Summary

The Light Components are objects which cast light into a 3D scene. With the light parameters you can control the color, brightness, and atmosphere of geometry lit by the light. A scene can also be viewed through a light's perspective, similar to a camera.

PythonIcon.png lightCOMP_Class

Parameters - Light Page

Light Color /cr /cg /cb - You can modify the color of a light here by adjusting the red, green, and blue parameters. Alternatively, clicking on the color swatch will open a dialog with HSV and/or RGB sliders allowing interactive color picking with a preview of the selected color.

Dimmer /dimmer - This parameter changes the intensity of the light without affecting its hue. Lights with Dimmer intensity below 0.001 are ignored. This optimization allows lights that are set to 0.0 to not be calculated in the scene.

Light Type /lighttype - Specifies the type of light.

  • Point Light - Radiates light equally in all directions.
  • Cone Light - A directional spotlight that uses cone angle, delta, and falloff to control the size and intensity of the light.
  • Distant Light - All light radiates from one direction vector. This can be used to simulate lights at a far-off distance, for example, the sun. The light's position is ignored, only its direction is used.

Cone Angle /coneangle - This specifies the angle within which the light remains at full intensity. Decreasing the cone angle to between ten and forty degrees focuses the beam to spotlight proportions.

Cone Delta /conedelta - This value, in degrees, represents the angle outside the cone angle through which the light intensity drops from its maximum to zero. Beyond this area, no more light is cast.

Objects16.gif

Cone Rolloff /coneroll - This parameter (a value between one and ten) defines how gently or suddenly the amount of light decreases between full intensity and zero intensity within the Cone Delta area.

Distance-Attenuated /attenuation - Turn on this checkbox to enable distance-based attenuation of the light.

Attenuation Start /attenuationstart - The distance from the light source where the light attenuation begins.

Attenuated End /attenuationend - The distance from the light source where the light attenuation ends (i.e., no light radiates beyond this point).

Attenuated Rolloff /attenuationexp - Controls how the light fades off between the Attenuation Start and End points.

Projector Map /projmap - The path to a TOP used for the light's projector map.

Projector Map Mode /projmapmode - Specify how the projection map is applied

  • Simple Horizontal FOV /simplehorzfov - Uses field of view based on the Projector Angle parameter below.
  • Use View Settings /useview - Uses the settings on the View page of parameters.

Projector Angle /projangle - Specifies the cone angle spread of the projector map, similar to how the Cone Angle parameter works for Cone Lights.

Projector Extend /proextend - Sets the extend conditions for the Projector Map texture.

Polygon Front Faces /frontfacelit - Controls how the polygon's normal is used to light the front face of the polygon. For more information refer to the Two-Sided Lighting article.

Polygon Back Faces /backfacelit - Controls how the polygon's normal is used to light the back face of the polygon. For more information refer to the Two-Sided Lighting article.

Parameters - Shadows Page

Shadow Type shadowtype - Sets the type of shadows cast by the light.

  • Off - Shadow casting off.
  • Hard, 2D Mapped - Hard shadows.
  • Soft, 2D Mapped - Soft shadows.
  • Custom - Allows the use of a Custom Shadow Map.

Shadow Casters shadowcasters - The Geometry COMPs that will cast shadows from this light.

Light Size lightsize - Controls the size of the source light when using Soft or Custom shadows.

Max Shadow Softness maxshadowsoftness - Fine tuning for the shadow's software when using Soft or Custom shadows.

Polygon Offset Factor polygonoffsetfactor -

Polygon Offset Units polygonoffsetunits -

Shadow Resolution shadowresolution - The resolution of the shadow's texture map used for the calculation.

Custom Shadow Map shadowmap - The path to a TOP used for the light's shadow map. See also Rendering Shadows.

Parameters - View Page

Projection projection - A pop-up menu lets you choose the projection type.

  • Perspective - Uses a perspective projection.
  • Orthographic - Uses an orthographic projection.
  • Shadow Mapping Projection -
  • Custom Projection Matrix - A projection matrix specified by a CHOP, DAT or in builds 50000 or later a tdu.Matrix().

Aspect Correct Projection aspectcorrect - Keeps the aspect ratio of the view correct when using the light as a camera to look through.

Ortho Width orthowidth - Only active if Orthographic is chosen from the Projection pop-up menu. This specifies the width of the orthographic projection.

Use Cone Angle/Delta for FOV useconeforfov - If the light is set to Cone Light type, enabling this option sets the FOV using the Cone Angle and Cone Delta parameters on the Light parameter page.

Viewing Angle Method viewsanglemethod - This menu determines which method is used to define the camera's angle of view.

  • Horizontal FOV - Uses the FOV Angle parameter below to set the camera's angle of view horizontally.
  • Vertical FOV - Uses the FOV Angle parameter below to set the camera's angle of view vertically.
  • Focal Length and Aperture - Uses the Focal Length and Aperture parameters below to define the camera's angle of view.

FOV Angle fov - The field of view (FOV) angle is the angular extend of the scene imaged by the camera.

Focal Length (in MM) focal - The parameter sets the focal length of the lens, zooming in and out. Perspective is flattened or exaggerated depending on focal length. Some interesting distortion effects can be acheived with this parameter.

Aperture (in MM) aperature - This value relates to the area through which light can pass for the camera.

Near / Far near far - This control allows you to designate the near and far clipping planes. Geometry closer / further away from the lens than these distances will not be visible.

Matrix CHOP/DAT projmatrixop - When Custom Projection Matrix is selected, this parameters should be filled in with either a CHOP or a DAT with a custom 4x4 projection matrix. If a CHOP is used the first sample of the first 16 channels of the CHOP are used to create a 4x4 matrix. The channels can be thought as being read row-by-row or column-by-column. If a DAT is given a 4x4 table should be used. The matrix convention used is column major, which means vectors/points are multiplied on the right of the matrix.

Custom Projection customproj - Takes a DAT containing a GLSL shader to specify custom projection functions. Use this only with the built in MATs or GLSL MATs that are using GLSL version 3.3 or later. You must provide two functions in this shader. Both functions must be provided and return correct results for your rendering to work in all cases. As a starting point, here are the definitions for these functions that are used when custom ones are not provided.

 vec4 TDSOPToProj(vec4 p)
 {
     vec4 projP = uTDMat.worldCamProj * p;
     return projP;
 }
vec4 TDCamToProj(vec4 p) { vec4 projP = uTDMat.proj * p; return projP; }

The other convenience variations of these functions such as vec3 TDCamToProj(vec3 p) will automatically call the correct one of either of the two above functions. You can use uniforms/samplers in this shader code by declaring them here and providing them in the GLSL page of the Render TOP.

Scene Camera scenecamera -

X Bounds xbounds[1-2] -

Y Bounds ybounds[1-2] -

Z Bounds zbounds[1-2] -

Background Color bgcolor[rgba] - Set the background color of the view when using the light as a camera.

Parameters - Xform Page

The Xform parameter page controls the object component's transform in world space.

Transform Order xord - The menu attached to this parameter allows you to specify the order in which the changes to your Component will take place. Changing the Transform order will change where things go much the same way as going a block and turning east gets you to a different place than turning east and then going a block. In matrix math terms, if we use the 'multiply vector on the right' (column vector) convention, a transform order of Scale, Rotate, Translate would be written as translate * rotate * scale * vector.

Rotate Order rord - The rotational matrix presented when you click on this option allows you to set the transform order for the Component's rotations. As with transform order (above), changing the order in which the Component's rotations take place will alter the Component's final position.

Translate / Rotation / Scale t[xyz] r[xyz] s[xyz] - The three fields allow you to specify the amount of movement along any of the three axes; the amount, in degrees, of rotation around any of the three axes; and a non-uniform scaling along the three axes. As an alternative to entering the values directly into these fields, you can modify the values by manipulating the Component in the Viewport with the Select & Transform state.

Pivot p[xyz] - The Pivot point edit fields allow you to define the point about which a Component scales and rotates. Altering the pivot point of a Component produces different results depending on the transformation performed on the Component.

For example, during a scaling operation, if the pivot point of an Component is located at -1, -1, 0 and you wanted to scale the Component by 0.5 (reduce its size by 50%), the Component would scale toward the pivot point and appear to slide down and to the left.

Objects17.gif

In the example above, rotations performed on an Component with different pivot points produce very different results.

Uniform Scale scale - This field allows you to change the size of an Component uniformly along the three axes.

Note: Scaling a camera's channels is not generally recommended. However, should you decide to do so, the rendered output will match the Viewport as closely as possible when scales are involved.

Constrain To constrain - Allows the location of the object to be constrained to any other object whose path is specified in this parameter.

Look At lookat - Allows you to orient your Component by naming the Component you would like it to Look At, or point to. Once you have designated this Component to look at, it will continue to face that Component, even if you move it. This is useful if, for instance, you want a camera to follow another Component's movements. The Look At parameter points the Component in question at the other Component's origin.

Tip: To designate a center of interest for the camera that doesn't appear in your scene, create a Null Component and disable its display flag. Then Parent the Camera to the newly created Null Component, and tell the camera to look at this Component using the Look At parameter. You can direct the attention of the camera by moving the Null Component with the Select state. If you want to see both the camera and the Null Component, enable the Null Component's display flag, and use the Select state in an additional Viewport by clicking one of the icons in the top-right corner of the TouchDesigner window.

Look At Up Vector lookup - When specifying a Look At, it is possible to specify an up vector for the lookat. Without using an up vector, it is possible to get poor animation when the lookat Component passes through the Y axis of the target Component.

  • Don't Use Up Vector - Use this option if the look at Component does not pass through the Y axis of the target Component.
  • Use Up Vector - This precisely defines the rotates on the Component doing the looking. The Up Vector specified should not be parallel to the look at direction. See Up Vector below.
  • Use Quaternions - Quaternions are a mathematical representation of a 3D rotation. This method finds the most efficient means of moving from one point to another on a sphere.

Path SOP pathsop - Names the SOP that functions as the path you want this Component to move along. For instance, you can name an SOP that provides a spline path for the camera to follow.

Production Tip: For Smooth Motion Along a Path - Having a Component follow an animation path is simple. However, when using a NURBS curve as your path, you might notice that the Component speeds up and slows down unexpectedly as it travels along the path. This is usually because the CVs are spaced unevenly. In such a case, use the Resample SOP to redistribute the CVs so that they are evenly spaced along the curve. A caution however - using a Resample SOP can be slow if you have an animating path curve.

An alternative method is to append a Basis SOP to the path curve and change it to a Uniform Curve. This way, your Component will move uniformly down the curve, and there is no need for the Resample SOP and the unnecessary points it generates.

Roll roll - Using the angle control you can specify a Component's rotation as it animates along the path.

Position pos - This parameter lets you specify the Position of the Component along the path. The values you can enter for this parameter range from 0 to 1, where 0 equals the starting point and 1 equals the end point of the path. The value slider allows for values as high as 10 for multiple "passes" along the path.

Orient Along Path pathorient - If this option is selected, the Component will be oriented along the path. The positive Z axis of the Component will be pointing down the path.

Up Vector up - When orienting a Component, the Up Vector is used to determine where the positive Y axis points.

Auto-Bank Factor bank - The Auto-Bank Factor rolls the Component based on the curvature of the path at its current position. To turn off auto-banking, set the bank scale to 0.


Parameters - Pre-Xform Page

The Pre-Xform parameter page applies a transform to the object component before the Xform page's parameters are applied. That is, it is the same as connecting a Null COMP as a parent of this node, and putting same transform parameters in there as you would in the Pre-Xform page. In terms of matrix math, if we use the 'multiply vector on the right' (column vector) convention, the equation would be preXForm * xform * vector.

Xform Matrix/CHOP/DAT xformmatrixop - This parameter can be used to transform using a 4x4 matrix directly. If a CHOP is used, the 16 elements of the matrix are taken from the first 16 channels of the CHOP. It only uses the first sample of each channel. The matrix data is laid out in such as way that the 13th, 14th and 15th channels contain the translation. This can be thought of as either column or row-major conventions, reading the channels column by column or row by row.

If a DAT is used it should be a 4x4 table with the desired matrix values in each cell. The translation should be in the last column, which means it is using the convention of multiplying vectors/points on the right of the matrix (like GLSL does). If you are converting from a Table DAT using a DAT to CHOP, you'll want to use a Transpose DAT to get the channels in the correct order. It applied to the Xform Matrix in the Pre-Xform page of all Object CHOPs and the Projection Matrix in the View page of Lights and Cameras.

A tdu.Matrix can also be directly specified. Example of using a tdu.Matrix:

m = tdu.Matrix()
m.translate(5, 0, 0)
m.rotate(0, 45, 0)
someNode.store(‘xformMat’, m)

and in the node parameter you would put:

me.fetch(‘xformMat’)



Parameters - Render Page

The Display parameter page controls the component's material and rendering settings.

Material material - Selects a MAT to apply to the geometry inside.

Render render - Whether the Component's geometry is visible in the Render TOP. This parameter works in conjunction (logical AND) with the Component's Render Flag.

Draw Priority drawpriority - Determines the order in which the Components are drawn. Smaller values get drawn after (on top of) larger values.

Wireframe Color wcolor - Use the R, G, and B fields to set the Component's color when displayed in wireframe shading mode.


Parameters - Common Page

The Common parameter page sets the component's node viewer, clone relationships, Parent Shortcut, and Global OP Shortcut.

Parent Shortcut parentshortcut - Specifies a name you can use anywhere inside the component as the path to that component. See Parent Shortcut.

Global OP Shortcut opshortcut - Specifies a name you can use anywhere at all as the path to that component. See Global OP Shortcut.

Node View - Determines what is displayed in the node viewer, also known as the Node Viewer. Some options will not be available depending on the Component type (Object Component, Panel Component, Misc.)

  • Geometry Viewer - Shows a 3D geometry viewer displaying the geometry inside the component. This option is only available for Object components.
  • Control Panel - Displays the Control Panel, only available for Panel Components.
  • Operator Viewer - Displays the node viewer from any operator specified in the Operator Viewer parameter below.

Operator Viewer opviewer - Select which operator's node viewer to use when the Node View parameter is set to Operator Viewer.

Enable Cloning enablecloning - Control if the OP should be actively cloned.

Clone Master clone - Path to a component used as the Master Clone. If the component specified as Master exists, then this component becomes a clone.

Load On Demand loadondemand - Loads the component into memory only when required. Good to use for components that are not always used in the project.

External .tox externaltox - Path to a .tox file on disk which will source the component's content upon start of a .toe. This allows for components to contain networks that can be updated independently of the .toe file. Paths used to locate .tox files should not contain expressions or root variables. Built-in and Environment variables (like $MYDOCUMENTS, $DESKTOP and $HOME) are accepted. If the .tox file can not be found, whatever the .toe file was saved with will be loaded.

Reload .tox on Start reloadtoxonstart - When on (default), the external .tox file will be loaded when the .toe starts and the contents of the COMP will match that of the external .tox. This can be turned off to avoid loading from the referenced external .tox on startup if desired (the contents of the COMP are instead loaded from the .toe file). Useful if you wish to have a COMP reference an external .tox but not always load from it unless you specifically push the Re-Init Network parameter button.

Save Backup of External savebackup - When this checkbox is enabled, a backup copy of the component specified by the External .tox parameter is saved in the .toe file. This backup copy will be used if the External .tox can not be found. This may happen if the .tox was renamed, deleted, or the .toe file is running on another computer that is missing component media.

Sub-Component to Load subcompname - When loading from an External .tox file, this option allows you to reach into the .tox and pull out a COMP and make that the top-level COMP, ignoring everything else in the file (except for the contents of that COMP). For example if a .tox file named project1.tox contains project1/geo1, putting geo1 as the Sub-Component to Load, will result in geo1 being loaded in place of the current COMP. If this parameter is blank, it just loads the .tox file normally using the top level COMP in the file.

Re-Init Network reinitnet - This button will re-load from the external .tox file (if present), followed by re-initializing itself from its master, if it's a clone.


Examples

See OP Snippets -> Light COMP for newer versions.

This first example shows a point light, a cone light, and a cone light with delta/rolloff used.

Media:Lights_Basic.tox

This example shows how the attenuation parameters can be used to control how much influence the light has at distances.

Media:Attenuated_Light.tox

This example shows a simple setup with a projector map.

Media:Projection_light.tox