From 5f237e67cc8cdd829ec53bdd228050086251e123 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 12 Apr 2005 11:45:06 +0000 Subject: [PATCH] Bug fix #2323 The addition in 2.36 to correct bumpmapping for View and Object rotation, made many nice bumpmap setups in older files less nice. Especially apparent when you apply "flipped" mappings in "Map Input" Panel, like map the X to Z and the Z to X. A correction then gives wrong results. Since the "correct bumpmapping" is actually a new option, causing extra rendertime too, I've made it an option now. With the "Map To" Panel being fully used, I've put the new button option (temporally I hope) in the first "Texture" Panel in material context. Will be updated in release log page! --- source/blender/makesdna/DNA_texture_types.h | 1 + source/blender/render/intern/source/texture.c | 14 ++++++-------- source/blender/src/buttons_shading.c | 5 ++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 14617018910..ccf1e29fff7 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -283,6 +283,7 @@ typedef struct Tex { #define MTEX_STENCIL 2 #define MTEX_NEGATIVE 4 #define MTEX_ALPHAMIX 8 +#define MTEX_VIEWSPACE 16 /* blendtype */ #define MTEX_BLEND 0 diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index cbce271da7f..9b2f1e891de 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -1620,11 +1620,10 @@ void do_material_tex(ShadeInput *shi) warpvec[2]= mtex->warpfac*texres.nor[2]; warpdone= 1; } -#if 0 - // rotate to global coords - if(mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) { - // hrms, for sphere/tube map this rotating doesn't work nice - if(mtex->mapping==MTEX_FLAT || mtex->mapping==MTEX_CUBE) { + + if(mtex->texflag & MTEX_VIEWSPACE) { + // rotate to global coords + if(mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) { if(shi->vlr && shi->vlr->ob) { float len= Normalise(texres.nor); // can be optimized... (ton) @@ -1635,7 +1634,6 @@ void do_material_tex(ShadeInput *shi) } } } -#endif } /* mapping */ @@ -1726,10 +1724,10 @@ void do_material_tex(ShadeInput *shi) } if(mtex->maptoneg & MAP_DISPLACE) { - factt= (0.5-texres.tin)*mtex->dispfac; facmm= 1.0-factt; + factt= (texres.tin-0.5)*mtex->dispfac; facmm= 1.0-factt; } else { - factt= (texres.tin-0.5)*mtex->dispfac; facmm= 1.0-factt; + factt= (0.5-texres.tin)*mtex->dispfac; facmm= 1.0-factt; } if(mtex->blendtype==MTEX_BLEND) { diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index b723f52d528..6121ae0df0e 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -2774,7 +2774,10 @@ static void material_panel_texture(Material *ma) else uiDefIconBut(block, BUT, 0, ICON_PARLIB, 219,130,21,20, 0, 0, 0, 0, 0, ""); } uiBlockSetCol(block, TH_AUTO); - uiDefBut(block, BUT, B_TEXCLEAR, "Clear", 122, 130, 72, 20, 0, 0, 0, 0, 0, "Erases link to texture"); + uiDefBut(block, BUT, B_TEXCLEAR, "Clear", 122, 130, 72, 20, 0, 0, 0, 0, 0, "Erases link to texture"); + + uiDefButS(block, TOG|BIT|4, B_DIFF, "Correct Nor Map", 100,18,163,19, &(mtex->texflag), 0, 0, 0, 0, "This channel will correct normal mapping for View space and Object space"); + } else uiDefButS(block, TOG, B_EXTEXBROWSE, "Add New" ,100, 150, 163, 20, &(G.buts->texnr), -1.0, 32767.0, 0, 0, "Adds a new texture datablock");