SteamVR/Environments/Overlay Tutorial

From Valve Developer Community
< SteamVR‎ | Environments
Revision as of 16:59, 23 January 2018 by Redspike474 (talk | contribs) (Initial posting of Overlay Tutorial)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Adding Overlays to your Environments

The iconic Lambda logo emblazoned on the wall of this environment is an example use of overlays.

In this tutorial we will not only teach you how to create overlay textures and materials, but also how to apply them to your pre-existing maps.

SteamVR Home handles overlays slightly differently to what users may expect, especially users familiar with Source 1’s implementation. Although different, overlays in Source 2 are far superior and have a wide range of options making them an extremely flexible resource for adding an additional layer of detail to your environments.

Overlays are a type of material or “decal” that is projected onto a surface, like a type of digital sticker. They are most commonly used to add an additional layer of 2D detail to a surface that the underlying texture does not contain.

A few common uses for overlays include:

  • Posters
  • Graffiti
  • Logos
  • Signage
  • Destruction
  • Dirt and grime
  • Blood splatters
  • Roads and paths
  • Industrial markings


Overlays now support the regular shading model “vr_standard” that’s utilized by all other renderable entities, for example this means that specular, normal mapping, texture animation, and most of the other standard material features can be used in your overlays material.




Tip.png Tip: This tutorial assumes you already know the basics of using Hammer and have already created a map in which you wish to add overlays to. For a beginner's introduction to level design and the SteamVR Home tools click here.




Creating an Overlay material

The addition of a gloss map makes the Lambda logo look almost wet.

We will not cover the basics of material creation in this tutorial, for an indepth look at material creation see this article.


Only materials that have the overlay parameter enabled can be used as overlays, however most materials will support being projected as an overlay if you create and save a variant with this parameter enabled. This is particularly useful in a situation where you want an overlay version of a regular world material.

By default the overlay parameter in your material is greyed out, to enable this parameter in the material editor you must first have the transparency parameter checked.

In Source 1 transparency was often stored in the alpha channel of a material’s colour texture, however this is not the case in Source 2 which utilizes a separate greyscale texture to define the transparency of a material. The engine’s resource compiler will then combine the various input textures from your material into runtime optimized formats.


Tip.png Tip:  Did you know that there is a practical use to Source 2's naming convention? The material editor will automatically pick textures that follow the correct naming convention based on the name of your colour texture. If your colour texture is called banana01_colour then when looking for a normal map the material editor will search for files matching the filename “banana01” and with the appropriate suffix”_normal”.


Tip.png Tip:  Overlays don't always need to produce a specular response, when applicable it's recommended to save on performance by not ticking the specular box in your material and thus omitting the overlay from expensive specular calculations. Likewise in some cases you can also save on performance by omitting a normal map for overlays that don't need to show any visible surface variation.






Applying an Overlay

The currently active material is one that supports being projected as an overlay.
Bug.png Bug:  Once an overlay ready material is set as the active material you will no longer be able to change geometry type in the block tool, because of this it is important to make sure your geometry tool is set to block before you select your material. Switching back to a regular material fixes this issue.
Tip.png Tip: The block tool will display a warning to let you know if your current active material supports creation of an overlay.


Follow these steps to correctly place an overlay;

  • The first step in applying an overlay to your scene is to set your active material to one that supports overlays.
  • Once you have an overlay material selected change your active tool to the block tool by pressing Shift-B.
  • Drag out a block volume to represent the rough shape that you wish your overlay to encompass (you will be able to change the shape again later by pressing Q to enable the editing gizmo).
  • When you are happy with the shape of your overlay volume press enter to confirm the creation of your overlay.
  • You will now see a static overlay helper attached to your volume, left clicking this with the selection tool will display the object properties for this entity.


Additional Parameters

Is there something on my face? In Source 2 you can project overlays onto not just world geometry but also onto models.


Below is a description of the different options that are available to edit in the overlay entities object properties.


  • Projection Distance

You may notice that the Z axis (depth) of your overlay’s projection volume cannot be modified, this is because it is controlled directly in the object properties as the parameter projection distance. By default your overlay will be set to project up to a distance of 128 world units, this means all faces up to a depth of 128 units will be covered with your overlay texture. This can lead to artifacts where overlays project through walls; it’s important to tweak this value appropriately for your specific scene so that only the faces you intended receive the overlay.


  • Render Order

If you have multiple overlays that share the same space they will flicker and fight for priority. A solution to this problem is to specify a hierarchical rendering order for your overlays by specifying which order they should render in the overlay entities object properties.


  • Colour

In some instances you will want to utilize the same overlay texture several times, rather than creating several different coloured versions you can specify a render colour to tint the whole overlay. In situations when using numerical or alphabetical signage it may be useful to place overlays with various colour variations. For example as the player progresses through an environment that is comprised of several different areas, you may want the same sign displayed in each area but colored differently to represent difficulty, progress, or orientation.

  • Projection Mode

It is possible to restrict the projection type of overlays to only cast onto one type of receiver. For example the projection mode option lets you choose between casting onto only world geometry, models or both. By default both the world and models will receive an overlay projection.


  • Project On Backfaces

In some rare cases you will want your overlay to render on both sides of your geometries faces, enabling project on backfaces in the entities object properties will allow for two sided projection.


  • Projection Targets

By default overlays will cast onto anything in their projection path, however it is possible to set a specific projection target or targets to limit overlays to cast on to only these. - omg i suck at wording.




Example Materials

To help you get to grips with Source 2’s new overlay system, we have included an example overlay material, texture and a basic map to demonstrate the steps mentioned in this tutorial.


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