Castle Game Engine: X3DNodes: Object TLightInstance

# Object TLightInstance
Description | Hierarchy | Fields | Methods | Properties
## Unit X3DNodes ## Declaration `type TLightInstance = object(TObject)` ## 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. ## Hierarchy TObject TLightInstance ## Overview ### Fields
| `Node: TAbstractLightNode;`
| `Transform: TMatrix4Single;`
| `TransformScale: Single;`
| `Location: TVector3Single;`
| `Direction: TVector3Single;`
| `Radius: Single;`
| `WorldCoordinates: boolean;`
### Methods
| `function Contribution( const Point: TVector3Single; const PointPlaneNormal: TVector4Single; State: TX3DGraphTraverseState; const CamPosition: TVector3Single): TVector3Single;`
| `function ContributionCameraIndependent( const Point, PointPlaneNormal, MaterialDiffuseColor: TVector3Single): TVector3Single;`
## Description ### Fields
| `Node: TAbstractLightNode;`
| `Transform: TMatrix4Single;`
| `TransformScale: Single;`
| `Location: TVector3Single;`
Light location, already transformed by the Transform matrix. For TAbstractPositionalLightNode lights.
| `Direction: TVector3Single;`
Light direction, already normalized and transformed by the Transform matrix. For spot and directional lights.
| `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).
| `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 T3DTransform or direct OpenGL modelview changes. 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). Useful for example for headlight.
### Methods
| `function Contribution( const Point: TVector3Single; const PointPlaneNormal: TVector4Single; State: TX3DGraphTraverseState; const CamPosition: TVector3Single): TVector3Single;`
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.
| `function ContributionCameraIndependent( const Point, PointPlaneNormal, MaterialDiffuseColor: TVector3Single): TVector3Single;`
Light contribution, without knowing the camera or full material. We have a 3D vertex, we know it lies on a plane with given normal, and we have light information. Try to calculate VRML/X3D lighting equation as close as possible to the fully correct version (see regular Contribution method) with this information. The specular lighting part must be simply ignored in this case.
Generated by PasDoc 0.13.0 on 2013-08-17 21:27:15