$seamless scale

From Valve Developer Community
Jump to: navigation, search
English

$seamless_scale is a material shader parameter available in all Source Source games since Source 2007 Source 2007 for LightmappedGeneric, WorldVertexTransition, Lightmapped_4WayBlend. It was created to sidestep texture stretching issues on displacement surfaces. Models can use this effect on detail textures only with $seamless_detail.

Basic Syntax

$seamless_scale <float>
LightMappedGeneric
{
	$basetexture Example\Example01
	$surfaceprop concrete
	$seamless_scale 0.005
}
VertexlitGeneric
{
	$basetexture Example\Example01
	$surfaceprop concrete
	$detail "models\props_forest\cliff_detail"
	$detailscale 4
	$detailblendfactor 1
	$detailblendmode 0
	$seamless_detail 1
	$seamless_scale 0.005
}

Additional Parameters

$seamless_detail<boolean>
Enables the effect on detail textures with the VertexLitGeneric shader. Requires $seamless_scale to set the scale of the effect and only applies to the detail texture.

To do: What about $seamless_base?

Caveats

History

According to Half-Life 2: Episode Two Half-Life 2: Episode Two's developer commentary, this feature was added in response to difficulties experienced with the creation of the antlion caves section. The complicated topography of the areas exaggerated a previously bearable material-stretching effect.

This effect is a result of how Source usually handles displacements: a UV map is locked to the vertices of a displacement surface, and when a vertex on it is translated the polygons linking it to its neighbours stretch or contract accordingly, carrying the texture with them. This can lead to polygons with squashed textures sitting beside others with stretched and blurred ones; an unpleasant effect.

$seamless_scale separates the material's coordinate system from the vertices of the displacement, allowing it to maintain a regular scale across an entire surface without any designer effort.

Matching Texture Scale

Assuming a texture size of 1024x1024, setting $seamless_scale to 0.0078125 will match the 0.25 scale in hammer. This was achieved by dividing (1 / (texture size * desired scale)).

For example, if texture size was 1024x1024:

  • 0.125 = (1 / (1024 * 0.125)) = 1 / 128 = 0.0078125
  • 0.25 = (1 / (1024 * 0.25)) = 1 / 256 = 0.00390625
  • 0.50 = (1 /(1024 * 0.5)) = 1 / 512 = 0.001953125
  • 0.75 = (1 / (1024 * 0.75)) = 1 / 768 = 0.0013020833333333
  • 1.00 = (1 / (1024 * 1.0)) = 1 / 1024 = 0.0009765625
  • 1.25 = (1 / (1024 * 1.25)) = 1 / 1280 = 0.00078125

Additionally, it appears textures are inverted on the Y axis.