[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12595] trunk/blender/source/blender: * New material option: TexFace Alpha

Matt Ebb matt at mke3.net
Thu Nov 15 01:11:00 CET 2007


Revision: 12595
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12595
Author:   broken
Date:     2007-11-15 01:11:00 +0100 (Thu, 15 Nov 2007)

Log Message:
-----------
* New material option: TexFace Alpha

This is an additional option for 'TexFace', which uses the alpha of 
the UV assigned faces as well as the colour. It appears in material 
buttons as a little 'A' button next to 'TexFace', when 'TexFace is 
switched on. It's a bit horrible, but no point tweaking that layout in 
isolation at this stage.

This image is using texface alpha, with different assigned images, all 
sharing the one material:
http://mke3.net/blender/devel/rendering/texface_alpha.jpg

Usually I consider texface (and teaching people to use it for UV 
mapping) to be pretty evil, but in some cases, when you have lots of 
separate images that you want to control in the one material, it can 
be quite handy.

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_material_types.h
    trunk/blender/source/blender/render/extern/include/RE_shader_ext.h
    trunk/blender/source/blender/render/intern/source/shadeinput.c
    trunk/blender/source/blender/render/intern/source/shadeoutput.c
    trunk/blender/source/blender/render/intern/source/texture.c
    trunk/blender/source/blender/src/buttons_shading.c

Modified: trunk/blender/source/blender/makesdna/DNA_material_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_material_types.h	2007-11-14 23:46:18 UTC (rev 12594)
+++ trunk/blender/source/blender/makesdna/DNA_material_types.h	2007-11-15 00:11:00 UTC (rev 12595)
@@ -188,6 +188,7 @@
 /* qdn: a bit clumsy this, tangents needed for normal maps separated from shading */
 #define MA_NORMAP_TANG	0x8000000
 #define MA_GROUP_NOLAY	0x10000000
+#define MA_FACETEXTURE_ALPHA	0x20000000
 
 #define	MA_MODE_MASK	0x1fffffff	/* all valid mode bits */
 

Modified: trunk/blender/source/blender/render/extern/include/RE_shader_ext.h
===================================================================
--- trunk/blender/source/blender/render/extern/include/RE_shader_ext.h	2007-11-14 23:46:18 UTC (rev 12594)
+++ trunk/blender/source/blender/render/extern/include/RE_shader_ext.h	2007-11-15 00:11:00 UTC (rev 12595)
@@ -124,7 +124,7 @@
 	float layerfac;
 	
 	/* texture coordinates */
-	float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[3], rad[3];
+	float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4], rad[3];
 	float refcol[4], displace[3];
 	float strand, tang[3], stress, winspeed[4];
 

Modified: trunk/blender/source/blender/render/intern/source/shadeinput.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/shadeinput.c	2007-11-14 23:46:18 UTC (rev 12594)
+++ trunk/blender/source/blender/render/intern/source/shadeinput.c	2007-11-15 00:11:00 UTC (rev 12595)
@@ -675,11 +675,13 @@
 					shi->vcol[0]= shi->col[0].col[0];
 					shi->vcol[1]= shi->col[0].col[1];
 					shi->vcol[2]= shi->col[0].col[2];
+					shi->vcol[3]= 1.0f;
 				}
 				else {
 					shi->vcol[0]= 0.0f;
 					shi->vcol[1]= 0.0f;
 					shi->vcol[2]= 0.0f;
+					shi->vcol[3]= 1.0f;
 				}
 			}
 
@@ -721,6 +723,7 @@
 						shi->vcol[0]= 1.0f;
 						shi->vcol[1]= 1.0f;
 						shi->vcol[2]= 1.0f;
+						shi->vcol[3]= 1.0f;
 					}
 					if(tface && tface->tpage)
 						render_realtime_texture(shi, tface->tpage);
@@ -739,6 +742,7 @@
 					shi->vcol[0]= 1.0f;
 					shi->vcol[1]= 1.0f;
 					shi->vcol[2]= 1.0f;
+					shi->vcol[3]= 1.0f;
 				}
 			}
 		}

Modified: trunk/blender/source/blender/render/intern/source/shadeoutput.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/shadeoutput.c	2007-11-14 23:46:18 UTC (rev 12594)
+++ trunk/blender/source/blender/render/intern/source/shadeoutput.c	2007-11-15 00:11:00 UTC (rev 12595)
@@ -829,6 +829,8 @@
 		shi->r= shi->vcol[0];
 		shi->g= shi->vcol[1];
 		shi->b= shi->vcol[2];
+		if(ma->mode & (MA_FACETEXTURE_ALPHA))
+			shi->alpha= shi->vcol[3];
 	}
 	
 	if(ma->texco)
