From a550cca5d824e8619c205a7f840a7e762a431c18 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 30 Jan 2011 14:19:12 +0000 Subject: Bugfix #25855 New bump code: option "Texture space" only works for image textures. It appears this option is some kind of "fake normal map" actually. Needs nicer name... maybe "Image space". Now it ignores the option when no image texture is used. --- source/blender/render/intern/source/texture.c | 32 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 07ea6bb9b4b..a7a6727c508 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -1912,7 +1912,8 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T // TODO: solve this Hscale issue more elegantly. if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) - Hscale *= 130.0f; + if(tex->ima) + Hscale *= 130.0f; if(!(mtex->texflag & MTEX_5TAP_BUMP)) { // compute height derivatives with respect to output image pixel coordinates x and y @@ -2033,10 +2034,12 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T abs_fDet = ntap_bump->sgn_det * fDet; if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { - // crazy hack solution that gives results similar to normal mapping - part 1 - normalize_v3(ntap_bump->vR1); - normalize_v3(ntap_bump->vR2); - abs_fDet = 1.0f; + if(tex->ima) { + // crazy hack solution that gives results similar to normal mapping - part 1 + normalize_v3(ntap_bump->vR1); + normalize_v3(ntap_bump->vR2); + abs_fDet = 1.0f; + } } for(xyz=0; xyz<3; xyz++) @@ -2053,14 +2056,17 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { - // crazy hack solution that gives results similar to normal mapping - part 2 - float vec[2]; - vec[0] = tex->ima->gen_x*dxt[0]; - vec[1] = tex->ima->gen_y*dxt[1]; - dHdx *= 1.0f/len_v2(vec); - vec[0] = tex->ima->gen_x*dyt[0]; - vec[1] = tex->ima->gen_y*dyt[1]; - dHdy *= 1.0f/len_v2(vec); + if(tex->ima) { + // crazy hack solution that gives results similar to normal mapping - part 2 + float vec[2]; + + vec[0] = tex->ima->gen_x*dxt[0]; + vec[1] = tex->ima->gen_y*dxt[1]; + dHdx *= 1.0f/len_v2(vec); + vec[0] = tex->ima->gen_x*dyt[0]; + vec[1] = tex->ima->gen_y*dyt[1]; + dHdy *= 1.0f/len_v2(vec); + } } // subtract the surface gradient from vNacc -- cgit v1.2.3