diff options
author | Ton Roosendaal <ton@blender.org> | 2004-12-07 20:46:14 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-12-07 20:46:14 +0300 |
commit | 0e7ac575c097f834d1151048e5ce7d44c4f825c7 (patch) | |
tree | 383355423d28bf8e051a484bf2729cac0ce2e698 /source/blender | |
parent | d0cdf2bd4b237c321e61278a94be4fd04eeb3619 (diff) |
Sneak in little feature for texture editing pleasure;
- New channel for "Map to" added, "Warp"
- Use the slider next to the option to set amount of influence the texture
will have on the coordinates of the next texture.
- Warp uses for this the same values as for Normal or Displacement mapping
- Warp remains active for all channels, until replaced (or zeroed).
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesdna/DNA_material_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/texture.c | 21 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 5 |
4 files changed, 23 insertions, 6 deletions
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 28f3a7551c7..fa2447a12f4 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -209,6 +209,7 @@ typedef struct Material { #define MAP_TRANSLU 1024 #define MAP_AMB 2048 #define MAP_DISPLACE 4096 +#define MAP_WARP 8192 /* pr_type */ #define MA_FLAT 0 diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index e6586936f9c..634d9e887eb 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -59,7 +59,7 @@ typedef struct MTex { float colfac, norfac, varfac; float dispfac; - short pad1, pad2; + float warpfac; } MTex; diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 9e791fc5809..e8aac6da803 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -1310,8 +1310,8 @@ void do_material_tex(ShadeInput *shi) Tex *tex; float *co = NULL, *dx = NULL, *dy = NULL; float fact, facm, factt, facmm, stencilTin=1.0; - float texvec[3], dxt[3], dyt[3], tempvec[3], norvec[3], Tnor=1.0; - int tex_nr, rgbnor= 0; + float texvec[3], dxt[3], dyt[3], tempvec[3], norvec[3], warpvec[3], Tnor=1.0; + int tex_nr, rgbnor= 0, warpdone=0; /* here: test flag if there's a tex (todo) */ @@ -1374,12 +1374,17 @@ void do_material_tex(ShadeInput *shi) else continue; // can happen when texco defines disappear and it renders old files /* de pointer defines if bumping happens */ - if(mtex->mapto & (MAP_NORM|MAP_DISPLACE)) { + if(mtex->mapto & (MAP_NORM|MAP_DISPLACE|MAP_WARP)) { tex->nor= norvec; norvec[0]= norvec[1]= norvec[2]= 0.0; } else tex->nor= NULL; - + + if(warpdone) { + VECADD(tempvec, co, warpvec); + co= tempvec; + } + if(tex->type==TEX_IMAGE) { /* new: first swap coords, then map, then trans/scale */ @@ -1512,6 +1517,14 @@ void do_material_tex(ShadeInput *shi) tex->nor[2]= f2*co-f1*si; } } + // warping, local space + if(mtex->mapto & MAP_WARP) { + warpvec[0]= mtex->warpfac*tex->nor[0]; + warpvec[1]= mtex->warpfac*tex->nor[1]; + warpvec[2]= mtex->warpfac*tex->nor[2]; + warpdone= 1; + } + // rotate to global coords if(mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) { if(shi->vlr && shi->vlr->ob) { diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index f14269cd1b4..a2d7da34c2e 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -2622,7 +2622,10 @@ static void material_panel_map_to(Material *ma) uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 155,80,155,19, &(mtex->norfac), 0.0, 25.0, 0, 0, "Sets the amount the texture affects normal values"); uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 155,60,155,19, &(mtex->varfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects other values"); uiDefButF(block, NUMSLI, B_MATPRV, "Disp ", 155,40,155,19, &(mtex->dispfac), 0.0, 1.0, 0, 0, "Sets the amount the texture displaces the surface"); - uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefButS(block, TOG|BIT|13, B_MATPRV, "Warp", 155,10,40,19, &(mtex->mapto), 0, 0, 0, 0, "Let the texture warp texture coordinates of next channels"); + uiDefButF(block, NUMSLI, B_MATPRV, "fac ", 195,10,115,19, &(mtex->warpfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects texture coordinates of next channels"); } |