diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-03-01 21:11:09 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-03-01 21:11:09 +0300 |
commit | 1b30b13a4d505ec293d1a7872c53a4bc735db92f (patch) | |
tree | fe44f30726e9d0b0e6e9e5c70717440b6a9175a1 /source/blender/render/intern/source/texture.c | |
parent | a3300bcac8f9658f1cac099d5d1520de6f2abc29 (diff) |
Fix #21227, #21346 and #21336: image texture wasn't centered correctly
when sculpting and using it from material nodes.
Diffstat (limited to 'source/blender/render/intern/source/texture.c')
-rw-r--r-- | source/blender/render/intern/source/texture.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 17ff1238061..9e89d101215 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -1311,18 +1311,18 @@ int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, localmtex.object= NULL; localmtex.texco= TEXCO_ORCO; - VECCOPY(texvec_l, texvec); + copy_v3_v3(texvec_l, texvec); if(dxt && dyt) { - VECCOPY(dxt_l, dxt); - VECCOPY(dyt_l, dyt); + copy_v3_v3(dxt_l, dxt); + copy_v3_v3(dyt_l, dyt); } else { - dxt_l[0]= dxt_l[1]= dxt_l[2]= 0.0f; - dyt_l[0]= dyt_l[1]= dyt_l[2]= 0.0f; + zero_v3(dxt_l); + zero_v3(dyt_l); } do_2d_mapping(&localmtex, texvec_l, NULL, NULL, dxt_l, dyt_l); - rgbnor= multitex(tex, texvec, dxt_l, dyt_l, osatex, texres, thread, which_output); + rgbnor= multitex(tex, texvec_l, dxt_l, dyt_l, osatex, texres, thread, which_output); } return rgbnor; @@ -2119,19 +2119,18 @@ void do_material_tex(ShadeInput *shi) } if( (mtex->mapto & MAP_NORM) ) { if(texres.nor) { - tex->norfac= mtex->norfac; + float norfac= mtex->norfac; /* we need to code blending modes for normals too once.. now 1 exception hardcoded */ if ((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP)) { /* qdn: for normalmaps, to invert the normalmap vector, it is better to negate x & y instead of subtracting the vector as was done before */ - tex->norfac = mtex->norfac; - if (tex->norfac < 0.0f) { + if (norfac < 0.0f) { texres.nor[0] = -texres.nor[0]; texres.nor[1] = -texres.nor[1]; } - fact = Tnor*fabs(tex->norfac); + fact = Tnor*fabs(norfac); if (fact>1.f) fact = 1.f; facm = 1.f-fact; if(mtex->normapspace == MTEX_NSPACE_TANGENT) { @@ -2179,15 +2178,15 @@ void do_material_tex(ShadeInput *shi) float nor[3], dot; if(shi->mat->mode & MA_TANGENT_V) { - shi->tang[0]+= Tnor*tex->norfac*texres.nor[0]; - shi->tang[1]+= Tnor*tex->norfac*texres.nor[1]; - shi->tang[2]+= Tnor*tex->norfac*texres.nor[2]; + shi->tang[0]+= Tnor*norfac*texres.nor[0]; + shi->tang[1]+= Tnor*norfac*texres.nor[1]; + shi->tang[2]+= Tnor*norfac*texres.nor[2]; } /* prevent bump to become negative normal */ - nor[0]= Tnor*tex->norfac*texres.nor[0]; - nor[1]= Tnor*tex->norfac*texres.nor[1]; - nor[2]= Tnor*tex->norfac*texres.nor[2]; + nor[0]= Tnor*norfac*texres.nor[0]; + nor[1]= Tnor*norfac*texres.nor[1]; + nor[2]= Tnor*norfac*texres.nor[2]; dot= 0.5f + 0.5f*INPR(nor, shi->vn); @@ -2212,11 +2211,11 @@ void do_material_tex(ShadeInput *shi) /* Now that most textures offer both Nor and Intensity, allow */ /* both to work, and let user select with slider. */ if(texres.nor) { - tex->norfac= mtex->norfac; + float norfac= mtex->norfac; - shi->displace[0]+= 0.2f*Tnor*tex->norfac*texres.nor[0]; - shi->displace[1]+= 0.2f*Tnor*tex->norfac*texres.nor[1]; - shi->displace[2]+= 0.2f*Tnor*tex->norfac*texres.nor[2]; + shi->displace[0]+= 0.2f*Tnor*norfac*texres.nor[0]; + shi->displace[1]+= 0.2f*Tnor*norfac*texres.nor[1]; + shi->displace[2]+= 0.2f*Tnor*norfac*texres.nor[2]; } if(rgbnor & TEX_RGB) { |