From Valve Developer Community
Revision as of 22:39, 9 December 2006 by Ts2do (talk | contribs)
Jump to: navigation, search

Phong is a rendering technique introduced to the Source Engine with Half-Life 2: Episode One and looks best on a normal mapped model with some bit of specularity.

VMT Parameters

  • "$phong" "1" Enables Phong effect
  • "$phongboost" "X" Increases the overall Phong effect by X factor, default seems to be 1
  • "$phongfresnelranges" "[1 3 6]" Higher numbers result in more visible highlights, but need clarification on its relation to RGB color, if any
  • "$phongexponenttexture" "path/filename_exp.vmt" Mask to determine Phong brightness effects on a texture, where a white pixel denotes full Phong illumination, and a black pixel denotes no Phong illumination.
  • "$phongexponent" "0" contrast, (0-1) Higher values denote higher Phong illumination.
  • "$phongalbedotint" "1" Phongal Bedo Tint: unknown usage

Exponent Map

The Phong shader automatically uses the normal maps alpha channel if available to determine where to apply the Phong effect, just as specular mapping with $normalmapenvmask does. In addition to this an exp map can be used, which gives further control over Phong properties on the material. All of Day of Defeat: Source's player models have both normal maps with alpha channels and exponent maps; check them out for a solid reference to get a subtle Phong effect.

A common technique for creating an exponent map would be to first create the normal map's alpha channel. This generally starts as a desaturated copy of your regular texture. Next you would mask out areas with black for no shine, and darken areas for more subtle reflection. Overall, this is going to be darker than your base texture except for metal surfaces (i.e. for a soft shine smooth leather it needs to be nearly black).

When finished with your normal map's alpha, copy that layer to a new document as an image (in PhotoShop you'd select all on the alpha channel, Copy, File...->New, Paste). At this point you may darken or lighten areas specifically for Phong brightness. Reduce the image size and save it as a compressed texture with no alpha. You can afford to reduce the resolution and compress the exponent texture: A scaled down 256x256 exponent map is sufficient for a 1024x1024 texture.

External Links

Since valve has offered no documentation a lot of this information can be credited to user experimentation and tutorials such as

Hopefully this knowledge will continue to be expanded on, this is a wiki guys!

This article is a stub. You can help by adding to it.