[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38661] branches/soc-2011-carrot/source/ blender: Dynamic Paint:

Miika Hamalainen miika.hamalainen at kolumbus.fi
Sun Jul 24 19:03:33 CEST 2011


Revision: 38661
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38661
Author:   miikah
Date:     2011-07-24 17:03:33 +0000 (Sun, 24 Jul 2011)
Log Message:
-----------
Dynamic Paint:
* Added alpha support renderer for vertex colors. You can now easily render Dynamic Paint produced vertex colors by checking "Vertex Color" in material options.
* Added "Vertex Alpha" socket for "Geometry" material node.
* Fixed vertex surface color output issues.

Modified Paths:
--------------
    branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
    branches/soc-2011-carrot/source/blender/nodes/intern/SHD_nodes/SHD_geom.c
    branches/soc-2011-carrot/source/blender/nodes/intern/SHD_util.h
    branches/soc-2011-carrot/source/blender/render/extern/include/RE_shader_ext.h
    branches/soc-2011-carrot/source/blender/render/intern/source/shadeinput.c
    branches/soc-2011-carrot/source/blender/render/intern/source/shadeoutput.c

Modified: branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c	2011-07-24 13:21:54 UTC (rev 38660)
+++ branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c	2011-07-24 17:03:33 UTC (rev 38661)
@@ -1272,7 +1272,7 @@
 						/* save layer data to output layer */
 
 						/* paint layer */
-						col = CustomData_get_layer_named(&dm->faceData, CD_MCOL, surface->output_name);
+						col = CustomData_get_layer_named(&result->faceData, CD_MCOL, surface->output_name);
 						if (col) {
 							#pragma omp parallel for schedule(static)
 							for (i=0; i<numOfFaces; i++) {
@@ -1288,10 +1288,11 @@
 								}
 							}
 						}
+						
 						MEM_freeN(fcolor);
 
 						/* wet layer */
-						col = CustomData_get_layer_named(&dm->faceData, CD_MCOL, surface->output_name2);
+						col = CustomData_get_layer_named(&result->faceData, CD_MCOL, surface->output_name2);
 						if (col) {
 							#pragma omp parallel for schedule(static)
 							for (i=0; i<numOfFaces; i++) {

Modified: branches/soc-2011-carrot/source/blender/nodes/intern/SHD_nodes/SHD_geom.c
===================================================================
--- branches/soc-2011-carrot/source/blender/nodes/intern/SHD_nodes/SHD_geom.c	2011-07-24 13:21:54 UTC (rev 38660)
+++ branches/soc-2011-carrot/source/blender/nodes/intern/SHD_nodes/SHD_geom.c	2011-07-24 17:03:33 UTC (rev 38661)
@@ -47,6 +47,7 @@
 	{	SOCK_VECTOR, 0, "UV",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 	{	SOCK_VECTOR, 0, "Normal",	0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 	{	SOCK_RGBA,   0, "Vertex Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+	{	SOCK_VALUE,   0, "Vertex Alpha", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 	{	SOCK_VALUE,   0, "Front/Back", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 	{	-1, 0, ""	}
 };
@@ -93,10 +94,14 @@
 			}
 
 			VECCOPY(out[GEOM_OUT_VCOL]->vec, scol->col);
-			out[GEOM_OUT_VCOL]->vec[3]= 1.0f;
+			out[GEOM_OUT_VCOL]->vec[3]= scol->col[3];
+
+			out[GEOM_OUT_VCOL_ALPHA]->vec[0]= scol->col[3];
 		}
-		else
+		else {
 			memcpy(out[GEOM_OUT_VCOL]->vec, defaultvcol, sizeof(defaultvcol));
+			out[GEOM_OUT_VCOL_ALPHA]->vec[0]= 1.0f;
+		}
 		
 		if(shi->osatex) {
 			out[GEOM_OUT_GLOB]->data= shi->dxgl;

Modified: branches/soc-2011-carrot/source/blender/nodes/intern/SHD_util.h
===================================================================
--- branches/soc-2011-carrot/source/blender/nodes/intern/SHD_util.h	2011-07-24 13:21:54 UTC (rev 38660)
+++ branches/soc-2011-carrot/source/blender/nodes/intern/SHD_util.h	2011-07-24 17:03:33 UTC (rev 38661)
@@ -94,6 +94,7 @@
 #define GEOM_OUT_NORMAL	5
 #define GEOM_OUT_VCOL	6
 #define GEOM_OUT_FRONTBACK	7
+#define GEOM_OUT_VCOL_ALPHA	8
 
 
 /* input socket defines */

Modified: branches/soc-2011-carrot/source/blender/render/extern/include/RE_shader_ext.h
===================================================================
--- branches/soc-2011-carrot/source/blender/render/extern/include/RE_shader_ext.h	2011-07-24 13:21:54 UTC (rev 38660)
+++ branches/soc-2011-carrot/source/blender/render/extern/include/RE_shader_ext.h	2011-07-24 17:03:33 UTC (rev 38661)
@@ -92,7 +92,7 @@
 } ShadeInputUV;
 
 typedef struct ShadeInputCol {
-	float col[3];
+	float col[4];
 	char *name;
 } ShadeInputCol;
 

Modified: branches/soc-2011-carrot/source/blender/render/intern/source/shadeinput.c
===================================================================
--- branches/soc-2011-carrot/source/blender/render/intern/source/shadeinput.c	2011-07-24 13:21:54 UTC (rev 38660)
+++ branches/soc-2011-carrot/source/blender/render/intern/source/shadeinput.c	2011-07-24 17:03:33 UTC (rev 38661)
@@ -473,17 +473,20 @@
 					scol->col[0]= cp[3]/255.0f;
 					scol->col[1]= cp[2]/255.0f;
 					scol->col[2]= cp[1]/255.0f;
+					scol->col[3]= cp[0]/255.0f;
 				}
 
 				if(shi->totcol) {
 					shi->vcol[0]= shi->col[shi->actcol].col[0];
 					shi->vcol[1]= shi->col[shi->actcol].col[1];
 					shi->vcol[2]= shi->col[shi->actcol].col[2];
+					shi->vcol[3]= shi->col[shi->actcol].col[3];
 				}
 				else {
 					shi->vcol[0]= 0.0f;
 					shi->vcol[1]= 0.0f;
 					shi->vcol[2]= 0.0f;
+					shi->vcol[3]= 0.0f;
 				}
 			}
 
