$seamless scale: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Tested normal maps in CSGO)
m (→‎Caveats: Investigate: neither normal map seems to work in tf2)
Line 35: Line 35:
* Hammer's 3D view renders the material itself correctly, but others will stop working.
* Hammer's 3D view renders the material itself correctly, but others will stop working.
* [[$bumpmap|Standard normal mapping]] is supported in {{csgo}}, in other games [[$ssbump|only its self-shadowing cousin]].
* [[$bumpmap|Standard normal mapping]] is supported in {{csgo}}, in other games [[$ssbump|only its self-shadowing cousin]].
* {{todo|Investigate: Neither seems to work in {{tf2}}}}
* <code>[[$detail]]</code> textures are unsupported. {{todo|Investigate <code>$seamless_detail</code>.}}
* <code>[[$detail]]</code> textures are unsupported. {{todo|Investigate <code>$seamless_detail</code>.}}



Revision as of 09:01, 17 April 2021

Template:Shaderparam 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

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 Counter-Strike: Global Offensive, in other games only its self-shadowing cousin.
  • Todo: Investigate: Neither seems to work in Team Fortress 2
  • $detail textures are unsupported.
    Todo: Investigate $seamless_detail.

History

According to 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 0.25 scale

Assuming a texture size of 1024x1024, setting $seamless_scale to 0.001953125 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:

  • Scale = 1 / (1024 * scale)
  • 0.125 = 0.0078125 (1 / 128)
  • 0.25 = 0.001953125 (1 / 256)
  • 0.50 = 0.0009765625 (1 / 512)
  • 0.75 = 0.00065104166 (1 / 768)
  • 1.00 = 0.00048828125 (1 / 1024)
  • 1.25 = 0.000390625 (1 / 1280)

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