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

Sky (Source 1 shader): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
 
(19 intermediate revisions by 7 users not shown)
Line 1: Line 1:
'''Sky''' is a shader for materials in [[Source]] meant for [[Skybox_(2D)|2D skyboxes]]. The old method of making skyboxes before [[Source 2007]] involved using the [[UnlitGeneric]] shader with <code>[[$ignorez]] 1</code>. This shader expands the amount of usable parameters and also allows for HDR skyboxes.
{{tabsBar|main=Sky (shader)}}
'''Sky''' is a shader for materials in [[Source]] meant for [[Skybox_(2D)|2D skyboxes]]. The old method of making skyboxes before [[Source 2007]] involved using the [[UnlitGeneric]] shader with <code>[[$ignorez|$ignorez 1]]</code>. This shader expands the amount of usable parameters and also allows for [[HDR]] skyboxes.
{{tip|{{l4d2|since}} [[$basetexture]] is not necessary for games that are HDR-only, as only the [[$hdrbasetexture]] or [[$hdrcompressedtexture]] will be used.}}
{{note|This shader always ignores fog. Skyboxes with [[UnlitGeneric]] (and without <code>$nofog 1</code>) are affected by fog.}}
{{warning|The {{cs2|2}} import script doesn't like {{code|$hdrcompressedtexture}}; change it to {{code|$basetexture}}, then decompress to {{w|OpenEXR|EXR}} with {{no_vtf|3.1}} and use that instead{{clarify}}.}}
{{warning|While rare, mat_fullbright set to 1 might sometimes break the rendering of this shader.}}


Most of the time, VMTs should only exist for [[High Dynamic Range|HDR]] skyboxes that have an LDR fallback. An example of an HDR skybox with a fallback will look like this:
=== With an uncompressed HDR skybox texture ===
If the skybox texture uses [[Valve Texture Format#Image_data_formats|uncompressed BGRA16f16f16f16f]], then the [[VMT]] should look something like this:


<source lang=vmt>
<syntaxhighlight lang=php>
"sky"
sky
{
{
"$hdrcompressedTexture" "skybox/sky_wasteland_00_hdrup"
$basetexture skybox/sky_wasteland_00up // Sky texture to use for LDR
"$nofog" "1"
$hdrbasetexture skybox/sky_wasteland_00_hdrup // Uncompressed HDR Sky texture to use for HDR-enabled maps
"$ignorez" "1"
$nofog 1
"$basetexture" "skybox/sky_wasteland_00up"          // VMT will load this VTF instead if not running in HDR.
$ignorez 1
"$basetexturetransform" "center 0 0 scale 1 2 rotate 0 translate 0 0"          // For cutting off the bottom halves of the skybox
$nomip 1
}
}
</source>
</syntaxhighlight>
 
=== With a compressed HDR skybox texture ===
If the skybox has been [[Valve Texture Format#HDR compression|compressed using BGRA8888]], then [[$hdrcompressedtexture]] should be used instead:
 
<syntaxhighlight lang=php>
sky
{
$basetexture skybox/sky_wasteland_00up // Sky texture to use for LDR
$hdrcompressedtexture skybox/sky_wasteland_00_hdrup // Compressed HDR Sky texture to use for HDR-enabled maps
$nofog 1
$ignorez 1
$nomip 1
}
</syntaxhighlight>
 
{{todo|Figure out what the "HDR compression method B" mentioned in {{file|sky_hdr_dx9|cpp}} does differently, as it asks for $hdrcompressedtexture0, $hdrcompressedtexture1, and $hdrcompressedtexture2 instead of a single $hdrcompressedtexture.}}
 
=== Without an HDR skybox texture ===
If an HDR version of the skybox texture is not available, [[$hdrbasetexture]] can use the same VTF as [[$basetexture]]:
 
<syntaxhighlight lang=php>
sky
{
$basetexture skybox/sky_wasteland_00up // Sky texture to use for LDR
$hdrbasetexture skybox/sky_wasteland_00up // Sky texture to use for HDR, if the texture has NOT been specifically compiled for HDR
$nofog 1
$ignorez 1
$nomip 1
}
</syntaxhighlight>
 
=== Issues ===
{{cleanup|See [[HDR Skybox Creation]] for better explanation of when $basetexturetransform may be necessary.}}
You might find that skyboxes sometimes fit the entire projection area of a level. To re-scale the material to fit, use [[$basetexturetransform]] or add the following line:
<syntaxhighlight lang=php>
$basetexturetransform "center 0 0 scale 1 2 rotate 0 translate 0 0" // For cutting off the bottom halves of the skybox
</syntaxhighlight>
 
The {{code|scale 1 2}} segment will maintain the fill-sizing of the X-axis, while locking the texture to the center line of the Y-axis (i.e. the absolute horizon line).
 
{{src topicon|nocat=1}}
[[Category:Shaders]]
[[Category:Shaders]]

Latest revision as of 07:39, 13 February 2025

edit

Sky is a shader for materials in Source meant for 2D skyboxes. The old method of making skyboxes before Source 2007 involved using the UnlitGeneric shader with $ignorez 1. This shader expands the amount of usable parameters and also allows for HDR skyboxes.

Tip.pngTip:(in all games since Left 4 Dead 2) $basetexture is not necessary for games that are HDR-only, as only the $hdrbasetexture or $hdrcompressedtexture will be used.
Note.pngNote:This shader always ignores fog. Skyboxes with UnlitGeneric (and without $nofog 1) are affected by fog.
Warning.pngWarning:The Counter-Strike 2 Counter-Strike 2 import script doesn't like $hdrcompressedtexture; change it to $basetexture, then decompress to Wikipedia icon EXR with no_vtf and use that instead[Clarify].
Warning.pngWarning:While rare, mat_fullbright set to 1 might sometimes break the rendering of this shader.

With an uncompressed HDR skybox texture

If the skybox texture uses uncompressed BGRA16f16f16f16f, then the VMT should look something like this:

sky
{
	$basetexture skybox/sky_wasteland_00up // Sky texture to use for LDR
	$hdrbasetexture skybox/sky_wasteland_00_hdrup // Uncompressed HDR Sky texture to use for HDR-enabled maps
	$nofog 1
	$ignorez 1
	$nomip 1
}

With a compressed HDR skybox texture

If the skybox has been compressed using BGRA8888, then $hdrcompressedtexture should be used instead:

sky
{
	$basetexture skybox/sky_wasteland_00up // Sky texture to use for LDR
	$hdrcompressedtexture skybox/sky_wasteland_00_hdrup // Compressed HDR Sky texture to use for HDR-enabled maps
	$nofog 1
	$ignorez 1
	$nomip 1
}
Todo: Figure out what the "HDR compression method B" mentioned in 🖿sky_hdr_dx9.cpp does differently, as it asks for $hdrcompressedtexture0, $hdrcompressedtexture1, and $hdrcompressedtexture2 instead of a single $hdrcompressedtexture.

Without an HDR skybox texture

If an HDR version of the skybox texture is not available, $hdrbasetexture can use the same VTF as $basetexture:

sky
{
	$basetexture skybox/sky_wasteland_00up // Sky texture to use for LDR
	$hdrbasetexture skybox/sky_wasteland_00up // Sky texture to use for HDR, if the texture has NOT been specifically compiled for HDR
	$nofog 1
	$ignorez 1
	$nomip 1
}

Issues

Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality because:
See HDR Skybox Creation for better explanation of when $basetexturetransform may be necessary.
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.

You might find that skyboxes sometimes fit the entire projection area of a level. To re-scale the material to fit, use $basetexturetransform or add the following line:

	$basetexturetransform "center 0 0 scale 1 2 rotate 0 translate 0 0" // For cutting off the bottom halves of the skybox

The scale 1 2 segment will maintain the fill-sizing of the X-axis, while locking the texture to the center line of the Y-axis (i.e. the absolute horizon line).