written by Flanders
Prefab and settings
Here we use func_fx’s to simulate random interval lightning. Start by loading up the tdm_sky_storm_thunder prefab in prefabs/nature/skyboxes. The func_fx underneath the skybox is used to create a light and a sound inside your map. Move it to a position high in your map where you want the flash to appear. The func_fx in the skybox makes a flash in the sky.
To trigger the lightning a trigger_timer is used. The time between triggering is a random time between “wait” ± “random” in seconds. The trigger_timer targets the func_fx’s. The fx effects are defined in thunder.fx in the fx folder. The fx that is used can be set with the “fx” property.
- fx/thunder.fx for standard lightning
- fx/thunder_distant.fx for distant lightning (dim light, long time between flash and sound)
- fx/thunder_close.fx for close lightning (bright light, immediate sound)
These are for the fx inside the skybox:
Here there is a short explanation on how to change the appearance of the used skybox.
To change the colour of the sky select the big light and edit its properties. To change the colour of the small lights in the sky edit the two smaller lights. To make the clouds move at a different speed select the func_static with the cloud texture and add “shaderparm3” to it and give it a value (0.5 ~ 3). You can change the size of the clouds with the surface inspector, as long as you make sure it fits a rounded number of times so that there are no seams when the texture scrolls. As you can see, the whole skybox can be edited by editing the objects in the prefab skybox. The sky that is used in your map is just a projection of the stuff surrounding the info_portalsky.
Flashing decals, webs
Decals like spider webs that get lit by nearby lights might flash in the lightning even when they are deep in an underground cave. To fix this, you need to place a visportal that's been forced shut, in between the decal and the thunder_fx entity. There are 2 ways to force a portal shut: put a closed door in it, or a closed func_portal. If you don't want to use an auto-closing door to fix your scene, use a func_portal that's set to close when the player is a short distance away.
The problem happens because webs and other translucent-but-lit decals don't ever get shadowed. So the surrounding walls don't shadow them from the lightning flash. A portal that's been shut by a door or func_portal effectively seals off the visleafs behind from all lights the other side.