游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1143|回复: 0

diffuse color in shader(normal)

[复制链接]

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
发表于 2007-12-17 01:08:00 | 显示全部楼层 |阅读模式
我的???是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;
}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-17 16:01

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表