float *nvec = texres->nor;
texres->nor = NULL;
- if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) {
- if(tex->ima)
- Hscale *= 13.0f; // appears to be a sensible default value
- } else
- Hscale *= 0.1f; // factor 0.1 proved to look like the previous bump code
+ if(found_deriv_map==0) {
+ if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) {
+ if(tex->ima)
+ Hscale *= 13.0f; // appears to be a sensible default value
+ } else
+ Hscale *= 0.1f; // factor 0.1 proved to look like the previous bump code
+ }
if( !ntap_bump->init_done ) {
copy_v3_v3(ntap_bump->vNacc, shi->vn);
}
if(found_deriv_map) {
- float dBdu, dBdv;
+ float dBdu, dBdv, auto_bump;
float s = 1; // negate this if flipped texture coordinate
texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres);
+
+ auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale;
+ auto_bump /= sqrtf((float) (dimx*dimy));
// this variant using a derivative map is described here
// http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html
- dBdu = Hscale*dimx*(2*texres->tr-1);
- dBdv = Hscale*dimy*(2*texres->tg-1);
+ dBdu = auto_bump*Hscale*dimx*(2*texres->tr-1);
+ dBdv = auto_bump*Hscale*dimy*(2*texres->tg-1);
dHdx = dBdu*dxt[0] + s * dBdv*dxt[1];
dHdy = dBdu*dyt[0] + s * dBdv*dyt[1];