Bugfix
authorCampbell Barton <ideasman42@gmail.com>
Sun, 13 Jan 2008 11:15:23 +0000 (11:15 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 13 Jan 2008 11:15:23 +0000 (11:15 +0000)
[#6861] Black dots when using small lamps on Mirror materials in 2.44 and 2.43.
some values were not initialized properly, for example, the window coordinates for reflections, this caused NAN color values for some pixels, (may also fix plumiferos bad pixel problem from last bconf)

source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pixelshading.c
source/blender/render/intern/source/rayshade.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/shadeinput.c

index fa60a891ce191a46e3ab6362c3c39004f8b489bd..1e39150822884e2002669fd52f0a8c7a6ed5945b 100644 (file)
@@ -2148,8 +2148,16 @@ static void displace_render_face(Render *re, VlakRen *vlr, float *scale)
 {
        ShadeInput shi;
 
 {
        ShadeInput shi;
 
+       /* Warning, This is not that nice, and possibly a bit slow,
+       however some variables were not initialized properly in, unless using shade_input_initialize(...), we need to do a memset */
+       memset(&shi, 0, sizeof(ShadeInput)); 
+       /* end warning! - Campbell */
+       
        /* set up shadeinput struct for multitex() */
        /* set up shadeinput struct for multitex() */
-       shi.osatex= 0;          /* signal not to use dx[] and dy[] texture AA vectors */
+       
+       /* memset above means we dont need this */
+       /*shi.osatex= 0;*/              /* signal not to use dx[] and dy[] texture AA vectors */
+
        shi.vlr= vlr;           /* current render face */
        shi.mat= vlr->mat;              /* current input material */
        
        shi.vlr= vlr;           /* current render face */
        shi.mat= vlr->mat;              /* current input material */
        
index cffed99c73811aee4f49111557ce4acfd853e767..a1088d1a920b2437cf65efeec54353194e8b7113 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include <math.h>
  */
 
 #include <math.h>
+#include <string.h>
 #include "BLI_arithb.h"
 
 /* External modules: */
 #include "BLI_arithb.h"
 
 /* External modules: */
@@ -130,6 +131,12 @@ static void render_lighting_halo(HaloRen *har, float *colf)
                
                if(lar->mode & LA_TEXTURE) {
                        ShadeInput shi;
                
                if(lar->mode & LA_TEXTURE) {
                        ShadeInput shi;
+                       
+                       /* Warning, This is not that nice, and possibly a bit slow,
+                       however some variables were not initialized properly in, unless using shade_input_initialize(...), we need to do a memset */
+                       memset(&shi, 0, sizeof(ShadeInput)); 
+                       /* end warning! - Campbell */
+                       
                        VECCOPY(shi.co, rco);
                        shi.osatex= 0;
                        do_lamp_tex(lar, lv, &shi, lacol);
                        VECCOPY(shi.co, rco);
                        shi.osatex= 0;
                        do_lamp_tex(lar, lv, &shi, lacol);
index 69e90a7537c30d91cf3228bef332cd2e9797931b..5038518e71ae6f5c51ce56fe64f703ffd8e53b15 100644 (file)
@@ -409,6 +409,11 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo
        float ref[3], maxsize=RE_ray_tree_max_size(R.raytree);
        float dist_mir = origshi->mat->dist_mir;
 
        float ref[3], maxsize=RE_ray_tree_max_size(R.raytree);
        float dist_mir = origshi->mat->dist_mir;
 
+       /* Warning, This is not that nice, and possibly a bit slow for every ray,
+       however some variables were not initialized properly in, unless using shade_input_initialize(...), we need to do a memset */
+       memset(&shi, 0, sizeof(ShadeInput)); 
+       /* end warning! - Campbell */
+       
        VECCOPY(isec.start, start);
        if (dist_mir > 0.0) {
                isec.end[0]= start[0]+dist_mir*vec[0];
        VECCOPY(isec.start, start);
        if (dist_mir > 0.0) {
                isec.end[0]= start[0]+dist_mir*vec[0];
@@ -430,13 +435,13 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, flo
                shi.osatex= origshi->osatex;
                shi.depth= 1;                                   /* only used to indicate tracing */
                shi.thread= origshi->thread;
                shi.osatex= origshi->osatex;
                shi.depth= 1;                                   /* only used to indicate tracing */
                shi.thread= origshi->thread;
-               shi.sample= 0;
+               //shi.sample= 0; // memset above, so dont need this
                shi.xs= origshi->xs;
                shi.ys= origshi->ys;
                shi.lay= origshi->lay;
                shi.passflag= SCE_PASS_COMBINED; /* result of tracing needs no pass info */
                shi.combinedflag= 0xFFFFFF;              /* ray trace does all options */
                shi.xs= origshi->xs;
                shi.ys= origshi->ys;
                shi.lay= origshi->lay;
                shi.passflag= SCE_PASS_COMBINED; /* result of tracing needs no pass info */
                shi.combinedflag= 0xFFFFFF;              /* ray trace does all options */
-               shi.do_preview= 0;
+               //shi.do_preview= 0; // memset above, so dont need this
                shi.light_override= origshi->light_override;
                shi.mat_override= origshi->mat_override;
                
                shi.light_override= origshi->light_override;
                shi.mat_override= origshi->mat_override;
                
@@ -1231,16 +1236,22 @@ static void ray_trace_shadow_tra(Isect *is, int depth, int traflag)
                float d= 1.0f;
                /* we got a face */
                
                float d= 1.0f;
                /* we got a face */
                
+               /* Warning, This is not that nice, and possibly a bit slow for every ray,
+               however some variables were not initialized properly in, unless using shade_input_initialize(...), we need to do a memset */
+               memset(&shi, 0, sizeof(ShadeInput)); 
+               /* end warning! - Campbell */
+               
                shi.depth= 1;                                   /* only used to indicate tracing */
                shi.mask= 1;
                shi.depth= 1;                                   /* only used to indicate tracing */
                shi.mask= 1;
-               shi.osatex= 0;
+               
+               /*shi.osatex= 0;
                shi.thread= shi.sample= 0;
                shi.lay= 0;
                shi.passflag= 0;
                shi.combinedflag= 0;
                shi.do_preview= 0;
                shi.light_override= NULL;
                shi.thread= shi.sample= 0;
                shi.lay= 0;
                shi.passflag= 0;
                shi.combinedflag= 0;
                shi.do_preview= 0;
                shi.light_override= NULL;
-               shi.mat_override= NULL;
+               shi.mat_override= NULL;*/
                
                shade_ray(is, &shi, &shr);
                if (traflag & RAY_TRA)
                
                shade_ray(is, &shi, &shr);
                if (traflag & RAY_TRA)
@@ -1300,6 +1311,12 @@ int ray_trace_shadow_rad(ShadeInput *ship, ShadeResult *shr)
                
                if(RE_ray_tree_intersect(R.raytree, &isec)) {
                        float fac;
                
                if(RE_ray_tree_intersect(R.raytree, &isec)) {
                        float fac;
+                       
+                       /* Warning, This is not that nice, and possibly a bit slow for every ray,
+                       however some variables were not initialized properly in, unless using shade_input_initialize(...), we need to do a memset */
+                       memset(&shi, 0, sizeof(ShadeInput)); 
+                       /* end warning! - Campbell */
+                       
                        shade_ray(&isec, &shi, &shr_t);
                        fac= isec.labda*isec.labda;
                        fac= 1.0f;
                        shade_ray(&isec, &shi, &shr_t);
                        fac= isec.labda*isec.labda;
                        fac= 1.0f;
index 3eda349eef946f7e2b9c0643049708889d3d40ea..e2f331afafdb8589fff6822afc1b4383745f0be2 100644 (file)
@@ -296,7 +296,7 @@ static void lamphalo_tile(RenderPart *pa, RenderLayer *rl)
        long *rd= pa->rectdaps;
        int x, y, *rz= pa->rectz;
        
        long *rd= pa->rectdaps;
        int x, y, *rz= pa->rectz;
        
-       shade_input_initialize(&shi, pa, rl, 0);
+       shade_input_initialize(&shi, pa, rl, 0); /* this zero's ShadeInput for us */
        
        for(y=pa->disprect.ymin; y<pa->disprect.ymax; y++) {
                for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, rz++, pass+=4) {
        
        for(y=pa->disprect.ymin; y<pa->disprect.ymax; y++) {
                for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, rz++, pass+=4) {
index a6f4108c9df69b1cf1017912a7526e42ba6b58e4..d862729317b7df0b1ab6bda916657574da5fea06 100644 (file)
@@ -1187,7 +1187,9 @@ void shade_input_set_shade_texco(ShadeInput *shi)
                                }
                        }
                }
                                }
                        }
                }
-       }       
+       } /* else {
+        Note! For raytracing winco is not set, important because thus means all shader input's need to have their variables set to zero else in-initialized values are used
+       */
 }
 
 /* ****************** ShadeSample ************************************** */
 }
 
 /* ****************** ShadeSample ************************************** */