Skybox (2D) with Terragen: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Updated script with better alternative.)
m (Nesciuse moved page Skybox (2D) with Terragen/en to Skybox (2D) with Terragen without leaving a redirect: Move en subpage to basepage)
 
(12 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{LanguageBar}}
[[category:tutorials]][[category:Third Party Tools]][[category:Material System]]
[[category:tutorials]][[category:Third Party Tools]][[category:Material System]]
'''[http://www.planetside.co.uk/terragen/ Terragen]''' is a freeware scenery generator which can be used to create [[2D skybox]]es.  The freeware version has a limitation that effectively limits the texture dimensions of the skybox to 960, so it can only really be used for skies at 512x512. If Terragen is registered for $99 (US), the size limitation is removed, so skies at 1024x1024 could potentially be rendered.
{{terraingen|4.1}} is a freeware scenery generator which can be used to create [[2D skybox]]es.  The freeware version has a limitation that effectively limits the texture dimensions of the skybox to 960, so it can only really be used for skies at 512x512. If Terragen is registered for $99 (US), the size limitation is removed, so skies at 1024x1024 could potentially be rendered.


This tutorial will explain how to use a scene in Terragen to create a 2D skybox that can be used in Hammer.
This tutorial will explain how to use a scene in Terragen to create a 2D skybox that can be used in Hammer.
==Creating the scene==
==Creating the Scene==
Terragen can be downloaded [http://www.planetside.co.uk/terragen/win/downloadwin.shtml here].
Terragen can be downloaded [http://www.planetside.co.uk/terragen/win/downloadwin.shtml here].


Terragen takes a little bit of practice to get the hang of.  There are many websites that can teach you the basics.  Here are some good ones:
Terragen takes a little bit of practice to get the hang of.  There are many websites that can teach you the basics.  Here are some good ones:


*[http://www.planetside.co.uk/terragen/guide/ The official guide]
*[https://planetside.co.uk/wiki/index.php?title=Main_Page The official guide]
*[http://individual.utoronto.ca/edegiuli/TGtut/TerragenTutMain.htm Terragen tutorial by E. DeGiuli]
*[https://web.archive.org/web/20090924172404/http://individual.utoronto.ca/edegiuli/TGtut/TerragenTutMain.htm Terragen tutorial by E. DeGiuli]
*[http://www.caroluk.org.uk/terratut/ Terragen tutorial by C. Brooksbank] - Recommended
*[https://web.archive.org/web/20101220011606/http://www.caroluk.org.uk/terratut/ Terragen tutorial by C. Brooksbank] - Recommended


Create your scene and save it.  The camera position doesn't matter for now.  Terragen can render realistic land if you're very skilled. In source engine games making terrain is not recommended for a 2D skybox, since Source has [[3D Skybox|3D skyboxes]]; however, it can often be a good idea to use the tool to create a downwards facing texture to use on a displacement map in your skybox, like de_inferno in CSS. Removing FOV distortion can be a pain, but its not entirely necessary.
Create your scene and save it.  The camera position doesn't matter for now.  Terragen can render realistic land if you're very skilled. In source engine games making terrain is not recommended for a 2D skybox, since Source has [[3D Skybox|3D skyboxes]]; however, it can often be a good idea to use the tool to create a downwards facing texture to use on a displacement map in your skybox, like de_inferno in CSS. Removing FOV distortion can be a pain, but its not entirely necessary.


==Set up the script==
==Set up the Script==
The skybox requires six images to be rendered.  This script will automate the creation of all six so you do not have to repeatedly come back to your computer and readjust the camera after each render.
The skybox requires six images to be rendered.  This script will automate the creation of all six so you do not have to repeatedly come back to your computer and readjust the camera after each render.


Line 73: Line 74:
frend
frend
</pre>
</pre>
{{Note|You actually have to make sure that you the script is saved using DOS line endings or else Terragen will not process it and immediately tell you ''End of script'' without any action.}}
{{Note|You actually have to make sure that the script is saved using DOS line endings (ANSI encoding) or else Terragen will not process it and immediately tell you ''End of script'' without any action. You can make sure this is done by changing UTF-8 to ANSI in Notepad's ''Save As'' dialog.}}
 
==Render the skybox==


==Render the Skybox==
1. Now, in Terragen, uncheck ''both'' of the Fixed Height Above Surface boxes in the Rendering Control window. Place your Terragen camera where you want the viewpoint of the skybox to be.  What's important here is the Camera Position.  The Camera Orientation doesn't matter.  Note that changing the height can affect the appearance of the clouds even though the horizon is always in the same location.
1. Now, in Terragen, uncheck ''both'' of the Fixed Height Above Surface boxes in the Rendering Control window. Place your Terragen camera where you want the viewpoint of the skybox to be.  What's important here is the Camera Position.  The Camera Orientation doesn't matter.  Note that changing the height can affect the appearance of the clouds even though the horizon is always in the same location.


<center>[[Image:Terrastep1.jpg]]</center>
<center>[[File:Terrastep1.jpg]]</center>


2. Set the detail all the way up in the Rendering Control window.  Set the width and height both to 512.  This is the best you can do with the freeware version.  If you have registered Terragen, set them both to 1024.
2. Set the detail all the way up in the Rendering Control window.  Set the width and height both to 512.  This is the best you can do with the freeware version.  If you have registered Terragen, set them both to 1024.
{{tip|For a softer image and better antialiasing, set both dimensions to 960, then downscale the results to 512 in a image editor.}}


<center>[[Image:Terrastep2.jpg]]</center>
<center>[[File:Terrastep2.jpg]]</center>


3. You should double check that you did the first two steps right so you don't waste a lot of time. Now, choose ''Execute Script...'' from the ''Terragen'' menu, and choose the file skyboxscript.tgs that you created earlier.  Now the rendering will commence.  It may take a couple of hours or more.  Call someone you love.
3. You should double check that you did the first two steps right so you don't waste a lot of time. Now, choose ''Execute Script...'' from the ''Terragen'' menu, and choose the file skyboxscript.tgs that you created earlier.  Now the rendering will commence.  It may take a couple of hours or more.  Call someone you love.


4. When the rendering is complete, a dialog will pop up saying the script is complete.  Quit Terragen.  
4. When the rendering is complete, a dialog will pop up saying the script is complete.  Quit Terragen.


==Get the textures ready==
==Get the Textures Ready==
Now, if you open up the C: drive, you'll see six new BMP files.  Rename them as follows, where xxxx is whatever you want to name your sky:
Now, if you open up the C: drive, you'll see six new BMP files.  Rename them as follows, where xxxx is whatever you want to name your sky:


Line 115: Line 116:
|}
|}


Use Photoshop or PaintShopPro to save them as [[TGA]] files into <code>...sourcesdk_content/materialsrc/skybox</code>. Create the folder if you have to.  Then drag the six TGAs onto [[Vtex]] to create your [[VTF]]s.
Use Photoshop or PaintShopPro to save them as [[TGA]] files into <code>...sourcesdk_content/materialsrc/skybox</code>. Create the folder if you have to.  Then drag the six TGAs onto [[Vtex (Source 1)|Vtex]] to create your [[VTF]]s.


==Create the VMTs==
==Create the VMTs==
Line 133: Line 134:
The skybox is complete.  To use it in Hammer, go to '''Map properties...''' in the '''Map''' menu and change the skybox entry to xxxx, where xxxx represents the name you chose for your sky.
The skybox is complete.  To use it in Hammer, go to '''Map properties...''' in the '''Map''' menu and change the skybox entry to xxxx, where xxxx represents the name you chose for your sky.
{{envart}}
{{envart}}
__noeditsection__
{{sdktools|0}}

Latest revision as of 10:40, 12 July 2024

English (en)Français (fr)Translate (Translate)

Terragen Terragen is a freeware scenery generator which can be used to create 2D skyboxes. The freeware version has a limitation that effectively limits the texture dimensions of the skybox to 960, so it can only really be used for skies at 512x512. If Terragen is registered for $99 (US), the size limitation is removed, so skies at 1024x1024 could potentially be rendered.

This tutorial will explain how to use a scene in Terragen to create a 2D skybox that can be used in Hammer.

Creating the Scene

Terragen can be downloaded here.

Terragen takes a little bit of practice to get the hang of. There are many websites that can teach you the basics. Here are some good ones:

Create your scene and save it. The camera position doesn't matter for now. Terragen can render realistic land if you're very skilled. In source engine games making terrain is not recommended for a 2D skybox, since Source has 3D skyboxes; however, it can often be a good idea to use the tool to create a downwards facing texture to use on a displacement map in your skybox, like de_inferno in CSS. Removing FOV distortion can be a pain, but its not entirely necessary.

Set up the Script

The skybox requires six images to be rendered. This script will automate the creation of all six so you do not have to repeatedly come back to your computer and readjust the camera after each render.

Use Notepad to save the following script as skyboxscript.tgs. It can be saved anywhere.

initanim "C:\output\sky_testft", 1

;_ft
Zoom 1.0
CamH 0
CamP 0
CamB 0
frend

initanim "C:\output\sky_testlf", 1

;_lf
Zoom 1.0
CamH 90
CamP 0
CamB 0
frend

initanim "C:\output\sky_testup", 1

;_up
Zoom 1.0
CamH 270
CamP 90
CamB 0
frend

initanim "C:\output\sky_testbk", 1

;_bk
Zoom 1.0
CamH 180
CamP 0
CamB 0
frend

initanim "C:\output\sky_testrt", 1

;_rt
Zoom 1.0
CamH 270
CamP 0
CamB 0
frend

initanim "C:\output\sky_testdn", 1

;_dn
Zoom 1.0
CamH 270
CamP -90
CamB 0
frend
Note.pngNote:You actually have to make sure that the script is saved using DOS line endings (ANSI encoding) or else Terragen will not process it and immediately tell you End of script without any action. You can make sure this is done by changing UTF-8 to ANSI in Notepad's Save As dialog.

Render the Skybox

1. Now, in Terragen, uncheck both of the Fixed Height Above Surface boxes in the Rendering Control window. Place your Terragen camera where you want the viewpoint of the skybox to be. What's important here is the Camera Position. The Camera Orientation doesn't matter. Note that changing the height can affect the appearance of the clouds even though the horizon is always in the same location.

Terrastep1.jpg

2. Set the detail all the way up in the Rendering Control window. Set the width and height both to 512. This is the best you can do with the freeware version. If you have registered Terragen, set them both to 1024.

Tip.pngTip:For a softer image and better antialiasing, set both dimensions to 960, then downscale the results to 512 in a image editor.
Terrastep2.jpg

3. You should double check that you did the first two steps right so you don't waste a lot of time. Now, choose Execute Script... from the Terragen menu, and choose the file skyboxscript.tgs that you created earlier. Now the rendering will commence. It may take a couple of hours or more. Call someone you love.

4. When the rendering is complete, a dialog will pop up saying the script is complete. Quit Terragen.

Get the Textures Ready

Now, if you open up the C: drive, you'll see six new BMP files. Rename them as follows, where xxxx is whatever you want to name your sky:

Original filename Change to
skyrender0001.bmp xxxxft.bmp
skyrender0002.bmp xxxxlf.bmp
skyrender0003.bmp xxxxup.bmp
skyrender0004.bmp xxxxbk.bmp
skyrender0005.bmp xxxxrt.bmp
skyrender0006.bmp xxxxdn.bmp

Use Photoshop or PaintShopPro to save them as TGA files into ...sourcesdk_content/materialsrc/skybox. Create the folder if you have to. Then drag the six TGAs onto Vtex to create your VTFs.

Create the VMTs

Head over to your new VTFs. They'll be in ...materials/skybox for whichever game you're editing. Now create six VMTs with the same names as the VTFs using this format:

"UnlitGeneric"
{
    "$basetexture" "skybox/xxxxbk"
    "$nofog" 1
    "$ignorez" 1
}

Where xxxx represents the name of your sky. For each of the six VMTs, change that bk to the appropriate suffix to match its filename.

Completion

The skybox is complete. To use it in Hammer, go to Map properties... in the Map menu and change the skybox entry to xxxx, where xxxx represents the name you chose for your sky.

Environment articles:
Skies and environment maps Source Source: Skybox (2D)Skybox (3D)HDR SkiesSkybox with TerragenSkybox with Terragen - AdvancedList of skies


Source 2 Source 2: Skybox (3D)

Terrain and displacement mapping DisplacementsCreating Holes in DisplacementsDigital Elevation ModelsCreating custom terrain with Worldmachine