From 47a2a79e2e57c244029dc794a2a95f3fe770a88e Mon Sep 17 00:00:00 2001 From: Blixibon Date: Sat, 14 Dec 2019 22:48:32 -0600 Subject: [PATCH] Updated Shader Changes (markdown) --- Shader-Changes.md | 48 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/Shader-Changes.md b/Shader-Changes.md index 685baa3..cf5d36b 100644 --- a/Shader-Changes.md +++ b/Shader-Changes.md @@ -1,10 +1,10 @@ -**Shaders** are special programs used to render the scene on a user's GPU. The Source SDK allows modders to modify or add shaders to the engine, as many mods have done. +**Shaders** are used for rendering a scene on a user's GPU. The Source SDK comes with Source's shaders and allows modders to modify or add shaders to the engine. -Mapbase modifies the shaders in various ways, but most of these changes aren't meant to improve graphical quality as much as they're meant to fix bugs or serve as quality-of-life improvements. This trend started with the projected texture fixes and more features were added from there to help make the steep caveat for modifying shaders worth the trouble. +Mapbase modifies Source's shaders in various ways, but most of these changes are just supposed to fix certain issues, add new capabilities, or make things easier to do. (todo: talk about mods that have already changed shaders) -Before we actually get into what these changes are, we need to talk about the main caveat of modifying existing shaders and how Mapbase gets past this caveat: +Before we go into more detail about these changes, there is a steep and demanding caveat of modifying existing shaders and that caveat needs to be made as clear as possible, especially how Mapbase gets past this caveat. # The Shader Caveat (IMPORTANT) @@ -14,9 +14,9 @@ The problem is that materials still using the original shaders won't use Mapbase Some mods go for things like an automatic passthrough system, which means all materials are changed to the new shaders without requiring the modificaton of any VMT files. This is useful for when you can't easily change every VMT that could be used in-game, e.g. when there's tons of VMTs embedded in tons of MP maps, but that has problems like material proxies being lost or decals not working with it. It also increases loading times. -For Mapbase, we instead opted for renaming all of the shaders in the VMTs themselves, which is the most basic and tedious solution, but the end result is much more efficient than the alternative. This isn't really too much of a problem, as these are just the plain-text VMTs, not the actual texture VTFs. Mapbase also comes with converted versions of all of Half-Life 2/EP1/EP2's VMTs, neatly packed in VPKs and staying at only 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/mod. If you are using custom materials or mounting materials from another game/mod, **Mapbase's installer contains a tool that can automatically change all of the materials in a directory to the new shaders.** In one trial, the mod version of Black Mesa: Source's 3,974 VMTs were converted to the new shaders in 1 minute and 58 seconds. It's recommended that you pack converted VMTs into a VPK file. +For Mapbase, we instead opted for renaming all of the shaders in the VMTs themselves, which is the most basic and tedious solution, but the end result is much more efficient than the alternative. This isn't really too much of a problem, as these are just the plain-text VMTs, not the actual texture VTFs. Mapbase also comes with converted versions of all of Half-Life 2/EP1/EP2's VMTs, neatly packed in VPKs and staying at only 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/mod. If you are using custom materials or mounting materials from another game/mod, **the [Mapbase Multi-Tool](https://www.moddb.com/mods/mapbase/downloads/mapbase-multi-tool) can automatically change all of the materials in a directory to the new shaders.** In one trial, the mod version of Black Mesa: Source's 3,974 VMTs were converted to the new shaders in 1 minute and 58 seconds. It's recommended that you pack converted VMTs into a VPK file. -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 their differences visible. +You could technically 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 their differences visible. The only real outright requirement related to new shaders is that rope materials *must* use the `SDK_Cable` shader due to some other code changes that make the original `Cable` unusable. @@ -24,6 +24,29 @@ The only real outright requirement related to new shaders is that rope materials --- +Here's a list of vanilla Source shaders which Mapbase has custom `SDK_` counterparts for: + +- `LightmappedGeneric` +- `VertexLitGeneric` +- `UnlitGeneric` +- `WorldVertexTransition` +- `Water` +- `Sprite` +- `Refract` +- `LightmappedReflective` +- `WorldTwoTextureBlend` +- `EyeRefract` +- `Eyes` +- `EyeGlint` +- `Teeth` +- `Cable` +- `DepthWrite` +- `DecalModulate` +- `UnlitTwoTexture` +- `MonitorScreen` + +--- + 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. --- @@ -45,7 +68,7 @@ The gnarliest Frankenstein of them all, Mapbase uses a combination of Alien Swar ### 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. +Radial fog first came to Valve's games through Left 4 Dead. 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. @@ -59,19 +82,18 @@ 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, mostly because it was more difficult to *not* port them than it was to just avoid it. 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) +This was ported with the projected texture changes when Mapbase gleaned shader stuff from the Insolence repo, mostly because it was more difficult to *not* port them than it was to just avoid it. 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](https://www.moddb.com/mods/city-17-episode-1). (todo: also figure out what it looks like with an exponent mask 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. +### Parallax Corrected Cubemaps -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 to have moved to a new shader I presume it would run faster or look better. +

+ +

-Even though the shader is actually `SplineRope`, it uses `SDK_Cable` in Mapbase for consistency with the other modded shaders. It needed code changes that make the original `Cable` shader unusable, so hopefully this is worth that sacrifice. - -(todo: figure out more details) +(todo: explain) --- ---