- Fix for bug #17825: baking SSS is not supported, but it didn't give
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 12 Oct 2008 13:32:28 +0000 (13:32 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 12 Oct 2008 13:32:28 +0000 (13:32 +0000)
  proper results, should bake as if SSS was disabled.
- Fix for GLSL to handle failing shadow buffer creation better.
- Fix for sky/atmosphere version patch, was not doing files from 2.46
  and newer.

source/blender/blenloader/intern/readfile.c
source/blender/gpu/intern/gpu_material.c
source/blender/render/intern/include/sss.h
source/blender/render/intern/source/shadeoutput.c
source/blender/render/intern/source/sss.c

index 25f9e179ca901cbc1aed8775eedef452cc310b11..0193acb9f9820454fb2300868d4434f5ad495c71 100644 (file)
@@ -7767,23 +7767,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
 
        /* sun/sky */
        if(main->versionfile < 246) {
-               Lamp *la;
                Object *ob;
                bActuator *act;
 
-               for(la=main->lamp.first; la; la= la->id.next) {
-                       la->sun_effect_type = 0;
-                       la->horizon_brightness = 1.0;
-                       la->spread = 1.0;
-                       la->sun_brightness = 1.0;
-                       la->sun_size = 1.0;
-                       la->backscattered_light = 1.0;
-                       la->atm_turbidity = 2.0;
-                       la->atm_inscattering_factor = 1.0;
-                       la->atm_extinction_factor = 1.0;
-                       la->atm_distance_factor = 1.0;
-                       la->sun_intensity = 1.0;
-               }
                /* dRot actuator change direction in 2.46 */
                for(ob = main->object.first; ob; ob= ob->id.next) {
                        for(act= ob->actuators.first; act; act= act->next) {
@@ -7946,6 +7932,26 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        }
                }
        }
+
+       if (main->versionfile < 248) {
+               Lamp *la;
+
+               for(la=main->lamp.first; la; la= la->id.next) {
+                       if(la->atm_turbidity == 0.0) {
+                               la->sun_effect_type = 0;
+                               la->horizon_brightness = 1.0;
+                               la->spread = 1.0;
+                               la->sun_brightness = 1.0;
+                               la->sun_size = 1.0;
+                               la->backscattered_light = 1.0;
+                               la->atm_turbidity = 2.0;
+                               la->atm_inscattering_factor = 1.0;
+                               la->atm_extinction_factor = 1.0;
+                               la->atm_distance_factor = 1.0;
+                               la->sun_intensity = 1.0;
+                       }
+               }
+       }
        
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
index db6117d854b1b3475cab939cf8637bb062e0d492..46df003cbbc0116cf51fe25a6b5875e6b82b7085 100644 (file)
@@ -1362,10 +1362,14 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l
 
 static void gpu_lamp_shadow_free(GPULamp *lamp)
 {
-       if(lamp->tex)
+       if(lamp->tex) {
                GPU_texture_free(lamp->tex);
-       if(lamp->fb)
+               lamp->tex= NULL;
+       }
+       if(lamp->fb) {
                GPU_framebuffer_free(lamp->fb);
+               lamp->fb= NULL;
+       }
 }
 
 GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par)
index 660fb5442275ea3fea89a1a60aa60b19b41ac5a1..9ffdcaf206a0fb5b6962d204c8f33746901cef38 100644 (file)
@@ -59,7 +59,7 @@ void sss_add_points(Render *re, float (*co)[3], float (*color)[3], float *area,
 void free_sss(struct Render *re);
 
 int sample_sss(struct Render *re, struct Material *mat, float *co, float *col);
-int has_sss_tree(struct Render *re, struct Material *mat);
+int sss_pass_done(struct Render *re, struct Material *mat);
 
 #endif /*SSS_H*/
 
index c4fac1aeb06c2d10322590770bd8b1ca89bc5f9f..4c627056c1dcfb04f8eaf7784857a709b614db67 100644 (file)
@@ -1568,7 +1568,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;
@@ -1722,7 +1722,7 @@ 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;
@@ -1772,7 +1772,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);
index e41c7c380692ca463764a479f321a23270eec141..2e7ca48affcbe55b507a3d62ac49848a98c5ad34 100644 (file)
@@ -1023,8 +1023,8 @@ int sample_sss(Render *re, Material *mat, float *co, float *color)
        return 0;
 }
 
-int has_sss_tree(struct Render *re, struct Material *mat)
+int sss_pass_done(struct Render *re, struct Material *mat)
 {
-       return (re->sss_hash && BLI_ghash_lookup(re->sss_hash, mat));
+       return ((re->flag & R_BAKING) || (re->sss_hash && BLI_ghash_lookup(re->sss_hash, mat)));
 }