Skip to content

Shader Changes

Blixibon edited this page Aug 30, 2019 · 15 revisions

Shaders are special programs ran by the GPU. The Source SDK allows modders to modify or add shaders to the engine, as many mods have done.

Mapbase modifies the shaders in various ways, but these changes aren't meant to improve graphical quality as much as they're meant to fix bugs or "improve the mapping experience".

Before we actually get into what these changes are, we need to talk about the caveat of modifying existing shaders:

The Shader Caveat (IMPORTANT)

The Source SDK comes with the original shader source code and files which you could compile yourself, but Source doesn't actually allow modders to change existing shaders for security reasons. You can create new shaders with code from existing shaders, but you can't actually modify existing shaders in the engine. This means you can't add things to the existing LightmappedGeneric, but you can create an identical shader called SDK_LightmappedGeneric with your own changes. This is how Mapbase modifies the shaders. It uses custom SDK_ versions of the original shaders.

The problem is that materials still using the original shaders won't use Mapbase's shader changes, so in order to take advantage of these changes, you must change all of your materials to use the custom shaders.

This isn't too bad since it only needs the VMTs (plain-text material files) to be changed, not the VTFs (actual texture files). Mapbase also already comes with converted versions of all of Half-Life 2/EP1/EP2's VMTs, neatly packed in VPKs and staying at about 2-3 MB total, so you'd only have to worry about this if you're adding custom materials or mounting materials from another game. Mapbase also provides an "installer" that can automatically change all of the materials in a directory to the new shaders.

You could potentially get away with using the original shaders if you don't need Mapbase's shader changes, as there's nothing inherently wrong with them, but they wouldn't look right if they're used alongside modded shaders because features like radial fog and projected texture changes would make them look weird. Rope materials also require the SDK_Cable shader due to some other code changes that make the original Cable unusable.



The majority of Mapbase's large-scale shader changes come from other projects or are based off of other versions of the engine, so they've been split into two categories for changes made by other people and changes made specifically for Mapbase.


"Third Party" shader changes

Other people's work from other people's projects that have been gathered into Mapbase.


Insolence's Alien Swarm/C17:EP1 projected textures

Mapbase uses a combination of Alien Swarm, City 17: Episode One, and G-String projected texture changes obtained from Insolence's repository. You can find more information on the dedicated article.


Downfall's Alien Swarm radial fog

Mapbase uses Half-Life 2: Downfall's implementation of Alien Swarm's radial fog.

Radial fog was implemented in Source at some point before Alien Swarm, possibly in L4D2 or something, but Half-Life 2 still uses "planar" fog, which is calculated as a plane and changes as you rotate the camera. You could often see past it by rotating the camera and looking at the edge of your screen.

HL2: Downfall implements radial fog in Source 2013, which Mapbase uses and also extends to other shaders. This means fog is calculated radially and doesn't change as you rotate the camera, unlike planar fog.

Using white fog in the example picture was probably a bad idea.


C17:EP1's phong on LightmappedGeneric

Mapbase uses City 17: Episode One's LightmappedGeneric/WorldVertexTransition phong, implemented from Insolence's repository.

This was ported with the projected texture changes when Mapbase gleaned shader stuff from the Insolence repo. It was ported because the FXC files were being copied directly instead of cherry-picking individual code changes. (there was a very large number of changes, they weren't replacing existing files, I was still learning how to mod shaders, etc.) There was also some mild demand for them. Again, even though I got this from the Insolence repo, the code was almost entirely from City 17: Episode One and you could find more information on their ModDB page. (todo: link)

(todo: also figure out what it looks like for an in-Mapbase screenshot)


Alien Swarm ropes (SplineRope)

Mapbase uses Alien Swarm ropes from Half-Life 2: Downfall, including both the SplineRope shader and the changes to move/keyframe_rope itself.

The circumstances behind this being added are similar to that of the "brush phong" above, but I didn't know whether this was required for the radial fog changes to work at the time. I still don't know many of the differences, although it does seem to look better.

(todo: figure out more details)



Mapbase's own shader changes

Shader changes created specifically for Mapbase, mostly by Blixibon.


$blendmodulatetexture fixes

Mapbase fixes $blendmodulatetexture not appearing under a flashlight, not working with transforms, and lets it show up in Hammer. It also uses Alien Swarm's version of the shader code.

You can find the VDC article here.


$phongdisablehalflambert

Mapbase ports this parameter from Alien Swarm, which allows $phong to be used without $halflambert being forced enabled.

You can find the VDC article for $phong here, which lists $phongdisablehalflambert.


$basetexturetransform2 on WorldVertexTransition in DX9

Mapbase adds $basetexturetransform2 to the DX9 version of the shader.

$basetexturetransform2 already existed on the

It doesn't work with $seamless_scale or the C17:EP1 brush phong.

Clone this wiki locally