|
我的???是VS中的normal???如何?理(??Q),我要算N dot L的值
我查?有?煞N算法,哪一?才是正?的?
input.normal = normalize(mul(matInvTransposeWorld, input.normal));
input.normal = normalize(mul(input.normal, WorldMatrix));
以下是在下的vertex shadern code
VS_OUTPUT Main(VS_INPUT input)
{
// zero out each member in output
VS_OUTPUT output = (VS_OUTPUT)0;
output.uvTex_color1=input.uvTex_color1;
// transform vertex position to homogenous clip space
output.position = mul(input.position, WorldViewProjMatrix);
//
// Transform lights and normals to view space. Set w
// components to zero since we're transforming vectors.
// Assume there are no scalings in the world
// matrix as well.
//input.normal = normalize(mul(matInvTransposeWorld, input.normal));
input.normal = normalize(mul(input.normal, WorldMatrix));
//
// Compute the 1D texture coordinate for toon rendering.
//
LightDirection=normalize(LightDirection);
float u = dot(LightDirection, input.normal);
//
// Clamp to zero if u is negative because u
// negative implies the angle between the light
// and normal is greater than 90 degrees. And
// if that is true then the surface receives
// no light.
//
if( u < 0.0f )
u = 0.0f;
//
// Set other tex coord to middle.
//
float v = 0.5f;
output.uvTex_color0.x = u;
output.uvTex_color0.y = v;
// save color
output.diffuse = Color;
return output;
} |
|