diff options
Diffstat (limited to 'source/blender/gpu/intern/gpu_material.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 274884000db..28624e9350c 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -906,6 +906,7 @@ static void do_material_tex(GPUShadeInput *shi) int init_done = 0, iBumpSpacePrev; GPUNodeLink *vNorg, *vNacc, *fPrevMagnitude; int iFirstTimeNMap=1; + int found_deriv_map = 0; GPU_link(mat, "set_value", GPU_uniform(&one), &stencil); @@ -1043,6 +1044,8 @@ static void do_material_tex(GPUShadeInput *shi) if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) { if(tex->type==TEX_IMAGE) { + found_deriv_map = tex->imaflag & TEX_DERIVATIVEMAP; + if(tex->imaflag & TEX_NORMALMAP) { /* normalmap image */ GPU_link(mat, "mtex_normal", texco, GPU_image(tex->ima, &tex->iuser), &tnor ); @@ -1082,9 +1085,10 @@ static void do_material_tex(GPUShadeInput *shi) GPU_link(mat, "mtex_blend_normal", tnorfac, shi->vn, newnor, &shi->vn); } - } else if( mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)) { + } else if( (mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)) || found_deriv_map) { /* ntap bumpmap image */ int iBumpSpace; + float ima_x, ima_y; float hScale = 0.1f; // compatibility adjustment factor for all bumpspace types float hScaleTex = 13.0f; // factor for scaling texspace bumps @@ -1142,9 +1146,24 @@ static void do_material_tex(GPUShadeInput *shi) iBumpSpacePrev = iBumpSpace; } + + // resolve texture resolution + if( (mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map ) { + ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, &tex->iuser); + ima_x= 512.0f; ima_y= 512.f; // prevent calling textureSize, glsl 1.3 only + if(ibuf) { + ima_x= ibuf->x; + ima_y= ibuf->y; + } + } - if( mtex->texflag & MTEX_3TAP_BUMP ) + if(found_deriv_map) { + GPU_link( mat, "mtex_bump_deriv", + texco, GPU_image(tex->ima, &tex->iuser), GPU_uniform(&ima_x), GPU_uniform(&ima_y), tnorfac, + &dBs, &dBt ); + } + else if( mtex->texflag & MTEX_3TAP_BUMP ) GPU_link( mat, "mtex_bump_tap3", texco, GPU_image(tex->ima, &tex->iuser), tnorfac, &dBs, &dBt ); @@ -1155,12 +1174,6 @@ static void do_material_tex(GPUShadeInput *shi) if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { - float ima_x= 512.0f, ima_y= 512.f; // prevent calling textureSize, glsl 1.3 only - ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, &tex->iuser); - if(ibuf) { - ima_x= ibuf->x; - ima_y= ibuf->y; - } GPU_link( mat, "mtex_bump_apply_texspace", fDet, dBs, dBt, vR1, vR2, |