Thread render fix; using ray-transp + mirror didnt work...
authorTon Roosendaal <ton@blender.org>
Mon, 3 Jan 2005 20:02:55 +0000 (20:02 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 3 Jan 2005 20:02:55 +0000 (20:02 +0000)
the face-normal had to be local too...

source/blender/render/extern/include/render_types.h
source/blender/render/intern/source/ray.c
source/blender/render/intern/source/rendercore.c
source/blender/src/buttons_editing.c
source/blender/src/buttons_shading.c

index e7b495ee566ebef992e0cf5163f08213c7d8fa45..05a5380847c64752f2ceef342dfd45fb05728338 100644 (file)
@@ -82,7 +82,7 @@ typedef struct ShadeInput
        
        /* texture coordinates */
        float lo[3], gl[3], uv[3], ref[3], orn[3], winco[3], sticky[3], vcol[3], rad[3];
-       float vn[3], view[3], refcol[4], displace[3];
+       float vn[3], facenor[3], view[3], refcol[4], displace[3];
        /* dx/dy OSA coordinates */
        float dxco[3], dyco[3];
        float dxlo[3], dylo[3], dxgl[3], dygl[3], dxuv[3], dyuv[3];
@@ -94,7 +94,7 @@ typedef struct ShadeInput
        float dxrefract[3], dyrefract[3];
        
        float xs, ys;   /* pixel to be rendered */
-       short osatex;
+       short osatex, puno;
        int mask;
        int depth;
        
index 9e11501ee22f96edee47570ecaea023af4970651..e1731d2dbb862cb97c7e75685e5a1a321b082e67 100644 (file)
@@ -1283,7 +1283,7 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
 {
        VlakRen *vlr= is->vlr;
        float l;
-       int osatex= 0, flip= 0;
+       int osatex= 0;
        
        /* set up view vector */
        VECCOPY(shi->view, is->vec);
@@ -1303,12 +1303,15 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
        /* face normal, check for flip */
        l= vlr->n[0]*shi->view[0]+vlr->n[1]*shi->view[1]+vlr->n[2]*shi->view[2];
        if(l<0.0) {     
-               flip= 1;
-               vlr->n[0]= -vlr->n[0];
-               vlr->n[1]= -vlr->n[1];
-               vlr->n[2]= -vlr->n[2];
+               shi->facenor[0]= -vlr->n[0];
+               shi->facenor[1]= -vlr->n[1];
+               shi->facenor[2]= -vlr->n[2];
                // only flip lower 4 bits
-               vlr->puno= vlr->puno ^ 15;
+               shi->puno= vlr->puno ^ 15;
+       }
+       else {
+               VECCOPY(shi->facenor, vlr->n);
+               shi->puno= vlr->puno;
        }
        
        // Osa structs we leave unchanged now
@@ -1317,7 +1320,7 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
        shi->dxco[0]= shi->dxco[1]= shi->dxco[2]= 0.0;
        shi->dyco[0]= shi->dyco[1]= shi->dyco[2]= 0.0;
        
-       // but, set O structs zero where it can confuse texture code
+       // but, set Osa stuff to zero where it can confuse texture code
        if(shi->mat->texco & (TEXCO_NORM|TEXCO_REFL) ) {
                shi->dxno[0]= shi->dxno[1]= shi->dxno[2]= 0.0;
                shi->dyno[0]= shi->dyno[1]= shi->dyno[2]= 0.0;
@@ -1343,25 +1346,18 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
                if(shi->translucency!=0.0) {
                        ShadeResult shr_t;
                        VecMulf(shi->vn, -1.0);
-                       VecMulf(vlr->n, -1.0);
+                       VecMulf(shi->facenor, -1.0);
                        shade_lamp_loop(shi, &shr_t);
                        shr->diff[0]+= shi->translucency*shr_t.diff[0];
                        shr->diff[1]+= shi->translucency*shr_t.diff[1];
                        shr->diff[2]+= shi->translucency*shr_t.diff[2];
                        VecMulf(shi->vn, -1.0);
-                       VecMulf(vlr->n, -1.0);
+                       VecMulf(shi->facenor, -1.0);
                }
        }
        
        SWAP(int, osatex, shi->osatex);  // XXXXX!!!!
 
-       if(flip) {      
-               vlr->n[0]= -vlr->n[0];
-               vlr->n[1]= -vlr->n[1];
-               vlr->n[2]= -vlr->n[2];
-               // only flip lower 4 bits
-               vlr->puno= vlr->puno ^ 15;
-       }
 }
 
 static void refraction(float *refract, float *n, float *view, float index)
@@ -1717,7 +1713,7 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr)
                        fb= shi->mirb;
 
                        if(vlr->flag & R_SMOOTH) 
