Difference between revisions of "HDR Skybox Creation"

From Valve Developer Community
Jump to: navigation, search
m (Released today)
m (Fixed vtf2tga redlink)
 
(35 intermediate revisions by 14 users not shown)
Line 1: Line 1:
[[Image:Ldrvshdr.jpg|thumb|200px|A Low Dynamic sky, compared to the same sky in High Dynamic.]]
+
{{otherlang2
 +
|ru=HDR_Skybox_Creation:ru
 +
}}
 +
[[File:Skybox ldr hdr.jpg|thumb|250px|HDR skyboxes (left) benefit from a wider range of brightness values.]]
  
An LDR (Low Dynamic Range) skybox is made up of six 24-bit .[[TGA]] files (front, left, back, right, up, and down). This format does not contain enough information to look good when adjusted by large exposure values, and will not produce high contrast lightmaps and reflections. An [[HDR]] (High Dynamic Range) skybox is a 32-bit floating-point format, saved out from an application that supports HDR as a .[[PFM]] file. This format contains the multiple exposure information required for exposure adjustments, high contrast lightmaps, and reflections.
+
Unlike most textures in a game, a [[skybox]] typically represents a collection of very large and very bright objects. '''This makes the need for [[high dynamic range]] imaging far more pressing.'''
  
{{note|The examples in this document assume you are creating an HDR skybox for Day of Defeat: Source. For other games, substitute the <code>day of defeat source/dod</code> in directory locations for the appropriate game directory of the game you are creating the skybox for (e.g. <code>hl2</code> or <code>hl2dm</code>). Currently, HDR is only supported in [[Day of Defeat: Source]], [[Counter-Strike: Source]], [[Half-Life 2: Episode 1]] and [[Half-Life 2: Lost Coast]]}}
+
[[VTF]] textures used for HDR skyboxes store their colors either lightly compressed in 16-bit [[Float|floating point]] (RGBA16161616f) or heavily compressed as 8-bit [[integer]] values (BGRA8888). In either case, they are created by [[VTEX]] from uncompressed 32-bit floating point Portable Float Map (.pfm) files.
  
You should have a basic understanding of the [[material]] system and creating Source materials to use this information.
+
{{tip|Uncompressed HDR VTFs can be decompiled to PFMs by [[VTF2TGA|vtf2tga]] (despite the name).}}
  
== Understanding the Sky at different exposures ==
+
== Creating PFMs ==
  
