Mmm... Well, easiest implementation I can think of... same as normal phong, but 
the vector of the incident light (as transformed into the tangent space) is 
compared to the grain... sounds like gibberish...

Use the surface normal of the triangle (or bump map/whatev) to project the 
incident light vector (the vector from the light source) onto the surface plane.

as vectors:
projected = normalize(incident * (1 - dotproduct(incident, surfacenormal)))

have a 3-coordinate in a texture, or per vertex, that represents the direction 
the "grain" (2 coord) and the anisotropy intensity. Multiply the tangent space 
vectors (the local U and V directions as used for texture mapping) each by the 
"grain" 2 coord, and add them together. This is the direction of the "grain" as 
mapped onto the model in world space. Note that the grain 2-coord, UVector, and 
VVector  MUST be normalized, unless you want to waste a LOT of GPU effort.

grainVector = UVector * grainX + VVector * grainY

Find the cosine between these two angles:

weight = absoluteValue(dotproduct(grainVector, projected))

This weight value goes from 0 to 1, and a 1 represents an incident light that 
is directly along the grain, 0 is perpendicular. Use that as a weight in your 
normal phong computations to complete it, along with the "anisotropy intensity" 
to determine the two extremes.

This is just pulled out of my arse, and I've never done this before... so... 
Sorry if it's totally messed up, but hopefully it gives you a good idea, and 
isn't too incredibly inefficient. There's no trig ops, so it should be pretty 
fast... I hope.

Good luck

> Date: Wed, 15 Jul 2009 15:32:28 +0200
> From: [email protected]
> To: [email protected]
> Subject: [hlcoders] Anistropic phong hilights
> 
> Hello!
> I want to make a shader with anistropic phong hilights for hair of
> characters in my mod. I have some experience with HLSL, but with this I
> just dont know where to begin. Any help will be appreciated.
> Thanks.
> Jan "Walter" Sluka
> 
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, please 
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
> 
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to