@@ -516,6 +519,7 @@
 						shi->vcol[0]= 1.0f;
 						shi->vcol[1]= 1.0f;
 						shi->vcol[2]= 1.0f;
+						shi->vcol[3]= 1.0f;
 					}
 				}
 			}
@@ -532,6 +536,7 @@
 					shi->vcol[0]= 1.0f;
 					shi->vcol[1]= 1.0f;
 					shi->vcol[2]= 1.0f;
+					shi->vcol[3]= 1.0f;
 				}
 			}
 
@@ -1111,13 +1116,14 @@
 					scol->col[0]= (l*((float)cp3[3]) - u*((float)cp1[3]) - v*((float)cp2[3]))/255.0f;
 					scol->col[1]= (l*((float)cp3[2]) - u*((float)cp1[2]) - v*((float)cp2[2]))/255.0f;
 					scol->col[2]= (l*((float)cp3[1]) - u*((float)cp1[1]) - v*((float)cp2[1]))/255.0f;
+					scol->col[3]= (l*((float)cp3[0]) - u*((float)cp1[0]) - v*((float)cp2[0]))/255.0f;
 				}
 
 				if(shi->totcol) {
 					shi->vcol[0]= shi->col[shi->actcol].col[0];
 					shi->vcol[1]= shi->col[shi->actcol].col[1];
 					shi->vcol[2]= shi->col[shi->actcol].col[2];
-					shi->vcol[3]= 1.0f;
+					shi->vcol[3]= shi->col[shi->actcol].col[3];
 				}
 				else {
 					shi->vcol[0]= 0.0f;

Modified: branches/soc-2011-carrot/source/blender/render/intern/source/shadeoutput.c
===================================================================
--- branches/soc-2011-carrot/source/blender/render/intern/source/shadeoutput.c	2011-07-24 13:21:54 UTC (rev 38660)
+++ branches/soc-2011-carrot/source/blender/render/intern/source/shadeoutput.c	2011-07-24 17:03:33 UTC (rev 38661)
@@ -865,13 +865,19 @@
 {
 	Material *ma= shi->mat;
 
-	if(ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE)) {
+	if(ma->mode & (MA_FACETEXTURE)) {
 		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];
 	}
+	else if(ma->mode & (MA_VERTEXCOLP)) {
+		float inv_alpha = 1.0f - shi->vcol[3];
+		shi->r= shi->r*inv_alpha + shi->vcol[0]*shi->vcol[3];
+		shi->g= shi->g*inv_alpha + shi->vcol[1]*shi->vcol[3];
+		shi->b= shi->b*inv_alpha + shi->vcol[2]*shi->vcol[3];
+	}
 	
 	if(ma->texco)
 		do_material_tex(shi);
@@ -1649,13 +1655,19 @@
 	
 	/* material color itself */
 	if(passflag & (SCE_PASS_COMBINED|SCE_PASS_RGBA)) {
-		if(ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE)) {
+		if(ma->mode & (MA_FACETEXTURE)) {
 			shi->r= shi->vcol[0];
 			shi->g= shi->vcol[1];
 			shi->b= shi->vcol[2];
 			if(ma->mode & (MA_FACETEXTURE_ALPHA))
-				shi->alpha= (shi->mode & MA_TRANSP) ? shi->vcol[3] : 1.0f;
+				shi->alpha= shi->vcol[3];
 		}
+		else if(ma->mode & (MA_VERTEXCOLP)) {
+			float inv_alpha = 1.0f - shi->vcol[3];
+			shi->r= shi->r*inv_alpha + shi->vcol[0]*shi->vcol[3];
+			shi->g= shi->g*inv_alpha + shi->vcol[1]*shi->vcol[3];
+			shi->b= shi->b*inv_alpha + shi->vcol[2]*shi->vcol[3];
+		}
 		if(ma->texco){
 			do_material_tex(shi);
 			if (!(shi->mode & MA_TRANSP)) shi->alpha = 1.0f;




More information about the Bf-blender-cvs mailing list