calculate factor before using MAX2 macro
authorMorten Mikkelsen <mikkelsen7@gmail.com>
Tue, 3 Jan 2012 22:18:52 +0000 (22:18 +0000)
committerMorten Mikkelsen <mikkelsen7@gmail.com>
Tue, 3 Jan 2012 22:18:52 +0000 (22:18 +0000)
source/blender/gpu/intern/gpu_material.c
source/blender/render/intern/source/render_texture.c

index e23428fb99159abe1c7c722c5bac14091e9c0ff1..bf575e092dc02fc03225d04c70ddd3f4e494ae62 100644 (file)
@@ -1120,7 +1120,11 @@ static void do_material_tex(GPUShadeInput *shi)
                                                // to inverting the bump map. Should this ever change
                                                // this negate must be removed.
                                                norfac = -hScale * mtex->norfac;
-                                               if(found_deriv_map) norfac /= MAX2(sqrtf(ima_x*mtex->size[0]*ima_y*mtex->size[1]), FLT_EPSILON);
+                                               if(found_deriv_map)
+                                               {
+                                                       float fVirtDim = sqrtf(ima_x*mtex->size[0]*ima_y*mtex->size[1]);
+                                                       norfac /= MAX2(fVirtDim, FLT_EPSILON);
+                                               }
 
                                                tnorfac = GPU_uniform(&norfac);
 
index 0e219cdb799efffc25ecd42d69f3acb7557aecf5..d9cabf0515542b6f9166b5ef3289cff969f9fd93 100644 (file)
@@ -1969,7 +1969,10 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
                {
                        auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale;
                }
-               auto_bump /= MAX2(sqrtf((float) (dimx*dimy)*mtex->size[0]*mtex->size[1]), FLT_EPSILON);
+               {
+                       float fVirtDim = sqrtf((float) (dimx*dimy)*mtex->size[0]*mtex->size[1]);
+                       auto_bump /= MAX2(fVirtDim, FLT_EPSILON);
+               }
                
                // this variant using a derivative map is described here
                // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html