derivative maps were not working correctly with UV scale (the texture setting size)

This commit is contained in:
Morten Mikkelsen 2012-01-03 22:09:22 +00:00
parent b197a7ea69
commit 5fbd6223c5
2 changed files with 2 additions and 2 deletions

@ -1120,7 +1120,7 @@ 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 /= sqrtf(ima_x*ima_y);
if(found_deriv_map) norfac /= MAX2(sqrtf(ima_x*mtex->size[0]*ima_y*mtex->size[1]), FLT_EPSILON);
tnorfac = GPU_uniform(&norfac);

@ -1969,7 +1969,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
{
auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale;
}
auto_bump /= sqrtf((float) (dimx*dimy));
auto_bump /= MAX2(sqrtf((float) (dimx*dimy)*mtex->size[0]*mtex->size[1]), FLT_EPSILON);
// this variant using a derivative map is described here
// http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html