@@ -1149,6 +1151,10 @@
 	
 	if (lar->energy == 0.0) return;
 	
+	/* optimisation, don't render fully black lamps */
+	if (!(lar->mode & LA_TEXTURE) && (lar->r + lar->g + lar->b == 0.0f))
+		return;
+	
 	/* lampdist, spot angle, area side, ... */
 	visifac= lamp_get_visibility(lar, shi->co, lv, &lampdist);
 	if(visifac==0.0f)
@@ -1471,6 +1477,8 @@
 			shi->r= shi->vcol[0];
 			shi->g= shi->vcol[1];
 			shi->b= shi->vcol[2];
+			if(ma->mode & (MA_FACETEXTURE_ALPHA))
+				shi->alpha= shi->vcol[3];
 		}
 		if(ma->texco)
 			do_material_tex(shi);

Modified: trunk/blender/source/blender/render/intern/source/texture.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/texture.c	2007-11-14 23:46:18 UTC (rev 12594)
+++ trunk/blender/source/blender/render/intern/source/texture.c	2007-11-15 00:11:00 UTC (rev 12595)
@@ -2450,6 +2450,7 @@
 	shi->vcol[0]*= texr.tr;
 	shi->vcol[1]*= texr.tg;
 	shi->vcol[2]*= texr.tb;
+	shi->vcol[3]*= texr.ta;
 }
 
 /* eof */

Modified: trunk/blender/source/blender/src/buttons_shading.c
===================================================================
--- trunk/blender/source/blender/src/buttons_shading.c	2007-11-14 23:46:18 UTC (rev 12594)
+++ trunk/blender/source/blender/src/buttons_shading.c	2007-11-15 00:11:00 UTC (rev 12595)
@@ -3785,8 +3785,9 @@
 			uiBlockSetCol(block, TH_BUT_SETTING1);
 			uiDefButBitI(block, TOG, MA_VERTEXCOL, B_MAT_VCOL_LIGHT,	"VCol Light",	8,166,74,20, &(ma->mode), 0, 0, 0, 0, "Adds vertex colors as extra light");
 			uiDefButBitI(block, TOG, MA_VERTEXCOLP, B_MAT_VCOL_PAINT, "VCol Paint",	82,166,74,20, &(ma->mode), 0, 0, 0, 0, "Replaces material's colors with vertex colors");
-			uiDefButBitI(block, TOG, MA_FACETEXTURE, B_REDR, "TexFace",		156,166,74,20, &(ma->mode), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
-			uiDefButBitI(block, TOG, MA_SHLESS, B_MATPRV, "Shadeless",	230,166,73,20, &(ma->mode), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
+			uiDefButBitI(block, TOG, MA_FACETEXTURE, B_REDR, "TexFace",		156,166,64,20, &(ma->mode), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
+			if (ma->mode & MA_FACETEXTURE) uiDefButBitI(block, TOG, MA_FACETEXTURE_ALPHA, B_REDR, "A",		220,166,20,20, &(ma->mode), 0, 0, 0, 0, "Use alpha channel in 'TexFace' assigned images");
+			uiDefButBitI(block, TOG, MA_SHLESS, B_MATPRV, "Shadeless",	240,166,63,20, &(ma->mode), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
 			
 			uiDefButBitI(block, TOG, MA_NOMIST, B_NOP,	"No Mist",		8,146,74,20, &(ma->mode), 0, 0, 0, 0, "Sets the material to ignore mist values");
 			uiDefButBitI(block, TOG, MA_ENV, B_MATPRV,	"Env",			82,146,74,20, &(ma->mode), 0, 0, 0, 0, "Causes faces to render with alpha zero: allows sky/backdrop to show through (only for solid faces)");
@@ -3830,7 +3831,8 @@
 			uiDefButF(block, NUMSLI, B_MATPRV, "B ",		128,57,175,19, colpoin+2, 0.0, 1.0, rgbsel, 0, "");
 		}
 		uiBlockEndAlign(block);
-		uiDefButF(block, NUMSLI, B_MATPRV, "A ",			128,30,175,19, &ma->alpha, 0.0, 1.0, 0, 0, "Alpha");
+		if (ma->mode & (MA_FACETEXTURE) && ma->mode & (MA_FACETEXTURE_ALPHA)) ;
+		else uiDefButF(block, NUMSLI, B_MATPRV, "A ",			128,30,175,19, &ma->alpha, 0.0, 1.0, 0, 0, "Alpha");
 		
 	}
 	uiBlockBeginAlign(block);





More information about the Bf-blender-cvs mailing list