Changes in code to allow double sided energy, but it's not possible
authorTon Roosendaal <ton@blender.org>
Sat, 26 Jun 2004 18:03:57 +0000 (18:03 +0000)
committerTon Roosendaal <ton@blender.org>
Sat, 26 Jun 2004 18:03:57 +0000 (18:03 +0000)
to activate it. Added comment in code how to enable it for those who
like to play (search for translu)

What doesnt work - according to me not satisfying - is fact that radiosity
hemicubes alias badly on short distances, so interior light doesn't spread
well.

source/blender/radiosity/extern/include/radio_types.h
source/blender/radiosity/intern/source/radfactors.c
source/blender/radiosity/intern/source/radpreprocess.c
source/blender/radiosity/intern/source/radrender.c

index 4d5e56d7a153cfc9ce3802065b20432174205d3d..910b50e4373ec014e9b1c4423d574c0b4761fae4 100644 (file)
@@ -70,6 +70,7 @@ typedef struct RadView {
 #define RAD_SHOOT              2
 #define RAD_SUBDIV             4
 #define RAD_BACKFACE   8
+#define RAD_TWOSIDED   16
 
 
 typedef struct RNode {                                 /* length: 76 */
index fb66f994cbcadae4bde4aa5fdba5accb083fea21..cbe861fa44385a225175b38761c4ad11135d047f 100644 (file)
@@ -524,6 +524,7 @@ void rad_init_energy()
 void progressiverad()
 {
        RPatch *shoot;
+       float unshot[3];
        int it= 0;
 
        rad_printstatus();
@@ -539,8 +540,16 @@ void progressiverad()
                
                drawpatch_ext(shoot, 0x88FF00);
 
+               if(shoot->first->f & RAD_TWOSIDED) {
+                       VECCOPY(unshot, shoot->unshot);
+                       VecMulf(shoot->norm, -1.0);
+                       if(makeformfactors(shoot))
+                               applyformfactors(shoot);
+                       VecMulf(shoot->norm, -1.0);
+                       VECCOPY(shoot->unshot, unshot);
+               }
+       
                if( makeformfactors(shoot) ) {
-               
                        applyformfactors(shoot);
        
                        it++;
index 80c6294db020faec2faa03df520007c4825f9a6d..1f2f8bc2a8945c90a7113d5ba99a6bb4ae954309 100644 (file)
@@ -459,6 +459,9 @@ void rad_collect_meshes()
                                                rp->emit[1]*= rp->ref[1];
                                                rp->emit[2]*= rp->ref[2];
 
+// uncommented, this is not satisfying, but i leave it in code for now (ton)                                           
+//                                             if(ma->translucency!=0.0) rn->f |= RAD_TWOSIDED;
+
                                                nodevert= (VeNoCo **)&(rn->v1);
                                                for(b=0; b<rp->type; b++) {
                                                        rp->cent[0]+= (*nodevert)->v[0];
index 61d069ce587aa093882f822105c66dbc56230b65..6c94d3f8da938caceff1fabaa1f78e78e3cba40b 100644 (file)
@@ -127,9 +127,8 @@ static void backface_test_rr(VlakRen *shoot)
        for(a=0; a<R.totvlak; a++) {
                if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++;
                if(vlr->radface) {
-                       rf= vlr->radface;
                        if(vlr!=shoot) {
-               
+                               rf= vlr->radface;
                                VecSubf(tvec, shoot->radface->cent, rf->cent);
                                
                                if( tvec[0]*rf->norm[0]+ tvec[1]*rf->norm[1]+ tvec[2]*rf->norm[2] < 0.0) {              
@@ -244,7 +243,8 @@ static void applyformfactors_rr(VlakRen *shoot)
                                r= (*fp)*unr*ref[0];
                                g= (*fp)*ung*ref[1];
                                b= (*fp)*unb*ref[2];
-       
+                               
+                               // if(rf->flag & RAD_BACKFACE) {
                                
                                rf->totrad[0]+= r;
                                rf->totrad[1]+= g;
@@ -267,21 +267,32 @@ static void progressiverad_rr()
 {
        extern void RE_local_timecursor(int);   // RE_callbacks.c
        VlakRen *shoot;
+       float unshot[3];
        int it= 0;
        
        shoot= findshoot_rr();
        while( shoot ) {
-       
-               /* backfaces receive no energy, but are zbuffered */
+               
+               /* backfaces receive no energy, but are zbuffered... */
                backface_test_rr(shoot);
+               
+               /* ...unless it's two sided */
+               if(shoot->radface->flag & RAD_TWOSIDED) {
+                       VECCOPY(unshot, shoot->radface->unshot);
+                       VecMulf(shoot->radface->norm, -1.0);
+                       makeformfactors_rr(shoot);
+                       applyformfactors_rr(shoot);
+                       VecMulf(shoot->radface->norm, -1.0);
+                       VECCOPY(shoot->radface->unshot, unshot);
+               }
+
                /* hemi-zbuffers */
                makeformfactors_rr(shoot);
                /* based at RG.formfactors array, distribute shoot energy over other faces */
                applyformfactors_rr(shoot);
-       
+               
                it++;
                RE_local_timecursor(it);
-               // printf("\r Radiosity step %d", it); fflush(stdout);
                
                clear_backface_test_rr();
                
@@ -359,7 +370,9 @@ printf(" Rad elems: %d emittors %d\n", RG.totelem, RG.totpatch);
                                RG.min[b]= MIN2(RG.min[b], rf->cent[b]);
                                RG.max[b]= MAX2(RG.max[b], rf->cent[b]);
                        }
-                       
+
+// uncommented; this isnt satisfying, but i leave it in the code for now (ton)                 
+//                     if(vlr->mat->translucency!=0.0) rf->flag |= RAD_TWOSIDED;
                        
                        vlr->radface= rf++;
                }