Revision: 16651
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16651
Author:   ton
Date:     2008-09-21 18:04:33 +0200 (Sun, 21 Sep 2008)

Log Message:
-----------
Sunsky / Atmoshphere:

- Added blending mode and factor option, so it's more clear and
  controllable what happens with it. Also nice for crazy effects
  of course!
- Preview render now shows preview for it too

On the todos:

- have this in World buttons (as well) for quicker sky setups
- review math of color clamping and scaling, this is definitely 
  not good... but a fix will make old files look very different.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_blender.h
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesdna/DNA_lamp_types.h
    trunk/blender/source/blender/makesdna/DNA_material_types.h
    trunk/blender/source/blender/render/intern/include/sunsky.h
    trunk/blender/source/blender/render/intern/source/convertblender.c
    trunk/blender/source/blender/render/intern/source/pixelshading.c
    trunk/blender/source/blender/render/intern/source/sunsky.c
    trunk/blender/source/blender/src/buttons_shading.c
    trunk/blender/source/blender/src/preview.blend.c
    trunk/blender/source/blender/src/previewrender.c

Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_blender.h       2008-09-21 
15:17:50 UTC (rev 16650)
+++ trunk/blender/source/blender/blenkernel/BKE_blender.h       2008-09-21 
16:04:33 UTC (rev 16651)
@@ -41,7 +41,7 @@
 struct MemFile;
 
 #define BLENDER_VERSION                        247
-#define BLENDER_SUBVERSION             4
+#define BLENDER_SUBVERSION             5
 
 #define BLENDER_MINVERSION             245
 #define BLENDER_MINSUBVERSION  15

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c     2008-09-21 
15:17:50 UTC (rev 16650)
+++ trunk/blender/source/blender/blenkernel/intern/object.c     2008-09-21 
16:04:33 UTC (rev 16651)
@@ -748,6 +748,9 @@
        la->atm_extinction_factor = 1.0;
        la->atm_distance_factor = 1.0;
        la->sun_intensity = 1.0;
+       la->skyblendtype= MA_RAMP_ADD;
+       la->skyblendfac= 1.0f;
+
        curvemapping_initialize(la->curfalloff);
        return la;
 }

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c   2008-09-21 
15:17:50 UTC (rev 16650)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c   2008-09-21 
16:04:33 UTC (rev 16651)
@@ -7818,6 +7818,13 @@
                }
        }
 
+       if (main->versionfile < 247 || (main->versionfile == 247 && 
main->subversionfile < 5)) {
+               Lamp *la= main->lamp.first;
+               for(; la; la= la->id.next) {
+                       la->skyblendtype= MA_RAMP_ADD;
+                       la->skyblendfac= 1.0f;
+               }
+       }
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! 
*/
        /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
 

Modified: trunk/blender/source/blender/makesdna/DNA_lamp_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_lamp_types.h      2008-09-21 
15:17:50 UTC (rev 16650)
+++ trunk/blender/source/blender/makesdna/DNA_lamp_types.h      2008-09-21 
16:04:33 UTC (rev 16651)
@@ -79,7 +79,7 @@
        
        /* sun/sky */
        short sun_effect_type;
-       short atm_pad[3];
+       short skyblendtype;
     float horizon_brightness;
     float spread;
     float sun_brightness;
@@ -90,8 +90,8 @@
     float atm_inscattering_factor;
     float atm_extinction_factor;
     float atm_distance_factor;
+       float skyblendfac;
 
-
        /* yafray: photonlight params */
        int YF_numphotons, YF_numsearch;
        short YF_phdepth, YF_useqmc, YF_bufsize, YF_pad;

Modified: trunk/blender/source/blender/makesdna/DNA_material_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_material_types.h  2008-09-21 
15:17:50 UTC (rev 16650)
+++ trunk/blender/source/blender/makesdna/DNA_material_types.h  2008-09-21 
16:04:33 UTC (rev 16651)
@@ -320,6 +320,7 @@
 #define MA_LAMP                        6
 #define MA_SKY                 7
 #define MA_HAIR                        10
