env_lensflare

From Valve Developer Community
Jump to: navigation, search
Lensflare.png

env_lensflare

is a point entity available in Black Mesa Black Mesa. It creates a Wikipedia icon lens flare that can be used to represent bright light sources.

An Official Black Mesa Lens Flare GIF From The ModDB Page.

Black Mesa Represented by class CLensflare.

Black Mesa Level Creation

Keyvalues

Name (targetname) <targetname>
The name that other entities refer to this entity by.
Parent (parentname) <targetname>
The name of this entity's parent in the movement hierarchy. Entities with parents move with their parent.
Pitch Yaw Roll (Y Z X) (angles) <angle>
This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
Note.pngNote:Using only for sun flares.
File (FlareFile) <string>
Optional - file defining the lens flare. Note: Hammer's parameters overwrite the file's parameters.
Blank image.pngTodo: Document what kind of file and what type.
Distance attenuation (FlareAttenuation) <float>
Distance where lensflare will be invisible. 0.0 if not attenuation with distance
Flare Type (FlareType) <choices>
Normal: normal lens flare (Pitch,Yaw,Roll not used) ------ Sun Flare: set the same Pitch,Yaw,Roll that the one from the sun light_env. That will define the position of the sun. the actual position of this entity is not used.
  • 0: Normal
  • 1: Sun Flare
Examples


Warning.pngWarning:Never place more then 4 lens flares with sun flare type, otherwise game will crash on map launch with this message.
If you'll try to place more then 4.
Appearance (FlareStyle) <choices>
Light Appearances
Literal Value Description Sequence Preview
0 Normal m Sequence 0.gif
10 Fluorescent flicker mmamammmmammamamaaamammma Sequence 10.gif
2 Slow, strong pulse abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba Sequence 2.gif
11 Slow pulse, noblack abcdefghijklmnopqrrqponmlkjihgfedcba Sequence 11.gif
5 Gentle pulse jklmnopqrstuvwxyzyxwvutsrqponmlkj Sequence 5.gif
1 Flicker A mmnmmommommnonmmonqnmmo Sequence 1.gif
6 Flicker B nmonqnmomnmomomno Sequence 6.gif
3 Candle A mmmmmaaaaammmmmaaaaaabcdefgabcdefg Sequence 3.gif
7 Candle B mmmaaaabcdefgmmmmaaaammmaamm Sequence 7.gif
8 Candle C mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa Sequence 8.gif
4 Fast strobe mamamamamama Sequence 4.gif
9 Slow strobe aaaaaaaazzzzzzzz Sequence 9.gif
12 !FGD Underwater light mutation mmnnmmnnnmmnn Sequence 12.gif
Size of Glow Proxy Geometry. (GlowProxySize) <float>
Size of the glow to be rendered for visibility testing. Must be larger than the distance from the sprite center to empty space. So if this glow is inside geometry (like a light bulb), set this value to be bigger than the bulb's radius. Any time a sphere of this radius would be visible (poking through any nearby geometry), the glow will be rendered.
Note.pngNote: - Richard's note : I noticed that value more than ~100 wont work correctly.
Flare 01 texture (Flare01_texture) to Flare 20 texture (Flare20_texture) <string>
image of the lens - if empty the flare doesn't exist
Flare 01 parameters (Flare01_params) to Flare 20 parameters (Flare20_params) <string>
parameters - example : DISK 1.0 10 10

See below for more details.

Flare 01 intensity (Flare01_intensity) to Flare 20 intensity (Flare20_intensity) <vector>
intensity of the flare - example : 1.0 1.0 1.0

Sets scale of intensity in three independent numbers, used number depends on the player's camera deviation.

First number sets when player look at entity center.
Second number sets when player camera have slight deviation.
Third number sets when player look far away from entity center.
Examples


Flare 01 sizes (Flare01_sizes) to Flare 20 sizes (Flare20_sizes) <vector>
intensity of the flare - example : 1.0 1.0 1.0

Sets scale of size in three independent numbers, used number depends on the player's camera deviation.

First number sets when player look at entity center.
Second number sets when player camera have slight deviation.
Third number sets when player look far away from entity center.
Note.pngNote:Never work with BOW function.
Examples


Flare 01 color (Flare01_color) to Flare 20 color (Flare20_color) <color255>
color factor of the texture - example : 255 255 255

