Bugfix #2841
authorTon Roosendaal <ton@blender.org>
Mon, 21 Nov 2005 22:47:23 +0000 (22:47 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 21 Nov 2005 22:47:23 +0000 (22:47 +0000)
Ancient issue with Image bumpmap & orientation... this report was about
UV textures, which flipped bump direction when UV coordinates rotate.
So... time to dive deeper into it, and I found a very bad old construction
in the way image textures handled bump normals. Instead of using the
correct dx,dy vectors it was calculating the boundbox for it, and applied
it as such (loosing negative direction for the dx or dy that way).

Anyhoo! To make a long story short; the weird "correct Nor Map" option
now can be removed... but requires careful testing!

Here's renders from file I got from env, 239 means old and 240 is this cvs.

http://www.blender.org/bf/dino239.jpg
http://www.blender.org/bf/dino240.jpg

http://www.blender.org/bf/dino239a.jpg
http://www.blender.org/bf/dino240a.jpg

Note the much finer detail, and the more consistant normals direction.
No, go render testing dudes!

source/blender/render/intern/source/imagetexture.c
source/blender/render/intern/source/texture.c

index 50b6178dcdc3f2eddeb3c3d1e79d96756fa30e2f..2a7d794249062e92d07387f96baa5767f06c3640 100644 (file)
@@ -643,10 +643,16 @@ int imagewraposa(Tex *tex, Image *ima, float *texvec, float *dxt, float *dyt, Te
                maxy= MAX3(dxt[1],dyt[1],dxt[1]+dyt[1] );
 
                /* tex_sharper has been removed */
-
                minx= tex->filtersize*(maxx-minx)/2.0f;
                miny= tex->filtersize*(maxy-miny)/2.0f;
                
+               if(tex->filtersize!=1.0f) {
+                       dxt[0]*= tex->filtersize;
+                       dxt[1]*= tex->filtersize;
+                       dyt[0]*= tex->filtersize;
+                       dyt[1]*= tex->filtersize;
+               }
+
                if(tex->imaflag & TEX_IMAROT) SWAP(float, minx, miny);
                
                if(minx>0.25) minx= 0.25;
@@ -781,14 +787,14 @@ int imagewraposa(Tex *tex, Image *ima, float *texvec, float *dxt, float *dyt, Te
                        
                        if(texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
                                /* a bit extra filter */
-                               minx*= 1.35f;
-                               miny*= 1.35f;
+                               //minx*= 1.35f;
+                               //miny*= 1.35f;
                                
-                               boxsample(ibuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, texres);
+                               boxsample(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres);
                                val1= texres->tr+texres->tg+texres->tb;
-                               boxsample(ibuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &texr);
+                               boxsample(ibuf, fx-minx+dxt[0], fy-miny+dxt[1], fx+minx+dxt[0], fy+miny+dxt[1], &texr);
                                val2= texr.tr + texr.tg + texr.tb;
-                               boxsample(ibuf, fx-2.0f*minx, fy-miny, fx+minx, fy+2.0f*miny, &texr);
+                               boxsample(ibuf, fx-minx+dyt[0], fy-miny+dyt[1], fx+minx+dyt[0], fy+miny+dyt[1], &texr);
                                val3= texr.tr + texr.tg + texr.tb;
        
                                if(previbuf!=ibuf) {  /* interpolate */
@@ -810,9 +816,9 @@ int imagewraposa(Tex *tex, Image *ima, float *texvec, float *dxt, float *dyt, Te
                                        }
                                        
                                        val1= dy*val1+ dx*(texr.tr + texr.tg + texr.tb);
-                                       boxsample(previbuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &texr);
+                                       boxsample(previbuf, fx-minx+dxt[0], fy-miny+dxt[1], fx+minx+dxt[0], fy+miny+dxt[1], &texr);
                                        val2= dy*val2+ dx*(texr.tr + texr.tg + texr.tb);
-                                       boxsample(previbuf, fx-2.0f*minx, fy-miny, fx+minx, fy+2.0f*miny, &texr);
+                                       boxsample(previbuf, fx-minx+dyt[0], fy-miny+dyt[1], fx+minx+dyt[0], fy+miny+dyt[1], &texr);
                                        val3= dy*val3+ dx*(texr.tr + texr.tg + texr.tb);
                                }
 
@@ -856,16 +862,14 @@ int imagewraposa(Tex *tex, Image *ima, float *texvec, float *dxt, float *dyt, Te
                        if(texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
                                
                                /* a bit extra filter */
-                               minx*= 1.35f;
-                               miny*= 1.35f;
+                               //minx*= 1.35f;
+                               //miny*= 1.35f;
                                
-                               boxsample(ibuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, texres);
+                               boxsample(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres);
                                val1= texres->tr+texres->tg+texres->tb;
-
-                               boxsample(ibuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &texr);
+                               boxsample(ibuf, fx-minx+dxt[0], fy-miny+dxt[1], fx+minx+dxt[0], fy+miny+dxt[1], &texr);
                                val2= texr.tr + texr.tg + texr.tb;
-                               
-                               boxsample(ibuf, fx-2.0f*minx, fy-miny, fx+miny, fy+2.0f*miny, &texr);
+                               boxsample(ibuf, fx-minx+dyt[0], fy-miny+dyt[1], fx+minx+dyt[0], fy+miny+dyt[1], &texr);
                                val3= texr.tr + texr.tg + texr.tb;
 
                                /* don't switch x or y! */
index c33c71d90829554012982178b08560f6320765ed..55e546a89f93a673504860bb759ffdc1387526aa 100644 (file)
@@ -1600,12 +1600,9 @@ void do_material_tex(ShadeInput *shi)
                                }
                        }
                        else {
-//                             texres.ta*= stencilTin;
                                Tnor*= stencilTin;
-//                             texres.tin*= stencilTin;
                        }
                        
-                       
                        if(texres.nor) {
                                if((rgbnor & TEX_NOR)==0) {
                                        /* make our own normal */
@@ -1636,7 +1633,7 @@ void do_material_tex(ShadeInput *shi)
                                        warpvec[2]= mtex->warpfac*texres.nor[2];
                                        warpdone= 1;
                                }
-                               
+#if 0                          
                                if(mtex->texflag & MTEX_VIEWSPACE) {
                                        // rotate to global coords
                                        if(mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) {
@@ -1650,6 +1647,7 @@ void do_material_tex(ShadeInput *shi)
                                                }
                                        }
                                }
+#endif                         
                        }
 
                        /* mapping */