Lightning: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
m (→‎Custom lightning sprites: Unicodifying, replaced: [[image: → [[File:)
 
(22 intermediate revisions by 8 users not shown)
Line 1: Line 1:
Ever wanted to add lightning to your map? Well now you can! Just follow this tutorial and you to can add Lightning to your Source Map.
This is a tutorial for adding a lightning storm to a map.


==''Required Files''==
It is assumed that the reader knows how to create a [[3D Skybox|3D skybox]] before reading this tutorial.
[[http://files.filefront.com/Lightning_Tutorial_Files/;5261042;;/fileinfo.html >>FileFront<<]]


'''Tutorial:'''
==Custom lightning sprites==


[[File:Lightning_test_01_screenshot0003.jpg|thumb|200px|Custom made lightning sprites.]]


Ok to start this tutorial off I have to say this will automatically start the lightning you'll have to do some random triggers if you want it to only be on at a certain part of the map.
Here are all the sprites of (normal) lightning bolts in the HL2 SDK:


Note: Before you go through this tutorial create a 3d skybox (The one I use in this tutorial is 1322x1674 Units) With Fog off!!!
* bluelight1.vmt
* lgtning.vmt
* lgtning_noz.vmt
* physcannon_bluelight1b.vmt


==Step One==
You can also download some custom made lightning sprites (seen in the screenshot to the right, but not required for this tutorial). Just create a new ''sprites'' folder in the ''hl2/materials/'' folder, unpack the custom sprite files into it, and refresh the SDK content, before running the example map.
{{clr}}


Ok place 2 sprites about 2-10 units away from each other. (Make sure ones in front of the other) Select the one closes to the skycamera entity. In the Sprite Name box write (Not Including Quotation Marks) "materials/sprites/lightningglow.vmt"
==Setting up==
Then click on scale and type in 7. After that make sure Render Mode is addictive and that the FX amount is 50. Also change the Name to (Not including Quote Marks) "lightning1glow". After that click apply and then Cancel.


http://img291.imageshack.us/img291/9894/step101gf2.jpg
1. Unless lightning is intended to be close enough to strike within the playing area, create the 3D skybox that will house the lightning storm. Make sure that its fog is disabled.


Now goto the properties on the other sprite. Type in the name "lightning1" and change the sprite name to "materials/sprites/lightning.vmt" and also make sure the Render Mode is Addictive and also that the FX Amount is 255. Change the scale amount (Under Scale) to .75
2. Create two [[env_sprite]]s and place them next to each other.


http://img81.imageshack.us/img81/8363/step102ul0.jpg
3. Select the one of these sprite entities, and open it's properties. This sprite will be the actual lighting bolt. This tutorial example will set the values as follows:
{{entity-kvalue-start|[[env_sprite]]}}
{{entity-kvalue|Name|lightning1| The name of the lightning sprite.}}
{{entity-kvalue|Render FX|Faster Strobe|}}
{{entity-kvalue|Render Mode|Additive|}}
{{entity-kvalue|FX Amount (0-255)|200|}}
{{entity-kvalue|Sprite Name|sprites/lgtning.vmt|The sprite to use for the lightning. (Don't forget to add ".vmt".)}}
{{entity-kvalue|Scale|2|}}
{{entity-kvalue-end}}


==Step Two==


Now that you've setup your sprites you must setup a logic_timer. This will take longer than placing the sprites. Ok first place a logic_timer somewhere near your sprites. Open it up in properties and set its name to "lightning1timer". Now make sure "Use Random Time" is set to yes and that Min Random Interval is set to 1 and Max Random Interval is set to 10. Then set Refire Interval to "0.35". Now click on outputs tab and add some things to make it look like this:
4. Open the properties of the other sprite. This sprite will be the background glow of the lightning, so that it will light up the sky. This tutorial example will set the values as follows:
{{entity-kvalue-start|[[env_sprite]]}}
{{entity-kvalue|Name|lightning1glow| The name of the glow sprite.}}
{{entity-kvalue|Render FX|Faster Strobe|}}
{{entity-kvalue|Render Mode|Additive|}}
{{entity-kvalue|FX Amount (0-255)|25|}}
{{entity-kvalue|Sprite Name|sprites/light_glow02.vmt|The sprite to use for the lightning glow. (Don't forget to add ".vmt".)}}
{{entity-kvalue|Scale|7|}}
{{entity-kvalue-end}}


http://img162.imageshack.us/img162/6269/step202af5.jpg


(Important Note: The example i'm using shows the number 2 but in this tutorial i used number 1 so just replace the 2 with 1. Also the Last line is an optional part of this tutorial!)
5. To add some thunder sounds it is recommended to use a soundscape (which is not covered by this tutorial), but a quicker way is to place an [[ambient_generic]] entity somewhere in the map in the direction of the lightning strike (Do not place it in the skybox.) and change its properties as follows:
Once you're done that click on the flags tab and make sure the only flag that showing is checked!
{{entity-kvalue-start|[[ambient_generic]]}}
{{entity-kvalue|Name|thunder1|The name of the thunder.}}
{{entity-kvalue|Sound Name|k_lab.teleport_post_thunder|You can find four more good thunder sounds if you search for ''thunder'' in the sound browser.}}
{{entity-kvalue-end}}


Ok!! You're Done!! Yay! Save it and test it out or follow these optional steps and add some cool additions to your map!


==Optional==
==Timing it==


Ok wanna add some Thunder to your lightning? well simply place an ambient_generic (Soundscape recommended but not covered by this tutorial sorry!) in a part of your map (not in the 3d skybox) and change it's name to Thunder.01 change its sound name to "k_lab.teleport_post_thunder" or another good thunder sound. Then go back to that logic_timer and add
1. Place a logic_timer in the map, preferably somewhere near your sprites.
"OnTimerLow"
Open its properties and make the following alterations:
"Thunder.02"
{{entity-kvalue-start|[[logic_timer]]}}
"PlaySound"
{{entity-kvalue|Name|lightning1timer|The name of the timer.}}
to the output tab and thats it  :).
{{entity-kvalue|Use Random Time|Yes|The lightning will strike at random intervals.}}
{{entity-kvalue|Min Random Interval|5|Minimum time between strikes. Set it lower than this and the thunder will cut itself.}}
{{entity-kvalue|Max Random Interval|60|Maximum time between strikes.}}
{{entity-kvalue-end}}


Wanna make your Lightning rotate around the skybox? (doesn't actually show the sprite moving great effect since lightning usually never hits the same spot twice.)
Well make a small brush using tool_invisible and make it a func_rotating and call it lightningrotator change the max rotating speed to 3 and change the friction to 20. Click apply and then close the window. go back to your two sprites and change their parent to lightningrotator. After your done that add a logic_auto to the map (Not sure if this is needed or not...) Then in the outputs tab add this:
"OnMapSpawn"
"lightningrotator"
"Start"
and then save your map and test it out!!!
Congrads your finish!!


2. Click on the ''Outputs'' tab and create the follow outputs:
{{entity-output-start}}
{{entity-output||OnTimer|lightning1glow|ShowSprite||0.00|No|}}
{{entity-output||OnTimer|lightning1|ShowSprite||0.00|No|}}
{{entity-output||OnTimer|lightning1glow|HideSprite||0.50|No|}}
{{entity-output||OnTimer|lightning1|HideSprite||0.50|No|}}
{{entity-output||OnTimer|thunder1|PlaySound||<delay>|No|<delay> is a value reflecting how far away the lightning struck.}}
{{entity-output-end}}


[[http://img392.imageshack.us/img392/2974/lightningtest01screenshot0003nh6.jpg|The End Result]]


3. Save it and test the map.


==''Credits==
4. So far only one lightning bolt has been created. To create more of them, simply place a number of copies of this created set around in the skybox, and name them in sequential order (''lightning2'', ''lightning3'', ''lightning4'', and so on).
Sprites - Troika Games
Vmf - Troika Games, Frostbite
Tutorial - Frostbite''


I've included the vmf I used to make this. Well the skybox is from the decompiled sm_hub1.bsp so thats why Troika is in the credits for the vmf. Hope you guys find this useful =)
 
==Randomized lightning==
 
To prevent the lightning from unrealistically striking at the same spot over and over again, you can also make the sprites rotate around the skybox. (The lightning will fortunately strike so fast that its movement while visible will barely be noticeable.)
 
1. Create a small brush textured with the ''invisible'' tool texture, turn it into a ''func_rotating'' entity, and change its properties as follows:
{{entity-kvalue-start|[[func_rotating]]}}
{{entity-kvalue|Name|lightningrotator|The name of the rotator.}}
{{entity-kvalue|max rotating speed|3|}}
{{entity-kvalue-end}}
 
Also set the following flag:
{{entity-flag-start}}
{{entity-flag|Start ON|on|}}
{{entity-flag-end}}
 
 
2. Go back to your two sprites and set their ''Parent'' field:
{{entity-kvalue-start|[[env_sprite]]}}
{{entity-kvalue|Parent|lightningrotator|The name of the rotator.}}
{{entity-kvalue-end}}
 
 
3. You could make another rotator within the actual map, to match the direction of the thunder with the lightning flashes, but using a single stationary ambient_generic for all the bolts won't make that much of a difference.
 
Just open the ambient_generic entity and set the following flag:
{{entity-flag-start}}
{{entity-flag|Play everywhere|on|}}
{{entity-flag-end}}
 
 
4. Save and test the map.
 
== See also==
* [[Skybox]]
 
[[Category:Level Design]]

Latest revision as of 10:53, 8 January 2024

This is a tutorial for adding a lightning storm to a map.

It is assumed that the reader knows how to create a 3D skybox before reading this tutorial.

Custom lightning sprites

Custom made lightning sprites.

Here are all the sprites of (normal) lightning bolts in the HL2 SDK:

  • bluelight1.vmt
  • lgtning.vmt
  • lgtning_noz.vmt
  • physcannon_bluelight1b.vmt

You can also download some custom made lightning sprites (seen in the screenshot to the right, but not required for this tutorial). Just create a new sprites folder in the hl2/materials/ folder, unpack the custom sprite files into it, and refresh the SDK content, before running the example map.

Setting up

1. Unless lightning is intended to be close enough to strike within the playing area, create the 3D skybox that will house the lightning storm. Make sure that its fog is disabled.

2. Create two env_sprites and place them next to each other.

3. Select the one of these sprite entities, and open it's properties. This sprite will be the actual lighting bolt. This tutorial example will set the values as follows:

Class: env_sprite
Keyvalues Comments
Name lightning1 The name of the lightning sprite.
Render FX Faster Strobe
Render Mode Additive
FX Amount (0-255) 200
Sprite Name sprites/lgtning.vmt The sprite to use for the lightning. (Don't forget to add ".vmt".)
Scale 2


4. Open the properties of the other sprite. This sprite will be the background glow of the lightning, so that it will light up the sky. This tutorial example will set the values as follows:

Class: env_sprite
Keyvalues Comments
Name lightning1glow The name of the glow sprite.
Render FX Faster Strobe
Render Mode Additive
FX Amount (0-255) 25
Sprite Name sprites/light_glow02.vmt The sprite to use for the lightning glow. (Don't forget to add ".vmt".)
Scale 7


5. To add some thunder sounds it is recommended to use a soundscape (which is not covered by this tutorial), but a quicker way is to place an ambient_generic entity somewhere in the map in the direction of the lightning strike (Do not place it in the skybox.) and change its properties as follows:

Class: ambient_generic
Keyvalues Comments
Name thunder1 The name of the thunder.
Sound Name k_lab.teleport_post_thunder You can find four more good thunder sounds if you search for thunder in the sound browser.


Timing it

1. Place a logic_timer in the map, preferably somewhere near your sprites. Open its properties and make the following alterations:

Class: logic_timer
Keyvalues Comments
Name lightning1timer The name of the timer.
Use Random Time Yes The lightning will strike at random intervals.
Min Random Interval 5 Minimum time between strikes. Set it lower than this and the thunder will cut itself.
Max Random Interval 60 Maximum time between strikes.


2. Click on the Outputs tab and create the follow outputs:

My output Target entity Target input Parameter Delay Only once Comments
Entity-output-icon.png OnTimer lightning1glow ShowSprite 0.00 No
Entity-output-icon.png OnTimer lightning1 ShowSprite 0.00 No
Entity-output-icon.png OnTimer lightning1glow HideSprite 0.50 No
Entity-output-icon.png OnTimer lightning1 HideSprite 0.50 No
Entity-output-icon.png OnTimer thunder1 PlaySound <delay> No <delay> is a value reflecting how far away the lightning struck.


3. Save it and test the map.

4. So far only one lightning bolt has been created. To create more of them, simply place a number of copies of this created set around in the skybox, and name them in sequential order (lightning2, lightning3, lightning4, and so on).


Randomized lightning

To prevent the lightning from unrealistically striking at the same spot over and over again, you can also make the sprites rotate around the skybox. (The lightning will fortunately strike so fast that its movement while visible will barely be noticeable.)

1. Create a small brush textured with the invisible tool texture, turn it into a func_rotating entity, and change its properties as follows:

Class: func_rotating
Keyvalues Comments
Name lightningrotator The name of the rotator.
max rotating speed 3

Also set the following flag:

Flag
Checkbox-on.png Start ON


2. Go back to your two sprites and set their Parent field:

Class: env_sprite
Keyvalues Comments
Parent lightningrotator The name of the rotator.


3. You could make another rotator within the actual map, to match the direction of the thunder with the lightning flashes, but using a single stationary ambient_generic for all the bolts won't make that much of a difference.

Just open the ambient_generic entity and set the following flag:

Flag
Checkbox-on.png Play everywhere


4. Save and test the map.

See also