To Know - Creating Your Own Texture

[release]


Basic First Texture

Tools used:

  Image editor such as GIMP, Paint.net, or Photoshop.
  [VTFEdit](http://nemesis.thewavelength.net/index.php?c=178)
  SourceSDK

IMAGE EDITOR
Your texture MUST be a power of 2.
Example:
256x512
256x1024
64x512 (not recommended, but still usable)
or just plain 512x512.
Minimum texture size is 1x1, while max is 4096x4096.

Make your image save it as a .tga file.
[img_thumb]http://img101.imageshack.us/img101/9456/textureexample.jpg[/img_thumb]

Load up VTFEdit and press Import. Once you have found your .tga texture select it and press ok.

Once you press okay, you might see this:

And you are thinking “What the hell is all this?” Well its quite simple actually.

Normal Format is the format the texture uses if it doesn’t have an alpha channel.
Alpha Format is the format the texture uses if it does have an alpha channel.
Texture Format is the format the texture will be used for.

Animated Texure is most common, even if the texture is not animated. There are also the environment map format but that is for reflections and stuff, i.e. custom reflection, which can be selected in the $envmap parameter later (see below). And there is volume texture, which I am not to sure what it is for.See more. See more2.

Resize: Kind of obvious don’t you think? You can resize your texture to whatever you want.

Important: Mipmaps are like LOD (level of detail) on your textures. If you have no Mipmaps for your texture, you will have a grain effect from far away.
[img_thumb]http://i163.photobucket.com/albums/t319/FirePawX/dm_sandtrap_m0004.jpg[/img_thumb]

In VTF Edit:
[img_thumb]http://img514.imageshack.us/img514/8828/texturetile.jpg[/img_thumb]

Generate Normal Maps
This is used to create our bumpmaps later on, do not use this if you don’t have bumpmaps on your textures. If you generate bumpmaps save the file as _normal.vtf so its easy to remember.
[img_thumb]http://img691.imageshack.us/img691/9529/texturenormal.jpg[/img_thumb]

Once you have your image, we can write our .vmt (Valve Map Texture) I personally use notepad, but you can use notepad++ or whatever you perfer.

Open our text editor.

Now of course there are a bunch of different types of shaders you can use:



LightmappedGeneric
Patch
Refract
SpriteCard
UnlitGeneric
UnlitTwoTexture
VertexLitGeneric
Water
WorldTwoTextureBlend
WorldVertexTransition

Each is used for a different type of texture.

I’ll only explain a few textures that you will most likely use.

“LightmappedGeneric” Is most commonly used for texturing a wall, or rock, or anything that uses Lightmaps to apply shadows and lighting. See more.

“UnlitGeneric” Used for making textures full bright, they are not effected by lightmaps. See more.

“UnlitTwoTexture” Used for making fullbright texture with a blend; Have one texture blend into another by making it a displacement and painting alpha. See more.

“VertexLitGeneric” Used to render models. Although I’m not sure how lighting is calculated on it, I assume by the name it works from the vertexes (vertecies?) on how its lit. See more.

“Water” Take a guess, you can make water textures with it. Water refracts cubemaps or the world depending if it is a cheap or expensive material. See more.

“WorldVertexTransition” Used to render a blend between two textures. Most commonly used on displacements, you can use the blend texture on non-displacements, but you cannot change the texture unless you turn it into one and use the “paint alpha tool.”
See more.

Once we have our selected shader we can go ahead and choose what our effects are.

Example:


LightmappedGeneric
{
	$basetexture	"custom/texture01"
	$surfaceprop	"brick"
	$bumpmap	"custom/texture01_normal"
}

the $bumpmap effect is used to give the illusion of having a 3D texture instead of a flat texture.
Example:

The $surfaceprop parameter tell the source engine what kind of surface properties it has, such as brick, concrete, sand, grass, ect…See more.

We could also add in the $envmap parameter to our texture to give it a type of shine to it. This can be accomplished by using an env_cubemap.


$envmap "env_cubemap"

See more.

Once we have our .vmt written, we can go ahead and save it. Save the .vmt with the same name as the .vtf you have, inside the same folder. We do not need to create a seprate .vmt for our texture01_normal.
Example folder:
C:\Program Files\steam\steamapps\Firegod522\materials\custom\Texture01.vmt
•C:\Program Files\steam\steamapps\Firegod522\materials\custom\Texture01.vtf
•C:\Program Files\steam\steamapps\Firegod522\materials\custom\Texture01_normal.vtf

Once we load up hammer editor we can type in custom/ as the filter and we should have texture01 show up in the list. Apply it to your brush/displacement (whichever you chose) and compile!
[img_thumb]http://img63.imageshack.us/img63/3383/tiletest0000.jpg[/img_thumb][/release]

[release]


Detail Textures

Detail textures are a great way to adding details to your texture whithout having to actually edit the texture every time you want to add it in.

Basic rules apply.
Must be power of 2.
Also has to be an 8-bit greyscale texture.

I’ll be using a default Valve detail texture (detail/rock_detail_01)

Here is my texture:
[img_thumb]http://img175.imageshack.us/img175/783/textureroadexample.jpg[/img_thumb]

Here is my code:



"LightmappedGeneric"
{
	"$basetexture" "Roads/Clean_Road001"
	"$bumpmap" "Roads/Clean_Road001_normal"
	"$surfaceprop" "concrete"
	"$detail" "detail/rock_detail_01"
	"$detailscale" "5"
	"$detailblendfactor" ".6"
	"$detailblendmode" "0"

}

$detailscale controls how many copy of this detail is in the texture. The higher the number, the more times its copied. The lower, the less its in the texture. See more.

$detailblendfactor controls how visable the detail is on the texture. The higher, the more visable, the lower, the less.

$detailblendmode controls how the texture blends. 0 is darken the texture. 1 makes the detail addictive (which brightens) 2 blends the texture through the alpha. 3 I don’t know what it does. I haven’t tried it.

Once we compiled our map with the texture it should show up how you want it.
[img_thumb]http://img156.imageshack.us/img156/306/withwithout.jpg[/img_thumb]
:siren:


Look at the difference it makes!

:siren:
[/release]

[release]


Customizing Water Textures

Water is a normal map, which can have plenty of effects to it, such as changing the color, changing the reflectivity, ect…

Basic rule of being a power of 2.

Since water textures are Normal maps, they don’t have a specific color to them. You can easily change them in the .vmt, which is easy for testing instead of having to color and recolor your texture to match your scene.

I will be making my own water code, just for a tropical island map I need.


"Water"
{
	"$abovewater" 1
	"%compilewater" 1
	"$forceexpensive" 1
	"$reflectentities" 0
	"$envmap" "env_cubemap"
	"%tooltexture" "nature/water_frame01_normal"
	"$refracttexture" "_rt_WaterRefraction"
	"$refractamount" "0"


	"$reflecttexture" "_rt_WaterReflection"
	"$reflectamount" "2"

	"$bumpmap" "nature/water_coast01_dudv"
	"$normalmap" "nature/water_coast01_normal"

	"$surfaceprop" "water"
	"$bottommaterial" "nature/water_coast01_beneath"
	"$bumpframe" "0"

	"$fogenable" 1
	"$fogcolor" "[63 214 225]"
	"srgb?$fogcolor" "{63 214 225}"
	"$fogstart" -1024
	"$fogend" 0

	"$scroll1" "[.01 .01 .05]"
	"$scroll2" "[-.025 .025 .075]"

	"Proxies"
	{
		"TextureScroll"
		{
			"texturescrollvar" "$bumptransform"
			"texturescrollrate" .01

			"texturescrollangle" 25.00
		}
		"WaterLOD"
		{
		}
			
	}

}

I’ll try my best to explain this.

•$abovewater tells the engine that this texture is for above the water, which is where it will be rendered for reflectivity and refractions

•$forceexpensive controls if the water texture is going to reflect in real time. 1 would mean it does, 0 would make the texture depend on the water_lod_control

•$reflectentities tells the engine if they should reflect entities. I haven’t noticed and difference with this on or off.

•$refracttexture Is the texture that refracts depending on the normal map. _rt_WaterRefraction is default code built in with the engine and should always be used for $refracttexture for real time refractions.

•$refractamount controls the amount of warping applied to the refraction. Higher values means more warping.

•$reflecttexture tells the engine to reflect in real time. Always use _rt_WaterReflection for real time reflections.

•$reflectamount controls the amount of warp on the reflection. Using higher values makes reflections more visable.

•$bumpmap tells the material what to use for reflections and for effects. Same applies to $normalmap.

•$bottommaterial is the material seen when you are underwater.

•$bumpframe tells the texture what frame to start using the bumpmap

•$fogenable controls if fog is on or not.

•$fogcolor tells the engine what color the water is going to look from above.

•I’ve yet to discover what srgb?$fogcolor does opposed to fogcolor.

•$fogstart is where the fog starts. Use negative values for it to start behind the player.

•$fogend Controls when the fog ends from eye level.

•$scroll1 is the size of the first layer texture scrolling. (there are 2)
•$scroll2 is the sie of the second layer texture scrolling.
Generally Scroll 1 and 2 are hardly noticable but if you look closly its there.
(sorry if I didn’t really explain it too well. :saddowns:)

See more.

Proxies are generally used for moving texture effects.

texturescrollvar is for what texture is scrolling (in this case, we want to transform the bumpmap. To make it animate)
texturescrollrate is self explainitory, it controls how fast the texture scrolls.
texturescrollangle also self explainitory, it controls the angle the texture scrolls.

In game:
[img_thumb]http://img180.imageshack.us/img180/3254/islands20002.jpg[/img_thumb]
[img_thumb]http://img269.imageshack.us/img269/6756/islands20003.jpg[/img_thumb]
[/release]

[release]


Amazing use of Seamless_scale

Seamless_scale was originally coded in to solve for use of the antlion tunnels in ep2, to fix some odd stretching. It can be easily used to fix up environment stretching.

Requires texture to be a power of two.

Here is the texture I’ll be using:
[img_thumb]http://img72.imageshack.us/img72/9586/textureseamless.jpg[/img_thumb]

$seamless_scale uses some odd number system which I’ve yet to figure out, but it appears the more zeros, the larger the scale. I found 0.0085 to be 0.25 in the normal scale dialog for hammer.
See More.

$seamless_scale is NOT compadible with a normal bumpmap or a normal normalmap. You must use a SSBump texture.

Here is my code:


"LightmappedGeneric"
{
	"$baseTexture" "nature/forest_grass_01"
	"$surfaceprop" "dirt"
	**"$seamless_scale" "0.0085"**
	"%keywords" "ep2"
}

In game:

[img_thumb]http://img94.imageshack.us/img94/9414/textureseamlessexample.jpg[/img_thumb]

Look at the Amazing differences![/release]

[release]


Refracting Windows

Being able to refract from windows is a cool little effect that can change up the overall feel of some part of your map, even if its a brush based shower or something.
Required:
A Power of 2 texture
A normalmap texture
A Dudvmap texture for lower end users on dx8 graphic cards

I’m going to be using the previous normal map texture.
[img_thumb]http://img691.imageshack.us/img691/9529/texturenormal.jpg[/img_thumb]

Here is my code:



"Refract"
{
	"$normalmap" "Tile\Tile_floor_normal"
	"$dudvmap" "Tile\Tile_floor_dudv"
	"$refracttint" "[.9 .9 1]"
	"$refractamount" ".2"
	"$surfaceprop" "glass"
	"$envmap" "env_cubemap"
	"$envmaptint" "[.6 .6 .85]"
}

I’m assuming you read the other begining section, so you should know what envmap, and normal map stuff is for.

•$refractamount Controls how strong the refraction is. Generally higher amounts makes objects on the opposite side more distorted, while smaller shows less noticeable distortions.
•$refracttint Allows you to set the tint of the glass or distortion, so that it can look like you are looking through colored glass.
See More.

Now with my texture in game:
[img_thumb]http://img811.imageshack.us/img811/4400/skychange0001.jpg[/img_thumb]

:siren:Neither World Brushes or Func_detail can be used with this shader!:siren:[/release]

[release]


Decals

Decals are a very important part of a map. They make walls not so plain, they can be used for letting people read something for a backstory. Decals are also pretty good for breaking up repetition.

Required:
Power of two texture
Picture with an alpha channel (depending if transparent)

Alright so here is my current image I’m going to be using.
[img_thumb]http://img258.imageshack.us/img258/3914/facepunchdecal.png[/img_thumb]
I have made an alpha channel so its just the face and not the white background.

Code:



LightmappedGeneric
{
	$basetexture	decals\Facepunch_decal
	$decal		1
	$decalscale	0.1
	$translucent	1
}


•$decal Required for making a decal work. Otherwise it will not show up properly.
•$decalscale Controls the scale of the actual image in game. Without this, it will show up in the engine a 1 inch per pixel, and that is huge. Usually around 0.1 to 0.3 are good starters.
•$translucent Tells the engine that this texture is translucent (has an alpha channel)
See more.

Shot in hammer:
[img_thumb]http://img253.imageshack.us/img253/1894/facepunchlogo.jpg[/img_thumb]
In game:
[img_thumb]http://img411.imageshack.us/img411/9735/hallwaylighting0037.jpg[/img_thumb][/release]

[release]


Blend Textures

Blend textures are a great tool for adding feel to places. You don’t want to have grass sitting where there is a obvious pool of water, it doesn’t work like that.

Alright blend textures aren’t that hard to set up. Its just 2 textures. Assuming you have 2 already made, you can easily modify a .vmt



WorldVertexTransition
{
	$basetexture	"custom\grass"
	$basetexture2	"custom\dirt"
	
	$surfaceprop	"grass"
	$surfaceprop2	"dirt"
}


in game:
[img_thumb]http://img9.imageshack.us/img9/5990/grass002a0001.jpg[/img_thumb]

Now its not required to have $surfaceprop in the .vmt, this just makes it sound different when you are walking on it.

Notice that the shader we are using is WorldVertexTransition

•$blendmodulatetexture Is a special texture which blends the alpha mask of a texture a specific way.
Left is without, right is with.
[img_thumb]http://developer.valvesoftware.com/w/images/9/9c/Blendmodulate.jpg[/img_thumb]
•$seamless_scale Is a specific value which textures can stop stretching once you move a displacement vertex. This parameter was used in ep2’s Antlion caves. note: texture application tool will not effect the size. its 1 and only 1 size. read more.
•$ssbump Is a special texture which gives dynamic shadows a “3D” effect on textures. This texture was also in the Antlion caves, and several textures. Valve use this more often with their newer games. L4D, alien swarm, and will most likely be used in others.Read more.

See more.

:siren: If you happen to be making this texture, and they are backwards, dirt shows up in hammer, but in game its grass, this is because you didn’t change the shader to WorldVertexTransition! :siren:
[/release]

[release]


Grea$eMonkey's Animated Texture Tutorial

[/release]

[release]SSBump Textures

Required
SSBump Generator
A height map
Patience

This is my height map
[img_thumb]http://img857.imageshack.us/img857/7052/ssbumptexture.png[/img_thumb]

So go ahead and open up the ssbump generator program, and it looks a little confusing, but first things first set it to advanced mode, then press the windows preview button with the plus in the bottom right image.

http://img812.imageshack.us/img812/4450/menugy.png

Rays - The number of samples per color
•Radius - How far the color will cast
•Height Scale - Adjusts the ratio of height per color amount
•Theta Limit - Is the radius of which the Rays are cast from, similar to raising a light_spot’s radius.
•Alpha Limit - Represents the amount of spread Rays are moved from.

Its okay to play around with these values if you know what you are doing, but mainly for testing use a low amount of Rays, that way its quicker.

I’m going to use a height scale of 0.35 because its somewhat grey, and it will look pretty flat, and I want a shadow that pops out.
[img_thumb]http://img24.imageshack.us/img24/539/ssbumptexturessbump.png[/img_thumb]

Now we are going to write a .vmt for it.



LightmappedGeneric
{
    "$basetexture"    "ssbump/ssbump_texture"
    "$bumpmap" "ssbump/ssbump_texture-ssbump"
    "$ssbump"    "1"
}


Now when you go in game, shine your flashlight on it, and it will cast shadows based off pre compiled positions. Valve did this in ep2, when you were in the antlion caves, to fake the bumpyness of the antlion caves, it was pretty flat if you don’t cast your flashlight on it.
[/release]
If I have forgot something/You want to know something, post in this thread. I’ll try my best to add it in here.

Minimum to maximum size of possible textures for source:

1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, and 4096.

good job on the op, informative!

Added to OP. Thanks.

It doesn’t have to be a power of 2, in VTFEdit, in the scnreenshot you provided, there’s an option to resize.

[editline]10:15PM[/editline]

Good tutorial, rated tool.

[editline]10:15PM[/editline]

One thing though, it doesn’t seem very noob friendly.

http://img155.imageshack.us/img155/7830/resize.png

:smile:

Hows it not very noob friendly? I added pictures and pretty clear instructions.

No, it has to be a power of 2.

2^0 = 1
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128
2^8 = 256
2^9 = 512
2^10 = 1024
2^11 = 2048
2^12 = 4096

EDIT: oh, i see what you are saying. you are saying that if you’re too lazy to resize it to a power of 2 in your image editing program, then VTFedit will resize it for you.

If you’re creating your own texture in an image editor, why not resize / crop it yourself rather than let an external program change it up?

Added some more pics to OP.

This is definitely a nice thread. Maybe add a section about the Photoshop VTF plugin, and exporting from it?

I saw this coming from that other thread, lovely tutorial though, very informative.

Added in section for $detail

The smaller pieces you got from the Valve Developers thing, you should reword and make it easier to understand. Valve tends to put confusing text, in my opinion, like could you possibly say the following in English?

How those are explained kind of just throws me off. I’d really appreciate it though. :slight_smile:

Alpha channels and normal textures get their own formats.
If you mean what opaque means, it means its solid, doesn’t have an alpha channel.

Oh, alright. Yeah I didn’t know what opaque meant, honestly I thought it was some type of coloring. Do you possibly know what the DXT1 and things are? Or, if you explain it, could you quote it? I may have skipped that part. :S

Click the 2 see mores in that area.

Oh, thanks. You should try to put those in your main thread somewhere, although they aren’t that important, it would be good for advanced creators. (If those settings are advanced.)

Attempted to add in water. :ohdear: I hope it makes some sense.

Can you go into detail about the mipmaps? I don’t really get what they are for or how to make them.

I kinda did. To make them, tick the generate mipmap box.

Pretty much when you are far away the engine will render the textures at a different mipmap level to save on memory usage. It’s good during high detail scenes.

Hurrah, my map was used as a bad example! :v: