[Bf-committers] Minnaert diffuse shader

Johnny Matthews johnny.matthews at gmail.com
Sat Jan 8 18:24:33 CET 2005


I applied the patch and made the changes to the

else if(ma->diff_shader==MA_DIFF_TOON) is= Minnaert(nor, lv, shi.view, ma->darkness);

to

else if(ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(nor, lv, shi.view, ma->darkness);

and added an entry on the buttons_shading panel, and everything seems to work *except* the result does not show up in the final render. It shows up in shaded view, but not in the render. Any ideas?



lordloki at vodafone.es wrote:

>hi  
>I've implemented the Minnaert shader. This shader is good, for  
>example, to make cloth, velvet, sun's reflexion over the sea....  
>  
>regards  
>P.D. Sorry for my bad english  
>  
>  
>
>------------------------------------------------------------------------
>
>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.20
>diff -u -r1.20 stubs.c
>--- source/blender/blenkernel/bad_level_call_stubs/stubs.c	27 Dec 2004 19:28:48 -0000	1.20
>+++ source/blender/blenkernel/bad_level_call_stubs/stubs.c	8 Jan 2005 01:03:47 -0000
>@@ -99,6 +99,7 @@
> float Toon_Spec(float *n, float *l, float *v, float a, float b){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 *n, float *l, float *v, float a){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.53
>diff -u -r1.53 displist.c
>--- source/blender/blenkernel/intern/displist.c	27 Dec 2004 19:28:49 -0000	1.53
>+++ source/blender/blenkernel/intern/displist.c	8 Jan 2005 01:04:07 -0000
>@@ -673,6 +673,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_TOON) is= Minnaert(nor, lv, shi.view, ma->darkness);
> 		}
> 		
> 		back= 0;
>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.24
>diff -u -r1.24 DNA_material_types.h
>--- source/blender/makesdna/DNA_material_types.h	29 Dec 2004 17:04:14 -0000	1.24
>+++ source/blender/makesdna/DNA_material_types.h	8 Jan 2005 01:04:14 -0000
>@@ -81,6 +81,7 @@
> 	/* shaders */
> 	short diff_shader, spec_shader;
> 	float roughness, refrac;
>+	float darkness, pad1;
> 	float param[4];		/* size, smooth, size, smooth, for toonshader */
> 	short texco, mapto;
> 	
>@@ -151,6 +152,7 @@
> #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
>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.12
>diff -u -r1.12 render.h
>--- source/blender/render/extern/include/render.h	7 Jan 2005 14:11:00 -0000	1.12
>+++ source/blender/render/extern/include/render.h	8 Jan 2005 01:04:29 -0000
>@@ -176,7 +176,7 @@
> struct EnvMap *RE_copy_envmap(struct EnvMap *env);
> 
> /* --------------------------------------------------------------------- */
>-/* rendercore (10)                                                        */
>+/* rendercore (11)                                                        */
> /* --------------------------------------------------------------------- */
> float Phong_Spec(float *n, float *l, float *v, int hard);
> float CookTorr_Spec(float *n, float *l, float *v, int hard);
>@@ -184,6 +184,7 @@
> float Toon_Spec( float *n, float *l, float *v, float size, float smooth);
> 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 *n, float *l, float *v, float darkness);
> 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.100
>diff -u -r1.100 rendercore.c
>--- source/blender/render/intern/source/rendercore.c	7 Jan 2005 14:11:00 -0000	1.100
>+++ source/blender/render/intern/source/rendercore.c	8 Jan 2005 01:04:55 -0000
>@@ -865,6 +865,21 @@
> 	return OrenNayar_Diff_i(nl, n, l, v, rough);
> }
> 
>+/* Minnaert diffuse */
>+float Minnaert_Diff(float *n, float *l, float *v, float darkness)
>+{
>+	float i, nv, nl;
>+
>+	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.0;
>+
>+	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.0;
>+
>+	i = nl * pow (nl, darkness) * pow ( (1.001 - nv), (1 - darkness) );
>+	return i;
>+}
>+
> 
> /* --------------------------------------------- */
> /* also called from texture.c */
>Index: source/blender/src/buttons_shading.c
>===================================================================
>RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_shading.c,v
>retrieving revision 1.116
>diff -u -r1.116 buttons_shading.c
>--- source/blender/src/buttons_shading.c	3 Jan 2005 20:11:44 -0000	1.116
>+++ source/blender/src/buttons_shading.c	8 Jan 2005 01:06:48 -0000
>@@ -2868,6 +2868,8 @@
> 			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->darkness), 0, 1.1, 0, 0, "Sets Minnaert darkness");
> 		uiBlockEndAlign(block);
> 		
> 		/* spec shader buttons */
>Index: source/blender/src/previewrender.c
>===================================================================
>RCS file: /cvsroot/bf-blender/blender/source/blender/src/previewrender.c,v
>retrieving revision 1.46
>diff -u -r1.46 previewrender.c
>--- source/blender/src/previewrender.c	7 Jan 2005 21:48:25 -0000	1.46
>+++ source/blender/src/previewrender.c	8 Jan 2005 01:07:01 -0000
>@@ -896,6 +896,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(shi->vn, lv, shi->view, mat->darkness);
> 			// else Lambert
> 			
> 			inp= (shi->refl*is + shi->emit);
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Bf-committers mailing list
>Bf-committers at projects.blender.org
>http://projects.blender.org/mailman/listinfo/bf-committers
>  
>



More information about the Bf-committers mailing list