Index: source/blender/render/intern/source/shadeoutput.c =================================================================== --- source/blender/render/intern/source/shadeoutput.c (revision 14333) +++ source/blender/render/intern/source/shadeoutput.c (working copy) @@ -697,6 +697,26 @@ return i; } +/* KajiyaKay spec */ +/* t means tangent to strand */ +static float KajiyaKay_Spec(float *t, float *l, float *v, int hard) +{ + float tl, tv, i, a[3], stl, stv, r; + + tl = Inpf(t, l); + tv = Inpf(t, v); + + CROSS(a, t, l); + stl = sasqrt(Inpf(a,a)); + + CROSS(a, t, v); + stv = sasqrt(Inpf(a,a)); + + r =(tl*tv + stl*stv); + + return spec(r, hard); +} + /* cartoon render diffuse */ static float Toon_Diff( float *n, float *l, float *v, float size, float smooth ) { @@ -804,6 +824,16 @@ return fresnel_fac(lv, vn, fac_i, fac); } +/* Diffuse part of KajiyaKay */ +/* Is this really needed (don't other shaders do this */ +static float KajiyaKay_Diff(float *t, float *l) +{ + float a[3]; + CROSS(a, t, l); + return sasqrt(Inpf(a, a)); +} + + /* --------------------------------------------- */ /* also called from texture.c */ void calc_R_ref(ShadeInput *shi) @@ -1303,6 +1333,7 @@ else if(ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(vn, lv, view, ma->param[0], ma->param[1]); else if(ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(inp, vn, view, ma->darkness); else if(ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(vn, lv, view, ma->param[0], ma->param[1]); + else if(ma->diff_shader==MA_DIFF_KAJIYAKAY) is = KajiyaKay_Diff(vn, lv); else is= inp; // Lambert } @@ -1414,6 +1445,8 @@ specfac= Blinn_Spec(vn, lv, view, ma->refrac, (float)shi->har, (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V)); else if(ma->spec_shader==MA_SPEC_WARDISO) specfac= WardIso_Spec( vn, lv, view, ma->rms, (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V)); + else if(ma->spec_shader==MA_SPEC_KAJIYAKAY) + specfac= KajiyaKay_Spec(vn, lv, view, ma->har); else specfac= Toon_Spec(vn, lv, view, ma->param[2], ma->param[3], (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V)); Index: source/blender/python/api2_2x/Material.c =================================================================== --- source/blender/python/api2_2x/Material.c (revision 14333) +++ source/blender/python/api2_2x/Material.c (working copy) @@ -386,11 +386,15 @@ PyConstant_Insert(c, "DIFFUSE_ORENNAYAR", PyInt_FromLong(MA_DIFF_ORENNAYAR)); PyConstant_Insert(c, "DIFFUSE_TOON", PyInt_FromLong(MA_DIFF_TOON)); PyConstant_Insert(c, "DIFFUSE_MINNAERT", PyInt_FromLong(MA_DIFF_MINNAERT)); + PyConstant_Insert(c, "DIFFUSE_FRESNEL", PyInt_FromLong(MA_DIFF_FRESNEL)); + PyConstant_Insert(c, "DIFFUSE_KAJIYAKAY", PyInt_FromLong(MA_DIFF_KAJIYAKAY)); + PyConstant_Insert(c, "SPEC_COOKTORR", PyInt_FromLong(MA_SPEC_COOKTORR)); PyConstant_Insert(c, "SPEC_PHONG", PyInt_FromLong(MA_SPEC_PHONG)); PyConstant_Insert(c, "SPEC_BLINN", PyInt_FromLong(MA_SPEC_BLINN)); PyConstant_Insert(c, "SPEC_TOON", PyInt_FromLong(MA_SPEC_TOON)); PyConstant_Insert(c, "SPEC_WARDISO", PyInt_FromLong(MA_SPEC_WARDISO)); + PyConstant_Insert(c, "SPEC_KAJIYAKAY", PyInt_FromLong(MA_SPEC_KAJIYAKAY)); } Index: source/blender/makesdna/DNA_material_types.h =================================================================== --- source/blender/makesdna/DNA_material_types.h (revision 14333) +++ source/blender/makesdna/DNA_material_types.h (working copy) @@ -212,6 +212,7 @@ #define MA_DIFF_TOON 2 #define MA_DIFF_MINNAERT 3 #define MA_DIFF_FRESNEL 4 +#define MA_DIFF_KAJIYAKAY 5 /* spec_shader */ #define MA_SPEC_COOKTORR 0 @@ -219,6 +220,7 @@ #define MA_SPEC_BLINN 2 #define MA_SPEC_TOON 3 #define MA_SPEC_WARDISO 4 +#define MA_SPEC_KAJIYAKAY 5 /* dynamode */ #define MA_DRAW_DYNABUTS 1 Index: source/blender/src/buttons_shading.c =================================================================== --- source/blender/src/buttons_shading.c (revision 14333) +++ source/blender/src/buttons_shading.c (working copy) @@ -3851,8 +3851,8 @@ uiBlockEndAlign(block); } else { - char *str1= "Diffuse Shader%t|Lambert %x0|Oren-Nayar %x1|Toon %x2|Minnaert %x3|Fresnel %x4"; - char *str2= "Specular Shader%t|CookTorr %x0|Phong %x1|Blinn %x2|Toon %x3|WardIso %x4"; + char *str1= "Diffuse Shader%t|Lambert %x0|Oren-Nayar %x1|Toon %x2|Minnaert %x3|Fresnel %x4|Kajiya Kay %x5"; + char *str2= "Specular Shader%t|CookTorr %x0|Phong %x1|Blinn %x2|Toon %x3|WardIso %x4|Kajiya Kay %x5"; /* diff shader buttons */ uiDefButS(block, MENU, B_MATPRV, str1, 9, 180,78,19, &(ma->diff_shader), 0.0, 0.0, 0, 0, "Creates a diffuse shader"); @@ -3878,7 +3878,7 @@ uiBlockBeginAlign(block); uiDefButF(block, NUMSLI, B_MATPRV, "Spec ", 90,120,150,19, &(ma->spec), 0.0, 2.0, 0, 0, "Sets the degree of specularity"); - if ELEM3(ma->spec_shader, MA_SPEC_COOKTORR, MA_SPEC_PHONG, MA_SPEC_BLINN) { + if ELEM4(ma->spec_shader, MA_SPEC_COOKTORR, MA_SPEC_PHONG, MA_SPEC_BLINN,MA_SPEC_KAJIYAKAY) { uiDefButS(block, NUMSLI, B_MATPRV, "Hard:", 90, 100, 150,19, &(ma->har), 1.0, 511, 0, 0, "Sets the hardness of the specularity"); } if(ma->spec_shader==MA_SPEC_BLINN)