-                               reflection(vec, shi->vn, shi->view, vlr->n);
+                               reflection(vec, shi->vn, shi->view, shi->facenor);
                        else
                                reflection(vec, shi->vn, shi->view, NULL);
        
@@ -1999,7 +1995,7 @@ void ray_ao(ShadeInput *shi, World *wrld, float *shadfac)
        }
        else {
                bias= 0.0;
-               nrm= shi->vlr->n;
+               nrm= shi->facenor;
        }
        
        vec= sphere_sampler(wrld->aomode, wrld->aosamp, floor(shi->xs+0.5), floor(shi->ys+0.5) );
index c0654bf1ca3aee97a07cabf5c32869347bb66f97..4744a9664d958e3f288906196ec76860b02f3aad 100644 (file)
@@ -1245,7 +1245,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
                                        float shad[4];
                                        
                                        /* single sided? */
-                                       if( vlr->n[0]*lv[0] + vlr->n[1]*lv[1] + vlr->n[2]*lv[2] > -0.01) {
+                                       if( shi->facenor[0]*lv[0] + shi->facenor[1]*lv[1] + shi->facenor[2]*lv[2] > -0.01) {
                                                ray_shadow(shi, lar, shad);
                                                shadfac[3]+= shad[3];
                                                ir+= 1.0;
@@ -1760,7 +1760,7 @@ void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, i
                }
        }
        else {
-               VECCOPY(shi->vn, vlr->n);
+               VECCOPY(shi->vn, shi->facenor);
        }
 
        /* texture coordinates. shi->dxuv shi->dyuv have been set */
@@ -1958,10 +1958,14 @@ void *shadepixel(float x, float y, int vlaknr, int mask, float *col)
                shi.har= shi.mat->har;
                if((shi.mat->mode & MA_RAYMIRROR)==0) shi.ray_mirror= 0.0;
                shi.osatex= (shi.mat->texco & TEXCO_OSA);
-
+               
+               /* copy the face normal (needed because it gets flipped for tracing */
+               VECCOPY(shi.facenor, vlr->n);
+               shi.puno= vlr->puno;
+               
                v1= vlr->v1;
-               dvlak= v1->co[0]*vlr->n[0]+v1->co[1]*vlr->n[1]+v1->co[2]*vlr->n[2];
-
+               dvlak= v1->co[0]*shi.facenor[0]+v1->co[1]*shi.facenor[1]+v1->co[2]*shi.facenor[2];
+               
                /* COXYZ AND VIEW VECTOR  */
                shi.view[0]= (x+(R.xstart)+bluroffsx +0.5);
 
@@ -1983,7 +1987,7 @@ void *shadepixel(float x, float y, int vlaknr, int mask, float *col)
                        shi.view[2]= -panosi*u + panoco*v;
                }
 
-               deler= vlr->n[0]*shi.view[0] + vlr->n[1]*shi.view[1] + vlr->n[2]*shi.view[2];
+               deler= shi.facenor[0]*shi.view[0] + shi.facenor[1]*shi.view[1] + shi.facenor[2]*shi.view[2];
                if (deler!=0.0) fac= zcor= dvlak/deler;
                else fac= zcor= 0.0;
                
