From c492729b3a0d52ae01ee67e5ad92bdb02f6585df Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 8 Dec 2005 22:05:42 +0000 Subject: New feature: "Stress" texture input channel (As usual movies disappears after while) Face example showing stress values on a blend. White is stretch, black is squeeze http://www.blender.org/bf/0001_0014.avi Quick test with softbody stretch http://www.blender.org/bf/0001_0100.avi Based on the difference of the "Orco" (original undeformed coordinate) and the actual render coordinate, a stress value is computed to make textures react to stretching or wrinking skin. The texture coordinate is neutral (0) on relaxed state. -1 is squeezed to zero, +1 is stretched to infinity. Note that scaling (object itself or parent) also will result in stress values. The reason for the huge commit is a cleanup in allocating memory for the vertices. These were growing too large with new options, so now it allocates the optional coordinates dynamically. Saves about 20 MB memory per 1M vertices already. But best of all is that I now can add much more fun... so tangents, here we come! --- source/blender/radiosity/intern/source/radrender.c | 124 ++++----------------- 1 file changed, 24 insertions(+), 100 deletions(-) (limited to 'source/blender/radiosity') diff --git a/source/blender/radiosity/intern/source/radrender.c b/source/blender/radiosity/intern/source/radrender.c index 50b9569c09f..a6ff8657d0c 100644 --- a/source/blender/radiosity/intern/source/radrender.c +++ b/source/blender/radiosity/intern/source/radrender.c @@ -399,100 +399,16 @@ static void vecaddfac(float *vec, float *v1, float *v2, float fac) } -#if 0 -/* unused now, doesnt work... */ -static void filter_rad_values(void) -{ - VlakRen *vlr=NULL; - VertRen *v1=NULL; - RadFace *rf; - float n1[3], n2[3], n3[4], n4[3], co[4]; - int a; - - /* one filter pass */ - for(a=0; a>8]; else v1++; - if(v1->accum>0.0) { - v1->rad[0]= v1->rad[0]/v1->accum; - v1->rad[1]= v1->rad[1]/v1->accum; - v1->rad[2]= v1->rad[2]/v1->accum; - v1->accum= 0.0; - } - } - /* cosines in verts accumulate in faces */ - for(a=0; a>8]; else vlr++; - - if(vlr->radface) { - rf= vlr->radface; - - /* calculate cosines of angles, for weighted add (irregular faces) */ - VecSubf(n1, vlr->v2->co, vlr->v1->co); - VecSubf(n2, vlr->v3->co, vlr->v2->co); - Normalise(n1); - Normalise(n2); - - if(vlr->v4==NULL) { - VecSubf(n3, vlr->v1->co, vlr->v3->co); - Normalise(n3); - - co[0]= saacos(-n3[0]*n1[0]-n3[1]*n1[1]-n3[2]*n1[2])/M_PI; - co[1]= saacos(-n1[0]*n2[0]-n1[1]*n2[1]-n1[2]*n2[2])/M_PI; - co[2]= saacos(-n2[0]*n3[0]-n2[1]*n3[1]-n2[2]*n3[2])/M_PI; - co[0]= co[1]= co[2]= 1.0/3.0; - } - else { - VecSubf(n3, vlr->v4->co, vlr->v3->co); - VecSubf(n4, vlr->v1->co, vlr->v4->co); - Normalise(n3); - Normalise(n4); - - co[0]= saacos(-n4[0]*n1[0]-n4[1]*n1[1]-n4[2]*n1[2])/M_PI; - co[1]= saacos(-n1[0]*n2[0]-n1[1]*n2[1]-n1[2]*n2[2])/M_PI; - co[2]= saacos(-n2[0]*n3[0]-n2[1]*n3[1]-n2[2]*n3[2])/M_PI; - co[3]= saacos(-n3[0]*n4[0]-n3[1]*n4[1]-n3[2]*n4[2])/M_PI; - co[0]= co[1]= co[2]= co[3]= 1.0/4.0; - } - - rf->totrad[0]= rf->totrad[1]= rf->totrad[2]= 0.0; +/* unused now, doesnt work..., find it in cvs of nov 2005 or older */ +/* static void filter_rad_values(void) */ - vecaddfac(rf->totrad, rf->totrad, vlr->v1->rad, co[0]); - vecaddfac(rf->totrad, rf->totrad, vlr->v2->rad, co[1]); - vecaddfac(rf->totrad, rf->totrad, vlr->v3->rad, co[2]); - if(vlr->v4) { - vecaddfac(rf->totrad, rf->totrad, vlr->v4->rad, co[3]); - } - } - } - - /* accumulate vertexcolors again */ - for(a=0; a>8]; else vlr++; - - if(vlr->radface) { - rf= vlr->radface; - - vecaddfac(vlr->v1->rad, vlr->v1->rad, rf->totrad, rf->area); - vlr->v1->accum+= rf->area; - vecaddfac(vlr->v2->rad, vlr->v2->rad, rf->totrad, rf->area); - vlr->v2->accum+= rf->area; - vecaddfac(vlr->v3->rad, vlr->v3->rad, rf->totrad, rf->area); - vlr->v3->accum+= rf->area; - if(vlr->v4) { - vecaddfac(vlr->v4->rad, vlr->v4->rad, rf->totrad, rf->area); - vlr->v4->accum+= rf->area; - } - } - } - -} -#endif static void make_vertex_rad_values() { VertRen *v1=NULL; VlakRen *vlr=NULL; RadFace *rf; + float *col; int a; RG.igamma= 1.0/RG.gamma; @@ -515,26 +431,34 @@ static void make_vertex_rad_values() if(vlr->mat->g > 0.0) rf->totrad[1]/= vlr->mat->g; if(vlr->mat->b > 0.0) rf->totrad[2]/= vlr->mat->b; - vecaddfac(vlr->v1->rad, vlr->v1->rad, rf->totrad, rf->area); - vlr->v1->accum+= rf->area; - vecaddfac(vlr->v2->rad, vlr->v2->rad, rf->totrad, rf->area); - vlr->v2->accum+= rf->area; - vecaddfac(vlr->v3->rad, vlr->v3->rad, rf->totrad, rf->area); - vlr->v3->accum+= rf->area; + col= RE_vertren_get_rad(vlr->v1, 1); + vecaddfac(col, col, rf->totrad, rf->area); + col[3]+= rf->area; + + col= RE_vertren_get_rad(vlr->v2, 1); + vecaddfac(col, col, rf->totrad, rf->area); + col[3]+= rf->area; + + col= RE_vertren_get_rad(vlr->v3, 1); + vecaddfac(col, col, rf->totrad, rf->area); + col[3]+= rf->area; + if(vlr->v4) { - vecaddfac(vlr->v4->rad, vlr->v4->rad, rf->totrad, rf->area); - vlr->v4->accum+= rf->area; + col= RE_vertren_get_rad(vlr->v4, 1); + vecaddfac(col, col, rf->totrad, rf->area); + col[3]+= rf->area; } } } /* make vertex colors */ for(a=0; a>8]; else v1++; - if(v1->accum>0.0) { - v1->rad[0]/= v1->accum; - v1->rad[1]/= v1->accum; - v1->rad[2]/= v1->accum; + if((a & 255)==0) v1= RE_findOrAddVert(a); else v1++; + col= RE_vertren_get_rad(v1, 0); + if(col[3]>0.0) { + col[0]/= col[3]; + col[1]/= col[3]; + col[2]/= col[3]; } } -- cgit v1.2.3