Everything I Need To Know About Phong


Watevaman
03-10-2007, 07:50 AM
Hey, everyone, I've recently ramped up my anty and have started dwelling in the hell that is Valve's phong shader. As of yet, it hasn't been a very pleasant trip, with all these parameters and channels, I'm still kind of wandering around. What I was hoping is, that I could get some help from some of you guys who make nice clean, and good looking, phong effects. From what I gather so far:

-The normal's alpha channel holds a mask telling what is phonged? (black - none, white - full?)
-The _exp mask tells what is shiny and what is a flat shading?
-What are some limits to the parameters, such as fresnelranges, that'll totally screw up the look, so I don't go that far?

And there is one example of what I'm looking to get out of this (reminds me so much of CoD2), and that is Wicked's LCVP in this movie.

http://www.youtube.com/watch?v=JOIC99DPYRg

Thanks for any and all help that I get!

Little Edit: For your knowledge, what I'm trying to get a good, clean phong out of at the moment is the Tiger tank, so advice on metal phonging would be a bit more helpful, but phonging organics will also come soon, so I'll take any help.

Wile E Coyote
03-10-2007, 10:53 AM
Well, one thing you should know is that in Source phong shaders and normalmap shaders go hand-in-hand, since the alpha channel of the normalmap is used to control the intensity of the shader effect and the Exponent map is used to control how diffused the reflected light off the object surface appears.

There was another really good explanation, I think by Gingerlord, that I cannot find that had some really good points in it, especially about the exponent map

http://developer.valvesoftware.com/wiki/Phong_materials


I disagree with some of the methods in this tutorial, but it has very solid info and examples on how to set up the VMT files
http://www.dayofdefeat.net/forums/showthread.php?t=66731

I'm including my normal map tut (which tends to move too fast, my bad) simply because you need to do a normalmap to get the phong to show up.
http://www.dayofdefeat.net/forums/showthread.php?t=70741

Trp. Jed
03-10-2007, 11:09 AM
Actually I wrote that article with help from Jason Mitchel at Valve who is one of their main graphics/shader guys. It's probably the most authorative info out there on how the shader works as the info came from Valve themselves (I just tried to document it in as easy to undestand manner as possible).

Watevaman
03-10-2007, 11:39 AM
Yeah, I've seen the Wiki, and was reading it while working on stuff. Thanks Wile and Trp., your works (your normal tut isn't too fast for me, Wile, it just takes time to do, which is fine) are both great and very helpful. :D

Edit: Alright, did it, but as my earlier endeavors, I'm getting these white lines.

http://img250.imageshack.us/img250/4841/lcvpik5.jpg

Can someone explain these to me in general? I've seen a few skins with them, but deleting the normal or something fixed 'em. Could it be because my original texture is 2048 instead of 1024? Is it a .vmt parameter? Here's my .vmt right now

"VertexLitGeneric"
{
"$baseTexture" "models/props_vehicles/lcvp"
"$bumpmap" "models/props_vehicles/lcvp_normal"

"$phong" "1"
"$phongexponent" "40"
"$phongexponenttexture" "models/props_vehicles/lcvp_exp"
"$phongboost" ".5"
"$phongfresnelranges" "[1 3 6]"
"$phongalbedotint" "1"
}

Wile E Coyote
03-10-2007, 02:02 PM
Honestly, I've asked about them in the past, nobody has yet told me what causes it. I can tell you they only appear where there are VERY skinny surface areas AND they only appear with certain video cards / drivers. I have never seen them myself, only screenshots like above.

I have tried saving the normal maps in every format combination possible, but the person who was testing these for me (he had the same problem) said none of them fixed the problem.

He also said he did not get these white lines with the default skins, so I would really like to know what they did :D

Ginger Lord
03-10-2007, 02:20 PM
6800GT's are notorious for that problem.

Watevaman
03-10-2007, 02:41 PM
6800GT's are notorious for that problem.

And that is unfortunately the card I have. :( Oh well, glad to know it won't show up for others. (it won't, right?)

BERSERK3R
03-16-2007, 09:10 AM
[...]

http://www.youtube.com/watch?v=JOIC99DPYRg

Thanks for any and all help that I get!

[..]

Wooowie!!
That video is that made from a mod?
First those phong effects are superb on that boat.
Second does the water/ground uses differenct textures or is it just the quality of the video that makes it look different?
Also the "wiggling" while running is that done "manually" or is it scripted/animated??

Anyone know more of this?
It looks so much more real!

If not, I really like to make these "features" into a mod!
Who will be up for it, to join me.

Watevaman
03-17-2007, 11:13 AM
Wooowie!!
That video is that made from a mod?
First those phong effects are superb on that boat.
Second does the water/ground uses differenct textures or is it just the quality of the video that makes it look different?
Also the "wiggling" while running is that done "manually" or is it scripted/animated??

Anyone know more of this?
It looks so much more real!

If not, I really like to make these "features" into a mod!
Who will be up for it, to join me.

It's a video by somethingwicked, and I believe everything in it is made by him. The bobbing seemed to be manually done and the map/textures were probably personal stuff he did.

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.