關於頭髮渲染中dirther的反思

來源:

float StrandSpecular (float3 T, float3 V, float3 L, float exponent)
{
    float3 H = normalize(L + V);
    float dotTH = dot(T, H);
    float sinTH = sqrt(1.0 - dotTH*dotTH);
    float dirAtten = smoothstep(-1.0, 0.0, dot(T, H));
    return dirAtten * pow(sinTH, exponent);
}

smoothstep函數:
smoothstep(a, b, x)
{
x<a, 返回0;
x>b,返回1;
a<x<b,返回 w=(x-a)/(b-a), ww(3-2*w)
}

當dot(T,H)小於-1,生成0;
當dot(T,H)大於0,生成1;
當-1<dot(T,H)<0,返回smoothstep的值。
smoothstep函數裏w=x+1。如圖:
在這裏插入圖片描述
橫座標爲dot(T,H)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章