Record TLightInstance

Hierarchy
Properties

Unit

Declaration

type TLightInstance = record

Description

Light source instance in the scene. References VRML/X3D light source node (see Node), and keeps track of light source transformation in the 3D world. For the sake of speed also stores a couple of light's properties already multiplied by the transformation.

This record may be initialized only by TAbstractLightNode.CreateLightInstance. Update it (when transform changes) by TAbstractLightNode.UpdateLightInstance.

Overview

Fields

Public Node: TAbstractLightNode;
Public Transform: TMatrix4;
Public TransformScale: Single;
Public Location: TVector3;
Public Direction: TVector3;
Public Radius: Single;
Public WorldCoordinates: boolean;

Methods

Public function Position: TVector4;
Public function Contribution( const Point: TVector3; const PointPlaneNormal: TVector3; State: TX3DGraphTraverseState; const CamPosition: TVector3; const MainTextureColor: TCastleColorRGB): TVector3;

Description

Fields

Public Node: TAbstractLightNode;

This item has no description.

Public Transform: TMatrix4;

This item has no description.

Public TransformScale: Single;

This item has no description.

Public Location: TVector3;

Light location, already transformed by the Transform matrix. For TAbstractPositionalLightNode lights.

Public Direction: TVector3;

Light direction, already normalized and transformed by the Transform matrix. For spot and directional lights.

Public Radius: Single;

Light radius, already transformed by the Transform matrix. For lights with radius (positional lights in VRML >= 2.0, that is TAbstractPositionalLightNode with HasRadius = true).

Public WorldCoordinates: boolean;

Are light location, direction (in this class and inside Node fields) expressed in world coordinates. If not, they are expressed in scene coordinates.

This matters if you render the scene using TCastleScene, and transform it (by wrapping it in TCastleTransform, or by directly changing TCastleScene transformation properties inherited from TCastleTransform). By default (WorldCoordinates = false) we assume that light is defined in scene space, so it will be transformed by the whole modelview matrix (camera matrix with scene transformations). When this is true, during rendering we take care to transform this light only by camera matrix (not additional scene transformation).

Methods

Public function Position: TVector4;

Position expressed in homogeneous coordinates. For positional lights, the last component is always 1. For directional lights, the last component is always 0.

Public function Contribution( const Point: TVector3; const PointPlaneNormal: TVector3; State: TX3DGraphTraverseState; const CamPosition: TVector3; const MainTextureColor: TCastleColorRGB): TVector3;

Light contribution to the specified vertex color. This can be used by software renderers (ray-tracers etc.) to calculate pixel color following VRML/X3D specifications. TX3DGraphTraverseState.Emission should be added to TLightInstance.Contribution (for each light), and resulting color should be processed by TFogNode.ApplyFog.

We do not clamp color components to (0, 1). This would be a waste of time, you should clamp only at the end (or never). This also allows to multiply / accumulate values outside of the (0, 1) range during calculations. OpenGL also clamps only at the end.

MainTextureColor is color of the "main" texture. See TAppearanceNode.MainTexture for definition what is this texture.


Generated by PasDoc 0.16.0-snapshot.