Light Source Tutorial: Difference between revisions
Hypoxic125 (talk | contribs) m (→Heli Spotlight) |
Lou Montana (talk | contribs) (Add proper Light Reflector notion, about time) |
||
Line 1: | Line 1: | ||
{{TOC|side}} | {{TOC|side}} | ||
{{GVI|arma1|1.00}} | |||
== Basics == | == Basics == | ||
A | A '''light source''' is a non-physical object that shines a light. Its light does not cast shadows (only the sun or the moon can) and can go through walls. It can be of one of these two types: | ||
* A '''light point''' (glowing light source) is an all-directional light source, like a floating lightbulb, that emits light all around it. | |||
* A '''light reflector''', much like projectors or vehicle headlights, is a beam-shaped light that was introduced in {{GVI|arma3|2.06|size= 0.75}} (see {{Link|#Heli Spotlight|this example below}}). | |||
Such light source is '''[[Multiplayer Scripting#Locality|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. | |||
<div style="float: left; padding-top: 2.5em"><!-- little trick to keep Flare's infobox aligned --> | |||
[[File:lightpoint_redColor_blueAmbient.jpg|thumb|left|200px|Lightpoint with {{Color|darkred|red}} colour, and {{Color|blue|blue}} ambient. | [[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}}.]] | Note how the {{Color|darkred|red}} and {{Color|blue|blue}} hues mix to create {{Color|purple|purple}}.]] | ||
</div> | |||
=== Colour === | === Colour === | ||
Line 16: | Line 19: | ||
=== Ambient === | === Ambient === | ||
Colour set ''via'' [[setLightAmbient]] determines the outer colour shone by the | Colour set ''via'' [[setLightAmbient]] determines the outer colour shone by the light source. | ||
{{Feature | important | Light colour does not affect AI, but ambient '''does'''.}} | {{Feature|important|Light colour does not affect AI, but ambient '''does'''.}} | ||
=== Flare === | === Flare === | ||
The flare is the "colour point" centre that emits light. It can be visible or invisible (set by [[setLightUseFlare]]). | The flare is the "colour point" centre that emits light. It can be visible or invisible (set by [[setLightUseFlare]]). | ||
{{Feature | | {{Feature|informative|Flare is '''not''' visible by day, even using [[setLightDayLight]].}} | ||
== How To == | == How To == | ||
The list of all | The list of all light source commands can be found in the [[:Category:Command Group: Lights|Lights command group]] category. | ||
=== Create a | === Create a Light Source === | ||
<sqf>private | <sqf> | ||
private _lightSource = "#lightpoint" createVehicleLocal player modelToWorld [0, 2, 1.5]; | |||
// alternatively, a light reflector (cone) can be created | |||
private _lightSource = "#lightreflector" createVehicleLocal player modelToWorld [0, 2, 1.5]; | |||
</sqf> | |||
{{Feature | | {{Feature|informative|A light source is '''local''' (and all the light commands take a local argument too), hence [[createVehicleLocal]]'s usage.}} | ||
=== Set Light Colour === | === Set Light Colour === | ||
==== Colour ==== | ==== Colour ==== | ||
<sqf> | <sqf>_lightSource setLightColor [0.25, 1, 1]; // also defines Flare colour</sqf> | ||
==== Ambient Colour ==== | ==== Ambient Colour ==== | ||
<sqf> | <sqf>_lightSource setLightAmbient [1, 1, 1]; // sets the colour applied to the surroundings</sqf> | ||
=== Set Flare === | === Set Flare === | ||
{{Feature | | {{Feature|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|4|Enable Flare|{{GVI|arma3|0.50}}}} | {{ArgTitle|4|Enable Flare|{{GVI|arma3|0.50}}}} | ||
<sqf> | <sqf>_lightSource setLightUseFlare true;</sqf> | ||
{{ArgTitle|4|Set Flare Size|{{GVI|arma3|0.50}}}} | {{ArgTitle|4|Set Flare Size|{{GVI|arma3|0.50}}}} | ||
<sqf> | <sqf>_lightSource setLightFlareSize 1; // in meter</sqf> | ||
{{ArgTitle|4|Set Flare Visibility|{{GVI|arma3|0.50}}}} | {{ArgTitle|4|Set Flare Visibility|{{GVI|arma3|0.50}}}} | ||
<sqf> | <sqf>_lightSource setLightFlareMaxDistance 100; // in meter</sqf> | ||
=== Set Light Brightness === | === Set Light Brightness === | ||
==== Set Brightness ==== | ==== Set Brightness ==== | ||
<sqf> | <sqf>_lightSource setLightBrightness 8;</sqf> | ||
{{ArgTitle|4|Set intensity|{{GVI|arma3|0.50}}}} | {{ArgTitle|4|Set intensity|{{GVI|arma3|0.50}}}} | ||
<sqf> | <sqf>_lightSource setLightIntensity 3000;</sqf> | ||
{{ArgTitle|4|Set attenuation|{{GVI|arma3|0.50}}}} | {{ArgTitle|4|Set attenuation|{{GVI|arma3|0.50}}}} | ||
<sqf> | <sqf>_lightSource setLightAttenuation [0, 2, 4, 4, 0, 9, 10]; // [start, constant, linear, quadratic, hardLimitStart, hardLimitEnd]</sqf> | ||
{{Feature | | {{Feature|informative|Formula is {{hl|1 / (constant + linear × dist + quadratic × dist × dist)}} - see [[setLightAttenuation]] for more information.}} | ||
{{ArgTitle|3|Make light visible by day|{{GVI|arma3|0.50}}}} | {{ArgTitle|3|Make light visible by day|{{GVI|arma3|0.50}}}} | ||
<sqf> | <sqf>_lightSource setLightDayLight true; // only for the light itself, not the flare</sqf> | ||
=== Delete | === Delete Light Source === | ||
<sqf>deleteVehicle | <sqf>deleteVehicle _lightSource; // as simple as that</sqf> | ||
Line 84: | Line 91: | ||
skipTime -dayTime; | skipTime -dayTime; | ||
_lightSource = "#lightpoint" createVehicleLocal [0,0,0]; | |||
_lightSource attachTo [player, [0, 0, 1.5]]; | |||
_lightSource setLightColor [0,0,0]; | |||
_lightSource setLightAmbient [1,0.8, 0.25]; | |||
_lightSource setLightBrightness 0.15; | |||
</sqf> | </sqf> | ||
Line 97: | Line 104: | ||
private _position = player modelToWorld [0, 20, 1.5]; | private _position = player modelToWorld [0, 20, 1.5]; | ||
private | private _lightSource = "#lightpoint" createVehicleLocal _position; | ||
_lightSource setLightColor [0,1,1]; | |||
_lightSource setLightAmbient [0.2,0.0,0.3]; | |||
_lightSource setLightUseFlare true; | |||
_lightSource setLightFlareSize 3; | |||
_lightSource setLightFlareMaxDistance 3.5; | |||
_lightSource setLightBrightness 4; | |||
_lightSource setLightDayLight true; | |||
_lightSource spawn { | |||
while { sleep 0.05; player distance _this > 2 } do | while { sleep 0.05; player distance _this > 2 } do | ||
{ | { | ||
Line 137: | Line 144: | ||
_light setLightIntensity 10; | _light setLightIntensity 10; | ||
</sqf> | </sqf> | ||
== See Also == | == See Also == | ||
Line 144: | Line 152: | ||
[[Category:Arma Scripting Tutorials]] | [[Category:Arma Scripting Tutorials]] | ||
<!-- {{GameCategory|arma1|Tutorials}} --> | |||
{{GameCategory|arma2|Tutorials}} | {{GameCategory|arma2|Tutorials}} | ||
{{GameCategory|arma3|Tutorials}} | {{GameCategory|arma3|Tutorials}} |
Revision as of 14:26, 27 April 2023
Basics
A light source is a non-physical object that shines a light. Its light does not cast shadows (only the sun or the moon can) and can go through walls. It can be of one of these two types:
- A light point (glowing light source) is an all-directional light source, like a floating lightbulb, that emits light all around it.
- A light reflector, much like projectors or vehicle headlights, is a beam-shaped light that was introduced in 2.06 (see this example below).
Such light source 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.
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 light source.
Flare
The flare is the "colour point" centre that emits light. It can be visible or invisible (set by setLightUseFlare).
How To
The list of all light source commands can be found in the Lights command group category.
Create a Light Source
Set Light Colour
Colour
Ambient Colour
Set Flare
Enable Flare
Set Flare Size
Set Flare Visibility
Set Light Brightness
Set Brightness
Set intensity
Set attenuation
Make light visible by day
Delete Light Source
Examples
Dark Souls
Contact
Heli Spotlight