$ssbump: Difference between revisions
m (Nesciuse moved page $ssbump/en to $ssbump without leaving a redirect: Move en subpage to basepage) |
ShiroDkxtro2 (talk | contribs) ($SSBumpMathFix explanation and documentation) |
||
Line 21: | Line 21: | ||
$ssbump 1 | $ssbump 1 | ||
$SSBumpMathFix 1 | $SSBumpMathFix 1 | ||
}</nowiki>}} | }</nowiki>}} | ||
{{note|An ssbump can also be used as a [[$detail|detail texture]] on non-fullbright [[brush]]es and [[displacement]]s, with [[$detailblendmode|blend modes 10 or 11]] being automatically chosen if the texture has the ssbump [[VTF]] flag, depending upon whether the material has a [[normal map]].}} | {{note|An ssbump can also be used as a [[$detail|detail texture]] on non-fullbright [[brush]]es and [[displacement]]s, with [[$detailblendmode|blend modes 10 or 11]] being automatically chosen if the texture has the ssbump [[VTF]] flag, depending upon whether the material has a [[normal map]].}} | ||
==$SSBumpMathFix== | |||
The parameter addresses an issue with SSBump Textures being too bright.<br> | |||
It can be found in the VMT's of {{as|2}}, {{csgo|2}}, {{l4d2|2}}, {{bms|2}} and {{p2|2}}<br> | |||
However the Parameter itself does not appear to be functional in some of them.<br> | |||
{{confirm|Which one does it work in? Confirmed : {{l4d2}}}} | |||
{{note|Does not work in {{csgo}}, textures appears fine however and don't overbright!}} | |||
The Parameter addresses an issue where SSBump's unlike their Normal Map counter parts are non-unit Vectors.<br> | |||
More specifically, unlike the .x and .y components of the Bump Basis, the .z components don't cancel out.<br> | |||
The maximum range of the result, is equal to the sum of the .z components. <code>3* (1.0f / sqrt(3.0f))</code> or <code>1.73205f</code> <br> | |||
This causes SSBumps to be MUCH too bright.<br> | |||
Luckily, this can retroactively be accounted for by multiplying the result with <code>Desired_Range / Current_Range</code> or numerically<code>1.0f / 1.73205f</code> <br> | |||
{{note|It can easily be tested that this fix is applied in {{l4d2|2}} using the following method.<br> | |||
1. Compare a $SSBump material using $SSBumpMathFix and a $Color value of <code>1.73205</code>, with the same material without both.<br> | |||
2. Compare a $SSBump Material using $SSBumpMathFix, with the same material without $SSBumpMathFix and a $Color value of <code>0.57735</code>}} | |||
{{important|This issue appears to affect most, if not all, publicly available SSBump Generators! Including Valves!! }} | |||
{{tip| You can use this knowledge to your advantage! This fix can still be applied, even in Source Branches that don't have native support for $SSBumpMathFix!<br> | |||
Multiply your $Color Parameter with the Value <code>0.57735</code>, or in case you don't have $Color yet simply add it with that Value! <br> | |||
This works because $Color is applied specifically to the Lightmap, in the Shader.}} | |||
==Limitations== | ==Limitations== |
Revision as of 20:19, 3 August 2024


$ssbump
is a material shader parameter available in all Source games since
Source 2007.
It is a boolean parameter that flags a $bumpmap texture as being a self-shadowing bump map.
Standard bump maps only darken texels that are facing away from a light source. Self-shadowing bump maps darken both texels facing away and also any texels which are 'behind' them, similar to Ambient Occlusion maps in modern game engines. You can read more about the technology behind it in this paper.

Example

$SSBumpMathFix
The parameter addresses an issue with SSBump Textures being too bright.
It can be found in the VMT's of Alien Swarm,
Counter-Strike: Global Offensive,
Left 4 Dead 2,
Black Mesa and
Portal 2
However the Parameter itself does not appear to be functional in some of them.
The Parameter addresses an issue where SSBump's unlike their Normal Map counter parts are non-unit Vectors.
More specifically, unlike the .x and .y components of the Bump Basis, the .z components don't cancel out.
The maximum range of the result, is equal to the sum of the .z components. 3* (1.0f / sqrt(3.0f))
or 1.73205f
This causes SSBumps to be MUCH too bright.
Luckily, this can retroactively be accounted for by multiplying the result with Desired_Range / Current_Range
or numerically1.0f / 1.73205f


1. Compare a $SSBump material using $SSBumpMathFix and a $Color value of 1.73205
, with the same material without both.
0.57735


Multiply your $Color Parameter with the Value 0.57735
, or in case you don't have $Color yet simply add it with that Value!
Limitations
The shadows cast by the bump map are permanently baked into the texture, meaning that they can only appear in one of three predefined locations. height2ssbump
generates shadows for light arriving from the right, top-left, and bottom-left of the texture.

If light arrives from between those directions (such as from the left), the nearest available baked shadows are blended between, producing an acceptable but hardly ideal image.
Additionally, in order to preserve the illusion of height, low areas of a SSBumped material will receive less light even if it arrives head-on. This can look odd if you have too intense (rugged) a SSBump.
Creation
You need to use height2ssbump
, a command line SDK tool. The command is:
height2ssbump <options> <path\to\heightmap.tga> <float|bumpscale>
The output is <input name>-ssbump.tga
, in the same folder as the input file. Bumpscale
controls the intensity of the ssbump (i.e., coarseness of the surface).



height2ssbump
is currently non-functional in 


You can use normal2ssbump
, another SDK tool, to generate an SSBump from a normal bump map (as opposed to a height or displacement map) - Unlike height2ssbump
you do not need to run through the command line or use any additional parameters; simply drag-and-drop your normal map onto the program or a shortcut.

Options
<path/filename>
- The source heightmap (TGA format).
-r <int>
- Set the number of 'rays' (default 250). More rays take more time.
-n
- Generate a conventional bump map as
<input name>-bump.tga
. -d
(in all games since)(also in
)
- Generate an ssbump detail texture, used with $detailblendmode 10 and 11.
Confirm:How does this differ from a making regular SSBump? public/bitmap/float_bm.h has a description.
-A
- Generate ambient occlusion in the alpha channel.
-f <int>
- Set smoothing filter radius (default 10; 0 disables).
-D
- Write out filtered result as
filtered.tga
.
An example of a complete command is:
height2ssbump -r 275 "C:\Path\to\example-height.tga" 35
Third Party Tools
Third-party tools capable of generating SSbump maps:

|