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

$seamless_scale

From Valve Developer Community
Jump to navigation Jump to search
English (en)Translate (Translate)
Todo: Provide screenshots showing how this parameter affects textures

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

Icon-Bug.pngBug:Renders as fully black if the user has mat_specular set to 0. No known workaround.  [todo tested in?]

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

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.
Todo: What about $seamless_base?

Caveats

  • This is not a total solution—there are still some situations where stretching will occur (such as sudden 90° outcroppings). It's handled as best it can be, though.
  • You can no longer scale the material with the Hammer Face Edit Dialog. The parameter's value must instead changed in the material itself.
  • Hammer's 3D view renders the material itself correctly, but others will stop working.
  • Standard normal mapping is supported in CS:GO engine branch CS:GO engine branch, but in other games only its self-shadowing cousin.
  • Todo: Investigate: Neither seems to work in Team Fortress 2 Team Fortress 2.
  • $detail textures are unsupported.
    Todo: Investigate $seamless_detail.

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.