Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorten Mikkelsen <mikkelsen7@gmail.com>2012-01-04 02:18:52 +0400
committerMorten Mikkelsen <mikkelsen7@gmail.com>2012-01-04 02:18:52 +0400
commitaa1325ef55bce6792acfa8141f0bb53b7529d2a1 (patch)
treeded37df9dfbd1d0593cd797ab5735dbc6fed4f51
parent5fbd6223c56dc8696af20f1c0eda22401a955359 (diff)
calculate factor before using MAX2 macro
-rw-r--r--source/blender/gpu/intern/gpu_material.c6
-rw-r--r--source/blender/render/intern/source/render_texture.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index e23428fb991..bf575e092dc 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -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);
diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c
index 0e219cdb799..d9cabf05155 100644
--- a/source/blender/render/intern/source/render_texture.c
+++ b/source/blender/render/intern/source/render_texture.c
@@ -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