Bugfix #17711
authorTon Roosendaal <ton@blender.org>
Mon, 29 Sep 2008 17:55:11 +0000 (17:55 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 29 Sep 2008 17:55:11 +0000 (17:55 +0000)
SunSky didn't include skycolor in raytrace.
Note: there seems to be  an error in sunsky when looking straight down,
so this option requires raytracing stuff not in outer space. :)

source/blender/render/intern/include/pixelshading.h
source/blender/render/intern/source/pixelshading.c
source/blender/render/intern/source/rayshade.c

index 15d696df89d8f991ae9a63066b8f1abaf2ff787f..c6b11b4af9af8cde41004ff78fddb8a92f5d9796 100644 (file)
@@ -56,7 +56,7 @@ int shadeHaloFloat(HaloRen *har,
 void shadeSkyPixel(float *collector, float fx, float fy);
 void shadeSkyView(float *colf, float *rco, float *view, float *dxyview);
 void shadeAtmPixel(struct SunSky *sunsky, float *collector, float fx, float fy, float distance);
-
+void shadeSunView(float *colf, float *view);
 /* ------------------------------------------------------------------------- */
 
 #endif
index a13829d0306a09ac2ef6bb27651b48875b76c173..60723963af93bf14ba67cbb06653192076acaa36 100644 (file)
@@ -570,27 +570,37 @@ void shadeSkyView(float *colf, float *rco, float *view, float *dxyview)
 }
 
 /* shade sky according to sun lamps, all parameters are like shadeSkyView except sunsky*/
-void shadeSunView(struct SunSky *sunsky, float *colf, float *rco, float *view, float *dxyview)
+void shadeSunView(float *colf, float *view)
 {
-       float colorxyz[3];
+       GroupObject *go;
+       LampRen *lar;
+       float sview[3];
+       int do_init= 1;
+       
+       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)){
+                       float sun_collector[3];
+                       float colorxyz[3];
                        
-       /**
-       sunAngle = sqrt(sunsky->sunSolidAngle / M_PI);
-
-       sunDir[0] = sunsky->toSun[0];
-       sunDir[1] = sunsky->toSun[1];
-       sunDir[2] = sunsky->toSun[2];
-       */
+                       if(do_init) {
+                               
+                               VECCOPY(sview, view);
+                               Normalize(sview);
+                               MTC_Mat3MulVecfl(R.imat, sview);
+                               if (sview[2] < 0.0)
+                                       sview[2] = 0.0;
+                               Normalize(sview);
+                               do_init= 0;
+                       }
                        
-       Normalize(view);
-       MTC_Mat3MulVecfl(R.imat, view);
-       if (view[2] < 0.0)
-               view[2] = 0.0;
-       Normalize(view);
-       
-       GetSkyXYZRadiancef(sunsky, view, colorxyz);
-       
-       xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &colf[0], &colf[1], &colf[2], sunsky->sky_colorspace);
+                       GetSkyXYZRadiancef(lar->sunsky, sview, colorxyz);
+                       xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &sun_collector[0], &sun_collector[1], &sun_collector[2], 
+                                          lar->sunsky->sky_colorspace);
+                       
+                       ramp_blend(lar->sunsky->skyblendtype, colf, colf+1, colf+2, lar->sunsky->skyblendfac, sun_collector);
+               }
+       }
 }
 
 
@@ -599,8 +609,6 @@ void shadeSunView(struct SunSky *sunsky, float *colf, float *rco, float *view, f
  */
 void shadeSkyPixel(float *collector, float fx, float fy) 
 {
-       GroupObject *go;
-       LampRen *lar;
        float view[3], dxyview[2];
 
        /*
@@ -648,19 +656,9 @@ void shadeSkyPixel(float *collector, float fx, float fy)
                shadeSkyView(collector, NULL, view, dxyview);
                collector[3] = 0.0f;
        }
-               
-       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)){
-                       float sun_collector[3];
-                       
-                       calc_view_vector(view, fx, fy);
-                       Normalize(view);
-
-                       shadeSunView(lar->sunsky, sun_collector, NULL, view, NULL);
-                       ramp_blend(lar->sunsky->skyblendtype, collector, collector+1, collector+2, lar->sunsky->skyblendfac, sun_collector);
-               }
-       }
+       
+       calc_view_vector(view, fx, fy);
+       shadeSunView(collector, view);
 }
 
 /* aerial perspective */
index 48ae84379bac7d46b5db9ae2a994688df007c4f8..9d457e7f0fc1a886189d6a612e3d815b798e9e4d 100644 (file)
@@ -397,6 +397,7 @@ static void ray_fadeout_endcolor(float *col, ShadeInput *origshi, ShadeInput *sh
                Normalize(shi->view);
                
                shadeSkyView(col, isec->start, shi->view, NULL);
+               shadeSunView(col, shi->view);
        }
 }
 
@@ -1627,6 +1628,7 @@ static void ray_ao_qmc(ShadeInput *shi, float *shadfac)
                        }
                        else {  /* WO_AOSKYTEX */
                                shadeSkyView(skycol, isec.start, view, dxyview);
+                               shadeSunView(skycol, shi->view);
                                shadfac[0]+= skycol[0];
                                shadfac[1]+= skycol[1];
                                shadfac[2]+= skycol[2];
@@ -1751,6 +1753,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *shadfac)
                                }
                                else {  /* WO_AOSKYTEX */
                                        shadeSkyView(skycol, isec.start, view, dxyview);
+                                       shadeSunView(skycol, shi->view);
                                        shadfac[0]+= skycol[0];
                                        shadfac[1]+= skycol[1];
                                        shadfac[2]+= skycol[2];