+#define MA_ATMOS               11
 
 /* pr_back */
 #define MA_DARK                        1

Modified: trunk/blender/source/blender/render/intern/include/sunsky.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/sunsky.h 2008-09-21 
15:17:50 UTC (rev 16650)
+++ trunk/blender/source/blender/render/intern/include/sunsky.h 2008-09-21 
16:04:33 UTC (rev 16651)
@@ -33,7 +33,7 @@
 
 typedef struct SunSky
 {
-    short effect_type;
+    short effect_type, skyblendtype;
     float turbidity;
     float theta, phi;
     
@@ -53,7 +53,8 @@
     float sun_brightness;
     float sun_size;
     float backscattered_light;
-    
+    float skyblendfac;
+       
     float atm_HGg;
 
     float atm_SunIntensity;
@@ -84,7 +85,8 @@
  * back_scatter, controls back scatter light
  * */
 void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float 
horizon_brightness, 
-                               float spread,float sun_brightness, float 
sun_size, float back_scatter);
+                               float spread,float sun_brightness, float 
sun_size, float back_scatter,
+                               float skyblendfac, short skyblendtype);
 
 /**
  * GetSkyXYZRadiance:

Modified: trunk/blender/source/blender/render/intern/source/convertblender.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/convertblender.c  
2008-09-21 15:17:50 UTC (rev 16650)
+++ trunk/blender/source/blender/render/intern/source/convertblender.c  
2008-09-21 16:04:33 UTC (rev 16651)
@@ -3638,7 +3638,8 @@
                    Normalize(vec);
                    
                        InitSunSky(lar->sunsky, la->atm_turbidity, vec, 
la->horizon_brightness, 
-                                       la->spread, la->sun_brightness, 
la->sun_size, la->backscattered_light);
+                                       la->spread, la->sun_brightness, 
la->sun_size, la->backscattered_light,
+                                          la->skyblendfac, la->skyblendtype);
                        
                        InitAtmosphere(lar->sunsky, la->sun_intensity, 1.0, 
1.0, la->atm_inscattering_factor, la->atm_extinction_factor,
                                        la->atm_distance_factor);

Modified: trunk/blender/source/blender/render/intern/source/pixelshading.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/pixelshading.c    
2008-09-21 15:17:50 UTC (rev 16650)
+++ trunk/blender/source/blender/render/intern/source/pixelshading.c    
2008-09-21 16:04:33 UTC (rev 16651)
@@ -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 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 @@
                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 */

Modified: trunk/blender/source/blender/render/intern/source/sunsky.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/sunsky.c  2008-09-21 
15:17:50 UTC (rev 16650)
+++ trunk/blender/source/blender/render/intern/source/sunsky.c  2008-09-21 
16:04:33 UTC (rev 16651)
@@ -135,7 +135,8 @@
  * back_scatter, controls back scatter light
  * */
 void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float 
