* Fixes for shading objects inside volumes
authorMatt Ebb <matt@mke3.net>
Sun, 30 Aug 2009 07:07:02 +0000 (07:07 +0000)
committerMatt Ebb <matt@mke3.net>
Sun, 30 Aug 2009 07:07:02 +0000 (07:07 +0000)
source/blender/render/intern/include/render_types.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/volumetric.c

index c4910f7733dc0198bc632261e8f1cf2141a891e2..e50e498228d6ed82c735393afc7442698e09edf5 100644 (file)
@@ -419,6 +419,7 @@ typedef struct VolumeOb
 typedef struct MatInside {
        struct MatInside *next, *prev;
        struct Material *ma;
+       struct ObjectInstanceRen *obi;
 } MatInside;
 
 typedef struct VolPrecachePart
index e486daf25851616b9499268e08bc3a270d03a9c2..cf6246e3641d6373e513b9b2a42d905ebfaab313 100644 (file)
@@ -2999,6 +2999,7 @@ static void init_camera_inside_volumes(Render *re)
                                        
                                        mi = MEM_mallocN(sizeof(MatInside), "camera inside material");
                                        mi->ma = vo->ma;
+                                       mi->obi = obi;
                                        
                                        BLI_addtail(&(re->render_volumes_inside), mi);
                                }
index 046a145e9dacb77f1e0bf4e3b871d45787aeeae5..4fa31674bbe1329521d9fc8d81520c8ba65c4b07 100644 (file)
@@ -674,15 +674,25 @@ void shade_volume_inside(ShadeInput *shi, ShadeResult *shr)
 {
        MatInside *m;
        Material *mat_backup;
+       ObjectInstanceRen *obi_backup;
+       float prev_alpha = shr->alpha;
        
        //if (BLI_countlist(&R.render_volumes_inside) == 0) return;
        
        /* XXX: extend to multiple volumes perhaps later */
        mat_backup = shi->mat;
+       obi_backup = shi->obi;
+       
        m = R.render_volumes_inside.first;
        shi->mat = m->ma;
+       shi->obi = m->obi;
+       shi->obr = m->obi->obr;
        
        volume_trace(shi, shr, VOL_SHADE_INSIDE);
-
+       shr->alpha += prev_alpha;
+       CLAMP(shr->alpha, 0.f, 1.f);
+       
        shi->mat = mat_backup;
+       shi->obi = obi_backup;
+       shi->obr = obi_backup->obr;
 }
\ No newline at end of file