Base:
Name (targetname) <string>
The name that other entities use to refer to this entity.
Parent (parentname) <targetname>
Maintain the same initial offset to this entity. An attachment point can also be used if separated by a comma at the end. (parentname [targetname],[attachment])
Tip.pngTip:Entities transition to the next map with their parents
Tip.pngTip:phys_constraint can be used as a workaround if parenting fails.
Origin (X Y Z) (origin) <coordinates>
The position of this entity's center in the world. Rotating entities typically rotate around their origin.
Note.pngNote:Hammer does not move the entities accordingly only in the editor.
Pitch Yaw Roll (X Y Z) (angles) <angle>
This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
Note.pngNote:This works on brush entities, although Hammer doesn't show the new angles.
Classname (classname) <string> !FGD
Determines the characteristics of the entity before it spawns.
Tip.pngTip:Changing this on runtime still has use, like making matching an entry in S_PreserveEnts will persist the entity on new rounds!
Flags (spawnflags) <flags> !FGD
Toggles exclusive features of an entity, its specific number is determined by the combination of flags added.
Effects (effects) <flags> !FGD
Combination of effect flags to use.
Entity Scripts (vscripts) <scriptlist> (in all games since Left 4 Dead 2) (also in Team Fortress 2)
Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions. Scripts executed on the worldspawn entity will be placed in root scope.
Think function (thinkfunction) <string> (in all games since Left 4 Dead 2) (also in Team Fortress 2)
Name of the function within this entity's script that'll be called automatically every 100 milliseconds, or a user-defined interval if the function returns a number. Avoid expensive operations in this function, as it may cause performance problems.
Lag Compensation (LagCompensate) <boolean> (in all games since Left 4 Dead 2) !FGD
Set to Yes to lag compensate this entity. Should be used very sparingly!
Is Automatic-Aim Target (is_autoaim_target) <boolean> (in all games since Counter-Strike: Global Offensive) !FGD
If set to 1, this entity will slow down aiming movement for consoles and joystick controllers when the entity is under the crosshairs.

Inputs

ColorRedValue
Sets the red color channel's value (0 - 255).
Note.pngNote:Unlike env_sprite it does nothing.
ColorGreenValue
Sets the green color channel's value (0 - 255).
Note.pngNote:Unlike env_sprite it does nothing.
ColorBlueValue
Sets the blue color channel's value (0 - 255).
Note.pngNote:Unlike env_sprite it does nothing.
SetScale
Set the lensflare's scale (0 - 8.0).
Warning.pngWarning:This input only in FGD and doesn't exists in the game.
HideLensFlare
Hide the lensflare. Won't be drawn until the 'ShowLensFlare' input is received.
ShowLensFlare
Show the lensflare.
ToggleLensFlare
Toggle the lensflare between hidden and shown.

Base:
AddContext <string>
Adds to the entity's list of response contexts. See Context.
AddOutput <string>
Assigns a new keyvalue/output on this entity. For keyvalues, some rely on extra necessary code to be ran and won't work if its simply just changed through this input. There is a strict format that must be followed:
// Format of changing KeyValues: "AddOutput [key] [value]"
//// Raw text:
"OnUser1" "!self,AddOutput,targetname new_name"

