svn merge -r 17502:18705 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / blender / render / intern / source / shadeinput.c
index 1cd8ec110f9729795b61ce3430d59404159dfb0a..294175460bff7c1f3ac4124a9999cd4779452605 100644 (file)
@@ -121,7 +121,7 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr)
        }
        
        /* depth >= 1 when ray-shading */
-       if(shi->depth==0) {
+       if(shi->depth >= 0 && (shi->depth < MAX2(shi->mat->ray_depth_tra, shi->mat->ray_depth))) {
                if(R.r.mode & R_RAYTRACE) {
                        if(shi->ray_mirror!=0.0f || ((shi->mat->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) {
                                /* ray trace works on combined, but gives pass info */
@@ -132,10 +132,13 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr)
                if(shi->mat->mode & MA_RAYTRANSP) 
                        if((shi->layflag & SCE_LAY_SKY) && (R.r.alphamode==R_ADDSKY))
                                shr->alpha= 1.0f;
-       }       
+       }
+       
+       if(R.r.mode & R_RAYTRACE) {
+               shade_volume_inside(shi, shr);
+       }
 }
 
-
 /* do a shade, finish up some passes, apply mist */
 void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr)
 {
@@ -151,7 +154,12 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr)
                memcpy(&shi->r, &shi->mat->r, 23*sizeof(float));
                shi->har= shi->mat->har;
                
-               shade_material_loop(shi, shr);
+               if (shi->mat->material_type == MA_SOLID) {
+                       shade_material_loop(shi, shr);
+               } else if (shi->mat->material_type == MA_VOLUME) {
+                       if(R.r.mode & R_RAYTRACE)
+                               shade_volume_outside(shi, shr);
+               }
        }
        
        /* copy additional passes */
@@ -667,6 +675,10 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float *
                }
        }
        
+       /* set camera coords - for scanline, it's always 0.0,0.0,0.0 (render is in camera space)
+        * however for raytrace it can be different - the position of the last intersection */
+       shi->camera_co[0] = shi->camera_co[1] = shi->camera_co[2] = 0.0f;
+       
        /* cannot normalize earlier, code above needs it at viewplane level */
        Normalize(view);
 }