First open up your unity scene.
Click on Layers -> Edit Layers...
Open up the Tags list and add in VFog. This name can be customised see below in notes.
Select your main camera and add the V-Fog Script by clicking Component -> Image Effects -> V-Fog.
Next add in fog volumes by clicking GameObject -> Create Other -> V-Fog (Primitive Type).
Switch to the Game tab to preview the fog. To go back and edit your fog shapes click Show Fog Shapes to show the shapes. Then toggle off Show Fog Shapes to preview your fog.
Custom Materials / Meshes
To use your own meshes simply create a new material with shader V-Fog/Fog and apply it to your mesh. Then apply the VFog tag to it.
V-Fog Inspector Options
- Ramp Texture: This is a 1D texture(red channel) that is used to determine how the fog fades in and out.
- Ramp Scale: Scales the ramp texture.
- Fog Objects: These are the fog shapes managed by the script. This shouldn't be touched when Auto Manage Objects is on.
- Global Density Multipler: Adjusting this value will fade in and out all of the fog objects managedby this script.
- Downscale: For older cards with less fill rate power you can downscale the fog so it rendersthe fog at a lower resolution.
- Blur Radius: This let's you do a simple 8-tap blur to soften the fog. This is useful when Downscale is greater than one to reduce aliasing.
- Draw Wireframes: Displays an outline of the mesh when Show fog shapes it's togged off.
- Auto Manage Objects: When ticked on the system will search for all objects tagged VFog and use them as fog volumes. When off the user can manually drag in what fog objects they want to use under Fog Shapes, this is useful if you want to render fog objects with different fog ramps. You can do this by adding multiple V-Fog scripts to the same camera, disabling Auto Manage Objects and then dragging in fog shapes manually.
- Show fog shapes: Toggles the fog meshes on and off. Turn this on when you wish to transform the fog meshes. When off the wireframe of the mesh will be displayed. This is automatically toggled off in game mode.
- Blend Mode: Choose Additive or Subtractive or lighten or darken mode. Be careful when mixing two types of blending modes on the same camera as things will not sort correctly.
V-Fog renders volumes efficiently because it's based on convex shapes and additive/subtractive blending.
Shapes will render no matter what but may show artefacts if the shape is not convex.
To customise what tag V-Fog uses open up V-Fog/Scripts/VFog.cs
On Line 10: public const string FOG_TAG = "VFog";
Change "VFog" to whatever unique tag name you with to use.
The VFog tag is only used when Auto Manage Objects is on. It's possible not to use the VFog tag by manually dragging the meshes under Fog Objects.