PTBake
Path-traced lighting for Source maps.
Replaces VRAD in Hammer or Hammer++, using your GPU to bake lighting.
Abstract light study: a light installation in a shallow gallery alcove, with a warm vertical light bar, a cool overhead bar and a low plinth. Website artwork, not PTBake output.
Results
No bake captures are published yet.
Get the beta.
Public beta · Windows x64
One Windows executable with nothing to install. Choose it as Hammer's lighting compiler and compile as usual.
Requirements
- System
- Windows, 64-bit
- Minimum GPU
- Supports Vulkan 1.0
- Recommended
- GPU with hardware ray tracingOptional. NVIDIA RTX, AMD Radeon RX 6000 or newer, Intel Arc.
Beta notes
ptbake.exeis not code-signed.- The first bake may take longer, including after a graphics driver update.
- Heavy maps on slower or laptop GPUs can trigger a Windows GPU reset. The bake stops and writes a crash report.
Setup
Set up in Hammer or Hammer++
Choose PTBake as your lighting compiler, then compile maps through Hammer as usual.
Download and extract PTBake. Place
ptbake.exein the same folder ashammer.exeorhammerplusplus.exe. That is usually your game'sbinfolder, but some installs keep the editor in a subfolder ofbin: use the folder your editor actually runs from.Open Hammer or Hammer++. Go to Tools > Options.
Select the Build Programs tab. If you have more than one game configuration, choose the one you want to use with PTBake.
Change the RAD executable. Click Browse beside that field and select the
ptbake.exeyou extracted. This replaces the path to your current lighting compiler.Save your settings. Click Apply, then OK.
Compile your map as usual. Keep the lighting (RAD) step enabled. Hammer will use PTBake to bake the lighting.
Keep your original lighting executable. To switch back, select it again in the RAD executable field.
Command-line usage
Open a terminal in the folder with ptbake.exe and check the build:
ptbake.exe -versionIt prints the version, source commit, build id and shader set. Include this in bug reports.
Bake a compiled map in place:
ptbake.exe -game <gamedir> <map.bsp><gamedir>is the mod folder that holdsgameinfo.txt, for example...\Half-Life 2\hl2. The lit map replaces the input.bsp; add-output PATHto write it elsewhere.
Quality presets
| Preset | Samples | Bounces | Blur | Use |
|---|---|---|---|---|
-fast | 64 | 4 | 2 | Quick preview |
(none) | 1024 | 20 | 1 | Default |
-final | 4096 | 20 | 1 | Release bake |
-samples, -bounces and -blur override a preset. More samples mean less noise and a longer bake. In Hammer, add a preset to the RAD step's parameters (Run Map, Expert mode).
Advanced options
-bounces Nsets how many times light bounces between surfaces. The default is 20.-radbakes area lights from.radtexture lights. Experimental and off by default.-adaptiveturns on adaptive sampling. Experimental.
In Hammer, add them to the RAD step's parameters (Run Map, Expert mode).
It takes the VRAD step.
PTBake is a command-line compiler. It reads a compiled .bsp, bakes its lightmaps, prop lighting and ambient lighting on the GPU, and writes them back. The rest of your compile stays the same.
- 01
Compile as usual
Your geometry and visibility steps run as before. PTBake replaces only the VRAD step, in Hammer or in a build script.
- 02
Bake on the GPU
PTBake loads the map with the materials and models from the game folder you pass with
-game, traces its lighting, and writes it back into the same.bsp. - 03
Test in game
Hammer's Copy File step copies the lit map into the game, the same as after VRAD.
What it handles
- Bounced light
- Light reflects between surfaces, carrying their color into the surrounding scene.
- Light from the sky
- The sky texture contributes light and color to the scene.
- Your existing lights
- Supports
light,light_spot,light_environmentandlight_directional. Named and switchable lights can still toggle in game. Set_light_radiusfor softer shadows. - Static prop lighting
- Bakes lighting onto static props, with per-texel lightmaps for props using
generatelightmapsin Garry's Mod and Source MP maps. - 3D skyboxes
- Sunlight, skylight and bounced light travel between your map and its 3D skybox.
- Glass, foliage and water
- Accounts for glass, water and cutout textures such as foliage when baking shadows and bounced light.
- Ray tracing hardware is optional
- Uses hardware ray tracing when available. GPUs without it can still bake using software tracing on the GPU.
- LDR and HDR
- Bake LDR, HDR or both. With
-both, PTBake shares data between the two lighting modes to keep BSP size down.
Report a problem.
Beta reports shape the next build. Tell us what went wrong; logs help when you have them.
The feedback link for the beta is not published yet.
What to include
- What happenedWhat went wrong, what you expected, and the steps to reproduce it. Screenshots help with lighting problems.
- Your PTBake versionThe first line of Hammer's compile window shows it.
- Logs, if you have themThe compile log, and the crash report if the bake stopped with an error.
Save the compile log from Hammer
Copy the output from Hammer's compile window into a text file and attach it.
For a more detailed log:
- Open Run Map and switch to Expert mode.
- Select the lighting (RAD) step.
- Add
-log-fileand a path to a new file to its Parameters, for example-log-file C:\maps\mymap-ptbake.log. - Compile again, then attach that file.
Use a file name that doesn't exist yet: PTBake won't overwrite a file.
Find the crash report
When a bake stops with FATAL GPU ERROR, PTBake writes a file named after your map, such as mymap.ptbake-crash.txt, next to the compiled map. From Hammer, that is usually the folder with your .vmf. Attach it as it is.
From the command line
ptbake.exe -version prints the version, source commit, build id and shader set. Add -log-file PATH to a bake to save the detailed log.
If a bake stops with a GPU error
- Close games and other GPU-heavy programs.
- On a laptop, connect AC power.
- Update the graphics driver, then reboot.
- If it still fails, add
-no-ray-queryto the RAD step's parameters to use software ray tracing instead, and mention it in your report.