Cleanup is going to take awhile, so the site is back up but editing has been disabled.
Details on materials (like grass)
From HalfLife 2 Knowledge Base
by Dawa
In this tutorial, I will explain about details on a texture.
To know all about details, we will be covering the following:
Contents |
What are details?
A material can contain elements of detail. You should know that materials can blend, but they can also contain sprites, models, and placed compilation. The example I will be reviewing is the application of grass:
How do details function?
A file named "detail.vbsp" must be in the root of the Mod. Some examples are: "half-life 2\hl2\", "counter-strike source\cstrike\", or "SourceMods\mymod\". This file is only used by the compiler. You do not need to publish it with your map (.BSP). Once compiled, the elements of details will be registered in your map (.BSP). Each function (paragraph) present in this file states a name which is used in the .VMT of a texture. Each function (paragraph) contains various parameters to change the model. In Half-Life 2, this file is provided and should be used as your base. Counter Strike: Source, however, contains only two functions (paragraphs) created for Prodigy and Compound.
Appling details to Counter Strike: Source
We will make an example with the "blendrockgrass00a" material (HL2 material). Create a brush using Hammer (with it set on CS:S), apply the texture ("blendrockgrass00a"), then compile the map. You should find no grass details present on the texture. To fix this, we must consult the .VMT texture:
"WorldVertexTransition"
{
"$basetexture" "nature/rockfloor005a"
"$basetexture2" "nature/dirtfloor006a"
"%tooltexture" "nature/blendrockgrass004a_tooltexture"
"$basetexturetransform" "center .5 .5 scale 1 1 rotate 0 translate 0 0"
"$basetexturetransform2" "center .5 .5 scale 1 1 rotate 10 translate 0 0"
"%detailtype" "coastline_redgrass01"
"$surfaceprop" "dirt"
"%keywords" "coastline"
"$bumpmap" "nature/rockfloor005a_normal"
}
The line that sets the detail is found present. Here is the code:
"%detailtype" "coastline_redgrass01"
The material will use the function (paragraph) named "coastline_redgrass01" as the reference to build the details. Now, open the file "detail.vbsp" (located in:"half-life 2\hl2") and then find the function (paragraph) named: "coastline_redgrass01". You should find:
"coastline_redgrass01"
//reduced size by 0.75
{
"density" "600.0"
Group1
{
"alpha" "1"
Model1
{
"sprite" "288 0 128 128 512"
"spritesize" "0.5 0.0 19 25"
"spriterandomscale" "0.2"
"amount" "0.2"
"detailOrientation" "2"
}
Model2
{
"sprite" "0 0 128 128 512"
"spritesize" "0.5 0.0 23 30"
"spriterandomscale" "0.2"
"amount" "0.1"
"detailOrientation" "2"
}
Model3
{
"sprite" "144 0 128 128 512"
"spritesize" "0.5 0.0 15 15"
"spriterandomscale" "0.2"
"amount" "0.15"
"detailOrientation" "2"
}
Model4
{
"sprite" "144 144 128 128 512"
"spritesize" "0.5 0.0 18 21"
"spriterandomscale" "0.2"
"amount" "0.2"
"detailOrientation" "2"
}
//shrub
Model5
{
"sprite" "144 288 128 128 512"
"spritesize" "0.5 0.0 38 38"
"spriterandomscale" "0.2"
"amount" "0.2"
"detailOrientation" "2"
}
Model6
{
"sprite" "0 288 128 128 512"
"spritesize" "0.5 0.0 23 23"
"spriterandomscale" "0.2"
"amount" "0.1"
"detailOrientation" "2"
}
Model7
{
"sprite" "288 288 128 128 512"
"spritesize" "0.5 0.0 42 42"
"spriterandomscale" "0.2"
"amount" "0.1"
"detailOrientation" "2"
}
}
Group2
{
"alpha" "0.0"
}
}
It can seem complicated at first, so follow closly. Copy and paste this block into the "detail.vbsp" located in "counter-strike source\cstrike\". Compile the map again, and you should find the grass detail is now present.
Internal details
The material used by HL2 and CSS for the details is "detailsprites.vtf". It's located in the file "materialsource.gcf", at "Hl2/materials/Detail". Here is this file:
We see 9 sprite grasses distributed on this image. Each grass image is present in a square of 128x128 pixels.
Parameter setting
Here is the parameter setting which I applied to a map in Counter Strike: Source:
"coastline_redgrass01"
{
"density" "300.0"
Group1
{
"alpha" "1"
Model1
{
"sprite" "288 288 128 128 512"
"spritesize" "0.5 0.0 15 15"
"spriterandomscale" "0.2"
"amount" "0.4"
"detailOrientation" "2"
}
Model2
{
"sprite" "144 288 128 128 512"
"spritesize" "0.5 0.0 18 21"
"spriterandomscale" "0.2"
"amount" "0.1"
"detailOrientation" "2"
}
}
Group2
{
"alpha" "0.0"
}
}
- density 300.0: corresponds to the density of grass present on your material. The more you increase this figure, the more grass there will be. You will notice that I reduced the density by half when compared to HL2, as it is necessary to prevent lag issues in multiplayer. The total for all the sprites for the material is stated by using:
- sprite 288 288 128 128 512. The numbers are the coordinates of the image which I chose. To clearify, "288, 288" is the x and y placement of the image, "128, 128" is the width and height of the image, and "512" is the total size of the material.
The grass I end up with is:
- spritesize 0.5 0.0 15 15: States the size of the sprite.
- spriterandomscale 0.2 and "amount" "0.4": Defines the factors for the random placement. They can be defined by sprites (contrary to density).
- detailOrientation 2: States orientation. Use 2 for all details, as the other orientations are unknown to me.
It is also possible to use models instead of sprites, but doing leads to lag issues with most graphics.
Making custom details
So you want to make your own details? Here's how, but be warned, I did not have time to test it and the following is a theory.
Create a material according to the format of the material found in "detailsprites.vtf". Place your material into the directory: "materials/Detail". Add the detail like usual. Note: If you distribute your map with this file, it will take effect for all maps the client plays.
To avoid this, pack your custom material in your .BSP, using either PakRat or BSPZip. That way people will only see that detail on your map, and not others.

