Light Source Tutorial: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
Line 118: Line 118:


<sqf>
<sqf>
private _reflector = "#lightreflector" createVehicle [0,0,0];
private _reflector = "#lightreflector" createVehicleLocal [0,0,0];
_reflector attachTo [myHeliVariable, [0,0,0], "light_l"];
_reflector attachTo [myHeliVariable, [0,0,0], "light_l"];
_reflector setLightColor [1,1,1];
_reflector setLightColor [1,1,1];
Line 127: Line 127:
_reflector setVectorDirAndUp _vector3D;
_reflector setVectorDirAndUp _vector3D;


private _light = "#lightpoint" createVehicle [0,0,0];
private _light = "#lightpoint" createVehicleLocal [0,0,0];
_light attachTo [myHeliVariable, [0,0,0], "light_l"];
_light attachTo [myHeliVariable, [0,0,0], "light_l"];
_light setLightColor [1,1,1];
_light setLightColor [1,1,1];
Line 137: Line 137:
_light setLightIntensity 10;
_light setLightIntensity 10;
</sqf>
</sqf>


== See Also ==
== See Also ==

Revision as of 19:21, 2 March 2023

Basics

A lightpoint (glowing light source) is a non-physical object that shines a light. Unlike projectors or vehicle headlights, this light type cannot be directed into a beam and can only glow uniformously. The glowing does not cast shadows (only the sun or the moon can) and can go through walls.

Lightpoint notions and commands were introduced in Armed Assault, some commands were later added in Arma 3 (e.g setLightIntensity, flare commands).

A lightpoint is local to the computer where the script has been called; one player could see a light in the dark while another would not have such light "object" created.

Lightpoint with red colour, and blue ambient. Note how the red and blue hues mix to create purple.

Colour

Colour set via setLightColor determines the lens flare effect colour, as well as light's first colour.

Ambient

Colour set via setLightAmbient determines the outer colour shone by the lightpoint.

Light colour does not affect AI, but ambient does.

Flare

The flare is the "colour point" centre that emits light. It can be visible or invisible (set by setLightUseFlare).

Flare is not visible by day, even using setLightDayLight.


How To

The list of all lightpoint commands can be found in the Lights command group category.

Create a Lightpoint

private _lightpoint = "#lightpoint" createVehicleLocal player modelToWorld [0, 2, 1.5];

A lightpoint is local (and all the lightpoint commands take a local argument too), hence createVehicleLocal usage.

Set Light Colour

Colour

_lightpoint setLightColor [0.25, 1, 1]; // also defines Flare colour

Ambient Colour

_lightpoint setLightAmbient [1, 1, 1]; // sets the colour applied to the surroundings

Set Flare

For the flare to be visible, all the following values (use flare, size, visibility) must be defined and light colour set by setLightColor must not be [0,0,0].

Enable Flare

_lightpoint setLightUseFlare true;

Set Flare Size

_lightpoint setLightFlareSize 1; // in meter

Set Flare Visibility

_lightpoint setLightFlareMaxDistance 100; // in meter

Set Light Brightness

Set Brightness

_lightpoint setLightBrightness 8;

Set intensity

_lightpoint setLightIntensity 3000;

Set attenuation

_lightpoint setLightAttenuation [0, 2, 4, 4, 0, 9, 10]; // [start, constant, linear, quadratic, hardLimitStart, hardLimitEnd]

Formula is 1 / (constant + linear × dist + quadratic × dist × dist) - see setLightAttenuation for more information.

Make light visible by day

_lightpoint setLightDayLight true; // only for the light itself, not the flare

Delete Lightpoint

deleteVehicle _lightpoint; // as simple as that


Examples

Dark Souls

skipTime -dayTime; _lightpoint = "#lightpoint" createVehicleLocal [0,0,0]; _lightpoint attachTo [player, [0, 0, 1.5]]; _lightpoint setLightColor [0,0,0]; _lightpoint setLightAmbient [1,0.8, 0.25]; _lightpoint setLightBrightness 0.15;

Contact

skipTime -dayTime; private _position = player modelToWorld [0, 20, 1.5]; private _lightpoint = "#lightpoint" createVehicleLocal _position; _lightpoint setLightColor [0,1,1]; _lightpoint setLightAmbient [0.2,0.0,0.3]; _lightpoint setLightUseFlare true; _lightpoint setLightFlareSize 3; _lightpoint setLightFlareMaxDistance 3.5; _lightpoint setLightBrightness 4; _lightpoint setLightDayLight true; _lightpoint spawn { while { sleep 0.05; player distance _this > 2 } do { _this setLightBrightness 4 max (40 / (player distance _this)); }; deleteVehicle _this; };

Heli Spotlight

private _reflector = "#lightreflector" createVehicleLocal [0,0,0]; _reflector attachTo [myHeliVariable, [0,0,0], "light_l"]; _reflector setLightColor [1,1,1]; _reflector setLightAmbient [1,1,1]; _reflector setLightIntensity 1e6; _reflector setLightConePars [60,10,1]; private _vector3D = [[[0,1,0],[0,0,1]], 0, -45, 0] call BIS_fnc_transformVectorDirAndUp; _reflector setVectorDirAndUp _vector3D; private _light = "#lightpoint" createVehicleLocal [0,0,0]; _light attachTo [myHeliVariable, [0,0,0], "light_l"]; _light setLightColor [1,1,1]; _light setLightAmbient [1,1,1]; _light setLightUseFlare true; _light setLightFlareSize 5; _light setLightFlareMaxDistance 500; _light setLightBrightness 1000; _light setLightIntensity 10;

See Also