[[Image:hdr_sky_reference.jpg|thumb|250px|An example of photos of the sky at various exposures. Click to enlarge.]]
+
{{tip|[[File:Skybox half.jpg|thumb|250px|Half the size, all of the image]] Since the lower halves of skybox sides generally aren't seen, it's often wise to cut away that area. For this trick to work, you must compile the side VTFs with these extra commands:
  
Before creating a HDR skybox we need to know what the sky looks like at different exposures. The following images are a series of photos taken of the sky at different exposures. As you can see the sun is still bright even at the camera's fastest shutter speed&#8230;1/4000<sup>th</sup> of a second.<br style="clear:both">
+
<source lang=php>
 +
clamps 1
 +
clampt 1
 +
</source>
  
== Create your base skybox ==
+
And add this command to the materials:
  
First you need to create the base .TGA files that make your skybox cube. This is done using the same method as standard (LDR) skyboxes. See [[Skybox (2D)|Skybox (2D)]] for information on how to create base skybox materials.
+
<source lang=php>
 +
$basetexturetransform "center 0 0 scale 1 2 rotate 0 translate 0 0"
 +
</source>
  
== Organize the skybox images into a single file ==
+
See [[#Creating the materials]] for details on how to use the commands.
 +
}}
  
[[Image:hdr_skybox_sides.jpg|thumb|250px|An example skybox with labels for each side of the cube. Click to enlarge.]]
+
=== Skies at different exposures ===
  
Once you've made the base skybox images, use your image editing software to assemble the separate six .TGA sides into one large single .TGA file, as shown in this sample image. For demonstration purposes, text was inserted into this image to show which piece of the skybox should go into each position. If you add this text yourself, it will show up in-game when the skybox is compiled.
+
Before creating a HDR skybox we need to know what the sky looks like at different exposures:
  
The SDK includes this sample skybox. The .TGA files can be found in: <code>sdk_content\dod\materialsrc\skybox\sdk_sky_example_hdr.tga</code>
+
[[Image:hdr_sky_reference.jpg|700px|center|Photos of the sky at various exposures.]]
<br style="clear:both">
 
  
== Edit and Save an HDR skybox ==
+
As you can see, the captured image changes as the exposure is altered. A single 8-bit image could never be used to create those effects: at 8-bit white is white, and the sun would only stand out if it was literally a different colour from the rest of the sky.
  
The following will demonstrate the basic steps for painting a "sun" effect into the different exposures and saving the file as a .PFM. We'll use HDR Shop for this demonstration. The HDR Shop program can be downloaded from [http://www.hdrshop.com/ www.hdrshop.com]. After it is installed, launch the application, and then open the above .TGA you created above.
+
=== Create a base skybox ===
  
When this window appears leave the default settings and Select '''OK''''.
+
First you need to create a basic skybox cube, as you would for an LDR skybox. See [[Skybox (2D)]].  
  
[[Image:hdrshop_curvedialog.png]]
+
With your images ready, arrange them in one large file as seen below. This step is required only if you are using the [[splitskybox]] tool. If you aren't then you are quite free to handle each texture separately.
  
[[Image:hdrshop_adjustedsky.jpg|thumb|250px|The skybox after the response curve has been adjusted in HDR Shop. Click to enlarge.]]
+
[[Image:hdr_skybox_sides.jpg|center|Recommended skybox layout (labelled)]]
  
To paint the 'sun' into the skybox you must first choose an exposure to edit. The '+' and '-' keys are used to adjust the image exposure up and down. The lower right hand corner of the screen indicates the exposure level, '+0.00 stops' indicates the base exposure level that was imported into HDR Shop. Adjust the exposure level so it reads '-3.00 stops' Then, go to the menu: File -> Edit in Image Editor. The image-editing program you have associated with .BMP format will automatically open up this file as <code>HDRShopTEMP.bmp</code> Now paint the sun into this file.
+
Save this assembled image as a TGA file. If you are prompted, do ''not'' use RLE compression and ''do'' place the origin at the bottom left.
  
When finished save the image and return to HDR Shop.<br style="clear:both">
+
=== Adding HDR data ===
  
After clicking '''OK''' in this dialog, the current exposure level will be updated with the image that was just painted with the image-editing program.
+
We will now paint a sun into our skybox, which will behave in the same way as the 'exposures' photographs above. A good tool to use for this step is [http://gl.ict.usc.edu/HDRShop HDR Shop].
  
[[Image:hdrshop_OKdialog.png]]
+
{{warning|HDR Shop is no longer free and is now locked behind a pricey license. You will have to search the internet for the freeware version.}}
  
[[Image:hdrshop_saveas.png|right]]
+
{{note|When you open your TGA in HDR Shop you'll see a dialogue with a slider. Feel free to fiddle with it, but you'll probably want to leave things at their defaults.}}
  
Try adjusting the exposure up and down in HDR Shop with the '+' and '-' keys and you'll see that the sun is now integrated into the other exposures. Continue editing the different exposures until the desired result is achieved. It will be a good idea to spend some time emulating the blown-out effects around the sun and the highlights on the clouds as seen in the photographic reference.
+
HDR Shop works by taking files created by other [[Image Manipulation Programs|image editors]] for different exposures and merging them together at 32-bit floating point. You can adjust the exposure you are working on with the {{key|+}} and {{key|-}} buttons on your keypad, or from the menu with <code>View > Exposure</code>. The current value is displayed in the lower-right corner of the screen.
  
When finished go to the '''File''' menu and choose '''Save as&#8230;''' and Select '''Portable Floatmap (.PFM)''' Save this file into your materialsrc content directory (e.g. <code>sdk_content\dod\materialsrc\skybox</code>).<br style="clear:both">
+
When you've reached the exposure you are looking for, choose <code>File -> Edit in image editor</code> and you will get an image to edit. HDR Shop will open the image in your default BMP editor at this point, but you can use whatever tool you want so long as you're saving the right file.
  
== Creating the auxiliary skybox files ==
+
There is a more detailed tutorial [http://gl.ict.usc.edu/HDRShop/tutorial/tutorial07.php available on HDR Shop's website].
  
The next stage is to create all the auxiliary skybox files: separate .PFM, .TXT, and .VMT files. A new application called <code>splitskybox.exe</code> was created to split the single .PFM skybox into the six separate files needed by the Source Engine. Copy a shortcut of the <code>Splitskybox.bat</code> (located in the <code>sourcesdk\bin\</code> directory) onto your desktop, then drag the .PFM file onto this shortcut.
+
When you are finished, OK away the HDR Shop's dialogue and choose <code>File -> Save as...</code> and select the 'Portable Floatmap' format. Name and save this PFM file as you would a 2D skybox source image.
  
Which should give you output similar to this:
+
==== sdk_sky_exampleup ====
  
<pre>
+
[[Image:Sdk sky exampleup.jpg|right|thumb|200px|sdk_sky_exampleup]]
splitskybox.exe "C:\Program Files\Steam\SteamApps\username\sourcesdk_content\dod\materialsrc\skybox\sdk_sky_example_hdr.pfm"
 
  
filename: C:\Program Files\Steam\SteamApps\username\sourcesdk_content\dod\materialsrc\skybox\sdk_sky_example_hdrft.pfm
+
Let's do this with <code>sourcesdk_content\dod\materialsrc\skybox\sdk_sky_exampleup.tga</code>. Open it up and adjust the exposure to -3 stops, then edit the image externally. Now paint in a sun.
filename: C:\Program Files\Steam\SteamApps\username\sourcesdk_content\dod\materialsrc\skybox\sdk_sky_example_hdrlf.pfm
 
filename: C:\Program Files\Steam\SteamApps\username\sourcesdk_content\dod\materialsrc\skybox\sdk_sky_example_hdrbk.pfm
 
filename: C:\Program Files\Steam\SteamApps\username\sourcesdk_content\dod\materialsrc\skybox\sdk_sky_example_hdrrt.pfm
 
filename: C:\Program Files\Steam\SteamApps\username\sourcesdk_content\dod\materialsrc\skybox\sdk_sky_example_hdrup.pfm
 
filename: C:\Program Files\Steam\SteamApps\username\sourcesdk_content\dod\materialsrc\skybox\sdk_sky_example_hdrdn.pfm
 
Press any key to continue . . .
 
</pre>
 
  
When finished the content directory (e.g. <code>sdk_content\dod\materialsrc\skybox</code>) will include six new files based one the same name but appended with (ft, lf, bk, rt, up, and dn) this designates the different directions of the skybox (front, left, back, right, up, and down).
+
After returning to HDR Shop and OKing the dialogue, the current exposure level will be updated with the image that you just painted.
  
Next, create six new .TXT files based on the new file names in the same directory. These .TXT files tell the Source Engine that the skybox is a .PFM file for compression reasons, and that the base exposure level matches '+0.00' in HDR Shop. If needed you can adjust the "pfmscale" so the base level is either higher or lower, but it is recommended to author skybox textures for a scale of 1.
+
Try adjusting the exposure up and down and you'll see that the sun is now integrated into the other exposures as well. Continue editing the different exposures until the desired result is achieved. It will be a good idea to spend some time emulating the blown-out effects around the sun and the highlights on the clouds as seen in the photographic reference.
  
With Notepad or another text editor, create these files:
+
=== Split the skybox ===
* sdk_sky_example_hdr'''ft'''.txt
 
* sdk_sky_example_hdr'''lf'''.txt
 
* sdk_sky_example_hdr'''bk'''.txt
 
* sdk_sky_example_hdr'''rt'''.txt
 
* sdk_sky_example_hdr'''up'''.txt
 
* sdk_sky_example_hdr'''dn'''.txt
 
  
With the following text in each file:
+
If you created your skyboxes in a single file as in the above image, you will need to use <code>splitskybox.exe</code> to split it into six. Just drag the PFM onto it.
<pre>
 
"pfm" "1"
 
"pfmscale" "1"
 
</pre>
 
  
Then, create six new .vmt files in the Game Directory (e.g. <code>day&nbsp;of&nbsp;defeat&nbsp;source\dod\materials\skybox</code>) and enter the following into each.
+
{{note|[[splitskybox]] Ep1 does not currently function. However, the OB version will work with either version of the engine.}}
 +
{{note|[[Left 4 Dead 2]] Splitskybox is not a required step. And in fact will not work without lots of retyping of suffixes of multiple files. Left 4 Dead 2's iteration of [[VTEX]] is able to take your "T" image array (both tga into LDR and pfm into HDR) and process it directly into the proper <name_bk>vtf format. In order to do this, create your "T" array as above. Recommended simply for the sake of sanity to get proper orientation for the top (and bottom if needed) images in your custom skybox. Create your txt file as normal and drag it onto Left 4 Dead 2's Vtex. Create materials and use in game as normal. A caveat here is, although the vtf files are compiled properly for LDR, if you are opting out of an HDR skybox and plan to use a LDR skybox only, the supplied LDR material template in the [[skybox_(2D)]] tutorial does not work. You will get the checkerboard pattern.
 +
If you are trying to import an HDR skybox (meaning, if you rendered out a set of skybox textures in your external software, and then used HDRShop to create the hdr data) of a night sky, you will experience extreme banding in the darker areas which resemble dx compression. This banding is actually a result of the way HDRShop handles color information and can be observed directly in HDRShop if you adjust down the exposure and inspect your image.}}
  
{{note|The file names should all match depending upon the skybox side. These .VMT files are the same from standard, non-HDR Source skyboxes except that there is now a <code>$hdrbasetexture</code> field for HDR. The standard <code>$basetexture</code> field is used for the LDR skybox fallback.}}
+
== Creating the materials ==
  
* sdk_sky_example_hdr'''ft'''.vmt
+
At this stage you should have six files:
<pre>
+
 
"sky"
+
*<code><skyname>_hdr'''ft'''.pfm</code>
{
+
*<code><skyname>_hdr'''lf'''.pfm</code>
    "$hdrbaseTexture" "skybox/sdk_sky_example_hdrft"
+
*<code><skyname>_hdr'''bk'''.pfm</code>
    "$nofog" "1"
+
*<code><skyname>_hdr'''rt'''.pfm</code>
    "$ignorez" "1"
+
*<code><skyname>_hdr'''up'''.pfm</code>
    "$basetexture" "skybox/sdk_sky_exampleft"
+
*<code><skyname>_hdr'''dn'''.pfm</code>
}
 
</pre>
 
  
* sdk_sky_example_hdr'''lf'''.vmt
+
Make sure they are under <code>your_mod\materialsrc\skybox\</code>. You now need to create '''six corresponding TXT files''' (e.g. <code><skyname>_hdrft.txt</code>) alongside them, in order to compile to VTF. Each must contain:
<pre>
 
"sky"
 
{
 
    "$hdrbaseTexture" "skybox/sdk_sky_example_hdrlf"
 
    "$nofog" "1"
 
    "$ignorez" "1"
 
    "$basetexture" "skybox/sdk_sky_examplelf"
 
}
 
</pre>
 
  
* sdk_sky_example_hdr'''bk'''.vmt
+
<source lang=php>
<pre>
+
pfm 1 // Flag as HDR texture
"sky"
+
pfmscale 1 // brightness multiplier
{
+
nonice 1 // prevent seams appearing at low texture detail
    "$hdrbaseTexture" "skybox/sdk_sky_example_hdrbk"
+
nocompress 1 // optional; removing halves filesize, but causes color banding under close inspection
    "$nofog" "1"
+
</source>
    "$ignorez" "1"
 
    "$basetexture" "skybox/sdk_sky_examplebk"
 
}
 
</pre>
 
  
* sdk_sky_example_hdr'''rt'''.vmt
+
Drag these text files onto VTEX and it will compile them (unfortunately [[VTFEdit]] doesn't import PFMs). The VTFs will appear in the corresponding materials subfolder (e.g. <code>your_mod\materials\skybox\</code>).
<pre>
 
"sky"
 
{
 
    "$hdrbaseTexture" "skybox/sdk_sky_example_hdrrt"
 
    "$nofog" "1"
 
    "$ignorez" "1"
 
    "$basetexture" "skybox/sdk_sky_examplert"
 
}
 
</pre>
 
  
* sdk_sky_example_hdr'''up'''.vmt
+
Now you just need to '''create six VMTs named <code><skyname>_hdr<face>.vmt</code>'''. These should read:
<pre>
 
"sky"
 
{
 
    "$hdrbaseTexture" "skybox/sdk_sky_example_hdrup"
 
    "$nofog" "1"
 
    "$ignorez" "1"
 
    "$basetexture" "skybox/sdk_sky_example_01up"
 
}
 
</pre>
 
  
* sdk_sky_example_hdr'''dn'''.vmt
+
<source lang=php>
<pre>
+
Sky
"sky"
 
 
{
 
{
    "$hdrbaseTexture" "skybox/sdk_sky_example_hdrdn"
+
// if you compiled with nocompress:
    "$nofog" "1"
+
$hdrbasetexture "skybox/sdk_sky_example_hdrft"
    "$ignorez" "1"
 
    "$basetexture" "skybox/sdk_sky_exampledn"
 
}
 
</pre>
 
  
== Creating LDR fallbacks ==
+
// if you didn't:
 +
$hdrcompressedtexture "skybox/sdk_sky_example_hdrft"
  
The LDR fallback for the skybox will be based on the original six .TGA files that were used to create the HDR version.
+
$basetexture "skybox/sdk_sky_exampleft"
 
+
}
Go ahead and save these six files into your content directory (e.g. <code>sdk_content\dod\materialsrc\skybox</code>):
+
</source>
* sdk_sky_example'''ft'''.tga
 
* sdk_sky_example'''lf'''.tga
 
* sdk_sky_example'''bk'''.tga
 
* sdk_sky_example'''rt'''.tga
 
* sdk_sky_example'''up'''.tga
 
* sdk_sky_example'''dn'''.tga
 
 
 
Create these text files into the same directory (just like standard LDR skybox [[Creating Materials|materials]]):
 
* sdk_sky_example'''ft'''.txt
 
* sdk_sky_example'''lf'''.txt
 
* sdk_sky_example'''bk'''.txt
 
* sdk_sky_example'''rt'''.txt
 
* sdk_sky_example'''up'''.txt
 
* sdk_sky_example'''dn'''.txt
 
  
With the following text in each file:
+
=== Creating LDR fallbacks ===
<pre>
 
"dxt5" "1"
 
"skybox" "1"
 
</pre>
 
  
== Compiling the skybox ==
+
You must also create standard low dynamic range VTFs for users who do not play in HDR. Compile with these settings:
  
The final stage is to compile all these files so they can be used in the engine. Copy a shortcut of the <code>[[Vtex|vtex.exe]]</code> (from the <code>sourcesdk\bin\</code> directory) onto your desktop, then drag the following .TGA and .PFM files onto this shortcut. For a full description of how to compile textures, see [[Creating Materials]].
+
<source lang=php>
 +
nonice 1
 +
dxt5 1 // or nocompress
 +
</source>
  
* sdk_sky_example_hdr'''ft'''.pfm
+
These are ordinary textures, so you can use [[VTFEdit]] if you prefer. There is no need to create new materials for LDR users; they will load the <code>_hdr</code> ones.
* sdk_sky_example_hdr'''lf'''.pfm
 
* sdk_sky_example_hdr'''bk'''.pfm
 
* sdk_sky_example_hdr'''rt'''.pfm
 
* sdk_sky_example_hdr'''up'''.pfm
 
* sdk_sky_example_hdr'''dn'''.pfm
 
  
* sdk_sky_example'''ft'''.tga
+
== Usage ==
* sdk_sky_example'''lf'''.tga
 
* sdk_sky_example'''bk'''.tga
 
* sdk_sky_example'''rt'''.tga
 
* sdk_sky_example'''up'''.tga
 
* sdk_sky_example'''dn'''.tga
 
  
If all went well, there should be 12 new .VTF files in your Game directory (e.g. <code>day&nbsp;of&nbsp;defeat&nbsp;source\dod\materials\skybox</code>) for a HDR skybox with a LDR fallback.
+
In Hammer, go to ''Main Menu > Map > Map Properties > Skybox Texture Name'' and type the name of your skybox, relative to <code>materials\skybox\</code> and without any of the face suffixes. (e.g. just <code>MySky</code>.)
  
 
== See also ==
 
== See also ==
Line 206: Line 136:
 
* [[HDR Lighting Basics]] - How to add basic HDR lighting effects.
 
* [[HDR Lighting Basics]] - How to add basic HDR lighting effects.
 
* [[HDR Lighting Settings]] - Information on customizing HDR lighting settings.
 
* [[HDR Lighting Settings]] - Information on customizing HDR lighting settings.
 +
* [[Sky (shader)]]
 
* [[Skybox (2D)|Skybox (2D)]]
 
* [[Skybox (2D)|Skybox (2D)]]
 +
* [[Sky Writer]] - 3ds Max tool that renders your scene into PFM and compiles to VTF.
 
* [[Material]]
 
* [[Material]]
  

Latest revision as of 22:47, 4 May 2019

Русский
HDR skyboxes (left) benefit from a wider range of brightness values.

Unlike most textures in a game, a skybox typically represents a collection of very large and very bright objects. This makes the need for high dynamic range imaging far more pressing.

VTF textures used for HDR skyboxes store their colors either lightly compressed in 16-bit floating point (RGBA16161616f) or heavily compressed as 8-bit integer values (BGRA8888). In either case, they are created by VTEX from uncompressed 32-bit floating point Portable Float Map (.pfm) files.

Tip:Uncompressed HDR VTFs can be decompiled to PFMs by vtf2tga (despite the name).

Creating PFMs

Tip:
Half the size, all of the image
Since the lower halves of skybox sides generally aren't seen, it's often wise to cut away that area. For this trick to work, you must compile the side VTFs with these extra commands:
clamps 1
clampt 1

And add this command to the materials:

$basetexturetransform "center 0 0 scale 1 2 rotate 0 translate 0 0"

See #Creating the materials for details on how to use the commands.

Skies at different exposures

Before creating a HDR skybox we need to know what the sky looks like at different exposures:

Photos of the sky at various exposures.

As you can see, the captured image changes as the exposure is altered. A single 8-bit image could never be used to create those effects: at 8-bit white is white, and the sun would only stand out if it was literally a different colour from the rest of the sky.

Create a base skybox

First you need to create a basic skybox cube, as you would for an LDR skybox. See Skybox (2D).

With your images ready, arrange them in one large file as seen below. This step is required only if you are using the splitskybox tool. If you aren't then you are quite free to handle each texture separately.

Recommended skybox layout (labelled)

Save this assembled image as a TGA file. If you are prompted, do not use RLE compression and do place the origin at the bottom left.

Adding HDR data

We will now paint a sun into our skybox, which will behave in the same way as the 'exposures' photographs above. A good tool to use for this step is HDR Shop.

Warning: HDR Shop is no longer free and is now locked behind a pricey license. You will have to search the internet for the freeware version.

Note:When you open your TGA in HDR Shop you'll see a dialogue with a slider. Feel free to fiddle with it, but you'll probably want to leave things at their defaults.

HDR Shop works by taking files created by other image editors for different exposures and merging them together at 32-bit floating point. You can adjust the exposure you are working on with the + and - buttons on your keypad, or from the menu with View > Exposure. The current value is displayed in the lower-right corner of the screen.

When you've reached the exposure you are looking for, choose File -> Edit in image editor and you will get an image to edit. HDR Shop will open the image in your default BMP editor at this point, but you can use whatever tool you want so long as you're saving the right file.

There is a more detailed tutorial available on HDR Shop's website.

When you are finished, OK away the HDR Shop's dialogue and choose File -> Save as... and select the 'Portable Floatmap' format. Name and save this PFM file as you would a 2D skybox source image.

sdk_sky_exampleup

sdk_sky_exampleup

Let's do this with sourcesdk_content\dod\materialsrc\skybox\sdk_sky_exampleup.tga. Open it up and adjust the exposure to -3 stops, then edit the image externally. Now paint in a sun.

After returning to HDR Shop and OKing the dialogue, the current exposure level will be updated with the image that you just painted.

Try adjusting the exposure up and down and you'll see that the sun is now integrated into the other exposures as well. Continue editing the different exposures until the desired result is achieved. It will be a good idea to spend some time emulating the blown-out effects around the sun and the highlights on the clouds as seen in the photographic reference.

Split the skybox

If you created your skyboxes in a single file as in the above image, you will need to use splitskybox.exe to split it into six. Just drag the PFM onto it.

Note:splitskybox Ep1 does not currently function. However, the OB version will work with either version of the engine.
Note:Left 4 Dead 2 Splitskybox is not a required step. And in fact will not work without lots of retyping of suffixes of multiple files. Left 4 Dead 2's iteration of VTEX is able to take your "T" image array (both tga into LDR and pfm into HDR) and process it directly into the proper <name_bk>vtf format. In order to do this, create your "T" array as above. Recommended simply for the sake of sanity to get proper orientation for the top (and bottom if needed) images in your custom skybox. Create your txt file as normal and drag it onto Left 4 Dead 2's Vtex. Create materials and use in game as normal. A caveat here is, although the vtf files are compiled properly for LDR, if you are opting out of an HDR skybox and plan to use a LDR skybox only, the supplied LDR material template in the skybox_(2D) tutorial does not work. You will get the checkerboard pattern. If you are trying to import an HDR skybox (meaning, if you rendered out a set of skybox textures in your external software, and then used HDRShop to create the hdr data) of a night sky, you will experience extreme banding in the darker areas which resemble dx compression. This banding is actually a result of the way HDRShop handles color information and can be observed directly in HDRShop if you adjust down the exposure and inspect your image.

Creating the materials

At this stage you should have six files:

  • <skyname>_hdrft.pfm
  • <skyname>_hdrlf.pfm
  • <skyname>_hdrbk.pfm
  • <skyname>_hdrrt.pfm
  • <skyname>_hdrup.pfm
  • <skyname>_hdrdn.pfm

Make sure they are under your_mod\materialsrc\skybox\. You now need to create six corresponding TXT files (e.g. <skyname>_hdrft.txt) alongside them, in order to compile to VTF. Each must contain:

pfm 1 // Flag as HDR texture
pfmscale 1 // brightness multiplier
nonice 1 // prevent seams appearing at low texture detail
nocompress 1 // optional; removing halves filesize, but causes color banding under close inspection

Drag these text files onto VTEX and it will compile them (unfortunately VTFEdit doesn't import PFMs). The VTFs will appear in the corresponding materials subfolder (e.g. your_mod\materials\skybox\).

Now you just need to create six VMTs named <skyname>_hdr<face>.vmt. These should read:

Sky
{
	// if you compiled with nocompress:
	$hdrbasetexture		"skybox/sdk_sky_example_hdrft"

	// if you didn't:
	$hdrcompressedtexture	"skybox/sdk_sky_example_hdrft"

	$basetexture		"skybox/sdk_sky_exampleft"
}

Creating LDR fallbacks

You must also create standard low dynamic range VTFs for users who do not play in HDR. Compile with these settings:

nonice 1
dxt5 1 // or nocompress

These are ordinary textures, so you can use VTFEdit if you prefer. There is no need to create new materials for LDR users; they will load the _hdr ones.

Usage

In Hammer, go to Main Menu > Map > Map Properties > Skybox Texture Name and type the name of your skybox, relative to materials\skybox\ and without any of the face suffixes. (e.g. just MySky.)

See also

Environment articles:
Skies and environment maps Skybox (2D)Skybox (3D)HDR SkiesSkybox with TerragenSkybox with Terragen - AdvancedList of skies
Terrain and displacement mapping DisplacementsHoles in displacementsDigital Elevation Models