Adding Overlays to your Environments
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:
- 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.
Creating an Overlay material
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.
Applying 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.
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.
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.
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.