Sunsky / Atmoshphere:
[blender-staging.git] / source / blender / render / intern / source / pixelshading.c
index ef723eea6b5a137717454e7633c8fbe7fc3e8c11..4a567042d127835a46660846c7ee1cebf6274fc9 100644 (file)
@@ -45,6 +45,7 @@
 
 #include "BKE_image.h"
 #include "BKE_global.h"
+#include "BKE_material.h"
 #include "BKE_texture.h"
 #include "BKE_utildefines.h"
 
@@ -604,12 +605,9 @@ void shadeSunView(struct SunSky *sunsky, float *colf, float *rco, float *view, f
  */
 void shadeSkyPixel(float *collector, float fx, float fy) 
 {
-       float view[3], dxyview[2];
-       float sun_collector[3];
-       float suns_color[3];
-       short num_sun_lamp;
        GroupObject *go;
        LampRen *lar;
+       float view[3], dxyview[2];
 
        /*
          The rules for sky:
@@ -657,33 +655,18 @@ void shadeSkyPixel(float *collector, float fx, float fy)
                collector[3] = 0.0f;
        }
                
-       suns_color[0] = suns_color[1] = suns_color[2] = 0;
-       num_sun_lamp = 0;
        for(go=R.lights.first; go; go= go->next) {
                lar= go->lampren;
                if(lar->type==LA_SUN && lar->sunsky && (lar->sunsky->effect_type & LA_SUN_EFFECT_SKY)){
-
-                       num_sun_lamp ++;
+                       float sun_collector[3];
+                       
                        calc_view_vector(view, fx, fy);
                        Normalize(view);
 
                        shadeSunView(lar->sunsky, sun_collector, NULL, view, NULL);
-                       suns_color[0] += sun_collector[0];
-                       suns_color[1] += sun_collector[1];
-                       suns_color[2] += sun_collector[2];
-
+                       ramp_blend(lar->sunsky->skyblendtype, collector, collector+1, collector+2, lar->sunsky->skyblendfac, sun_collector);
                }
        }
-       if( num_sun_lamp > 0 ){
-               suns_color[0] /= num_sun_lamp;
-               suns_color[1] /= num_sun_lamp;
-               suns_color[2] /= num_sun_lamp;
-
-               collector[0] += suns_color[0];
-               collector[1] += suns_color[1];
-               collector[2] += suns_color[2];
-               ClipColor(collector);
-       }
 }
 
 /* aerial perspective */