This article's documentation is for anything that uses the Strata engine. Click here for more information.
This article's documentation is for anything that uses the Source engine. Click here for more information.

Hotspot texturing

From Valve Developer Community
(Redirected from %rectanglemap)
Jump to navigation Jump to search

Edit Tabs

Hotspot texturing is a method to quickly apply textures to geometry by matching faces to predefined rectangles. This method is especially useful with texture maps consisting of trims and panels, and will allow you to automate a lot of the texture aligning process.

Example of a structure made with a hotspot texture

Valve used hotspot texturing extensively in the creation of Half-Life: Alyx Half-Life: Alyx to create modular geometry with bevelled edges. This feature has now been brought over to Source Source, inspired by the Source 2 Source 2 implementation.

This feature is only available in Hammer++ Hammer++ and Strata Hammer Strata Hammer.

Benefits

  • Easy to author: The rectangles in the texture can be created in a consistent and seamless style.
  • Improved performance: Since all the rectangles use the same material, they will only consume one draw call rather than multiple like with traditional textures.
  • Saves file size and VRAM: Don't need multiple textures, it can be packed into one texture instead.
  • Quick to apply: You can just select all faces and press Fit, and the result will be nearly perfect.

Authoring

1. Create a texture with rectangular regions. The rectangles can be any size, as long as they are axis aligned.

2. Create a .rect file. This is a plaintext file containing the list of rectangles. Place the .rect file beside your VMT/VTF.

Example file that has two rectangles. The origin (0, 0) is from the top left of the texture.

Rectangles
{
	rectangle
	{
		min		"0 0"
		max		"512 32"
	}
	rectangle
	{
		min		"512 0"
		max		"768 32"
		reflect 1
	}
}

Region flags can be defined by adding additional lines with flagname 1 inside a rectangle block. The following flags are recognized by existing map editors:

Flag Supported by Description
rotate Strata Hammer Enables regions to be rotated to better match the target surface.
reflect Strata Hammer Enables regions to be randomly horizontally flipped.
alt Strata Hammer Marks this region as an alternate. When the Alt key is held, only alternate rects are chosen.
tile None yet Will be implemented in next Hammer++ update. Marks region as allowed to tile in one or both directions (based upon the rectangle touching the edge of the texture on both sides).

3. Specify the path to your .rect file in your VMT as %rectanglemap (relative to the materials folder).

Example:

LightmappedGeneric
{
	$basetexture  "hotspot/hotspot_test"
	%rectanglemap "hotspot/hotspot_test"
	$surfaceprop  "metal"
	$alphatest    1
}

Example

This is an example grate texture with hotspotting.

Download

Usage

With a hotspot-ready texture in Hammer, apply the texture and then press the Fit button. Hammer will automatically read the .rect file and apply the hotspotting.

Hammer will try choose the closest matching rectangle within a margin of error. If there are multiple matches for a rectangle, a random one is chosen. Pressing Fit will generate a new random result in this case.

Utilities

VTFEdit++ VTFEdit++

Provides a GUI editor to create/edit hotspot maps for VTFs. It can be accessed under the Texture tab.

XBLAH's Modding Tool - Material Hotspot Editor.
XBLAH's Modding Tool XBlah's Modding Tool

Can create or edit RECT hotspot files. The editor shows a preview of the hotspots, and is integrated with Windows File Explorer.

RectMaker - Creating and modifying .rect files
RectMaker

GUI Editor for creation and modification of hotspot RECT files. Supports VTF/PNG/JPG/BMP/TIF/WEBP/PSD textures, can save and open RECT files directly, and can open VMT files.

SourceHotspot Addon

Open-source Blender addon that can generate both RECT files and embedded hotspot resources from a mesh's UV map. Useful for porting DreamUV atlases!

Hotspot Texture Tool

Online tool for creation and modification of hotspot .rect files. Supports VTF/PNG/JPG textures, can save and open RECT files.

See also