<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/rss.xsl" type="text/xsl"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Unsuario2 Portfolio</title><description>Unsuario2 website to share projects</description><link>https://unusuario2.github.io</link><item><title>File system with batch operations in Source Engine</title><link>https://unusuario2.github.io/posts/source_engine/tooling/flb/file-system-batch-operations</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/flb/file-system-batch-operations</guid><description>filesystem_batch.dll — adding real glob pattern matching and batch file operations on top of the Source Engine filesystem.</description><pubDate>Sun, 26 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;filesystem_batch.dll — Adding glob pattern support to Source Engine&lt;/h2&gt;
&lt;p&gt;Source Engine has basic wildcard support in its filesystem. Basic is the key word. It doesn&apos;t hold up when you&apos;re building an asset pipeline that needs to operate on large sets of files with real glob patterns and batch operations.&lt;/p&gt;
&lt;p&gt;So I extended it with &lt;strong&gt;filesystem_batch.dll&lt;/strong&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;What it does&lt;/h3&gt;
&lt;p&gt;It adds full glob pattern matching to the Source Engine filesystem through a facade module: you pass a pattern, it scans the directory, matches against the glob, discards what doesn&apos;t match, and returns the result. Batch operations on file sets with a clean interface on top of the existing filesystem.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Design decisions&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;DLL module&lt;/strong&gt; to keep it modular and reusable across tools and games. Any tool in the pipeline can consume it without pulling in unrelated code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Facade pattern.&lt;/strong&gt; The facade isolates the rest of the pipeline from filesystem internals. Clients don&apos;t need to know how the scanning or matching works — they just call the interface.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Interface + Singleton.&lt;/strong&gt; Abstracts the implementation from the client. One instance, consistent state, clean access point across the pipeline.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Portability.&lt;/strong&gt; Designed to be portable to other platforms such as POSIX or macOS if needed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Performance.&lt;/strong&gt; Fast enough that it doesn&apos;t become a bottleneck in the build process.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Example in action&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;resourcefilesystem.exe&lt;/strong&gt; — a tool that exposes the filesystem_batch API directly to the user, allowing manual glob queries against the Source Engine filesystem from the command line.&lt;/p&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/flb/flb_2.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;contentcleanup.exe&lt;/strong&gt; — sanitizes the game directory by removing temporary and user-generated files using glob-based pattern matching.&lt;/p&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/flb/flb_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;p&gt;There are many more examples where &lt;strong&gt;filesystem_batch&lt;/strong&gt; is used across the tooling (ContentBuilder, ContentWatch, ContentCheck, ResourceCompiler).&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Code snippet&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;./flb_4.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./flb_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./flb_3.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Class diagram (UML)&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;./flb_1.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Design references&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Facade pattern: &lt;a href=&quot;https://refactoring.guru/design-patterns/facade&quot;&gt;https://refactoring.guru/design-patterns/facade&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Singleton pattern: &lt;a href=&quot;https://refactoring.guru/design-patterns/singleton&quot;&gt;https://refactoring.guru/design-patterns/singleton&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>ContentCleanup: Game directory cleanup utility</title><link>https://unusuario2.github.io/posts/source_engine/tooling/cntnclp/contentcleanup</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/cntnclp/contentcleanup</guid><description>A command-line tool that removes temporary files and directories from the Source Engine game directory based on a KeyValues settings file.</description><pubDate>Fri, 01 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;strong&gt;ContentCleanup&lt;/strong&gt; is a command-line tool for Source Engine that deletes temporary files and directories from the game directory. What gets deleted is defined by a &lt;strong&gt;KeyValues&lt;/strong&gt; settings file that lives inside the game directory itself at &lt;strong&gt;scripts/tools/contentcleanup_settings.txt&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;It is invoked like any other Source tool.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;contentcleanup.exe -game &quot;C:/Games/MyMod/mygame&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It automates the cleanup step so your game directory doesn&apos;t bloat over time and your Steam builds don&apos;t ship with compiler leftovers, with no extra setup required.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./cntnclp_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;
&lt;p&gt;The tool uses &lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/flb/file-system-batch-operations&quot;&gt;IFileSystemBatch from filesystem_batch.dll&lt;/a&gt; for batch/glob operations. For the actual deletion work, a &lt;strong&gt;KeyValues&lt;/strong&gt; file is loaded for the config. Game path setup is the same as the rest of the toolchain (goes through &lt;strong&gt;CmdLib_InitFileSystem&lt;/strong&gt;).&lt;/p&gt;
&lt;p&gt;The main loop iterates every key in the settings file and dispatches by type.&lt;/p&gt;
&lt;p&gt;Missing paths produce a warning and continue — they don&apos;t abort the run. Unknown key names also warn, so typos in the settings file don&apos;t silently no-op.&lt;/p&gt;
&lt;p&gt;One thing worth noting: the game path is normalized to forward slashes early in init with &lt;strong&gt;V_FixSlashes(gamedir, &apos;/&apos;)&lt;/strong&gt;. Glob patterns break on Windows backslash paths, so this needs to happen before any path construction.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Settings file&lt;/h3&gt;
&lt;p&gt;The settings file supports three key types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Dir:&lt;/strong&gt; to remove a directory recursively.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Glob:&lt;/strong&gt; to remove files matching a pattern.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;File:&lt;/strong&gt; to remove a single file.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All paths are relative to the game directory.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;contentcleanup_settings.txt&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;ContentCleanup&quot; 
{
	// Note: This is always relative to the gamedir. 
	// For paths ALWAYS use the separator &apos;/&apos; for folders and never &apos;\&apos;	
	// You will run into some issues if done.
	// Three supported KeyValues:
	//	Dir : Delete the directory
	//	Glob: Given a Glob pattern delete files.
	//      File: Delete the file.

	// Builder dir
	&quot;Dir&quot;	&quot;_build&quot;
	&quot;Dir&quot;	&quot;_mapbuilder&quot;
	&quot;Dir&quot;	&quot;_unittest&quot;

	// Temp/user dir
	&quot;Dir&quot;	&quot;logs&quot;
	&quot;Dir&quot;	&quot;reslists&quot;
	&quot;Dir&quot;	&quot;save&quot;
	&quot;Dir&quot;	&quot;screenshots&quot;
	&quot;Dir&quot;	&quot;cubemap_screenshots&quot;
	&quot;Dir&quot;	&quot;screenshots&quot;
	&quot;Dir&quot;	&quot;testscripts&quot;
	&quot;Dir&quot;	&quot;config&quot;
	&quot;Dir&quot;	&quot;downloadlists&quot;
	&quot;Dir&quot;	&quot;downloads&quot;
	&quot;Dir&quot;	&quot;download&quot;
	&quot;Dir&quot;	&quot;sound_workshop&quot;
	&quot;Dir&quot;	&quot;workshop&quot;
	&quot;Dir&quot;	&quot;user_custom&quot;
	&quot;Dir&quot;	&quot;replay&quot;

	// We pack the files inside the vpk map.
	&quot;Dir&quot;		&quot;maps/graphs&quot;
	
	// Temp files
	&quot;Glob&quot;	&quot;/**/*.cache&quot;
	&quot;Glob&quot;	&quot;/**/*.tmp&quot;
	&quot;Glob&quot;	&quot;/**/*.dt&quot;
	&quot;Glob&quot;	&quot;/**/*.log&quot;
	&quot;Glob&quot;	&quot;/**/*.csv&quot;
	&quot;Glob&quot;	&quot;/**/*.lst&quot;
	&quot;Glob&quot;	&quot;/**/*.mdmp&quot;

	// We pack the file inside the vpk map.
	&quot;Glob&quot;	&quot;/**/*.nav&quot;

	// User files generated by running the mod.
	&quot;File&quot;	&quot;gamestate.txt&quot;
	&quot;File&quot;	&quot;stats.txt&quot;
	&quot;File&quot;	&quot;cfg/server_blacklist.txt&quot;
	&quot;File&quot;	&quot;cfg/config.cfg&quot;
	&quot;File&quot;	&quot;steam.inf&quot;
	&quot;File&quot;	&quot;textwindow_temp.html&quot; 
}
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3&gt;Example in action&lt;/h3&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/cntnclp/cntnclp_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Design references&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Glob Pattern: &lt;a href=&quot;https://www.malikbrowne.com/blog/a-beginners-guide-glob-patterns/&quot;&gt;https://www.malikbrowne.com/blog/a-beginners-guide-glob-patterns/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>ResourceFileSystem: A CLI Utility for file operations in Source Engine.</title><link>https://unusuario2.github.io/posts/source_engine/tooling/rsrflsys/resourcefilesystem</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/rsrflsys/resourcefilesystem</guid><description>A command-line tool that exposes the filesystem_batch.dll API directly to the user — copy, move, delete, and inspect files using glob patterns, no code required.</description><pubDate>Thu, 07 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;strong&gt;resourcefilesystem.exe&lt;/strong&gt; is a command-line tool that exposes the &lt;a href=&quot;https://www.linkedin.com/pulse/file-system-bacth-operations-source-engine-david-krekic-icmqe&quot;&gt;filesystem_batch.dll&lt;/a&gt; API directly to the user. Copy, move, delete, and inspect files and directories using glob patterns — from the command line, with no code required.&lt;/p&gt;
&lt;p&gt;It is invoked like any other Source tool:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;resourcefilesystem.exe &amp;lt;glob_pattern&amp;gt; &amp;lt;destination&amp;gt; -game &quot;C:/Games/MyMod/mygame&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./rsrflsys_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;What it does&lt;/h3&gt;
&lt;p&gt;The tool wraps &lt;a href=&quot;https://www.linkedin.com/pulse/file-system-bacth-operations-source-engine-david-krekic-icmqe&quot;&gt;IFileSystemBatch&lt;/a&gt; into a CLI with four main operation modes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Copy&lt;/strong&gt; — copies all files matching a glob pattern to a destination directory&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transfer&lt;/strong&gt; — copies then deletes the source (move semantics)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Delete&lt;/strong&gt; — removes a directory recursively with &lt;code&gt;-deletedir&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inspect&lt;/strong&gt; — lists all files matching a glob pattern with &lt;code&gt;-printdircontent&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Single file mode &lt;code&gt;-f&lt;/code&gt; is also supported for when you don&apos;t need glob matching.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;
&lt;p&gt;All batch operations delegate directly to IFileSystemBatch. The tool itself is thin — it parses the command line, validates the glob pattern via &lt;code&gt;IsValidGlob()&lt;/code&gt; before doing anything, and dispatches to the right operation. Error reporting is per-file: failed operations are collected into a &lt;code&gt;FileList&lt;/code&gt; and printed at the end without aborting the run.&lt;/p&gt;
&lt;p&gt;One detail worth noting: incompatible flag combinations (e.g. &lt;code&gt;-deletedir&lt;/code&gt; with &lt;code&gt;-transferfiles&lt;/code&gt;) are caught early with explicit sanity checks before any filesystem operation runs.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Design references&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;IFileSystemBatch: &lt;a href=&quot;https://www.linkedin.com/pulse/file-system-bacth-operations-source-engine-david-krekic-icmqe&quot;&gt;filesystem_batch.dll article&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Glob Pattern: &lt;a href=&quot;https://www.malikbrowne.com/blog/a-beginners-guide-glob-patterns/&quot;&gt;https://www.malikbrowne.com/blog/a-beginners-guide-glob-patterns/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2&gt;Example in action&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Inspect what&apos;s inside a directory: &lt;code&gt;resourcefilesystem.exe -pdc &quot;platform/**/*.vtf&quot;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/rsrflsys/rsrflsys_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Copy all .vtf textures from content to game directory: &lt;code&gt;resourcefilesystem.exe &quot;platform/**/*.vtf&quot; &quot;D:/Downloads/test&quot;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/rsrflsys/rsrflsys_2.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Move build output and delete source: &lt;code&gt;resourcefilesystem.exe -transferfiles &quot;D:/Downloads/test/**/*&quot; &quot;D:/Downloads/test2&quot;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/rsrflsys/rsrflsys_3.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>SceneImageBuilder: A CLI Utility for compiling scenes without Faceposer</title><link>https://unusuario2.github.io/posts/source_engine/tooling/scnimgbld/sceneimagebuilder</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/scnimgbld/sceneimagebuilder</guid><description>A command-line tool that compiles .vcd choreography scenes into a scenes.image binary, replacing Faceposer&apos;s GUI compile step so it can run inside an automated build pipeline.</description><pubDate>Tue, 12 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://developer.valvesoftware.com/wiki/Faceposer&quot;&gt;Faceposer&lt;/a&gt; is Source Engine&apos;s GUI tool for creating and compiling &lt;a href=&quot;https://developer.valvesoftware.com/wiki/Choreography_creation&quot;&gt;choreography scenes&lt;/a&gt; (.vcd files). It works. But opening a GUI just to compile scenes as part of an automated build pipeline makes no sense.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/Unusuario2/SceneImageBuilder&quot;&gt;SceneImageBuilder&lt;/a&gt; does the same compilation step from the command line.&lt;/p&gt;
&lt;p&gt;It is invoked like any other Source tool:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sceneimagebuilder.exe -game &quot;C:/Games/MyMod/mygame&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./scnimgbld_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The code can be &lt;a href=&quot;https://github.com/Unusuario2/SceneImageBuilder&quot;&gt;found here&lt;/a&gt;. Although it is a bit outdated, the core system remains the same.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;What it does&lt;/h3&gt;
&lt;p&gt;Source Engine doesn&apos;t load &lt;code&gt;.vcd&lt;/code&gt; files directly at runtime. It loads a compiled scenes.image binary that packs all scenes together. &lt;a href=&quot;https://developer.valvesoftware.com/wiki/Faceposer&quot;&gt;Faceposer&lt;/a&gt; handles that compilation step through its GUI. &lt;a href=&quot;https://github.com/Unusuario2/SceneImageBuilder&quot;&gt;SceneImageBuilder&lt;/a&gt; replaces that step with a single command, no GUI required.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Why this matters for a pipeline&lt;/h3&gt;
&lt;p&gt;Every tool in my pipeline follows the same pattern: one command, &lt;code&gt;-game&lt;/code&gt; path, done. &lt;a href=&quot;https://github.com/Unusuario2/SceneImageBuilder&quot;&gt;SceneImageBuilder&lt;/a&gt; fits that contract. You can call it from a build script or &lt;code&gt;contentbuilder.exe&lt;/code&gt; the same way you call VBSP, VVIS, or VRAD — no GUI, no manual steps, no interruptions.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Design references&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/ValveSoftware/source-sdk-2013/blob/master/src/public/tier3/tier3.h&quot;&gt;CTier3SteamApp: Source SDK AppFramework&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2&gt;Example in action&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;sceneimagebuilder.exe compiling all the .vcd files into scenes.image&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/scnimgbld/scnimgbld_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>MapBuilder: Standardizing &amp; Automating map compilation across the pipeline</title><link>https://unusuario2.github.io/posts/source_engine/tooling/mpbld/mapbuilder</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/mpbld/mapbuilder</guid><description>A config-driven tool that abstracts the VBSP/VVIS/VRAD compile sequence into a single command, shared by artists, programmers, and automated builds.</description><pubDate>Fri, 15 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Compiling a map in Source Engine means running VBSP, VVIS, and VRAD in sequence — each with its own flags, its own paths, and its own configuration. Artists should not spend time making the configuration in Hammer Editor. Do that manually every time and someone will eventually break it.&lt;/p&gt;
&lt;p&gt;MapBuilder abstracts the entire process into a single command and a config file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mapbuilder.exe -preset Final -game &quot;C:/Games/MyMod/mygame&quot;  &quot;mapsrc/mymap.vmf&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One command. Every step runs in order. Same result every time.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./mpbld_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The code can be &lt;a href=&quot;https://github.com/Unusuario2/MapBuilder&quot;&gt;found here&lt;/a&gt;. Although it is a bit outdated, the core system remains the same.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;The problem it solves&lt;/h3&gt;
&lt;p&gt;Map compilation in Source is not just VBSP → VVIS → VRAD. A full build also needs to copy the .bsp to the right directory, build cubemaps by launching the game executable, run vbspinfo, and optionally run custom post-processing steps. Each of those is a separate process with its own binary, its own arguments, and its own command-line options.&lt;/p&gt;
&lt;p&gt;Without a standardized tool, every person on the team runs that sequence differently. Artists forget steps. Flags drift between machines. Builds become inconsistent.&lt;/p&gt;
&lt;p&gt;MapBuilder defines the process once in a &lt;a href=&quot;https://developer.valvesoftware.com/wiki/Keyvalue&quot;&gt;KeyValues&lt;/a&gt; config file. Artists, programmers, and automated builds all use the same tool, the same preset, the same flags.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;How it works&lt;/h3&gt;
&lt;p&gt;The config file (&lt;code&gt;scripts/tools/mapbuilder_settings.txt&lt;/code&gt;) lives inside the game directory. It defines compile presets — named sequences of build steps, each with its own parameters.&lt;/p&gt;
&lt;p&gt;Supported build steps and their default tool:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;th&gt;Default tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RunWorldBuilder&lt;/td&gt;
&lt;td&gt;vbsp.exe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RunVisibilityBuilder&lt;/td&gt;
&lt;td&gt;vvis.exe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RunLightBuilder&lt;/td&gt;
&lt;td&gt;vrad.exe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RunMapInfo&lt;/td&gt;
&lt;td&gt;vbspinfo.exe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RunTransferFile&lt;/td&gt;
&lt;td&gt;resourcefilesystem.exe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RunCubemapBuilder&lt;/td&gt;
&lt;td&gt;game executable (e.g. tf.exe)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RunCustomBuilder&lt;/td&gt;
&lt;td&gt;any executable defined by the user&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RunResourceCompiler&lt;/td&gt;
&lt;td&gt;resourcecompiler.exe&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Every step supports a &lt;code&gt;ToolName&lt;/code&gt; key to override the default executable — useful for swapping in a custom compiler or an external tool without changing any code.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./mpbld_3.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Features&lt;/h2&gt;
&lt;h3&gt;Path resolution&lt;/h3&gt;
&lt;p&gt;Each step has a &lt;code&gt;BuildParams&lt;/code&gt; field with placeholder support. MapBuilder resolves these at runtime before building the command line:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Placeholder&lt;/th&gt;
&lt;th&gt;Resolves to&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%source&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Full path to the .vmf source file&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%filename&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Map name without extension&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%gamedir&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Path to the game directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%mapbsp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Full path to the compiled .bsp&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%mapdir&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;gamedir/maps/&amp;lt;relative source map dir&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Example expansion:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;RunLightBuilder
{
    BuildParams &quot;-final -game %gamedir %source&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Expands to:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;vrad.exe -final -game &quot;C:\Games\MyMod\mygame&quot; &quot;C:\maps\mymap.vmf&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;No hardcoded paths anywhere in the config.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Tool path resolution&lt;/h3&gt;
&lt;p&gt;Each step also supports three path modes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;BinDir &quot;1&quot;&lt;/code&gt; — searches for the tool in the same directory as mapbuilder.exe&lt;/li&gt;
&lt;li&gt;&lt;code&gt;BaseDir &quot;1&quot;&lt;/code&gt; — searches in the base game installation path&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ExternalPath &quot;&amp;lt;path&amp;gt;&quot;&lt;/code&gt; — explicit path to any directory&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This makes it possible to call tools that live outside the SDK bin directory — including the game executable itself for cubemap building.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Preset system&lt;/h3&gt;
&lt;p&gt;The default preset is declared in the config under &lt;code&gt;DefaultMapBuilderSettings&lt;/code&gt;. Any tool or artist can override it at runtime with &lt;code&gt;-preset&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mapbuilder.exe -preset Fast -game &quot;C:/Games/MyMod/mygame&quot;  &quot;mapsrc/mymap.vmf&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A full Final preset example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;Final&quot;
{
    RunWorldBuilder
    {
        BuildParams &quot;-game %gamedir %source&quot;
    }

    RunVisibilityBuilder
    {
        BuildParams &quot;-game %gamedir %source&quot;
    }

    RunLightBuilder
    {
        BuildParams &quot;-final -extrasky 64 -bounce 250 -game %gamedir %source&quot;
    }

    RunMapInfo
    {
        BuildParams &quot;-worldtexturestats -treeinfo %mapbsp&quot;
    }

    RunTransferFile
    {
        BuildParams &quot;-f %mapbsp %mapdir&quot;
    }

    RunCubemapBuilder
    {
        ToolName    &quot;tf.exe&quot;
        BuildParams &quot;-dev -novid -sw -console -buildcubemaps map %filename&quot;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Execution order follows declaration order. Steps run top to bottom. Running VVIS before VBSP will fail — the config makes the order explicit and enforced.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;
&lt;p&gt;The execution flow is straightforward and intentionally linear:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-&amp;gt; ParseMapBuilderScript()   — KV parse → Builder_t list
-&amp;gt; ParseStringBuildParams()  — placeholder substitution
-&amp;gt; CreateProcess() per step  — sequential execution
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Step 1 — Parsing the script.&lt;/strong&gt;
&lt;code&gt;ParseMapBuilderScript()&lt;/code&gt; loads &lt;code&gt;mapbuilder_settings.txt&lt;/code&gt; via the Source filesystem, resolves the active preset (default or &lt;code&gt;-preset&lt;/code&gt; override), then iterates every sub-key inside that preset in declaration order. For each key it finds a match in a &lt;code&gt;PairKvTl&lt;/code&gt; table that maps key names to their default tool and base path.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./mpbld_4.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The result is a &lt;code&gt;std::vector&amp;lt;Builder_t&amp;gt;&lt;/code&gt; — each entry holds the tool name, base path, and the fully assembled command line string, ready to execute.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2 — Placeholder substitution.&lt;/strong&gt;
Before each command line is built, &lt;code&gt;ParseStringBuildParams()&lt;/code&gt; walks the &lt;code&gt;BuildParams&lt;/code&gt; string character by character looking for &lt;code&gt;%&lt;/code&gt; tokens and replaces them inline into a static buffer. Paths with spaces are automatically wrapped in quotes during expansion — &lt;code&gt;%gamedir&lt;/code&gt;, &lt;code&gt;%source&lt;/code&gt;, &lt;code&gt;%mapdir&lt;/code&gt;, and &lt;code&gt;%mapbsp&lt;/code&gt; all get quoted, &lt;code&gt;%filename&lt;/code&gt; does not since it&apos;s just a name without spaces.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./mpbld_5.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3 — Sequential execution.&lt;/strong&gt;
&lt;code&gt;RunMapBuilder()&lt;/code&gt; iterates the &lt;code&gt;Builder_t&lt;/code&gt; list and calls &lt;code&gt;CreateProcess()&lt;/code&gt; for each entry, waiting for it to finish before starting the next. If a step fails and &lt;code&gt;-ignoreerrors&lt;/code&gt; is not set, execution stops immediately. The exit code of each process determines whether the build continues.&lt;/p&gt;
&lt;p&gt;The order of execution is exactly the order the keys appear in the config. No implicit sorting, no dependency graph — the config author is responsible for getting the order right, and the tool enforces it strictly.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./mpbld_6.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Why this matters for a pipeline&lt;/h3&gt;
&lt;p&gt;MapBuilder abstracts the process of compiling maps, which is particularly useful for an automated build system (ContentBuilder). It is also the tool artists run directly from the command line or from Hammer&apos;s compile configuration. Same binary, same config, same process — whether it&apos;s a human or an automated system running it.&lt;/p&gt;
&lt;p&gt;Any modder can also drop in a custom compiler via &lt;code&gt;ToolName&lt;/code&gt; and integrate it into the chain without touching the source code. The config is the interface.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Example in action&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Example of MapBuilder being called by the automated build system (ContentBuilder)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/mpbld/mpbld_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Example of MapBuilder being called inside Hammer editor (used by artists)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/mpbld/mpbld_2.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>ContentCheck: Asset validation for the Source Engine pipeline</title><link>https://unusuario2.github.io/posts/source_engine/tooling/cntnckc/contentcheck</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/cntnckc/contentcheck</guid><description>A validation tool that checks path integrity, sync status, and unknown/invalid assets across the Source Engine content pipeline.</description><pubDate>Sat, 23 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Before shipping a build, you need to know the state of your assets. Are all compiled files in sync with their source? Are there paths with uppercase letters that will break on Linux? Are there assets with non-ASCII characters, spaces, or paths exceeding the 260-character Windows limit? Are there unknown or invalid assets in the game directory?&lt;/p&gt;
&lt;p&gt;ContentCheck answers all of those questions in one run and writes a full report to disk.&lt;/p&gt;
&lt;p&gt;It is invoked like any other Source tool.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;contentcheck.exe -game &quot;C:/Games/MyMod/mygame&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./cntnckc_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;What it checks&lt;/h2&gt;
&lt;p&gt;ContentCheck runs three validation passes in sequence, each writing results to &lt;code&gt;_build/contentcheck_report.txt&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1: Path integrity.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Validates every asset path against three rules, using a bitmask flag system internally:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;No uppercase letters: Source Engine is case-sensitive on Linux; uppercase paths cause silent failures.&lt;/li&gt;
&lt;li&gt;No spaces or extra dots: for convention and to avoid breaking some SDK tools.&lt;/li&gt;
&lt;li&gt;No non-ASCII characters: causes undefined behavior in path operations.&lt;/li&gt;
&lt;li&gt;No paths exceeding 260 characters: Source Engine &lt;code&gt;MAX_PATH&lt;/code&gt; limit.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;./cntnckc_3.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2: Sync status.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Iterates every asset type in the cache and checks whether the compiled output is in sync with its source file. Six sync states are reported.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./cntnckc_4.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3: Unknown and invalid assets.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Enumerates assets flagged as &lt;code&gt;ASSET_UNKNOWN&lt;/code&gt; or &lt;code&gt;ASSET_INVALID&lt;/code&gt; in the cache — files the asset system couldn&apos;t classify or that failed validation during cache population.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 4: Printing all the asset information.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Sometimes as a developer you want to see all the information related to an asset. ContentCheck can do this with the &lt;strong&gt;-printassetinfo&lt;/strong&gt; command line flag.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./cntnckc_5.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Implementation&lt;/h2&gt;
&lt;p&gt;ContentCheck loads four modules at startup.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./cntnckc_6.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;The assetsystem module is a custom asset management layer — &lt;code&gt;IAssetSystemMgr&lt;/code&gt; — that populates a cache of all known assets across the content and mod search paths via &lt;code&gt;AddAllAssetTypesToTheCache()&lt;/code&gt;. All three check passes operate on that cache through &lt;code&gt;EnumerateAssetsInCache()&lt;/code&gt; and &lt;code&gt;EnumerateAllAssetsInCache()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The path integrity check uses a bitmask &lt;code&gt;StringCheck&lt;/code&gt; enum to accumulate multiple violations per path in a single pass, rather than short-circuiting on the first failure. This means a path with both uppercase letters and spaces gets both warnings reported — useful when fixing a large batch of assets.&lt;/p&gt;
&lt;p&gt;The sync check iterates every &lt;code&gt;AssetType_t&lt;/code&gt; in the enum range and for each type queries every asset&apos;s &lt;code&gt;GetSyncStatus()&lt;/code&gt;. Compilable assets (those with a source file) report both source and compiled paths. Non-compilable assets (binary-only) report only the compiled path.&lt;/p&gt;
&lt;p&gt;Everything accumulates into a &lt;code&gt;CUtlBuffer&lt;/code&gt; in &lt;code&gt;TEXT_BUFFER&lt;/code&gt; mode and gets written to &lt;code&gt;_build/contentcheck_report.txt&lt;/code&gt; at the end. The &lt;code&gt;_build&lt;/code&gt; directory is the same one ContentBuilder uses — the report lives alongside the rest of the build output.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Why this matters for a pipeline&lt;/h2&gt;
&lt;p&gt;Asset problems that go undetected before a build become problems during or after shipping. A texture with an uppercase path works on Windows but breaks on Linux. A compiled asset that&apos;s out of date ships stale data. An orphaned output bloats the package with files that have no source.&lt;/p&gt;
&lt;p&gt;ContentCheck is the validation step that runs before the build goes out. It doesn&apos;t fix anything — it tells you exactly what needs attention and where.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Example in action&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;contentcheck only checking if the paths are correct.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/cntnckc/cntnckc_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;contentcheck only checking the sync status of the assets.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/cntnckc/cntnckc_2.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;contentcheck in full action.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/cntnckc/cntnckc_3.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;!-- Caption 1: &quot;contentcheck only checking if the paths are correct.&quot; --&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>Inspector: A BSP analysis and diff tool for Source Engine</title><link>https://unusuario2.github.io/posts/source_engine/tooling/inspct/inspector</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/inspct/inspector</guid><description>A tool that parses compiled BSP files lump by lump and diffs two builds to expose exactly what a compiler change altered.</description><pubDate>Mon, 01 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;When you&apos;re modifying a compiler like VBSP or VRAD, you need to know exactly what changed in the output. Which lumps grew or shrank. Whether the lighting data is actually different or just reordered. What the pakfile contains. Whether two builds of the same map are byte-for-byte identical in the parts you didn&apos;t touch.&lt;/p&gt;
&lt;p&gt;Inspector reads a compiled BSP file and shows you its internal state. Pass two files and it diffs them.&lt;/p&gt;
&lt;p&gt;It is invoked like any other Source tool.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;inspector.exe &amp;lt;bpsfile&amp;gt; &amp;lt;bpsfile2&amp;gt; -game &quot;C:/Games/MyMod/mygame&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;inspct_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;What it shows&lt;/h3&gt;
&lt;p&gt;A BSP file is a binary container made of 64 lumps — each lump stores a different type of data. Inspector loads the entire file into memory and parses every layer:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;BSP header.&lt;/strong&gt; Version, map revision, total data size in bytes and MB.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;All 64 lumps.&lt;/strong&gt; For each lump: index, name, file offset, size, version, and a CRC32 checksum of the lump data. Empty lumps are hidden by default.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Game lumps (lump 35).&lt;/strong&gt; The game lump is a container inside the BSP that holds sub-lumps with game-specific data (static props, detail props, etc.). Inspector decodes each entry&apos;s 4-byte FourCC ID into a human-readable string, and reports offset, length, version, flags, and CRC32.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pakfile (lump 40).&lt;/strong&gt; The pakfile is an embedded ZIP archive inside the BSP. Inspector scans it manually by walking the raw bytes looking for the ZIP local file header signature, extracting filename, uncompressed size, compressed size, and CRC32 for every entry. Total uncompressed size is reported at the end.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Console output:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;inspct_3.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Diff mode&lt;/h3&gt;
&lt;p&gt;Pass two BSP files and Inspector runs a full structural diff:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Header diff&lt;/strong&gt; — version and map revision changes between builds.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Lump diff&lt;/strong&gt; — for every lump that changed: size delta in bytes, version change, and whether the content differs (detected by CRC32 mismatch). A lump with the same size but a different CRC means the data was modified in place — the kind of change that&apos;s easy to miss otherwise.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Game lump diff&lt;/strong&gt; — entries present only in A, only in B, or present in both but with different length, version, or content.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pakfile diff&lt;/strong&gt; — files added, removed, or modified between builds, with size delta and CRC comparison for each.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Console output:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;inspct_4.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;
&lt;p&gt;Inspector loads the entire BSP into memory in one read, then operates on raw pointers into that buffer — no seek operations, no partial reads. The header is copied into a struct directly. All 64 lump entries are parsed in a single loop, computing a CRC32 per lump with a standard polynomial.&lt;/p&gt;
&lt;p&gt;The pakfile parser doesn&apos;t use any ZIP library. It walks the raw bytes in the pakfile lump scanning for the local file header signature, reads the fixed-offset fields, extracts the filename, and advances to the next position. No decompression — just structural inspection.&lt;/p&gt;
&lt;p&gt;Game lump IDs are stored as 4-byte integers. Inspector reverses the byte order and prints them as ASCII strings — that&apos;s how Source&apos;s FourCC identifiers work.&lt;/p&gt;
&lt;p&gt;All output is color-coded: green for matching/present data, yellow for differences, red for errors or missing entries.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Why this matters for compiler development&lt;/h3&gt;
&lt;p&gt;Modifying VRAD, VBSP, or any other compiler that writes BSP data means verifying that only the lumps you intended to change actually changed. Without a tool like this, you&apos;re comparing binary files blindly or relying on in-game behavior to catch regressions.&lt;/p&gt;
&lt;p&gt;Inspector makes the internal state of a compiled map observable. If &lt;code&gt;LUMP_LIGHTING&lt;/code&gt; grew after a change to VRAD, you see it immediately. If the pakfile is missing an entry it shouldn&apos;t be, it shows up in the diff. If two builds of the same map produce identical lumps except the one you modified, you can confirm the change is isolated.&lt;/p&gt;
&lt;p&gt;That&apos;s the use case it was built for.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>AudioProcess: Mass audio converter for the Source Engine</title><link>https://unusuario2.github.io/posts/source_engine/tooling/audprccs/audioprocess</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/audprccs/audioprocess</guid><description>A command-line tool that batch-converts any audio format to the Source Engine&apos;s required WAV format using FFmpeg.</description><pubDate>Wed, 03 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://developer.valvesoftware.com/wiki/Source&quot;&gt;Source Engine&lt;/a&gt; expects audio in a specific format: WAV, 44100 Hz, 16-bit PCM. Any other format needs to be converted before it can be used in the game. Doing that manually for every audio file in the project doesn&apos;t scale.&lt;/p&gt;
&lt;p&gt;AudioProcess converts any audio file — or an entire directory of them — to the correct format in one command.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Single file
audioprocess.exe -game &quot;C:/Games/MyMod/mygame&quot; -i mysound.mp3 -o sounds/

// Entire directory, recursively
audioprocess.exe -game &quot;C:/Games/MyMod/mygame&quot; -i source_audio/ -o game/sound/
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./audprccs_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Supported formats&lt;/h3&gt;
&lt;p&gt;AudioProcess accepts 26 input formats: mp3, aac, m4a, flac, wav, ogg, opus, wma, alac, ac3, aiff, aif, amr, mp2, ape, tta, tak, wv, mlp, alaw, ulaw, gsm, qcp, mod, xm, it, s3m.&lt;/p&gt;
&lt;p&gt;Any of those can be excluded from a batch run with a flag.&lt;/p&gt;
&lt;p&gt;All output is WAV, 44100 Hz, signed 16-bit PCM — the format &lt;a href=&quot;https://developer.valvesoftware.com/wiki/Source&quot;&gt;Source Engine&lt;/a&gt; requires.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;
&lt;p&gt;AudioProcess uses FFmpeg for all decoding and resampling. For each file the pipeline is:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1 — Open and probe&lt;/strong&gt;
Opens the container and detects the audio stream, then selects the audio stream index.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2 — Decode&lt;/strong&gt;
Sets up the decoder for the stream&apos;s codec. Frames are read and decoded.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3 — Resample&lt;/strong&gt;
Every decoded frame is resampled to 44100 Hz, stereo (or original channel count if mono). The resampler preserves the original channel layout — a mono source stays mono, stereo stays stereo.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4 — Write WAV&lt;/strong&gt;
The output WAV is written manually with a hand-built RIFF header. The header is written with placeholder sizes first, then the PCM data is written frame by frame, and the RIFF and data chunk sizes are patched back in at the end once the total is known.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Batch mode&lt;/h3&gt;
&lt;p&gt;In path mode, AudioProcess scans the input directory recursively — one glob pattern per supported extension. All results are collected into a single list before conversion starts.&lt;/p&gt;
&lt;p&gt;The directory structure is preserved in the output.&lt;/p&gt;
&lt;p&gt;Per-operation counters track completed, failed, and skipped conversions. The summary is printed at the end.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Why this matters for a pipeline&lt;/h3&gt;
&lt;p&gt;Every audio file an artist drops into the project needs to be in Source Engine format before it can be tested in game. Without a conversion step in the pipeline, that&apos;s a manual process every time a file changes.&lt;/p&gt;
&lt;p&gt;AudioProcess fits into ContentBuilder the same way every other tool does — one command, &lt;code&gt;-game&lt;/code&gt; path, input and output directories. The conversion step runs automatically as part of the build.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Example in action&lt;/h3&gt;
&lt;p&gt;This conversion unit test was done with the same files that the &lt;a href=&quot;https://www.ffmpeg.org/&quot;&gt;FFmpeg&lt;/a&gt; team uses to test their modules.&lt;/p&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/audprccs/audprccs_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Code&lt;/h3&gt;
&lt;p&gt;Although the public GitHub code is not updated but the core principles are still the same: &lt;a href=&quot;https://github.com/Unusuario2/AudioProcess&quot;&gt;github.com/Unusuario2/AudioProcess&lt;/a&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>PsdWriter: Batch image to PSD converter for the Source Engine pipeline</title><link>https://unusuario2.github.io/posts/source_engine/tooling/psdwrtr/psdwriter</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/psdwrtr/psdwriter</guid><description>A tool that batch-converts images to Photoshop-compatible PSD files and auto-generates the matching vtex compile config.</description><pubDate>Fri, 05 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Artists working on UI, icons, and textures for Source Engine projects often work in formats like PNG, TGA, or HDR. Before those assets can be compiled with vtex, they need to be in a format Photoshop and the Source SDK toolchain can both work with. And for every texture, a .txt config file needs to be written telling vtex how to compile it.&lt;/p&gt;
&lt;p&gt;PsdWriter automates both steps — converting images to .psd and generating the vtex config alongside.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Single file
psdwriter.exe -i mytexture_color.png

// Entire materialsrc directory
psdwriter.exe -game &quot;C:/Games/MyMod/mygame&quot;

// Custom directory
psdwriter.exe -dir &quot;C:/art/textures/&quot; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./psdwrtr_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;What it does&lt;/h3&gt;
&lt;p&gt;PsdWriter converts any supported image format to a Photoshop-compatible .psd file using stb_image for decoding and psd_sdk for writing.&lt;/p&gt;
&lt;p&gt;Supported input formats: .jpg, .jpeg, .png, .tga, .bmp, .gif, .hdr, .pic, .ppm, .pgm.&lt;/p&gt;
&lt;p&gt;Each channel (R, G, B, and optionally A) is separated and written individually into the PSD layer — which is how psd_sdk requires the data. The merged image is also written so Photoshop displays it correctly on open.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Bit-depth preservation&lt;/h3&gt;
&lt;p&gt;By default PsdWriter forces all output to 8-bit, since some Source Engine branches fail with vtex on higher bit-depth PSDs. With &lt;code&gt;-dontforce8bitspsd&lt;/code&gt;, the native bit-depth of each format is preserved:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Format&lt;/th&gt;
&lt;th&gt;Bit-depth&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;.jpg, .jpeg, .tga, .bmp, .gif&lt;/td&gt;
&lt;td&gt;8-bit (uint8_t)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;.png, .ppm, .pgm&lt;/td&gt;
&lt;td&gt;16-bit (uint16_t)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;.hdr, .pic&lt;/td&gt;
&lt;td&gt;32-bit float (float32_t)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The bit-depth dispatch is handled at compile time via &lt;code&gt;if constexpr&lt;/code&gt; on a templated &lt;code&gt;WriteNBitsPsd&amp;lt;T&amp;gt;()&lt;/code&gt; — one function, three specializations, no runtime branching per format.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Compression modes&lt;/h3&gt;
&lt;p&gt;PSD files support four compression methods, selectable via &lt;code&gt;-psdcompression&lt;/code&gt;:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;RAW — no compression, fastest write&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;RLE (PackBits) — good for 8-bit data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;ZIP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;ZIP with prediction (delta encoding) — smallest output&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;hr /&gt;
&lt;h3&gt;Vtex config generation&lt;/h3&gt;
&lt;p&gt;With &lt;code&gt;-psdtemplategeneration&lt;/code&gt;, PsdWriter generates a vtex config file alongside each .psd. It detects the texture type from the filename suffix and copies the matching template from &lt;code&gt;materialsrc/template/&lt;/code&gt;:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Suffix&lt;/th&gt;
&lt;th&gt;Texture role&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_color&lt;/code&gt;, &lt;code&gt;_albedo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Base texture&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_normal&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Bump map&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_ao&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ambient occlusion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_specular&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Phong exponent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_envmap&lt;/code&gt;, &lt;code&gt;_envmapmask&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Environment map&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_trans&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Transparency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_detail&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Detail texture&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_flowmap&lt;/code&gt;, &lt;code&gt;_flowmapnoise&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Water flowing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_selfilum&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Self-illumination&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_lightwarp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Light warp&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_dudvmap&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Water DuDv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_blendmodulate&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Blend modulate&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;If the suffix doesn&apos;t match any known type, a warning is printed and the config is skipped — the PSD is still written.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Batch mode&lt;/h3&gt;
&lt;p&gt;In directory mode (&lt;code&gt;-game&lt;/code&gt; or &lt;code&gt;-dir&lt;/code&gt;), PsdWriter scans recursively using &lt;code&gt;FindFirstFile&lt;/code&gt;/&lt;code&gt;FindNextFile&lt;/code&gt;, checks each file against the supported extension list, and calls &lt;code&gt;CheckAndExportToPsd()&lt;/code&gt; for every match. A counter tracks total files converted, printed at the end.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;-deletesource&lt;/code&gt; removes the original input file after successful conversion — useful when the source format is no longer needed once the PSD exists.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Why this matters for a pipeline&lt;/h3&gt;
&lt;p&gt;Every texture an artist creates needs a PSD for Photoshop editing and a vtex config for Source compilation. Without this tool, both are manual steps repeated for every file. With PsdWriter in the pipeline, dropping images into &lt;code&gt;materialsrc/&lt;/code&gt; and running one command produces everything vtex needs to compile them.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Example in action&lt;/h3&gt;
&lt;p&gt;Batch conversion of a directory:&lt;/p&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/psdwrtr/psdwrtr_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;p&gt;Converted directory:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./psdwrtr_3.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Code&lt;/h3&gt;
&lt;p&gt;Available on GitHub here: &lt;a href=&quot;https://github.com/Unusuario2/PSDWriter&quot;&gt;github.com/Unusuario2/PSDWriter&lt;/a&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
</content:encoded><author>Unusuario2</author></item><item><title>VpkBuilder: A CLI Utility for creating VPK files</title><link>https://unusuario2.github.io/posts/source_engine/tooling/vpkbld/vpkbuilder</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/vpkbld/vpkbuilder</guid><description>A config-driven tool that builds signed, multi-chunk-ready VPK files.</description><pubDate>Mon, 31 Aug 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Packing a mod or a build into &lt;code&gt;.vpk&lt;/code&gt; files means deciding which directories go in, which files get excluded, whether the pack needs to be split into chunks, whether it needs to be signed, and then actually running &lt;code&gt;vpk.exe&lt;/code&gt; with the right flags. Doing that by hand or with a custom script, doesn&apos;t scale — and it&apos;s easy to forget a flag, not using the lastest script or leave a stale file in the pack.&lt;/p&gt;
&lt;p&gt;VpkBuilder wraps that entire process into a single command and a config file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;vpkbuilder.exe -game &quot;C:/Games/MyMod/mygame&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./vpkbld_3.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;What it does&lt;/h3&gt;
&lt;p&gt;VpkBuilder reads a KeyValues script (&lt;code&gt;scripts/tools/vpkbuilder_settings.txt&lt;/code&gt;) that defines one or more VPKs to build. For each one it collects the right files, stages them in a temp directory, calls &lt;code&gt;vpk.exe&lt;/code&gt; to pack them, and moves the result to the output directory — cleaning up after itself when it&apos;s done.&lt;/p&gt;
&lt;p&gt;It&apos;s the same philosophy as &lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/mpbld/mapbuilder&quot;&gt;MapBuilder&lt;/a&gt;: the process is defined once, in a config file, and every person or automated system that runs &lt;code&gt;vpkbuilder.exe -game &amp;lt;dir&amp;gt;&lt;/code&gt; gets the exact same result.&lt;/p&gt;
&lt;p&gt;Example of &lt;code&gt;scripts/tools/vpkbuilder_settings.txt&lt;/code&gt; file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;VpkBuilder&quot;
{
    &quot;VpkTempDir&quot;            &quot;_buildvpk&quot;     // Relative to the game dir. Full paths are also supported
    &quot;VpkPrivateSignKey&quot;     &quot;../../../../src/devtools/sign/vpksignature.privatekey.vdf&quot;    // This is always relative to the path of this file.  
    &quot;VpkPublicSignKey&quot;      &quot;../../../../src/devtools/sign/vpksignature.publickey.vdf&quot;  

    // Structure: Every new key is a vpk to be created
    // &quot;&amp;lt;vpkname&amp;gt;&quot;
    // {
    //      &quot;GenerateVpkMultiChunk&quot;             &quot;&amp;lt;boolean&amp;gt;&quot;             // If set to 1 it will generate multichunk vpk files
    //      &quot;VpkMultiChunkSize&quot;                 &quot;&amp;lt;unsigned integer&amp;gt;&quot;    // Size of the vpk chunk in MB
    //      &quot;VpkAlignBuild&quot;                     &quot;&amp;lt;unsigned integer&amp;gt;&quot;    // Padding of the files inside the vpk, if set to anything greated than 0 needs to have enabled the VpkUseFriendlySteamPipeAlgorithm 
    //      &quot;VpkUseFriendlySteamPipeAlgorithm&quot;  &quot;&amp;lt;boolean&amp;gt;&quot;             // Enable friendly steam pipe shit
    //      &quot;VpkOutDir&quot;                         &quot;&amp;lt;directory&amp;gt;&quot;           // Where we put the vpk after the build (always relative to the game dir)  
    //
    //     // This is a whitelist, if you want your to add some files, dir and more shit to the vpk put it in this KeyValue
    //     // Everything is relative to the gamedir
    //     &quot;VpkFiles&quot;
    //     {
    //         &quot;DirAddAll&quot;         &quot;materials&quot;         // Adds all the files inside the dir into the vpk. These files will be present in the vpk no matter whats in the VpkExcludeFiles KeyValue 
    //         &quot;DirConditional&quot;    &quot;vgui&quot;              // Adds the file in this dir, but these files can later be removed by the presets in the VpkExcludeFiles KeyValue 
    //         &quot;Glob&quot;              &quot;vgui/**/*.vmt&quot;     // Glob Pattern, add only the desired filed, the VpkExcludeFiles KeyValue can remove these some of these files.
    //         &quot;File&quot;              &quot;test.vmt&quot;          // For adding single files, the VpkExcludeFiles KeyValue cannot exclude this file.
    //     }
    //
    //     // This is a 
    //     &quot;VpkExcludeFiles&quot;           
    //     {
    //         &quot;Dir&quot;       &quot;materials&quot;      // Exclude this directory from the vpk.
    //         &quot;Glob&quot;      &quot;vgui/**/*.vmt&quot;  // Glob Pattern, exclude the files matching this pattern.
    //         &quot;File&quot;      &quot;test.vmt&quot;       // For removing single files.
    //     }
    // }

    &quot;platform&quot;
    {
        &quot;GenerateVpkMultiChunk&quot;             &quot;1&quot;
        &quot;VpkMultiChunkSize&quot;                 &quot;100&quot;
        &quot;VpkUseFriendlySteamPipeAlgorithm&quot;  &quot;1&quot;
        &quot;VpkOutDir&quot;                         &quot;&quot;  
        &quot;VpkAlignBuild&quot;                     &quot;1&quot;

        &quot;VpkFiles&quot;
        {
            &quot;DirAddAll&quot;         &quot;cfg&quot;         
            &quot;DirAddAll&quot;         &quot;maps&quot;         
            &quot;DirAddAll&quot;         &quot;materials&quot;         
            &quot;DirAddAll&quot;         &quot;media&quot;         
            &quot;DirAddAll&quot;         &quot;models&quot;         
            &quot;DirAddAll&quot;         &quot;particles&quot;         
            &quot;DirAddAll&quot;         &quot;resource&quot;         
            &quot;DirAddAll&quot;         &quot;sound&quot;         
            &quot;DirAddAll&quot;         &quot;sound&quot;         
            &quot;DirAddAll&quot;         &quot;soundscapes&quot;         
            &quot;DirAddAll&quot;         &quot;soundscript&quot;         
            &quot;DirAddAll&quot;         &quot;surfaceproperties&quot;         
        }

        &quot;VpkExcludeFiles&quot;           
        {
            // Safe guard, just in case someone add these files by error
            &quot;Dir&quot;       &quot;bin&quot;         
            &quot;Dir&quot;       &quot;tools&quot;         
            &quot;Dir&quot;       &quot;shaders&quot;         
            &quot;Glob&quot;      &quot;/**/*.bat&quot;    
            &quot;File&quot;      &quot;gameinfo.txt&quot;
            &quot;File&quot;      &quot;thirdpartylegalnotices.txt&quot;
        }
    }

    &quot;shaders&quot;
    {
        &quot;GenerateVpkMultiChunk&quot;             &quot;1&quot;
        &quot;VpkMultiChunkSize&quot;                 &quot;50&quot;
        VpkUseFriendlySteamPipeAlgorithm    &quot;1&quot;
        &quot;VpkOutDir&quot;                         &quot;&quot; 
        &quot;VpkAlignBuild&quot;                     &quot;1&quot;

        &quot;VpkFiles&quot;
        {
            &quot;DirAddAll&quot;         &quot;shaders&quot;         
        }

        &quot;VpkExcludeFiles&quot;           
        {
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3&gt;Defining a VPK&lt;/h3&gt;
&lt;p&gt;Each top-level key in the settings file is the name of a VPK to build. Inside it, a &lt;code&gt;VpkFiles&lt;/code&gt; block controls what goes in:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;th&gt;Behavior&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DirAddAll&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;adds every file in a directory (recursively), unconditionally&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;DirConditional&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;adds every file in a directory, but the files can still be excluded later&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Glob&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;adds files matching a glob pattern&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;File&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;adds a single file&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The distinction between &lt;code&gt;DirAddAll&lt;/code&gt; and &lt;code&gt;DirConditional&lt;/code&gt; matters: files added with &lt;code&gt;DirAddAll&lt;/code&gt; go into a separate static list that the exclude step never touches. Everything else can still be filtered out afterward.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;VpkExcludeFiles&lt;/code&gt; block runs after that, supporting &lt;code&gt;Dir&lt;/code&gt;, &lt;code&gt;Glob&lt;/code&gt;, and &lt;code&gt;File&lt;/code&gt; keys the same way, to remove anything that shouldn&apos;t ship.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Update mode vs full rebuild&lt;/h3&gt;
&lt;p&gt;By default, VpkBuilder looks for existing &lt;code&gt;.vpk&lt;/code&gt; files matching the target name in the output directory. If it finds them, it copies them into the temp build directory first, so &lt;code&gt;vpk.exe&lt;/code&gt; updates the existing pack instead of building from scratch. &lt;code&gt;-dont_update_vpk_files&lt;/code&gt; skips that and forces a clean rebuild — the settings file has a warning attached to it for a reason, since it overwrites whatever was there.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Signing&lt;/h3&gt;
&lt;p&gt;If &lt;code&gt;VpkPrivateSignKey&lt;/code&gt; and &lt;code&gt;VpkPublicSignKey&lt;/code&gt; are set in the settings file, VpkBuilder resolves both key paths relative to the settings file&apos;s own directory, verifies they exist, and passes them to &lt;code&gt;vpk.exe&lt;/code&gt; with &lt;code&gt;-K&lt;/code&gt;/&lt;code&gt;-k&lt;/code&gt; for every VPK it builds. If either key is missing, the tool prints a warning and builds unsigned packs instead of failing outright.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Implementation&lt;/h3&gt;
&lt;p&gt;The build for each VPK follows the same sequence:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-&amp;gt; Resolve existing VPKs (update mode) or start clean
-&amp;gt; Copy all included files into a per-VPK temp directory
-&amp;gt; Build the vpk.exe command line (align, chunking, signing flags)
-&amp;gt; StartExecutable() and wait for it to finish
-&amp;gt; Move the resulting .vpk(s) to the output directory
-&amp;gt; Delete the temp directory (unless -dont_delete_temp_dir)
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3&gt;Why this matters for a pipeline&lt;/h3&gt;
&lt;p&gt;Every VPK in a shipped build needs the same care: the right files, nothing stale, correctly chunked and signed if that&apos;s required. Without a standardized tool, that&apos;s a manual &lt;code&gt;vpk.exe&lt;/code&gt; script invocation someone has to remember, per pack, per build. VpkBuilder makes it declarative — the config says what a VPK contains, and &lt;code&gt;-game &amp;lt;dir&amp;gt;&lt;/code&gt; is the only thing that changes between a developer&apos;s machine.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Example in action&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;vpkbuilder.exe building and signing a multi-chunk VPK from the settings file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/vpkbld/vpkbld_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>SoundBuilder: Compiling audio assets inside the Resource Compiler System</title><link>https://unusuario2.github.io/posts/source_engine/tooling/sndbld/soundbuilder</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/sndbld/soundbuilder</guid><description>An AssetBuilder module that converts a single audio file to Source&apos;s required WAV format on demand — the same FFmpeg conversion core as AudioProcess, wired into the resource compiler system instead of run as a standalone batch tool.</description><pubDate>Sun, 06 Sep 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/audprccs/audioprocess&quot;&gt;AudioProcess&lt;/a&gt; batch-converts a whole directory of audio at once — you point it at a folder and it walks every file. That&apos;s the right tool when you&apos;re bulk-migrating a library. It&apos;s the wrong shape for the resource compiler, which doesn&apos;t think in directories — it thinks in individual assets that need to be compiled, one at a time, on demand, using the &lt;strong&gt;assetsystem&lt;/strong&gt; system.&lt;/p&gt;
&lt;p&gt;SoundBuilder is that per-asset version: an &lt;code&gt;IAppSystemDll&lt;/code&gt; module — &lt;code&gt;soundbuilder.dll&lt;/code&gt; — that the resource compiler loads and calls to turn one audio source file into one game-ready &lt;code&gt;.wav&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;resourcecompiler.exe -game &quot;Y:\buildworker\tssr_rel_win64\game\platform&quot; -i &quot;Y:\buildworker\tssr_rel_win64\content\platform\sound\core_diagnosis\core_diagnosis_125khz_to_10khz.wav&quot;

or 

resourcecompiler.exe -i &quot;Y:\buildworker\tssr_rel_win64\content\platform\sound\core_diagnosis\core_diagnosis_125khz_to_10khz.wav&quot;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./sndbld_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;What it does&lt;/h3&gt;
&lt;p&gt;SoundBuilder takes a single input file, validates it, converts it, and writes it out — nothing more. It doesn&apos;t scan directories, and it doesn&apos;t accept a list of files. That&apos;s intentional: as a module, it&apos;s meant to be called once per asset by whatever is driving the build.&lt;/p&gt;
&lt;p&gt;Before doing any conversion, it asks the asset system what kind of file it&apos;s looking at:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const IAssetInfo* pAssetInfo = g_pAssetSystemMgr-&amp;gt;QueryAssetInfo(this-&amp;gt;m_szFullPathInputFile);
if (pAssetInfo-&amp;gt;GetAssetType()-&amp;gt;GetAssetType() != AssetType_t::ASSET_SOUND)
{
    Warning(&quot;File is not an audio file: %s\n&quot;, this-&amp;gt;m_szFullPathInputFile);
    return -1;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the asset system doesn&apos;t recognize the file as a sound asset, SoundBuilder refuses to run.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Two ways to resolve the output path&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;-o &amp;lt;dir&amp;gt;&lt;/code&gt;&lt;/strong&gt; — manual mode. Used by &lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/audprccs/audioprocess&quot;&gt;AudioProcess&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;-use_content_game_directory&lt;/code&gt;&lt;/strong&gt; — mirror mode. The input file is expected to live under the project&apos;s content search path; SoundBuilder strips that prefix and rebuilds the same relative path under the game directory. No &lt;code&gt;-o&lt;/code&gt; needed — the output location is derived entirely from where the source file lives. Used by the &lt;strong&gt;resourcecompiler system&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Mirror mode is the one that matters for the pipeline: it&apos;s what lets the resource compiler call SoundBuilder on any changed source file in &lt;code&gt;content/&lt;/code&gt; and land the compiled &lt;code&gt;.wav&lt;/code&gt; in the matching spot under the game directory, without anything having to compute or pass that path in.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Why a module instead of a standalone tool&lt;/h3&gt;
&lt;p&gt;Every other stage in the pipeline that compiles a specific asset type — textures, models, scenes — is exposed as its own builder that the resource compiler can call by asset type. SoundBuilder fits that same shape for audio, so the compiler can find it, hand it one file, and get one compiled result back.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Example in action&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;soundbuilder.dll being invoked by the resource compiler to compile a single changed sound asset&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/sndbld/sndbld_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Design references&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/audprccs/audioprocess&quot;&gt;AudioProcess: Mass audio converter for the Source Engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.ffmpeg.org/&quot;&gt;FFmpeg&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>MaterialBuilder: Compiling materials for source engine</title><link>https://unusuario2.github.io/posts/source_engine/tooling/matbld/materialbuilder</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/matbld/materialbuilder</guid><description>A tool that generates Source Engine .vmt material files from a KeyValues script, validating every shader parameter against materialsystem.dll and compiling its textures through a shared channel-compositing pipeline.</description><pubDate>Sun, 13 Sep 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Writing a &lt;code&gt;.vmt&lt;/code&gt; by hand means knowing exactly which shader you&apos;re targeting, which parameters it actually exposes, and getting every texture referenced by it compiled and pointed at the right relative path. Get any of that wrong and the error only shows up later, in-engine, as a missing texture or a silently ignored parameter.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;MaterialBuilder&lt;/strong&gt; takes a KeyValues script instead and produces a validated &lt;code&gt;.vmt&lt;/code&gt;, catching mistakes — an unknown shader, a parameter that shader doesn&apos;t support — at compile time instead of at runtime.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;resourcecompiler.exe &quot;Y:\buildworker\tssr_rel_win64\content\platform\materials\models\dev\dev_uv_check.vmtbuilder&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./matbld_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Two builders, one tool&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;MaterialBuilder&lt;/strong&gt; picks its behavior from the input script&apos;s extension:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;.vmtbuilder&lt;/code&gt;&lt;/strong&gt; → &lt;code&gt;CMaterialBaker&lt;/code&gt; — builds a full material.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;.vtfbuilder&lt;/code&gt;&lt;/strong&gt; → &lt;code&gt;CTextureBaker&lt;/code&gt; — builds a single texture, standalone.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both implement the same &lt;code&gt;IBaker&lt;/code&gt; interface (&lt;code&gt;Init&lt;/code&gt; → &lt;code&gt;ParseScript&lt;/code&gt; → &lt;code&gt;Create&lt;/code&gt; → &lt;code&gt;Compile&lt;/code&gt; → &lt;code&gt;Destroy&lt;/code&gt;), so the entry point in &lt;code&gt;materialbuilder.cpp&lt;/code&gt; doesn&apos;t need to know which one it&apos;s driving — it just new&apos;s the right one based on the file extension and runs the same four-step sequence.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Validating against the live shader list&lt;/h3&gt;
&lt;p&gt;A &lt;code&gt;.vmtbuilder&lt;/code&gt; script names a shader and a set of &lt;code&gt;$&lt;/code&gt;-prefixed parameters:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;MaterialBaker&quot;
{
    &quot;Shader&quot; &quot;UnlitGeneric&quot;

    &quot;$BaseTexture&quot;
    {
        &quot;R&quot;     { &quot;R&quot;   &quot;background_color.png&quot; }
        &quot;G&quot;     { &quot;G&quot;   &quot;background_color.png&quot; }
        &quot;B&quot;     { &quot;B&quot;   &quot;background_color.png&quot; }
        &quot;A&quot;     { &quot;A&quot;   &quot;background_color.png&quot; }

        &quot;VtexConfig&quot;
        {
            &quot;Preset&quot;    &quot;Color&quot;
        }
    }

    &quot;%KeyWords&quot; &quot;dev, matsys, internal&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Before writing a single line of &lt;code&gt;.vmt&lt;/code&gt;, &lt;code&gt;CMaterialBaker::ParseScript&lt;/code&gt; checks the &lt;code&gt;&quot;Shader&quot;&lt;/code&gt; value against &lt;code&gt;g_pMaterialSystem&lt;/code&gt;&apos;s live shader list (&lt;code&gt;ShaderCount()&lt;/code&gt; / &lt;code&gt;GetShaders()&lt;/code&gt;) — not a hardcoded list, but whatever &lt;code&gt;materialsystem.dll&lt;/code&gt; actually reports at runtime. If the shader doesn&apos;t exist, it fails immediately with the shader&apos;s name in the error.&lt;/p&gt;
&lt;p&gt;Every &lt;code&gt;$parameter&lt;/code&gt; under it goes through the same check against that specific shader&apos;s declared parameters (&lt;code&gt;GetParamName()&lt;/code&gt;), so a typo&apos;d or misplaced parameter is caught the same way. Because a chunk of parameters — &lt;code&gt;$translucent&lt;/code&gt;, &lt;code&gt;$nocull&lt;/code&gt;, &lt;code&gt;$vertexcolor&lt;/code&gt;, &lt;code&gt;$alpha&lt;/code&gt;, and about forty others — are handled by the material system itself rather than declared per-shader, those are matched against a static exclusion table instead of the shader&apos;s own param list, so they don&apos;t get rejected as unknown.&lt;/p&gt;
&lt;p&gt;Once a parameter passes validation, &lt;code&gt;CMaterialBaker&lt;/code&gt; reads its &lt;code&gt;ShaderParamType_t&lt;/code&gt; from the shader and writes it into the output &lt;code&gt;.vmt&lt;/code&gt; KeyValues tree as the matching type — texture, int, color, vec2/3/4, float, bool, string, or material. Two now-obsolete types (&lt;code&gt;ENVMAP&lt;/code&gt;, &lt;code&gt;FOURCC&lt;/code&gt;) just get a warning instead. Anything prefixed with &lt;code&gt;%&lt;/code&gt; instead of &lt;code&gt;$&lt;/code&gt; — like &lt;code&gt;%KeyWords&lt;/code&gt; above — isn&apos;t a shader parameter at all, so it&apos;s copied through untouched; those exist for other tools like &lt;strong&gt;Hammer&lt;/strong&gt; and &lt;strong&gt;VBSP/VRAD&lt;/strong&gt; to read.&lt;/p&gt;
&lt;p&gt;Example of a material with a unknow shader:
&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/matbld/matbld_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;p&gt;Example of a material with a unknow shader parameter:
&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/matbld/matbld_2.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Texture parameters: reference or generate inline&lt;/h3&gt;
&lt;p&gt;A texture-typed parameter like &lt;code&gt;$BaseTexture&lt;/code&gt; has two ways to resolve:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Point at an existing &lt;code&gt;.vtfbuilder&lt;/code&gt;.&lt;/strong&gt; &lt;strong&gt;MaterialBuilder&lt;/strong&gt; compiles it as a child texture and rewrites the parameter to point at the resulting &lt;code&gt;.vtf&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Define it inline&lt;/strong&gt;, as in the example above — a &lt;code&gt;TextureBaker&lt;/code&gt; sub-block describing which source image channels go into which destination channels. &lt;strong&gt;MaterialBuilder&lt;/strong&gt; writes that block out to a temporary &lt;code&gt;.vtfbuilder&lt;/code&gt; file and compiles it the same way, through &lt;code&gt;CTextureBaker::CompileChildren&lt;/code&gt;.
Each material that defines the texture/s as inline owns the texture, this means that is not used in any
other material, this will become later very useful for the &lt;strong&gt;assetsystem&lt;/strong&gt; system to detect orphan textures.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Either way it&apos;s the same texture compiler underneath — a material never has its own bespoke texture-building code path, it just drives &lt;code&gt;CTextureBaker&lt;/code&gt; on the material&apos;s behalf.&lt;/p&gt;
&lt;p&gt;An &lt;code&gt;AnimatedTextureBaker&lt;/code&gt; sub-block is also recognized in the script format, for frame-sequence textures — but the implementation is still a stub (&lt;code&gt;CAnimatedTextureBaker&lt;/code&gt; only implements &lt;code&gt;Identifier()&lt;/code&gt; right now). Referencing one in a script currently just errors out; it&apos;s next on the list.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;The channel compositor&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;CTextureBaker&lt;/code&gt; is the piece that turns a &lt;code&gt;Channels&lt;/code&gt; block into an actual image:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;TextureBaker&quot;
{
    &quot;Channels&quot;
    {
        // &amp;lt;destination vtf channel&amp;gt; { &amp;lt;src image channel&amp;gt;  &amp;lt;path to the src file&amp;gt; }
        &quot;R&quot;     { &quot;R&quot;   &quot;mask_specular.png&quot; }
        &quot;G&quot;     { &quot;G&quot;   &quot;mask_specular.png&quot; }
        &quot;B&quot;     { &quot;B&quot;   &quot;mask_specular.png&quot; }
    }

    &quot;VtexConfing&quot;
    {
        &quot;Preset&quot;    &quot;Color&quot;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each destination &lt;strong&gt;RGBA&lt;/strong&gt; channel can pull from a &lt;em&gt;different&lt;/em&gt; source image&apos;s channel — the classic Source Engine trick of packing unrelated grayscale masks (specular, AO, roughness) into one RGBA texture instead of shipping four separate files. &lt;code&gt;CGeneratedImage&lt;/code&gt; loads every referenced source image with &lt;code&gt;stb_image&lt;/code&gt;, checks that all of them share the same resolution, allocates a zero-filled destination buffer sized for however many channels ended up being used, and copies each source channel into its destination slot one pixel at a time.&lt;/p&gt;
&lt;p&gt;The composited result is written out as an intermediate &lt;code&gt;.tga&lt;/code&gt; via &lt;code&gt;stb_image_write&lt;/code&gt;, and &lt;code&gt;vtex.dll&lt;/code&gt; is called in-process (&lt;code&gt;g_pVtex-&amp;gt;VTex(...)&lt;/code&gt;) to compile that &lt;code&gt;.tga&lt;/code&gt; into the final &lt;code&gt;.vtf&lt;/code&gt;. Vtex&apos;s own compile flags come from a &lt;code&gt;VtexConfig&lt;/code&gt; block — either a named preset resolved from &lt;code&gt;materialbuilder_settings.txt&lt;/code&gt; (&lt;code&gt;VtexConfigPresets&lt;/code&gt;), or ad-hoc &lt;code&gt;Param&lt;/code&gt; overrides — written to a companion &lt;code&gt;.txt&lt;/code&gt; file that &lt;code&gt;vtex.exe&lt;/code&gt;&apos;s config format expects.&lt;/p&gt;
&lt;p&gt;When a texture is compiled as a child of a material rather than standalone, one more thing happens after vtex finishes: &lt;strong&gt;MaterialBuilder&lt;/strong&gt; reopens the freshly compiled &lt;code&gt;.vtf&lt;/code&gt; and stamps a small resource chunk into it (&lt;code&gt;VTF_RSRC_CHILDREN_TEXTURE_FROM_MATERIAL&lt;/code&gt;) recording the parent material&apos;s name. That&apos;s what lets a generated child texture be told apart from one with its own independent &lt;code&gt;.vtfbuilder&lt;/code&gt; script later — useful for tooling like ContentCheck that walks the asset cache and needs to know whether a &lt;code&gt;.vtf&lt;/code&gt; is meant to be edited directly or regenerated from its owning material.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Temp files and cleanup&lt;/h3&gt;
&lt;p&gt;Both bakers stage their work in a temp directory next to the source script (&lt;code&gt;_vmtbuilder\&lt;/code&gt; or &lt;code&gt;_vtfbuilder\&lt;/code&gt;) and delete it once the compile succeeds. &lt;code&gt;-keeptempfiles&lt;/code&gt; skips the cleanup — ContentBuilder enables this mode when it drives &lt;strong&gt;MaterialBuilder&lt;/strong&gt; as part of a larger batch, so intermediate &lt;code&gt;.tga&lt;/code&gt;s and vtex config files can be inspected if something in the chain goes wrong.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Example in action&lt;/h3&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/matbld/matbld_3.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Why this matters for a pipeline&lt;/h3&gt;
&lt;p&gt;A shader&apos;s valid parameter set changes as &lt;code&gt;materialsystem.dll&lt;/code&gt; evolves, and channel-packing textures by hand in an image editor doesn&apos;t scale past a handful of materials. &lt;strong&gt;MaterialBuilder&lt;/strong&gt; ties both to the config file: the script describes intent — which shader, which parameters, which channels from which source images — and the tool resolves that against whatever the engine currently supports, failing loudly at compile time instead of leaving a broken material to be discovered later.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;MaterialBuilder&lt;/strong&gt; will be later used by &lt;strong&gt;Material Editor&lt;/strong&gt; the UI tool for creating and rendering the materials for artists.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>ResourceCompiler: One tool for every asset type in the pipeline</title><link>https://unusuario2.github.io/posts/source_engine/tooling/rescmp/resourcecompiler</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/rescmp/resourcecompiler</guid><description>A single entry point that looks at an asset&apos;s type and dispatches to the right builder automatically — replacing five or six separate tool invocations an artist used to have to know.</description><pubDate>Sun, 13 Sep 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Before this existed, compiling an asset meant knowing &lt;em&gt;which&lt;/em&gt; tool compiled it. A texture went through &lt;strong&gt;MaterialBuilder&lt;/strong&gt;, a sound through &lt;strong&gt;SoundBuilder&lt;/strong&gt;, a model through the &lt;strong&gt;ModelBuilder&lt;/strong&gt;, a map through VBSP/VVIS/VRAD in the right order with the right flags. Six different binaries, six different sets of arguments, and an artist had to remember which one applied to whatever file they were looking at.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ResourceCompiler&lt;/strong&gt; collapses all of that into one command:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;resourcecompiler.exe -game &quot;C:/Games/MyMod/mygame&quot; -i &quot;content/mymod/materials/metal/rusted_panel.vmtbuilder&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./rescmp_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Point it at any asset. It figures out the rest.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;One entry point, dispatched by asset type&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;ResourceCompiler&lt;/strong&gt; doesn&apos;t ask what kind of asset it&apos;s compiling — it asks &lt;strong&gt;assetsystem&lt;/strong&gt;. &lt;code&gt;main()&lt;/code&gt; calls &lt;code&gt;g_pAssetSystemMgr-&amp;gt;QueryAssetInfo()&lt;/code&gt; on the input file, reads back its &lt;code&gt;AssetType_t&lt;/code&gt;, and switches on that to route the call:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ASSET_MATERIAL / ASSET_TEXTURE  -&amp;gt; CompileMaterialResource / CompileTextureResource
ASSET_MODEL                     -&amp;gt; CompileModelResource
ASSET_SOUND                     -&amp;gt; CompileSoundResource
ASSET_CLOSECAPTION              -&amp;gt; CompileCloseCaptionResource
ASSET_SCENE                     -&amp;gt; CompileSceneImageResource
ASSET_MAP                       -&amp;gt; CompileMapResource
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the asset type isn&apos;t compilable at all, it says so and exits cleanly instead of trying. There&apos;s no &lt;code&gt;-mode texture&lt;/code&gt; or &lt;code&gt;-mode sound&lt;/code&gt; flag to get wrong — the file itself carries that information.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;What it replaces for an artist&lt;/h3&gt;
&lt;p&gt;This is the actual point of the tool. Before &lt;strong&gt;ResourceCompiler&lt;/strong&gt;, compiling a batch of changed assets meant an artist (or a script) had to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Know which compiler handles &lt;code&gt;.vmtbuilder&lt;/code&gt;/&lt;code&gt;.vtfbuilder&lt;/code&gt; files (MaterialBuilder).&lt;/li&gt;
&lt;li&gt;Know a different one handles &lt;code&gt;.wav&lt;/code&gt;/&lt;code&gt;.vtfbuilder&lt;/code&gt;-adjacent sound scripts (SoundBuilder).&lt;/li&gt;
&lt;li&gt;Know a third for models, a fourth for close captions, a fifth for scene images.&lt;/li&gt;
&lt;li&gt;For maps, run VBSP, then VVIS, then VRAD, by hand, in that exact order, then remember to also build the environment map and pack the nav mesh into the &lt;code&gt;.bsp&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That&apos;s not one skill, it&apos;s five or six — each with its own argument order and its own failure modes. Getting the map sequence wrong (running VVIS before VBSP, for instance) doesn&apos;t fail loudly, it just produces a broken map that looks fine until someone notices the lighting is missing.&lt;/p&gt;
&lt;p&gt;With &lt;strong&gt;ResourceCompiler&lt;/strong&gt;, none of that is the artist&apos;s problem anymore. They give it a path. It&apos;s the same command whether the file behind that path is a texture, a sound, a model, or a map — and the same command works whether a person types it or a build script generates it. The five-or-six-tools-to-remember problem becomes a one-tool problem.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;The builders live in-process, not as separate executables&lt;/h3&gt;
&lt;p&gt;At startup, &lt;strong&gt;ResourceCompiler&lt;/strong&gt; loads every builder DLL it might need as an &lt;code&gt;IAppSystemDll&lt;/code&gt; module in the same process — &lt;code&gt;materialbuilder&lt;/code&gt;, &lt;code&gt;soundbuilder&lt;/code&gt;, &lt;code&gt;modelbuilder&lt;/code&gt;, &lt;code&gt;worldbuilder&lt;/code&gt;, &lt;code&gt;visbuilder&lt;/code&gt;, &lt;code&gt;lightbuilder&lt;/code&gt;, &lt;code&gt;environmentmapbuilder&lt;/code&gt;, &lt;code&gt;closecaptionbuilder&lt;/code&gt; — alongside &lt;code&gt;assetsystem&lt;/code&gt;, &lt;code&gt;materialsystem&lt;/code&gt;, and &lt;code&gt;filesystem_batch&lt;/code&gt;. When an asset needs compiling, &lt;strong&gt;ResourceCompiler&lt;/strong&gt; doesn&apos;t shell out to &lt;code&gt;materialbuilder.dll&lt;/code&gt; as a subprocess — it builds a synthetic &lt;code&gt;argv[]&lt;/code&gt; (the same arguments &lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/matbld/materialbuilder&quot;&gt;MaterialBuilder&lt;/a&gt; or &lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/sndbld/soundbuilder&quot;&gt;SoundBuilder&lt;/a&gt; would expect standalone) and calls that module&apos;s &lt;code&gt;Main()&lt;/code&gt; directly, in-process:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const int retCode = g_pMaterialBuilder-&amp;gt;Main(argc, argv);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Every &lt;code&gt;Compile*Resource&lt;/code&gt; call in &lt;code&gt;CGeneralCompiler&lt;/code&gt; follows this same shape — build an argument list, hand it to the already-loaded builder, read back the exit code. The exception is scene images, which still shell out to &lt;code&gt;sceneimagebuilder.exe&lt;/code&gt; as an external process via &lt;code&gt;StartExecutable&lt;/code&gt;, and &lt;code&gt;bspzip.exe&lt;/code&gt; for the final map-packing step — everything else runs in the same address space as &lt;strong&gt;ResourceCompiler&lt;/strong&gt; itself.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Maps: a full pipeline behind one set of quality flags&lt;/h3&gt;
&lt;p&gt;Maps get the most involved treatment, because a map compile isn&apos;t one step. &lt;code&gt;CCompileMap::Compile&lt;/code&gt; runs, in order: world (BSP), vis, lightmap, environment map, Steam Audio, navigation, then packs the results into the final &lt;code&gt;.bsp&lt;/code&gt; — copying it from a scratch directory into the correct mirrored location under the game&apos;s &lt;code&gt;maps/&lt;/code&gt; folder:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-&amp;gt; WorldBuilder     (BSP geometry, portals, leafs)
-&amp;gt; VisBuilder        (PVS, fast / standard / final)
-&amp;gt; LightBuilder      (lightmap bake, LDR / HDR / both)
-&amp;gt; EnvironmentMapBuilder
-&amp;gt; SteamAudioBuilder
-&amp;gt; NavigationBuilder (.nav / .ain)
-&amp;gt; PackMap           (bspzip — folds .nav/.ain into the .bsp)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each stage is independently toggled and quality-tiered from the command line — &lt;code&gt;-world 2&lt;/code&gt;, &lt;code&gt;-vis 1&lt;/code&gt;, &lt;code&gt;-lightMapperQuality 2&lt;/code&gt;, and so on — or all set at once with &lt;code&gt;-fast&lt;/code&gt;, &lt;code&gt;-standard&lt;/code&gt;, or &lt;code&gt;-final&lt;/code&gt;. Every stage times itself and reports pass/fail, and the whole run ends with a summary table:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ResourceCompiler-&amp;gt; Process Information:
... Building &apos;World&apos;            00h:01m:12s   Yes
... Building &apos;Vis&apos;               00h:00m:41s   Yes
... Building &apos;Lighting&apos;          00h:04m:03s   Yes
... Building &apos;EnvironmentMap&apos;    00h:00m:22s   Yes
... Building &apos;SteamAudio&apos;        00h:00m:00s   Yes
... Building &apos;Navigation&apos;        00h:00m:08s   Yes
... Packing &apos;Map&apos;                00h:00m:02s   Yes
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;-game&lt;/code&gt; mod directory and the map&apos;s output folder are both inferred from the input path if not passed explicitly — &lt;strong&gt;ResourceCompiler&lt;/strong&gt; walks the file path looking for &lt;code&gt;content\&lt;/code&gt;, mirrors everything after it into &lt;code&gt;game\&lt;/code&gt;, and (unless &lt;code&gt;-DisableCorrectMapDir&lt;/code&gt; is set) reuses that same relative folder structure under &lt;code&gt;maps\&lt;/code&gt; so a source file nested in &lt;code&gt;content/mymod/maps/dev/&lt;/code&gt; lands in &lt;code&gt;game/mymod/maps/dev/&lt;/code&gt;, not dumped flat into &lt;code&gt;maps/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Worth noting: &lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/mpbld/mapbuilder&quot;&gt;MapBuilder&lt;/a&gt;&apos;s own config format lists &lt;code&gt;RunResourceCompiler&lt;/code&gt; as one of its available build steps, right alongside calling VBSP/VVIS/VRAD directly. &lt;strong&gt;ResourceCompiler&lt;/strong&gt;&apos;s in-process map pipeline is effectively the newer path — MapBuilder can either drive the classic external tools itself, or hand the whole compile off to &lt;strong&gt;ResourceCompiler&lt;/strong&gt; in one step.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;ContentBuilder integration&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;-contentbuildermode&lt;/code&gt; is the same convention seen in the other tools in this pipeline: it flips a global (&lt;code&gt;g_ContentBuilderMode&lt;/code&gt;) that changes behavior when &lt;strong&gt;ResourceCompiler&lt;/strong&gt; is being driven by the automated build system rather than a person. Right now the only place that matters is texture/material compiles — it forwards &lt;code&gt;-keeptempfiles&lt;/code&gt; down to MaterialBuilder, so when ContentBuilder starts a &lt;strong&gt;N&lt;/strong&gt; number of simultaneous materials compiles does not delete the temporal directories causing some assets to fail the build.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Why this matters for a pipeline&lt;/h3&gt;
&lt;p&gt;A pipeline where every asset type has its own compiler, its own flags, and its own invocation order is a pipeline were artists waste a lot of time doing setups. &lt;strong&gt;ResourceCompiler&lt;/strong&gt; removes that requirement: the asset system already knows what a file is, so the compiler doesn&apos;t need to be told — it needs to be pointed at a path. Artists get one tool instead of six. Automated builds get one process to launch instead of orchestrating several. And the map pipeline specifically — the part most prone to being run out of order by hand — becomes a single command with quality presets instead of three (or six, counting environment maps, Steam Audio, and nav) manual steps.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Example in action&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;ResourceCompiler&lt;/strong&gt; compiling a material:
&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/rescmp/rescmp_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ResourceCompiler&lt;/strong&gt; compiling a model:
&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/rescmp/rescmp_2.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ResourceCompiler&lt;/strong&gt; compiling a caption:
&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/rescmp/rescmp_3.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>ContentBuilder: Compiling an entire game&apos;s content</title><link>https://unusuario2.github.io/posts/source_engine/tooling/cntnbld/contentbuilder</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/cntnbld/contentbuilder</guid><description>The batch layer above ResourceCompiler — walks every asset in the content tree, compiles the ones that are out of date across multiple processes at once, and writes a full pass/fail report.</description><pubDate>Sun, 20 Sep 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/rescmp/resourcecompiler&quot;&gt;ResourceCompiler&lt;/a&gt; knows how to compile &lt;em&gt;one&lt;/em&gt; asset, whatever type it is. That&apos;s the right tool when an artist just changed a texture. It&apos;s the wrong shape for &quot;build the whole game&quot; — that&apos;s not one asset, it&apos;s potentially thousands, and running them one at a time, sequentially, in a loop, would make a full build take however long the slowest possible sum of every compile happens to be.&lt;/p&gt;
&lt;p&gt;ContentBuilder is that full-tree build. Point it at a game, and it finds everything that needs compiling and compiles it across several processes at once.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;contentbuilder.exe -game &quot;C:/Games/MyMod/mygame&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;cntnbld_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Finding what actually needs building&lt;/h3&gt;
&lt;p&gt;ContentBuilder asks &lt;strong&gt;assetsystem&lt;/strong&gt; for literally everything it knows about — &lt;code&gt;AddAllAssetTypesToTheCache()&lt;/code&gt; followed by &lt;code&gt;EnumerateAllAssetsInCache()&lt;/code&gt;, the same cache &lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/cntnckc/contentcheck&quot;&gt;ContentCheck&lt;/a&gt; validates against — then filters that list down in two passes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Keep only assets whose type &lt;code&gt;IsCompilable()&lt;/code&gt;. Binary-only assets with no source file don&apos;t belong in a build queue.&lt;/li&gt;
&lt;li&gt;Pull out anything whose &lt;code&gt;GetSyncStatus()&lt;/code&gt; is &lt;code&gt;ASSET_SYNC_MISSING_BOTH&lt;/code&gt;, &lt;code&gt;ASSET_SYNC_MISSING_SOURCE&lt;/code&gt;, &lt;code&gt;ASSET_SYNC_ORPHAN&lt;/code&gt;, or &lt;code&gt;ASSET_SYNC_UNKNOWN&lt;/code&gt;. Those can&apos;t be compiled correctly regardless.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Everything left over is what actually gets built this run.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Two passes: everything else, then maps&lt;/h3&gt;
&lt;p&gt;Scenes get pulled out and compiled in one shot — a single &lt;code&gt;resourcecompiler.exe -scenes -contentbuildermode -game &amp;lt;dir&amp;gt;&lt;/code&gt; call handles every scene asset in the game at once, rather than one process per scene.&lt;/p&gt;
&lt;p&gt;Maps get pulled out too, but for a different reason: they aren&apos;t compiled through ResourceCompiler directly. Each one is handed to &lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/mpbld/mapbuilder&quot;&gt;MapBuilder&lt;/a&gt; instead — &lt;code&gt;mapbuilder.exe -game &amp;lt;dir&amp;gt; &amp;lt;file.vmf&amp;gt;&lt;/code&gt; per map — since a map compile is the multi-stage VBSP/VVIS/VRAD sequence MapBuilder is already responsible for, not something ContentBuilder needs to know how to orchestrate itself.&lt;/p&gt;
&lt;p&gt;Everything else — materials, textures, sounds, models, close captions — goes through ResourceCompiler one file at a time:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;resourcecompiler.exe -contentbuildermode -game &amp;lt;dir&amp;gt; &amp;lt;asset file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3&gt;Parallel compilation with a bounded task window&lt;/h3&gt;
&lt;p&gt;Every per-asset compile is one OS process (&lt;code&gt;resourcecompiler.exe&lt;/code&gt; or &lt;code&gt;mapbuilder.exe&lt;/code&gt;), launched through &lt;code&gt;StartExecutable&lt;/code&gt;. ContentBuilder runs a bounded number of those concurrently using &lt;code&gt;std::async&lt;/code&gt; and a sliding window of &lt;code&gt;std::future&amp;lt;void&amp;gt;&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;tasks.emplace_back(std::async(std::launch::async, [=]() { /* run one compile, record it in the report */ }));

if (tasks.size() &amp;gt;= numthreads)
{
    tasks.front().get();        // wait for the oldest in-flight task
    tasks.erase(tasks.begin()); // and drop it
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Materials, textures, sounds, models and captions all share the same task window, so a build isn&apos;t waiting on one category to finish before starting the next — it&apos;s bounded by total concurrent processes, not by asset type.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;The report&lt;/h3&gt;
&lt;p&gt;Every compile — completed, failed, or skipped — gets recorded into &lt;code&gt;_build\contentbuilder_report.txt&lt;/code&gt;, right alongside &lt;code&gt;_build\contentbuilder.log&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Example report &lt;code&gt;_build\contentbuilder_report.txt&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;ContentBuilderReport&quot;
{
	&quot;CompileDate&quot;		&quot;Thu Sep 24 08:56:20 2026&quot;
	&quot;Successful&quot;
	{
		&quot;materials\debug\debugcamerarendertarget&quot;
		{
			&quot;Content&quot;		&quot;y:\buildworker\tssr_rel_win64\content\platform\materials\debug\debugcamerarendertarget.vmtbuilder&quot;
			&quot;Game&quot;		&quot;y:\buildworker\tssr_rel_win64\game\platform\materials\debug\debugcamerarendertarget.vmt&quot;
			&quot;CommandLine&quot;		&quot;y:\buildworker\tssr_rel_win64\game\bin\x64\resourcecompiler.exe -contentbuildermode -game Y:\buildworker\tssr_rel_win64\game\platform\ y:\buildworker\tssr_rel_win64\content\platform\materials\debug\debugcamerarendertarget.vmtbuilder&quot;
		}
	}
    &quot;Failed&quot;
	{
		&quot;materials\debug\debuglightingonly&quot;
		{
			&quot;Content&quot;		&quot;y:\buildworker\tssr_rel_win64\content\platform\materials\debug\debuglightingonly.vmtbuilder&quot;
			&quot;Game&quot;		&quot;y:\buildworker\tssr_rel_win64\game\platform\materials\debug\debuglightingonly.vmt&quot;
			&quot;CommandLine&quot;		&quot;y:\buildworker\tssr_rel_win64\game\bin\x64\resourcecompiler.exe -contentbuildermode -game Y:\buildworker\tssr_rel_win64\game\platform\ y:\buildworker\tssr_rel_win64\content\platform\materials\debug\debuglightingonly.vmtbuilder&quot;
		}
    }
	&quot;Skip&quot;
	{
		&quot;models\dev\primitives\primitive_cone_001\primitive_cone_001&quot;
		{
			&quot;Content&quot;		&quot;y:\buildworker\tssr_rel_win64\content\platform\models\dev\primitives\primitive_cone_001\primitive_cone_001.qc&quot;
			&quot;Game&quot;		&quot;y:\buildworker\tssr_rel_win64\game\platform\models\dev\primitives\primitive_cone_001\primitive_cone_001.mdl&quot;
			&quot;CommandLine&quot;		&quot;Null&quot;
		}
	}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The log itself is buffered in memory (&lt;code&gt;CContentBuilderLoggingListener&lt;/code&gt;) and flushed to disk immediately the moment anything hits &lt;code&gt;LS_ERROR&lt;/code&gt;, in addition to a final flush on shutdown — so a crash mid-build doesn&apos;t lose the log that would explain why.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Why this matters for a pipeline&lt;/h3&gt;
&lt;p&gt;Every other tool in this series answers &quot;how do I compile &lt;em&gt;this&lt;/em&gt;&quot; — one material, one sound, one map. ContentBuilder answers &quot;is the entire game&apos;s content up to date,&quot; and answers it in parallel instead of one file at a time. It&apos;s the step that actually runs before a build ships: not because any single asset is hard to compile, but because compiling all of them, correctly, and knowing afterward exactly what succeeded and what didn&apos;t, isn&apos;t something you want to do by hand.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Example in action&lt;/h3&gt;
&lt;p&gt;Scene, models and maps are not compiled in this video showcase.&lt;/p&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/cntnbld/cntnbld_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item><item><title>ContentWatch: Recompiling assets the moment a source file changes</title><link>https://unusuario2.github.io/posts/source_engine/tooling/cntnwch/contentwatch</link><guid isPermaLink="true">https://unusuario2.github.io/posts/source_engine/tooling/cntnwch/contentwatch</guid><description>A file-watching daemon that turns saving a source asset into a compile — the live counterpart to ContentBuilder&apos;s full-tree batch pass.</description><pubDate>Thu, 24 Sep 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/cntnbld/contentbuilder&quot;&gt;ContentBuilder&lt;/a&gt; answers &quot;is the whole game up to date&quot; and &lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/rescmp/resourcecompiler&quot;&gt;ResourceCompiler&lt;/a&gt; answers &quot;compile this one file I&apos;m naming&quot; — but neither answers &quot;keep compiling whatever I just changed, right now, while I&apos;m working.&quot; That gap is a real cost during iteration: an artist tweaking a texture shouldn&apos;t have to alt-tab to a terminal and retype a compile command every time they hit save.&lt;/p&gt;
&lt;p&gt;ContentWatch is a small utility that sits on a content directory and does exactly that.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;contentwatch.exe -game &quot;C:/Games/MyMod/mygame&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&quot;./cntnwch_2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;A narrower cache than ContentBuilder&apos;s&lt;/h3&gt;
&lt;p&gt;ContentBuilder seeds its asset cache with everything assetsystem knows about, across every asset type it can find. ContentWatch is scoped tighter — it only caches what&apos;s actually under the target game&apos;s content directory, via &lt;code&gt;AddFilesFromDirToTheCache()&lt;/code&gt;, then hands that same directory to a recursive file watcher (&lt;code&gt;filewatch::FileWatch&amp;lt;std::string&amp;gt;&lt;/code&gt;) instead of polling it on a loop.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;One callback, five event types&lt;/h3&gt;
&lt;p&gt;The watcher&apos;s callback receives a &lt;code&gt;filewatch::Event&lt;/code&gt; for everything that happens under the content tree — &lt;code&gt;added&lt;/code&gt;, &lt;code&gt;removed&lt;/code&gt;, &lt;code&gt;modified&lt;/code&gt;, &lt;code&gt;renamed_old&lt;/code&gt;, &lt;code&gt;renamed_new&lt;/code&gt; — and routes each one:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Event&lt;/th&gt;
&lt;th&gt;What happens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;added&lt;/code&gt; / &lt;code&gt;modified&lt;/code&gt; / &lt;code&gt;renamed_old&lt;/code&gt; / &lt;code&gt;renamed_new&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;CompileWatchAsset()&lt;/code&gt; — recompile it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;removed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;drop it from the asset cache (&lt;code&gt;ClearFileInCache&lt;/code&gt;), no compile&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Two kinds of paths get filtered out before any of that: directories (the watcher fires on folders too, but there&apos;s nothing to compile), and anything containing &lt;code&gt;_vmtbuilder&lt;/code&gt; or &lt;code&gt;_vftbuilder&lt;/code&gt; — the temp folders &lt;a href=&quot;/unsuario2_website/posts/source_engine/tooling/matbld/materialbuilder&quot;&gt;MaterialBuilder&lt;/a&gt; creates and deletes mid-compile. Without that filter, MaterialBuilder writing its own intermediate files while compiling a texture would itself trigger a change event, which would start another compile, which would write more temp files — ContentWatch reacting to its own compiler&apos;s side effects. The check is just a substring match on the folder name, not something the watcher&apos;s OS-level API filters for it.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Guard checks before spending a compile&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;CompileWatchAsset()&lt;/code&gt; looks at &lt;code&gt;GetSyncStatus()&lt;/code&gt; before doing anything: already &lt;code&gt;ASSET_SYNC_IN_SYNC&lt;/code&gt; just logs and returns, &lt;code&gt;ASSET_SYNC_MISSING_BOTH&lt;/code&gt; / &lt;code&gt;ASSET_SYNC_MISSING_SOURCE&lt;/code&gt; logs that it can&apos;t be compiled and returns, &lt;code&gt;ASSET_SYNC_UNKNOWN&lt;/code&gt; does the same. Only an asset that&apos;s actually out of date and has a known, compilable state reaches the point of building a command line:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;resourcecompiler.exe -game &quot;&amp;lt;gamedir&amp;gt;&quot; &quot;&amp;lt;source asset path&amp;gt;&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The watcher&apos;s callback blocks on that one compile before it&apos;s ready to process the next file system event — there&apos;s no task queue or thread pool here the way ContentBuilder has one. For a single artist saving a single file, that&apos;s the right tradeoff: reacting to one change at a time, in order, is simpler and exactly as fast as it needs to be. A short sleep (&lt;code&gt;-sleep&lt;/code&gt;, tenths of a second, applied after every handled event) debounces the callback so a single save that fires multiple file system events in quick succession doesn&apos;t queue up redundant compiles.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Why this matters for a pipeline&lt;/h3&gt;
&lt;p&gt;ContentBuilder and ContentWatch cover opposite ends of the same problem. ContentBuilder is the deliberate, from-scratch pass across everything, run before a build ships. ContentWatch is the background process an artist and tooling (like assetbrowser) leaves running while they work, so the round trip from &quot;changed a source file&quot; to &quot;see the compiled result&quot; doesn&apos;t require typing its command line by hand.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Example in action&lt;/h3&gt;
&lt;p&gt;Showcase of the automatic compiles:&lt;/p&gt;
&lt;p&gt;&amp;lt;video src=&quot;/unsuario2_website/media/source_engine/tooling/cntnwch/cntnwch_1.mp4&quot; controls&amp;gt;&amp;lt;/video&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;Part of an ongoing series on the custom Source Engine tooling I&apos;m building for my game. More tools and systems coming.&lt;/em&gt;&lt;/p&gt;
</content:encoded><author>Unusuario2</author></item></channel></rss>