WiseMaterialScroll: Create Scrolling Materials

From Valve Developer Community
Jump to: navigation, search

This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.

About a year ago I created a sample project for HL2 with a moving sidewalk by using the func_conveyor entity. The material I used on that conveyor was props\rubberconveyorbelt001a. It looked like a conveyor but didn’t move (scroll) with the func_conveyor. Recently Chris Britt contacted me about a new VMT he had created for use with func_conveyor. As you may or may not know you can create your own VMT (Source material data) for any of the SDK materials, your custom VMT can reference any other VTF (Source texture), in fact many Source materials do this as it’s not only a means to experiment with material properties but can also provide more than one use for the same texture. You could for example have a single material that has the properties of Glass or Metal, by creating an additional VMT.

One change I made to Chris’s new VMT was this:

"$surfaceprop" "no_decal"

This is because the conveyor looked strange if it received impact damage, say for example from the shotgun. By adding this the conveyor no longer receives impact damage decals.

The completed VMT is shown below:


"UnlitGeneric"
{
"$basetexture" "Props/rubberconveyerbelt001a"
"$surfaceprop" "no_decal"
"Proxies"
{
"TextureScroll"
{
"texturescrollvar" "$baseTextureTransform"
"texturescrollrate" "150"
"texturescrollangle" "0.00"
}
"ConveyorScroll"
{
"texturescrollvar" "$baseTextureTransform"
}
}
}

As you can see this new VMT still references the same VTF, props\rubberconveyorbelt001a.

There are two separate blocks of code properties in the proxies section.

TextureScroll

"texturescrollrate" "150"

This is very high. This is in units per second and normally you will not create scrolling textures that fast but it works out for the conveyor because it’s so long, with the func_conveyor set to a speed of 80 this new VMT works out well.

"texturescrollangle" "0.00"

This is the direction of the scroll effect. If for example you want the material to scroll down you would use -90 or 90 for scrolling up.

ConveyorScroll

This is only used by func_conveyor, no other entities.


To illustrate how simple this can be when you need a scrolling custom material I created a new material with transparency and a single horizontal red line.

WiseMaterialScroll line.png

If I use this new material with a normal VMT it will only be able to provide me with a line but by creating a VMT with scrolling properties for the same material will allow me to scroll my red line in any direction.

These are the properties for my red line:


"LightmappedGeneric"
{
"$basetexture" "akg/akg_redline_scroll"
"$surfaceprop" "no_decal"
"%keywords" "akg"
"$translucent" "1"
"Proxies"
{
"TextureScroll"
{
"texturescrollvar" "$baseTextureTransform"
"texturescrollrate" "0.3"
"texturescrollangle" "-90.0"
}
}
}

To show how the same image can be used I’ve created an additional VMT:


"LightmappedGeneric"
{
"$basetexture" "akg/akg_redline_scroll"
"$surfaceprop" "no_decal"
"%keywords" "akg"
"$translucent" "1"
"Proxies"
{
"TextureScroll"
{
"texturescrollvar" "$baseTextureTransform"
"texturescrollrate" "0.3"
"texturescrollangle" "90.0"
}
}
}

Notice that both of these VMTs reference the same VTF, akg_redline_scroll. Also notice that my texturescrollrate is 0.3, much slower than the conveyor. In fact this is incredibly slow, but I’ve designed the image and these settings to be used in a 3D Skybox, which as you know is 1/16th scale.

See also