SteamVR/Environments/Fog Tutorial: Difference between revisions
Redspike474 (talk | contribs) (Added example Vtex) |
Redspike474 (talk | contribs) (Minor fixes) |
||
Line 31: | Line 31: | ||
== Thickness, Opacity or Density of your Fog == | == Thickness, Opacity or Density of your Fog == | ||
[[Image:Fog_tut_third.png|thumb|256px|right|Example Alpha channel from a env_gradient_fog texture.]] | [[Image:Fog_tut_third.png|thumb|256px|right|Example Alpha channel from a env_gradient_fog texture.]] | ||
Currently we have covered how to create a texture that changes the color of your fog, but you're probably wondering how to change the opacity or “thickness” of your fog. Well it's as easy as authoring the color except fog opacity is stored in the alpha channel of your texture and not in the RGB channels. | Currently we have covered how to create a texture that changes the color of your fog, but you're probably wondering how to change the opacity or “thickness” of your fog. Well it's as easy as authoring the color, except fog opacity is stored in the alpha channel of your texture and not in the RGB channels. | ||
Left to right indicates the fog opacity over distance, and up and down fog opacity over height. | Left to right indicates the fog opacity over distance, and up and down fog opacity over height. Black represents 0 (fully transparent), and white represents 1 (fully opaque), creating a gradient between the two allows you to have gradual changes in the fogs opacity. | ||
It's worth noting that distance fog can never be outrun, although it is mapped to world units, it is mapped relative to your eye position, 0 0 0 being your eye position and thus you can never leave the fog as you would be able to in a volumetric solution. | It's worth noting that distance fog can never be outrun, although it is mapped to world units, it is mapped relative to your eye position, 0 0 0 being your eye position and thus you can never leave the fog as you would be able to in a volumetric solution. | ||
Conversely height fog is static and is mapped to the world rather than the players eye position, this means you can climb out or move above the layer of fog. This is particularly useful if you want low hanging fog in specific areas. | Conversely height fog is static and is mapped to the world rather than the players eye position, this means you can climb out or move above the layer of fog. This is particularly useful if you want low hanging fog in specific areas. | ||
{{Tip| More trivia than a tip | {{Tip| More trivia than a tip; in previous versions of Source2, gradient fog textures were authored slightly different and did not incorporate height fog into the texture. As of SteamVR Home this has changed to incorporate both height and distance fog into a single texture. }} | ||
{{bug| The texture “materials/effects/example_gradient_fog.vtex” was created before the change to the gradient fog system that allowed for height fog to be incorporated into the texture, and as such only provides an example of distance fog.}} | {{bug| The texture “materials/effects/example_gradient_fog.vtex” was created before the change to the gradient fog system that allowed for height fog to be incorporated into the texture, and as such only provides an example of distance fog.}} | ||
<br clear=all> | <br clear=all> | ||
Line 41: | Line 41: | ||
Once you have created your texture make sure you save it to your addons content folder, we suggest saving it to “materials/effects/”, this is not essential but it's a good idea for organization purposes. | Once you have created your texture make sure you save it to your addons content folder, we suggest saving it to “materials/effects/”, this is not essential but it's a good idea for organization purposes. | ||
Next you must create a vtex to point to your newly created texture, a vtex is Source2s texture definition format. This is a requirement for Source2’s resource compiler, the tool that takes raw textures and converts them into the engine’s optimized compiled format. | Next you must create a vtex to point to your newly created texture, a vtex is Source2s texture definition format. This is a requirement for Source2’s resource compiler, the tool that takes raw textures and converts them into the engine’s optimized compiled format. | ||
A Vtex is a dme format text file that is essentially a description for the resource compiler, telling it how to | A Vtex is a dme format text file that is essentially a description for the resource compiler, telling it how to process the textures according to your settings. | ||
Click [[SteamVR/Environments/Fog_Tutorial_VTEX|here]] to find an example vtex file that is setup to be used with a fog texture. | Click [[SteamVR/Environments/Fog_Tutorial_VTEX|here]] to find an example vtex file that is setup to be used with a fog texture. | ||
Save your vtex in the same location as your gradient fog texture | Save your vtex in the same location as your gradient fog texture. While running Source2 will automatically detect this file and compile your texture. | ||
<br clear=all> | <br clear=all> | ||
== Placing an env_gradient_fog entity in your map == | == Placing an env_gradient_fog entity in your map == | ||
[[Image:Fog_tut_fourth.png|thumb|256px|right|Selecting the env_gradient_fog entity.]] | [[Image:Fog_tut_fourth.png|thumb|256px|right|Selecting the env_gradient_fog entity.]] | ||
Follow these instructions to setup the fog entity in your map | Follow these instructions to setup the fog entity in your map: | ||
* In Hammer select the entity tool located on the left panel or Shift-E. | * In Hammer select the entity tool located on the left panel or Shift-E. | ||
* In the Tool properties panel change the entity class to env_gradient_fog. | * In the Tool properties panel change the entity class to env_gradient_fog. | ||
Line 55: | Line 55: | ||
* Whilst in the Object Properties panel make sure to also assign your newly authored gradient fog texture. | * Whilst in the Object Properties panel make sure to also assign your newly authored gradient fog texture. | ||
Changes to this entity will update in real time in hammer’s 3D viewports. | Changes to this entity will update in real time in hammer’s 3D viewports. | ||
You should now have everything required to have fog appear in your level, build your map and take a look at what your fog looks like in VR and marvel at its foggy splendor. | You should now have everything required to have fog appear in your level, build your map, and take a look at what your fog looks like in VR and marvel at its foggy splendor. | ||
<br clear=all> | <br clear=all> | ||
== Example Material’s == | == Example Material’s == |
Revision as of 15:42, 15 January 2018
Adding Fog to your Environments
Source2 introduces a new fog entity called env_gradient_fog, this entity can be utilized to create different types of fog effects. It’s a pretty fancy system allowing dense ground-hugging fog with super-subtle changes in colour or density. To see an example of this entity in action and used effectively, take a look at the main SteamVR Home map. In this tutorial we will teach you how to author fog textures and add fog to your pre existing maps as well as a detailed breakdown of this entities workings.



Env_Gradient_Fog Texture Guidelines
The env_gradient_fog entity is primarily controlled by a gradient texture, this textures dimensions should be equal to a power of 2 and the texture should also contain an alpha channel.
Suggested Image formats are png psd or tga.
At first glance authouring gradient fog textures may seem like a complicated and daunting process, but really once you come to understand how they work it's a pretty straightforward affair.
The Color of your Fog
The color in the RGB channels of your texture dictate the distribution of fog color over distance. This is controlled by specifying a start and end distance of the fog in the env_gradient fog entity, the start and end distance are specified in world units. The texture is read from left to right, and mapped from your start distance to your end distance, A good way to understand this is to visualize your fog texture being stretched from the start value to the end value. This is an extremely versatile system that allows for subtle or drastic changes in your fog’s color to match the artistic needs of your level. Changing fog color over distance can be used as an effective tool to illustrate the depth of your scene and add atmosphere.

Whilst left to right controls color over distance, up and down controls the color over height allowing you to create fog that has the illusion of variable properties as you ascend through it.
Thickness, Opacity or Density of your Fog
Currently we have covered how to create a texture that changes the color of your fog, but you're probably wondering how to change the opacity or “thickness” of your fog. Well it's as easy as authoring the color, except fog opacity is stored in the alpha channel of your texture and not in the RGB channels. Left to right indicates the fog opacity over distance, and up and down fog opacity over height. Black represents 0 (fully transparent), and white represents 1 (fully opaque), creating a gradient between the two allows you to have gradual changes in the fogs opacity. It's worth noting that distance fog can never be outrun, although it is mapped to world units, it is mapped relative to your eye position, 0 0 0 being your eye position and thus you can never leave the fog as you would be able to in a volumetric solution. Conversely height fog is static and is mapped to the world rather than the players eye position, this means you can climb out or move above the layer of fog. This is particularly useful if you want low hanging fog in specific areas.


Creating a VTEX
Once you have created your texture make sure you save it to your addons content folder, we suggest saving it to “materials/effects/”, this is not essential but it's a good idea for organization purposes.
Next you must create a vtex to point to your newly created texture, a vtex is Source2s texture definition format. This is a requirement for Source2’s resource compiler, the tool that takes raw textures and converts them into the engine’s optimized compiled format.
A Vtex is a dme format text file that is essentially a description for the resource compiler, telling it how to process the textures according to your settings.
Click here to find an example vtex file that is setup to be used with a fog texture.
Save your vtex in the same location as your gradient fog texture. While running Source2 will automatically detect this file and compile your texture.
Placing an env_gradient_fog entity in your map
Follow these instructions to setup the fog entity in your map:
- In Hammer select the entity tool located on the left panel or Shift-E.
- In the Tool properties panel change the entity class to env_gradient_fog.
- Left click in your scene to place this entity.
- Now return to the selection tool Shift-S and select your newly created fog entity.
- In the Object Properties panel on the right, assign start and end distances for both your distance and height fog.
- Whilst in the Object Properties panel make sure to also assign your newly authored gradient fog texture.
Changes to this entity will update in real time in hammer’s 3D viewports.
You should now have everything required to have fog appear in your level, build your map, and take a look at what your fog looks like in VR and marvel at its foggy splendor.
Example Material’s
To help you get to grips with this system we have included an example fog texture and also a basic map to demonstrate an example setup of the env_gradient_fog entity.

Credit and thanks to Adam Foster (CargoCult) for originally explaining this entities functionality here on the SteamVR Home discussion boards.