Light Source Tutorial: Difference between revisions
Lou Montana (talk | contribs) m (Lou Montana moved page Lightpoint Tutorial to Light Source Tutorial: Name standard) |
Lou Montana (talk | contribs) (Add #lightreflector commands and other intel) |
||
Line 9: | Line 9: | ||
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. | 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=" | <div class="float-right" style="margin-top: 1em"><!-- little trick to keep Flare's thumbnail 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}}.]] | ||
Line 20: | Line 20: | ||
Colour set ''via'' [[setLightAmbient]] determines the outer colour shone by the light source. | 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 spotting ability, but ambient '''does'''.}} | ||
=== Flare === | === Flare === | ||
Line 36: | Line 36: | ||
<sqf> | <sqf> | ||
private _lightSource = "#lightpoint" createVehicleLocal player modelToWorld [0, 2, 1.5]; | private _lightSource = "#lightpoint" createVehicleLocal player modelToWorld [0, 2, 1.5]; | ||
// alternatively, a light reflector (cone) can be created | // alternatively, a light reflector (cone) can be created since {{arma3}} v2.06 | ||
private _lightSource = "#lightreflector" createVehicleLocal player modelToWorld [0, 2, 1.5]; | private _lightSource = "#lightreflector" createVehicleLocal player modelToWorld [0, 2, 1.5]; | ||
</sqf> | </sqf> | ||
Line 58: | Line 58: | ||
{{ArgTitle|4|Set Flare Size|{{GVI|arma3|0.50}}}} | {{ArgTitle|4|Set Flare Size|{{GVI|arma3|0.50}}}} | ||
<sqf>_lightSource setLightFlareSize 1; // in | <sqf>_lightSource setLightFlareSize 1; // in metre</sqf> | ||
{{ArgTitle|4|Set Flare Visibility|{{GVI|arma3|0.50}}}} | {{ArgTitle|4|Set Flare Visibility|{{GVI|arma3|0.50}}}} | ||
<sqf>_lightSource setLightFlareMaxDistance 100; // in | <sqf>_lightSource setLightFlareMaxDistance 100; // in metre</sqf> | ||
=== Set Light Brightness === | === Set Light Brightness === | ||
Line 67: | Line 67: | ||
==== Set Brightness ==== | ==== Set Brightness ==== | ||
<sqf>_lightSource setLightBrightness 8;</sqf> | <sqf>_lightSource setLightBrightness 8;</sqf> | ||
{{Feature|important|Does '''not''' work with {{hl|#lightreflector}} - use {{Link|#Set Intensity|setLightIntensity}} instead.}} | |||
{{ArgTitle|4|Set | {{ArgTitle|4|Set Intensity|{{GVI|arma3|0.50}}}} | ||
<sqf>_lightSource setLightIntensity 3000;</sqf> | <sqf>_lightSource setLightIntensity 3000;</sqf> | ||
{{ArgTitle|4|Set | {{ArgTitle|4|Set Attenuation|{{GVI|arma3|0.50}}}} | ||
<sqf>_lightSource setLightAttenuation [0, 2, 4, 4, 0, 9, 10]; // [start, constant, linear, quadratic, hardLimitStart, hardLimitEnd]</sqf> | <sqf>_lightSource setLightAttenuation [0, 2, 4, 4, 0, 9, 10]; // [start, constant, linear, quadratic, hardLimitStart, hardLimitEnd]</sqf> | ||
{{Feature|informative|Formula is {{hl|1 / (constant + linear × dist + quadratic × dist × dist)}} - see [[setLightAttenuation]] for more information.}} | {{Feature|informative|Formula is {{hl|1 / (constant + linear × dist + quadratic × dist × dist)}} - see [[setLightAttenuation]] for more information.}} | ||
{{ArgTitle|3|Make | {{ArgTitle|3|Make Light Visible by Day|{{GVI|arma3|0.50}}}} | ||
<sqf>_lightSource setLightDayLight true; // only for the light itself, not the flare</sqf> | <sqf>_lightSource setLightDayLight true; // only for the light itself, not the flare</sqf> | ||
{{ArgTitle|3|Set IR|{{GVI|arma3|2.06}}}} | |||
<sqf>_lightSource setLightIR true;</sqf> | |||
{{ArgTitle|3|Set Reflector Angles|{{GVI|arma3|2.06}}}} | |||
==== Set Cone Parameters ==== | |||
<sqf>_lightReflector setLightConePars [90, 45, 1];</sqf> | |||
==== Set Reflector Volume Shape ==== | |||
<sqf>_lightReflector setLightVolumeShape ["a3\data_f\VolumeLightFlashlight.p3d", [1, 1, 1]];</sqf> | |||
=== Delete Light Source === | === Delete Light Source === | ||
Line 125: | Line 138: | ||
<sqf> | <sqf> | ||
private _reflector = "#lightreflector" createVehicleLocal [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]; | ||
_reflector setLightAmbient [1,1,1]; | _reflector setLightAmbient [1, 1, 1]; | ||
_reflector setLightIntensity 1e6; | _reflector setLightIntensity 1e6; | ||
_reflector setLightConePars [60,10,1]; | _reflector setLightConePars [60, 10, 1]; | ||
private _vector3D = [[[0,1,0],[0,0,1]], 0, -45, 0] call BIS_fnc_transformVectorDirAndUp; | private _vector3D = [[[0, 1, 0], [0, 0, 1]], 0, -45, 0] call BIS_fnc_transformVectorDirAndUp; | ||
_reflector setVectorDirAndUp _vector3D; | _reflector setVectorDirAndUp _vector3D; | ||
private _light = "#lightpoint" createVehicleLocal [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]; | ||
_light setLightAmbient [1,1,1]; | _light setLightAmbient [1, 1, 1]; | ||
_light setLightUseFlare true; | _light setLightUseFlare true; | ||
_light setLightFlareSize 5; | _light setLightFlareSize 5; | ||
Line 152: | Line 165: | ||
[[Category:Arma Scripting Tutorials]] | [[Category:Arma Scripting Tutorials]] | ||
{{GameCategory|arma1|Tutorials}} | |||
{{GameCategory|arma2|Tutorials}} | {{GameCategory|arma2|Tutorials}} | ||
{{GameCategory|arma3|Tutorials}} | {{GameCategory|arma3|Tutorials}} |
Latest revision as of 01:01, 4 March 2024
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
Set IR
Set Reflector Angles
Set Cone Parameters
Set Reflector Volume Shape
Delete Light Source
Examples
Dark Souls
Contact
Heli Spotlight