Portal 2

Portal 2

Not enough ratings
p0rtalmaster's Hammer Guide Series Part 14/19
By The Sojourner
Hello and welcome to part 14/19 of my series of mini-guides, designed to help you learn perhaps what is the biggest part of the Portal 2 Authoring tools: Hammer.

For a super-quick version of this series, please check out my other guide, Hammer for the Flustered.
   
Award
Favorite
Favorited
Unfavorite
The Works of Compiling
In an old update, the in-game editor shows progress of compiling your map in three stages: "Building geometry", "Computing visibility", and "Calculating lighting." Before that (for those of you who remember), there was only one progress ring which showed "Building Test Chamber..." Unfortunately this became tedious, as there were only 16 ticks and about 5 mins to compile a map.
This means there was about 18 seconds per tick, which made compiling a map look tedious.

Anyway, there are three corresponding stages of the compiling process:



1) vbsp, which compiles the geometry of your map, checks for leaks, etc. and gives you a portal (.prt) file if there's no leak.
2) vvis, which uses the .prt file to compute visibility. This step is so critical to Portal 2 maps that your map will not compile if it has a leak.
3) vrad, which uses the details from vvis and vbsp to calculate the lighting for your map. This normally takes the most time to finish, and twice as long for compiling both LDR (Low Dynamic Range) and HDR (High Dynamic Range).

The Hammer compiler/runner also has other nice options, such as copying your map into the Portal 2\portal2\maps directory (because that's where the game will recognize your map) and starting the game fullscreen or windowed. When it runs, it will run in "developer" mode, which gives a verbose runoff of stuff you see on the console (and then some) in the upper-right corner, so you can debug little problems without having to open the developer console (though you might still need to use the console to execute commands such as noclip unless you have them bound to a key).
Common Misconceptions and The Solution
Based on the hundreds of Hammer maps I've seen, I can confidently say that there are a couple of misconceptions:

1) There is only one way of compiling maps, so there may as well be just one "COMPILE" button.
2) Compiling on "Normal" with HDR checked is good enough.

Points of fact:

1) There is more than one way to compile your map, from quick & dirty modes to the slow & beautiful ones.
2) Compiling on "Normal" with HDR checked is never good enough! The compiler will only compute HDR lighting and not LDR lighting. Furthermore, -final is left out of the equation.

The proper way



1) When compiling, click on Expert... Despite the implication of the name of this button, you do NOT need to be an expert at Hammer to use this. There are presets that you can use without having to know much about how the system works (it's command-line based btw).



2) Select the "Full Compile -both -final (slow!)" mode from the drop-down menu.
3) Hit "Go!" and that's it!

TIP: you can check and uncheck the various parts of the compiling process seen below. For example, you can uncheck vrad to debug any logic errors in your map without having to wait the extra 3-4 mins for your map to finish compiling.



Then once you've debugged those errors, you can check vrad again and debug lighting issues. You can also uncheck the part that runs the map in-game if you have any custom content to embed before running/testing/debugging your map.
What Does It Look Like?
Maybe some of you don't understand what the visual effect of using a Full Compile is. Here's a little illustration of a couple of elevator rooms, both of which are very ubiquitous among Hammer maps on the workshop:



You should immediately notice the differences: the top image is darker than the bottom one — hell it's even hard to see what color the floor is supposed to be other than "black" despite there being the normal gray carpet texture there!

But in the bottom image, you can see that everything's well-lit, and moreover that it's evenly and plausibly lit. No extra light entities were added to make the bottom image brighter than the top one. That is the power of using a Full Compile when getting ready to publish a map.

If you want to see another example, check out the entrance hallway in all those exported PeTI maps. Normally there's a yellow wall in many of them, but without a Full Compile it's black instead. Another sign of a lack of Full Compile: deadly goo pits won't appear as dark and full in color as they would with a Full Compile.
Compiling Cubemaps
I decided to add this section here because cubemaps are very special things. They will eliminate and correct shininess in your maps.

What are they exactly? They are just another point entity: env_cubemap. They have a couple of keyvalues, but you don't need to worry about these. You also don't need to worry about inputs or outputs for cubemaps.

Good places to place them are right next to glassy objects such as observation room windows (both sides), pneumatic diversity vents, inside of cube droppers, and maybe even just one in the middle of a general area.

The wrinkle with cubemaps is when it comes time to build them. They are built not in Hammer, but inside the game engine. Portal 2 has been known to crash if you try to use the buildcubemaps console command. So how do we get those cubemaps built? The key is to place your compiled maps into the portal2_dlc2\maps folder. After you've done that, cubemaps are built this way:

1) Start of the game and load your map.
2) Run the buildcubemaps console command. You should see a momentary flashing at every location where there are cubemaps.
3) You now have cubemaps compiled for HDR (High Dynamic Range) mode.
4) Run the mat_hdr 0 console command. This will set your material level to LDR (Low Dynamic Range) mode.
5) Restart the map using the restart console command.
6) Run the buildcubemaps console command again.
7) You now have cubemaps compiled for both LDR and HDR.
8) To enjoy your game again, run the mat_hdr 2 console command and restart.

Cubemaps haven't been too big an issue in Portal 2 Hammer maps, but they shouldn't be neglected.
Mistakes to Avoid & More Information

  • Not using Full Compile on the build of your map that you plan to publish publicly
  • Forgetting to use Full Compile on the build of your map that you plan to publish publicly
  • Neglecting to use Full Compile on the build of your map that you plan to publish publicly
  • You get the idea, right?
  • Forgetting about cubemaps

More information from the VDC Wiki:
Master Guide List
Please note that there are still some works in progress. This section will be updated as I finish more guides for you!

You are currently viewing part 14/19 in the series.

| 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |

Previous Guide (about elevator rooms and beginning and ending a singleplayer map)
Next Guide (about testing elements behind-the-scenes)

Please feel free to leave a well-reasoned question or comment below. Either I or a qualified Test Chamber Associate (you'll know because they make all the good maps on the workshop) will respond. If your question or comment is not well-reasoned, I recommend reading over my guides again until you understand them 100%. No further information is required here or will be provided, and you will become an excellent Test Chamber Designer — using Hammer!

4 Comments
Catloaf Kory :3 14 Sep, 2019 @ 4:47am 
great tutorial but the portal 2 branch doesnt use lds afaik so its enough to compile final hdr
le frogé 2 Nov, 2016 @ 5:01am 
how do you do it
:steamsad:
soufi 1 Nov, 2016 @ 1:23am 
good
MapleMakes 23 Sep, 2016 @ 12:02pm 
Ahahaha Cubemaps will vex me no more