@@ -1993,8 +1997,8 @@ void *shadepixel(float x, float y, int vlaknr, int mask, float *col)
                
                /* pixel dx/dy for render coord */
                if(shi.osatex || (R.r.mode & R_SHADOW) ) {
-                       float u= dvlak/(deler-vlr->n[0]);
-                       float v= dvlak/(deler- R.ycor*vlr->n[1]);
+                       float u= dvlak/(deler-shi.facenor[0]);
+                       float v= dvlak/(deler- R.ycor*shi.facenor[1]);
 
                        shi.dxco[0]= shi.co[0]- (shi.view[0]-1.0)*u;
                        shi.dxco[1]= shi.co[1]- (shi.view[1])*u;
@@ -2094,13 +2098,13 @@ void *shadepixel(float x, float y, int vlaknr, int mask, float *col)
                        ShadeResult shr_t;
                        
                        VecMulf(shi.vn, -1.0);
-                       VecMulf(shi.vlr->n, -1.0);
+                       VecMulf(shi.facenor, -1.0);
                        shade_lamp_loop(&shi, &shr_t);
                        shr.diff[0]+= shi.translucency*shr_t.diff[0];
                        shr.diff[1]+= shi.translucency*shr_t.diff[1];
                        shr.diff[2]+= shi.translucency*shr_t.diff[2];
                        VecMulf(shi.vn, -1.0);
-                       VecMulf(shi.vlr->n, -1.0);
+                       VecMulf(shi.facenor, -1.0);
                }
                
                if(R.r.mode & R_RAYTRACE) {
index 6b27cf32113dd73f2241a642970ee7b549494b5f..bab09f7496cd7b15d963d1456b2bb9a2812a005d 100644 (file)
@@ -2557,7 +2557,7 @@ static void editing_panel_mesh_uvautocalculation(void)
 
        uiBlockBeginAlign(block);
        uiDefBut(block, BUT, B_UVAUTO_CUBE,"Cube",315,row,200,butH, 0, 0, 0, 0, 0, "Applies cube UV mapping");
-       uiDefButF(block, NUM,B_UVAUTO_CUBESIZE ,"Size:",315,row-butHB,200,butH, &uv_calc_cubesize, 0.0001, 100.0, 10, 0, "Defines the cubemap size");
+       uiDefButF(block, NUM,B_UVAUTO_CUBESIZE ,"Size:",315,row-butHB,200,butH, &uv_calc_cubesize, 0.0001, 100.0, 10, 3, "Defines the cubemap size");
        uiBlockEndAlign(block);
        row-= 2*butHB+butS;
 
@@ -2568,7 +2568,7 @@ static void editing_panel_mesh_uvautocalculation(void)
 
        uiBlockBeginAlign(block);
        uiDefBut(block, BUT, B_UVAUTO_CYLINDER,"Cylinder",315,row,200,butH, 0, 0, 0, 0, 0, "Applies cylindrical UV mapping");
-       uiDefButF(block, NUM,B_UVAUTO_CYLRADIUS ,"Radius:",315,row-butHB,200,butH, &uv_calc_radius, 0.1, 100.0, 10, 0, "Defines the radius of the UV mapping cylinder");
+       uiDefButF(block, NUM,B_UVAUTO_CYLRADIUS ,"Radius:",315,row-butHB,200,butH, &uv_calc_radius, 0.1, 100.0, 10, 3, "Defines the radius of the UV mapping cylinder");
        uiBlockEndAlign(block);
        row-= 2*butHB+butS;
 
index 9bdb533c1e4b4d1a1c126317cfc6514f19e70672..d5db271367b8e25767c9b67ebd275fc66efeccda 100644 (file)
@@ -1154,7 +1154,7 @@ static void texture_panel_envmap(Tex *tex)
                        uiDefButS(block, NUM, B_ENV_FREE,       "CubeRes",              160,90,150,20, &env->cuberes, 50, 2048.0, 0, 0, "Sets the pixel resolution of the rendered environment map");
 
                uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_TEXPRV, "Filter :",                             10,65,150,20, &tex->filtersize, 0.1, 25.0, 0, 0, "Adjusts sharpness or blurriness of the reflection"),
+               uiDefButF(block, NUM, B_TEXPRV, "Filter :",                             10,65,150,20, &tex->filtersize, 0.1, 25.0, 0, 3, "Adjusts sharpness or blurriness of the reflection"),
                uiDefButS(block, NUM, B_ENV_FREE, "Depth:",                             160,65,150,20, &env->depth, 0, 5.0, 0, 0, "Sets the number of times a map will be rendered recursively mirror effects"),
                uiDefButF(block, NUM, REDRAWVIEW3D,     "ClipSta",              10,40,150,20, &env->clipsta, 0.01, 50.0, 100, 0, "Sets start value for clipping: objects nearer than this are not visible to map");
                uiDefButF(block, NUM, 0,        "ClipEnd",                                      160,40,150,20, &env->clipend, 0.1, 5000.0, 1000, 0, "Sets end value for clipping beyond which objects are not visible to map");
@@ -1278,7 +1278,7 @@ static void texture_panel_image(Tex *tex)
 
        /* crop extend clip */
        
-       uiDefButF(block, NUM, B_TEXPRV, "Filter :",                     10,92,150,19, &tex->filtersize, 0.1, 25.0, 0, 0, "Sets the filter size used by mipmap and interpol");
+       uiDefButF(block, NUM, B_TEXPRV, "Filter :",                     10,92,150,19, &tex->filtersize, 0.1, 25.0, 0, 3, "Sets the filter size used by mipmap and interpol");
        uiDefButS(block, TOG|BIT|11, B_NOP, "Normal Map",       160,92,150,19, &tex->imaflag, 0.1, 25.0, 0, 0, "Use image RGB values for normal mapping");
 
        uiBlockBeginAlign(block);