horizon_brightness, 
-                               float spread,float sun_brightness, float 
sun_size, float back_scatter)
+                               float spread,float sun_brightness, float 
sun_size, float back_scatter,
+                               float skyblendfac, short skyblendtype)
 {
     
        float theta2;
@@ -151,6 +152,8 @@
        sunsky->sun_brightness = sun_brightness;
        sunsky->sun_size = sun_size;
        sunsky->backscattered_light = back_scatter;
+       sunsky->skyblendfac= skyblendfac;
+       sunsky->skyblendtype= skyblendtype;
        
        sunsky->toSun[0] = toSun[0];
     sunsky->toSun[1] = toSun[1];

Modified: trunk/blender/source/blender/src/buttons_shading.c
===================================================================
--- trunk/blender/source/blender/src/buttons_shading.c  2008-09-21 15:17:50 UTC 
(rev 16650)
+++ trunk/blender/source/blender/src/buttons_shading.c  2008-09-21 16:04:33 UTC 
(rev 16651)
@@ -2871,7 +2871,7 @@
 
        uiSetButLock(la->id.lib!=0, ERROR_LIBDATA_MESSAGE);
        
-       uiDefButBitS(block, TOG, LA_SUN_EFFECT_SKY, REDRAWVIEW3D, "Sky", 
10,205,BUTW2,20,&(la->sun_effect_type), 0, 0, 0, 0, "Apply sun light effect on 
sky.");
+       uiDefButBitS(block, TOG, LA_SUN_EFFECT_SKY, B_LAMPPRV, "Sky", 
10,205,BUTW2,20,&(la->sun_effect_type), 0, 0, 0, 0, "Apply sun light effect on 
sky.");
        uiDefButBitS(block, TOG, LA_SUN_EFFECT_AP, REDRAWVIEW3D, "Atmosphere", 
20+BUTW2,205,BUTW2,20,&(la->sun_effect_type), 0, 0, 0, 0, "Apply sun light 
effect on atmosphere.");
 
        if(la->sun_effect_type & (LA_SUN_EFFECT_SKY|LA_SUN_EFFECT_AP)){
@@ -2881,11 +2881,19 @@
        y = 180;
        if(la->sun_effect_type & LA_SUN_EFFECT_SKY)
        {
-               uiDefButF(block, NUM, B_LAMPREDRAW, 
"Hor.Bright:",10,y-25,BUTW2,19, &(la->horizon_brightness), 0.00f, 20.00f, 10, 
0, "Sets horizon brightness.");
-               uiDefButF(block, NUM, B_LAMPREDRAW, 
"Hor.Spread:",10,y-50,BUTW2,19, &(la->spread), 0.00f, 10.00f, 10, 0, "Sets 
horizon spread.");
-               uiDefButF(block, NUM, B_LAMPREDRAW, "Sun 
Bright:",10,y-75,BUTW2,19, &(la->sun_brightness), 0.00f, 10.0f, 10, 0, "Sets 
sun brightness.");
-               uiDefButF(block, NUM, B_LAMPREDRAW, "Sun 
Size:",10,y-100,BUTW2,19, &(la->sun_size), 0.00f, 10.00f, 10, 0, "Sets sun 
size.");
-               uiDefButF(block, NUM, B_LAMPREDRAW, "Back 
Light:",10,y-125,BUTW2,19, &(la->backscattered_light), -1.00f, 1.00f, 10, 0, 
"Sets backscatter light.");
+               uiBlockBeginAlign(block);
+               uiDefButS(block, MENU, B_LAMPPRV, "Mix %x0|Add %x1|Subtract 
%x3|Multiply %x2|Screen %x4|Overlay %x9|Divide %x5|Difference %x6|Darken 
%x7|Lighten %x8|Dodge %x10|Burn %x11|Color %x15|Value %x14|Saturation %x13|Hue 
%x12",
+                                        10,y-25,BUTW2/2,19, 
+                                        &la->skyblendtype, 0.0f, 0.0f, 0, 0, 
"Blend type for how it gets combined with sky");
+               uiDefButF(block, NUM, B_LAMPPRV, "",10+BUTW2/2,y-25,BUTW2/2,19, 
&(la->skyblendfac), 0.0f, 1.0f, 10, 0, "Sets blending factor with sky color");
+               uiBlockEndAlign(block);
+               
+               y -= 25;
+               uiDefButF(block, NUM, B_LAMPPRV, 
"Hor.Bright:",10,y-25,BUTW2,19, &(la->horizon_brightness), 0.00f, 20.00f, 10, 
0, "Sets horizon brightness.");
+               uiDefButF(block, NUM, B_LAMPPRV, 
"Hor.Spread:",10,y-50,BUTW2,19, &(la->spread), 0.00f, 10.00f, 10, 0, "Sets 
horizon spread.");
+               uiDefButF(block, NUM, B_LAMPPRV, "Sun 
Bright:",10,y-75,BUTW2,19, &(la->sun_brightness), 0.00f, 10.0f, 10, 0, "Sets 
sun brightness.");

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to