Light Source Tutorial: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Fix Camera remnants)
m (Text replacement - "Category:Arma 2: Editing" to "{{GameCategory|arma2|Editing}}")
(6 intermediate revisions by the same user not shown)
Line 2: Line 2:
== Basics ==
== 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.
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.
 
{{Informative | Lightpoint notions and commands were introduced in {{arma}}, some commands were later added in {{arma3}} (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.
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.
[[File:lightpoint_redColor_blueAmbient.jpg|thumb|left|200px|Lightpoint with {{Color|darkred|red}} colour, and {{Color|blue|blue}} ambient.
Note how the {{Color|darkred|red}} and {{Color|blue|blue}} hues mix to create {{Color|purple|purple}}.]]
=== Colour ===
Colour set ''via'' [[setLightColor]] determines the lens [[#Flare|flare]] effect colour, as well as light's first colour.
=== Ambient ===
Colour set ''via'' [[setLightAmbient]] determines the outer colour shone by the lightpoint.
{{Important | 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]]).
{{Informative |  Flare is '''not''' visible by day, even using [[setLightDayLight]].}}




Line 10: Line 28:


The list of all lightpoint commands can be found in the [[:Category:Command Group: Lights|Lights command group]] category.
The list of all lightpoint commands can be found in the [[:Category:Command Group: Lights|Lights command group]] category.
{{Informative | Light commands were introduced in {{arma}}, and some were added later in {{arma3}} (e.g [[setLightIntensity]], [[setLightUseFlare]]).}}


=== Create a lightpoint ===
=== Create a lightpoint ===
Line 17: Line 33:
  [[private]] _lightpoint = '''"#lightpoint"''' [[createVehicleLocal]] [[player]] [[modelToWorld]] [0,2,1.5];
  [[private]] _lightpoint = '''"#lightpoint"''' [[createVehicleLocal]] [[player]] [[modelToWorld]] [0,2,1.5];


{{Informative | Reminder that a lightpoint is '''local''' (and all the light commands take a local argument too), hence [[createVehicleLocal]].}}
{{Informative | A lightpoint is '''local''' (and all the lightpoint commands take a local argument too), hence [[createVehicleLocal]] usage.}}


=== Set light colour ===
=== Set light colour ===


==== Colour ====
==== Colour ====
  _lightpoint [[setLightColor]] [0.25, 1, 1];
  _lightpoint [[setLightColor]] [0.25, 1, 1]; {{cc|also defines [[#Set flare|Flare]] colour}}
{{Informative | Colour set by [[setLightColor]] also defines [[#Set flare|Flare]] colour.}}


==== Ambient Colour ====
==== Ambient Colour ====
Line 30: Line 45:
=== Set flare ===
=== Set flare ===


{{Informative | For the flare to be visible, all the following values (use flare, size, visibility) must be defined, and light colour [[#Colour|set by]] [[setLightColor]] must not be [0,0,0]. Flare is '''not''' visible by day, even using [[setLightDayLight]].}}
{{Informative | For the flare to be visible, all the following values (use flare, size, visibility) must be defined and light colour [[#Colour_2|set by]] [[setLightColor]] must not be [0,0,0].}}


{{ArgTitle|Enable flare|4|{{GVI|arma3|0.50}}}}
{{ArgTitle|Enable flare|4|{{GVI|arma3|0.50}}}}
Line 55: Line 70:
{{ArgTitle|Make light visible by day|3|{{GVI|arma3|0.50}}}}
{{ArgTitle|Make light visible by day|3|{{GVI|arma3|0.50}}}}


  _lightpoint [[setLightDayLight]] [[true]]; {{cc|Only for light itself, not the flare}}
  _lightpoint [[setLightDayLight]] [[true]]; {{cc|only for the light itself, not the flare}}


=== Delete lightpoint ===
=== Delete lightpoint ===
Line 85: Line 100:
  _lightpoint [[setLightFlareMaxDistance]] 3.5;
  _lightpoint [[setLightFlareMaxDistance]] 3.5;
  _lightpoint [[setLightBrightness]] 4;
  _lightpoint [[setLightBrightness]] 4;
  _lightpoint setLightDayLight true;
  _lightpoint [[setLightDayLight]] [[true]];
   
   
  _lightpoint [[spawn]] {
  _lightpoint [[spawn]] {
Line 98: Line 113:
== See also ==
== See also ==


* [[:Category:Command Group: Lights]]
* [[:Category:Command Group: Lights|Command Group: Lights]]




[[Category:Scripting Topics]]
[[Category:Scripting Topics]]
[[Category:ArmA: Editing]]
[[Category:ArmA: Editing]]
[[Category:Arma 2: Editing]]
{{GameCategory|arma2|Editing}}
[[Category:Arma 3: Editing]]
{{GameCategory|arma3|Editing}}
[[Category:Arma 2: Tutorials]]
[[Category:Arma 2: Tutorials]]
[[Category:Arma 3: Tutorials]]
[[Category:Arma 3: Tutorials]]

Revision as of 00:41, 28 July 2020

Template:SideTOC

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 Arma, 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].

4

_lightpoint setLightUseFlare true;

4

_lightpoint setLightFlareSize 1; // in meter

4

_lightpoint setLightFlareMaxDistance 100; // in meter

Set light brightness

Set brightness

_lightpoint setLightBrightness 8;

4

_lightpoint setLightIntensity 3000;

4

_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.

3

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

Delete lightpoint

deleteVehicle _lightpoint; // as simple as that

Full 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;
};


See also