// Format of adding an Output: "AddOutput {targetname}:{inputname}:{parameter}:{delay}:{max times to fire, -1 means infinite}"
//// Raw text:
"OnUser1" "!self,AddOutput,OnUser1:SetParent:!activator:0.0:-1"
// Arguments can be left blank, but the empty blank should still be contained.
//// Raw text:
"OnUser1" "!self,AddOutput,OnUser1:ClearParent::0.0:-1"
ClearContext
Removes all contexts from this entity's list.
ClearParent
Removes this entity from the the movement hierarchy, leaving it free to move independently.
FireUser1 to FireUser4
Fires the respectiveOnUseroutputs; see User Inputs and Outputs.
Kill
Removes this entity and any entities parented to it from the world.
KillHierarchy
Functions the same as Kill, although this entity and any entities parented to it are killed on the same frame, being marginally faster thanKillinput.
RemoveContext <string>
Remove a context from this entity's list. The name should match the key of an existing context.
SetParent <string>
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment <string>
Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
SetParentAttachmentMaintainOffset <string>
As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
Use  !FGD
Same as a player invoking +use; no effect in most cases.
DispatchResponse <string> !FGD
Dispatches a response to the entity. See Response and Concept.
DispatchEffect <string> (removed since Left 4 Dead) !FGD
Dispatches a special effect from the entity's origin; See also List of Client Effects. Replaced by the particle system since Left 4 Dead.
RunScriptFile <script> (in all games since Left 4 Dead 2) (also in Team Fortress 2)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode <string> (in all games since Left 4 Dead 2) (also in Team Fortress 2)
Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console.
Icon-Bug.pngBug:In Hammer, using string arguments will corrupt the VMF file's structure, making the file unviewable for the next Hammer session.
Note.pngFix:Remove the string argument manually with a text editor.
Note.pngNote:Team Fortress 2 Backtick characters ` are replaced with quotation marks at runtime, allowing quotation marks to be used when normally not possible.
CallScriptFunction <string> (in all games since Left 4 Dead 2) (also in Team Fortress 2) !FGD
Calls a VScript function defined in the scope of the receiving entity.
TerminateScriptScope  (only in Team Fortress 2) !FGD
Destroys the script scope of the receving entity.
SetLocalOrigin <coordinates> (in all games since Alien Swarm) !FGD
Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
SetLocalAngles <angles> (in all games since Alien Swarm) !FGD
Set this entity's angles.

Outputs

Base:

OnUser1 to OnUser4
These outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.

Flags

  •  [1] : Start on
  •  [2] : Play once

Lens Flare Properties

An individual env_lensflare can support up to 20 flares. Each flare have different properties that can be customized.

Texture

The texture property sets the material used by the flare. It is a path to a VMT file relative to the materials folder, without the file extension. Common flare materials are located in the effects/lensflare/ folder. Any material can be used as a lens flare, but flare materials should preferably use UnlitGeneric and be $additive.

Parameters

The parameters property controls the appearance of the flare. Parameters take the following form: TYPE parameters

The following lens flare types can be used:

DISK

A screen space flare that gets stronger when the player looks directly at the env_lensflare, and weaker as the player looks away. It takes three parameters.

The first number - how strong a image will move away from screen center. With 1 it will attached to screen center. If 0 - will stay at env_lensflare center. Negative number will mirror effect that do positive number.

The second number - distort a image along the axis Y. Doesn't work with negative numbers.

The third number - distort a image along the axis X. Doesn't work with negative numbers.

Examples


BOW

An effect that uses an image and distorts it between center of screen and env_lensflare center. It takes one parameter. Doesn't work with negative numbers.

The first number - change a picture scale.

Examples


CLA

This effect looks like copy of DISK. It use same parameters.

Examples


DISKH

An effect that uses an image and moves it along the X axis. It takes four parameter.

The first number - how strong the image will move away from screen center along the axis X. If number is 0 - it will stand at env_lensflare center. With 1 it will attached to screen center. Negative number will mirror effect that do positive number.

The second number - distort the image along the axis X. Doesn't work with negative numbers.

The third number - distort the image along the axis Y. Doesn't work with negative numbers.

The fourth number - change position of a image along the axis Y. If positive number - be higher, if negative number - be lower.

Examples


RAY

An effect that uses an image and scale it. It takes two parameter. Doesn't work with negative numbers.

The first number - distort the image along the axis Y.

The second number - distort the image along the axis X and Z.

Examples


Lens flare creation tips

There is no preview in Hammer for lens flares, there is also no UI editor for lens flares. The developers recommend to use their lens flares, or use their lens flares as base for your own. You can create your own lens flares from scratch by following these steps:

    • 1. Open the developer console.
    • 2. Enter in the console sv_cheats 1.
    • 3. Enter in the console ent_fire YourLensFlareName addoutput "FlareNUMBER_params ParameterName VALUES".
    • 4. Save and load the save.

After load save you will see changes, so, with this you don't need to recompile your level to see how your lens flare will looks like.}}

Bugs/Limitations

Lens flares render behind viewmodel and not vice versa

Not a bug, but this is not what you expect from real life, was fixed in Half-Life 2: Inhuman.


Sun flare incorrect work with point_viewcontrol

Sun flare change position in sky when player move, this affects to what show point_viewcontrol when it's enabled. If you want to see in your background level sun flare - place player on needed position. If your point_viewcontrol moves - attach player to it.


User can disable lens flares and see defect

In graphics settings user can turn off all flares, keep in mind this to escape situations like in the picture. Add sprites or corresponding skins, paint sun on your skybox if don't plan to use newLight_Dir.


Doesn't work with 3D Skybox

Don't use env_lensflare in your 3D skyboxes, 3D skybox will not show flares.


Sun flare render through 3D Skybox objects

Unlike env_sun sun flare render through any object pasted in 3D Skybox environment. Keep in mind this before you will create 3D Skybox.


Incorrect work with -tools

If you don't use Full Screen - lensflares will be displayed offset from where they initially should be.

See also

Blank image.pngTodo: May better describe functions. Clean up english. Add more issues if you'll find.