Cleanup is going to take awhile, so the site is back up but editing has been disabled.

Proxies

From HalfLife 2 Knowledge Base

Jump to: navigation, search

by FishMD

Material Proxies

Material Proxies allow materials to change rendering properties using game state and scripted equations. They are written in the vmt file of a texture. In this tutorial i will explain how i wrote a proxy that pans a texture upwards.

What you need:

  • a text editor, i use ConText
  • .vtf texture
  • source engine

How i did it

first you will need a texture, any texture. I used a texture i made myself that looks like smoke with an alpha channel for transparency. Lets assume it's in the folder /models/smoke and the vtf file is called smoke.vtf, and the vtm file is called smoke.vtm.

First we start off by creating our basic shader. I used an unlitgeneric here. Note that the following properties can be for anything.

smoke.vtm

"unlitgeneric"
{
  "$basetexture" "models/smoke/smoke" //this sets the base texture. Note, there is no .vtf ending
  "$translucent" "1" //makes the shader transparent using the alpha channel of $basetexture
  "$nocull" 1 //makes the texture double-sided. Use on transparent textures
  "$model" 1 //1 if applied on a model, leave it out if its a world texture

Pretty simple shader, will make a texture that is transparent and double sided.

Next we will add our proxies

"unlitgeneric"
{
  "$basetexture" "models/smoke/smoke" //this sets the base texture. Note, there is no .vtf ending
  "$translucent" "1" //makes the shader transparent using the alpha channel of $basetexture
  "$nocull" 1 //makes the texture double-sided. Use on transparent textures

"Proxies"{
       "TextureScroll"{
           "texturescrollvar" "$basetexturetransform" //$basetexturetransform is the property that
                                                      //will move the base texture upwards. Pretty
                                                      //much anything that ends in transform is the
                                                      //property that moves what it coresponds to.
                                                      //eg. "$envmapmasktransform" will move the
                                                      //environment map mask.
           "texturescrollrate" .1 //the movement speed. 1 is really fast.
           "texturescrollangle" 90  //the direction of the movement in degrees. 90 is up
    }
  }
}

This can be used for any transform property such as "$envmapmasktransform". Check the Shader_Parameters link for a complete reference of all paramaters and shader types.

More complex proxies to come

Personal tools