How to set up a material to use PHONG


Someth|ngW|cked
07-06-2006, 08:20 PM
This is quick guide on how to create a material that uses the new phong shader for models, this tutorial will tell you how to add phong to existing skins but the process is the same for custom content

This guide uses photoshop CS2 but any image manipulationapplication such as GIMP will work fine

I am also using the frag grenade for this example

__________________________________________________ _______

Open photoshop and load your TGA or .VTF (PS VTF plugin and other resources linked at the bottom of the thread)

http://img136.imageshack.us/img136/7411/colorrange17ps.jpg

Now the first step is to go into SELECT>COLOR RANGE andclick the eyedropper on the pure BLACK of the image (most skins use pure black for the area of the texture that does not cover the model) now check the INVERT option and set your "fuzziness", i use a "fuzziness" value of 50 which is usually perfect, your results should look like the image above

http://img82.imageshack.us/img82/9096/alpha13js.jpg

After clicking OK or pressing enter to accept the selection make sure that there is no alpha channel already in the image file then create a new alpha channel, make sure that your background color is pure white (255 255 255) and hit delete (clear) with the alpha channel selected, you should have have a result like the image above, the black areas will not have highlights and the white areas will

http://img82.imageshack.us/img82/2613/exponent14wy.jpg

With the color range selection still active select the RGB channel and create a new layer now press CTRL+J to create a new layer via copy then press CTRL+SHIFT+N to create a new blank layer, if not done automaticly by PS press CTRL+D to clear selection and fill the blank layer with pure green (0 255 0) and set it's blending mode to multiply, make sure that the green layer is on the top of the layer stack and that you delete the original BACKGROUND layer, your image should now look like the image above

Now flatten your image (layer>flatten image) and then press CTRL+SHIFT+S to save as, if you are using nem's VTF plugin then save as .VTF and set the TEMPLATE to Compressed Texture With Alpha, keep the filename the same but add _exp to the end of it

http://img375.imageshack.us/img375/126/normal29tq.jpg

Once again open your original image file (the base texture) and run the NVTools normal map filter using the settings in the image above, after pressing ok or enter to accept the filter drag and drop the alpha channel you created in your _exp to your newly created normalmap and make sure that the only alpha map in your image is the one you created now hit CTRL+SHIFT+S again to save as a .VTF this time setting the template to Normal Map With Alpha, keep the filename the same but this time add _normal to the end of it

That is all you need to do as far as image manipulation, now lets create the VMT to make all of this stuff work together


You can just use the existing v_frag.vmt and paste these perameters into it

"VertexLitGeneric"
{
"$baseTexture" "models/weapons/v_models/frag/v_frag"
"$bumpmap" "models/weapons/v_models/frag/v_frag_normal"

"$phong" "1"

"$phongexponent" "10"
"$phongboost" "1"
"$phongfresnelranges" "[1 3 6]"
// "$halflambert" "1"
"$phongexponenttexture" "models\weapons\v_models\frag/v_frag_exp"
"$phongalbedotint" "1"

}


These settings are pretty much ideal for any type of metal

The most important part to note is the "$phongexponent" and "$phongfresnelranges" values

"$phong exponent" as far as i can tell changes the contrast of the highlights against the exponent texture, higher numbers are more true to the exponent texture . . .

"$phongfresnelranges" is like using RGB on water, high numbers are more saturated, lower numbers are less saturated, so the lower these numbers the less visable the highlights are so this is like an opacity adjustment

Here are 2 more VMT example, the first is for skin (hands) and the second is for cloth (sleeves)



"VertexLitGeneric"
{
"$baseTexture" "models\weapons\v_models\hands/v_hand"
"$bumpmap" "models\weapons\v_models\hands/v_hand_normal"

"$phong" "1"

"$phongexponent" "15"
"$phongboost" "1"
"$phongfresnelranges" "[0.3 2.3 5.3]"
// "$halflambert" "1"
"$phongexponenttexture" "models\weapons\v_models\hands/v_hand_exp"
"$phongalbedotint" "1"
}





"VertexLitGeneric"
{
"$basetexture" "MODELS\WEAPONS\V_MODELS\HANDS\us_sleeve"
"$bumpmap" "models\weapons\v_models\HANDS\us_sleeve_normal"

"$phong" "1"

"$phongexponent" "30"
"$phongboost" "1"
"$phongfresnelranges" "[0.1 2.1 5.1]"
// "$halflambert" "1"
"$phongexponenttexture" "models\weapons\v_models\HANDS\us_sleeve_exp"
"$phongalbedotint" "1"
}

Please post any questions and or additons you might have

__________________________________________________ ______


* RESOURCES *


Nem's VTF plugin for Photoshop - http://nemesis.thewavelength.net/files/files/vtfplugin106.zip

Nvidia Normal Map plugin for Photoshop - http://download.nvidia.com/developer/NVTextureSuite/Photoshop_Plugins_7.83.0629.1500.exe

GIMP - http://www.gimp.org/downloads/

Photoshop Tryout - https://www.adobe.com/cfusion/tdrc/index.cfm?loc=en&product=photoshop

whc.demo
07-26-2006, 10:04 AM
are you able to have the phong on say only the helmet of a player while its turned off on the rest of the skin?

so with bumpmaps turned off you dont get the shiney effect on the player skin, only on the helmet?

Day of Defeat Forum Archive created by Neil Jedrzejewski.

This in an partial archive of the old Day of Defeat forums orignally hosted by Valve Software LLC.
Material has been archived for the purpose of creating a knowledge base from messages posted between 2003 and 2008.