Index: source/blender/blenkernel/bad_level_call_stubs/stubs.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/bad_level_call_stubs/stubs.c,v retrieving revision 1.21 diff -u -r1.21 stubs.c --- source/blender/blenkernel/bad_level_call_stubs/stubs.c 28 Mar 2005 15:23:36 -0000 1.21 +++ source/blender/blenkernel/bad_level_call_stubs/stubs.c 7 Apr 2005 16:54:10 -0000 @@ -97,8 +97,10 @@ float Blinn_Spec(float *n, float *l, float *v, float a, float b){return 0;} float CookTorr_Spec(float *n, float *l, float *v, int hard){return 0;} float Toon_Spec(float *n, float *l, float *v, float a, float b){return 0;} +float WardIso_Spec(float *n, float *l, float *v, float a){return 0;} float Toon_Diff(float *n, float *l, float *v, float a, float b){return 0;} float OrenNayar_Diff(float *n, float *l, float *v, float a, float b){return 0;} +float Minnaert_Diff(float nl, float *n, float *v, float a, short nv){return 0;} void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, float g, float b){} void ramp_diffuse_result(float *diff, ShadeInput *shi){} void do_specular_ramp(ShadeInput *shi, float is, float t, float *spec){} Index: source/blender/blenkernel/intern/displist.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/intern/displist.c,v retrieving revision 1.70 diff -u -r1.70 displist.c --- source/blender/blenkernel/intern/displist.c 4 Apr 2005 04:50:41 -0000 1.70 +++ source/blender/blenkernel/intern/displist.c 7 Apr 2005 16:54:36 -0000 @@ -567,6 +567,7 @@ if(ma->diff_shader==MA_DIFF_ORENNAYAR) is= OrenNayar_Diff(nor, lv, shi.view, ma->roughness); else if(ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(nor, lv, shi.view, ma->param[0], ma->param[1]); + else if(ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(is, nor, shi.view, ma->minnaert_darkness, ma->minnaert_nvidia); } back= 0; @@ -596,6 +597,8 @@ specfac= CookTorr_Spec(nor, lv, shi.view, shi.har); else if(ma->spec_shader==MA_SPEC_BLINN) specfac= Blinn_Spec(nor, lv, shi.view, ma->refrac, (float)shi.har); + else if(ma->spec_shader==MA_SPEC_WARDISO) + specfac= WardIso_Spec(nor, lv, shi.view, ma->rms); else specfac= Toon_Spec(nor, lv, shi.view, ma->param[2], ma->param[3]); Index: source/blender/blenkernel/intern/material.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenkernel/intern/material.c,v retrieving revision 1.25 diff -u -r1.25 material.c --- source/blender/blenkernel/intern/material.c 23 Mar 2005 12:47:23 -0000 1.25 +++ source/blender/blenkernel/intern/material.c 7 Apr 2005 16:54:40 -0000 @@ -100,6 +100,8 @@ ma->param[1]= 0.1; ma->param[2]= 0.5; ma->param[3]= 0.1; + ma->rms=0.1; + ma->minnaert_darkness=0.4; ma->ang= 1.0; ma->ray_depth= 2; Index: source/blender/blenloader/intern/readfile.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/blenloader/intern/readfile.c,v retrieving revision 1.111 diff -u -r1.111 readfile.c --- source/blender/blenloader/intern/readfile.c 2 Apr 2005 19:52:32 -0000 1.111 +++ source/blender/blenloader/intern/readfile.c 7 Apr 2005 16:55:24 -0000 @@ -4222,6 +4222,8 @@ ma->param[1]= 0.1; ma->param[2]= 0.1; ma->param[3]= 0.05; + ma->rms=0.1; + ma->minnaert_darkness=0.4; } // patch for old wrong max view2d settings, allows zooming out more for (sc= main->screen.first; sc; sc= sc->id.next) { Index: source/blender/makesdna/DNA_material_types.h =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_material_types.h,v retrieving revision 1.25 diff -u -r1.25 DNA_material_types.h --- source/blender/makesdna/DNA_material_types.h 24 Jan 2005 14:08:06 -0000 1.25 +++ source/blender/makesdna/DNA_material_types.h 7 Apr 2005 16:55:31 -0000 @@ -83,6 +83,9 @@ short diff_shader, spec_shader; float roughness, refrac; float param[4]; /* size, smooth, size, smooth, for toonshader */ + float rms, pad1; + float minnaert_darkness; + short minnaert_nvidia,pad6; short texco, mapto; /* ramp colors */ @@ -152,12 +155,14 @@ #define MA_DIFF_LAMBERT 0 #define MA_DIFF_ORENNAYAR 1 #define MA_DIFF_TOON 2 +#define MA_DIFF_MINNAERT 3 /* spec_shader */ #define MA_SPEC_COOKTORR 0 #define MA_SPEC_PHONG 1 #define MA_SPEC_BLINN 2 #define MA_SPEC_TOON 3 +#define MA_SPEC_WARDISO 4 /* dynamode */ #define MA_DRAW_DYNABUTS 1 Index: source/blender/render/extern/include/render.h =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/render/extern/include/render.h,v retrieving revision 1.15 diff -u -r1.15 render.h --- source/blender/render/extern/include/render.h 28 Mar 2005 21:49:48 -0000 1.15 +++ source/blender/render/extern/include/render.h 7 Apr 2005 16:55:49 -0000 @@ -171,14 +171,16 @@ struct EnvMap *RE_copy_envmap(struct EnvMap *env); /* --------------------------------------------------------------------- */ -/* rendercore (10) */ +/* rendercore (12) */ /* --------------------------------------------------------------------- */ float Phong_Spec(float *n, float *l, float *v, int hard); float CookTorr_Spec(float *n, float *l, float *v, int hard); float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_power); float Toon_Spec( float *n, float *l, float *v, float size, float smooth); +float WardIso_Spec(float *n, float *l, float *v, float rms); float OrenNayar_Diff(float *n, float *l, float *v, float rough); float Toon_Diff( float *n, float *l, float *v, float size, float smooth); +float Minnaert_Diff( float nl, float *n, float *v, float darkness, short nvidia); void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, float g, float b); void ramp_diffuse_result(float *diff, ShadeInput *shi); void do_specular_ramp(ShadeInput *shi, float is, float t, float *spec); Index: source/blender/render/intern/source/rendercore.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/render/intern/source/rendercore.c,v retrieving revision 1.111 diff -u -r1.111 rendercore.c --- source/blender/render/intern/source/rendercore.c 24 Mar 2005 21:01:12 -0000 1.111 +++ source/blender/render/intern/source/rendercore.c 7 Apr 2005 16:56:52 -0000 @@ -821,6 +821,35 @@ return rslt; } +/* Ward isotropic gaussian spec */ +float WardIso_Spec( float *n, float *l, float *v, float rms) +{ + float i, nh, nv, nl, h[3], angle, alpha; + + + /* half-way vector */ + h[0] = l[0] + v[0]; + h[1] = l[1] + v[1]; + h[2] = l[2] + v[2]; + Normalise(h); + + nh = n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */ + if(nh<=0.0) nh = 0.001; + + nv = n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */ + if(nv<=0.0) nv = 0.001; + + nl = n[0]*l[0]+n[1]*l[1]+n[2]*l[2]; /* Dot product between surface normal and light vector */ + if(nl<=0.0) nl = 0.001; + + angle = tan(acos(nh)); + alpha = MAX2(rms,0.001); + + i=(1.0/(4*PI*alpha*alpha)) * (exp( -(angle*angle)/(alpha*alpha))/(sqrt(nv*nl))); + + return i; +} + /* cartoon render diffuse */ float Toon_Diff( float *n, float *l, float *v, float size, float smooth ) { @@ -907,6 +936,27 @@ return OrenNayar_Diff_i(nl, n, l, v, rough); } +/* Minnaert diffuse */ +float Minnaert_Diff(float nl, float *n, float *v, float darkness, short nvidia) +{ + + float i, nv; + + /* nl = dot product between surface normal and light vector */ + if (nl <= 0.0) return 0.0; + + /* nv = dot product between surface normal and view vector */ + nv = n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; + if (nv < 0.0) nv = 0.0; + + /* The two minnaert models */ + if (nvidia) + i = pow(nl, (darkness + 1) ) * pow( (1.001 - nv), (1 - darkness) ); + else + i = nl * pow(MAX2(nv*nl, 0.001), (darkness - 1) ); /*The Real model*/ + + return i; +} /* --------------------------------------------- */ /* also called from texture.c */ @@ -1519,6 +1569,7 @@ /* diffuse shaders (oren nayer gets inp from area light) */ if(ma->diff_shader==MA_DIFF_ORENNAYAR) is= OrenNayar_Diff_i(inp, vn, lv, view, ma->roughness); 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->minnaert_darkness, ma->minnaert_nvidia); else is= inp; // Lambert } @@ -1593,6 +1644,8 @@ specfac= CookTorr_Spec(vn, lv, view, shi->har); else if(ma->spec_shader==MA_SPEC_BLINN) specfac= Blinn_Spec(vn, lv, view, ma->refrac, (float)shi->har); + else if(ma->spec_shader==MA_SPEC_WARDISO) + specfac= WardIso_Spec( vn, lv, view, ma->rms); else specfac= Toon_Spec(vn, lv, view, ma->param[2], ma->param[3]); Index: source/blender/src/buttons_shading.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_shading.c,v retrieving revision 1.129 diff -u -r1.129 buttons_shading.c --- source/blender/src/buttons_shading.c 31 Mar 2005 18:49:52 -0000 1.129 +++ source/blender/src/buttons_shading.c 7 Apr 2005 16:57:51 -0000 @@ -2871,8 +2871,8 @@ uiBlockEndAlign(block); } else { - char *str1= "Diffuse Shader%t|Lambert %x0|Oren-Nayar %x1|Toon %x2"; - char *str2= "Specular Shader%t|CookTorr %x0|Phong %x1|Blinn %x2|Toon %x3"; + char *str1= "Diffuse Shader%t|Lambert %x0|Oren-Nayar %x1|Toon %x2|Minnaert %x3"; + char *str2= "Specular Shader%t|CookTorr %x0|Phong %x1|Blinn %x2|Toon %x3|WardIso %x4"; /* diff shader buttons */ uiDefButS(block, MENU, B_MATPRV_DRAW, str1, 9, 180,78,19, &(ma->diff_shader), 0.0, 0.0, 0, 0, "Creates a diffuse shader"); @@ -2885,6 +2885,10 @@ uiDefButF(block, NUMSLI, B_MATPRV, "Size:", 90, 160,150,19, &(ma->param[0]), 0.0, 3.14, 0, 0, "Sets size of diffuse toon area"); uiDefButF(block, NUMSLI, B_MATPRV, "Smooth:",90,140,150,19, &(ma->param[1]), 0.0, 1.0, 0, 0, "Sets smoothness of diffuse toon area"); } + else if(ma->diff_shader==MA_DIFF_MINNAERT) { + uiDefButF(block, NUMSLI, B_MATPRV, "Dark:",90,160, 150,19, &(ma->minnaert_darkness), 0, 1.4, 0, 0, "Sets Minnaert darkness"); + uiDefButS(block, TOG|BIT|0, B_MATPRV, "Nvidia model", 90,140,150,19, &(ma->minnaert_nvidia), 0,0,0,0, "Use the nVidia \"flipped\" model."); + } uiBlockEndAlign(block); /* spec shader buttons */ @@ -2901,7 +2905,8 @@ uiDefButF(block, NUMSLI, B_MATPRV, "Size:", 90, 100,150,19, &(ma->param[2]), 0.0, 1.53, 0, 0, "Sets the size of specular toon area"); uiDefButF(block, NUMSLI, B_MATPRV, "Smooth:",90, 80,150,19, &(ma->param[3]), 0.0, 1.0, 0, 0, "Sets the smoothness of specular toon area"); } - + if(ma->spec_shader==MA_SPEC_WARDISO) + uiDefButF(block, NUMSLI, B_MATPRV, "rms:", 90, 100,150,19, &(ma->rms), 0.0, 0.4, 0, 0, "Sets the standard deviation of surface slope"); /* default shading variables */ uiBlockBeginAlign(block); uiDefButF(block, NUMSLI, 0, "Translucency ", 9,30,301,19, &(ma->translucency), 0.0, 1.0, 100, 2, "Amount of diffuse shading of the back side"); Index: source/blender/src/previewrender.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/src/previewrender.c,v retrieving revision 1.57 diff -u -r1.57 previewrender.c --- source/blender/src/previewrender.c 19 Mar 2005 21:08:12 -0000 1.57 +++ source/blender/src/previewrender.c 7 Apr 2005 16:58:03 -0000 @@ -888,6 +888,8 @@ specfac= CookTorr_Spec(shi->vn, lv, shi->view, shi->har); else if(mat->spec_shader==MA_SPEC_BLINN) specfac= Blinn_Spec(shi->vn, lv, shi->view, mat->refrac, (float)shi->har); + else if(mat->spec_shader==MA_SPEC_WARDISO) + specfac= WardIso_Spec(shi->vn, lv, shi->view, mat->rms); else specfac= Toon_Spec(shi->vn, lv, shi->view, mat->param[2], mat->param[3]); @@ -910,6 +912,7 @@ /* diffuse shaders */ if(mat->diff_shader==MA_DIFF_ORENNAYAR) is= OrenNayar_Diff(shi->vn, lv, shi->view, mat->roughness); else if(mat->diff_shader==MA_DIFF_TOON) is= Toon_Diff(shi->vn, lv, shi->view, mat->param[0], mat->param[1]); + else if(mat->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(is, shi->vn, shi->view, mat->minnaert_darkness, mat->minnaert_nvidia); // else Lambert inp= (shi->refl*is + shi->emit);