svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22668:22701
[blender.git] / source / blender / render / intern / source / shadeoutput.c
index 91621c24365810de283276913798737948554f5a..d5c8cf30b3000ec13466bd393144198012f1c701 100644 (file)
@@ -61,12 +61,14 @@ extern struct Render R;
 static ListBase *get_lights(ShadeInput *shi)
 {
        
+       if(R.r.scemode & R_PREVIEWBUTS)
+               return &R.lights;
        if(shi->light_override)
                return &shi->light_override->gobject;
-       else if(shi->mat && shi->mat->group)
+       if(shi->mat && shi->mat->group)
                return &shi->mat->group->gobject;
-       else
-               return &R.lights;
+       
+       return &R.lights;
 }
 
 #if 0
@@ -1005,6 +1007,7 @@ static void do_specular_ramp(ShadeInput *shi, float is, float t, float *spec)
 }
 
 /* pure AO, check for raytrace and world should have been done */
+/* preprocess, textures were not done, don't use shi->amb for that reason */
 void ambient_occlusion(ShadeInput *shi)
 {
        if((R.wrld.ao_gather_method == WO_AOGATHER_APPROX) && shi->mat->amb!=0.0f)
@@ -1020,8 +1023,8 @@ void ambient_occlusion(ShadeInput *shi)
 void ambient_occlusion_to_diffuse(ShadeInput *shi, float *diff)
 {
        if((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX) {
-               if(shi->mat->amb!=0.0f) {
-                       float f= R.wrld.aoenergy*shi->mat->amb;
+               if(shi->amb!=0.0f) {
+                       float f= R.wrld.aoenergy*shi->amb;
 
                        if (R.wrld.aomix==WO_AOADDSUB) {
                                diff[0] = 2.0f*shi->ao[0]-1.0f;
@@ -1460,10 +1463,10 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr)
                LampRen *lar;
                GroupObject *go;
                float inpr, lv[3];
-               float *vn, *view, shadfac[4];
+               float *view, shadfac[4];
                float ir, accum, visifac, lampdist;
                
-               vn= shi->vn;
+
                view= shi->view;
 
                accum= ir= 0.0f;
@@ -1568,7 +1571,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
                shr->col[2]= shi->b*shi->alpha;
                shr->col[3]= shi->alpha;
 
-               if((ma->sss_flag & MA_DIFF_SSS) && !has_sss_tree(&R, ma)) {
+               if((ma->sss_flag & MA_DIFF_SSS) && !sss_pass_done(&R, ma)) {
                        if(ma->sss_texfac == 0.0f) {
                                shi->r= shi->g= shi->b= shi->alpha= 1.0f;
                                shr->col[0]= shr->col[1]= shr->col[2]= shr->col[3]= 1.0f;
@@ -1710,7 +1713,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
                        shi->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra);
                        
                /* note: shi->mode! */
-               if(shi->mode & (MA_ZTRA|MA_RAYTRANSP)) {
+               if(shi->mode & MA_TRANSP) {
                        if(shi->spectra!=0.0f) {
                                float t = MAX3(shr->spec[0], shr->spec[1], shr->spec[2]);
                                t *= shi->spectra;
@@ -1722,16 +1725,17 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
        shr->alpha= shi->alpha;
        
        /* from now stuff everything in shr->combined: ambient, AO, radio, ramps, exposure */
-       if(!(ma->sss_flag & MA_DIFF_SSS) || !has_sss_tree(&R, ma)) {
+       if(!(ma->sss_flag & MA_DIFF_SSS) || !sss_pass_done(&R, ma)) {
                shr->combined[0]+= shi->ambr;
                shr->combined[1]+= shi->ambg;
                shr->combined[2]+= shi->ambb;
 
+               /* removed
                if(shi->combinedflag & SCE_PASS_RADIO) {
                        shr->combined[0]+= shi->r*shi->amb*shi->rad[0];
                        shr->combined[1]+= shi->g*shi->amb*shi->rad[1];
                        shr->combined[2]+= shi->b*shi->amb*shi->rad[2];
-               }
+               }*/
                
                /* add AO in combined? */
                if(R.wrld.mode & WO_AMB_OCC) {
@@ -1772,7 +1776,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
 
        /* modulate by the object color */
        if((ma->shade_flag & MA_OBCOLOR) && shi->obr->ob) {
-               if(!(ma->sss_flag & MA_DIFF_SSS) || !has_sss_tree(&R, ma)) {
+               if(!(ma->sss_flag & MA_DIFF_SSS) || !sss_pass_done(&R, ma)) {
                        float obcol[4];
 
                        QUATCOPY(obcol, shi->obr->ob->col);