- Separates displace from Var slider. Added Disp Slider to
control how the intensity channel affects displacement. Nor slider still controls how Nor channel affects displacement. - Scaled Nor displacement to make Nor slider more usable. - Removed Data scale from displacement routines. Made sliders unusable for objects scaled in editmode. Displacement now relative to unit sized object. Displace still tracks with object scale, so scale out of editmode if you want a large object with deep displacement.
This commit is contained in:
parent
39714fe42c
commit
52e5a15bab
|
@ -58,6 +58,8 @@ typedef struct MTex {
|
|||
float def_var;
|
||||
|
||||
float colfac, norfac, varfac;
|
||||
float dispfac;
|
||||
short pad1, pad2;
|
||||
|
||||
} MTex;
|
||||
|
||||
|
|
|
@ -1219,9 +1219,9 @@ void do_material_tex(ShadeInput *shi)
|
|||
if(mtex->maptoneg & MAP_DISPLACE) tex->norfac= -mtex->norfac;
|
||||
else tex->norfac= mtex->norfac;
|
||||
|
||||
shi->displace[0]+= Tnor*tex->norfac*tex->nor[0];
|
||||
shi->displace[1]+= Tnor*tex->norfac*tex->nor[1];
|
||||
shi->displace[2]+= Tnor*tex->norfac*tex->nor[2];
|
||||
shi->displace[0]+= 0.1f*Tnor*tex->norfac*tex->nor[0];
|
||||
shi->displace[1]+= 0.1f*Tnor*tex->norfac*tex->nor[1];
|
||||
shi->displace[2]+= 0.1f*Tnor*tex->norfac*tex->nor[2];
|
||||
}
|
||||
|
||||
if(rgbnor & TEX_RGB) {
|
||||
|
@ -1230,10 +1230,10 @@ void do_material_tex(ShadeInput *shi)
|
|||
}
|
||||
|
||||
if(mtex->maptoneg & MAP_DISPLACE) {
|
||||
factt= (0.5-Tin)*mtex->varfac; facmm= 1.0-factt;
|
||||
factt= (0.5-Tin)*mtex->dispfac; facmm= 1.0-factt;
|
||||
}
|
||||
else {
|
||||
factt= (Tin-0.5)*mtex->varfac; facmm= 1.0-factt;
|
||||
factt= (Tin-0.5)*mtex->dispfac; facmm= 1.0-factt;
|
||||
}
|
||||
|
||||
if(mtex->blendtype==MTEX_BLEND) {
|
||||
|
|
|
@ -3031,42 +3031,8 @@ void do_displacement(Object *ob, int startface, int numface, int startvert, int
|
|||
float min[3]={1e30, 1e30, 1e30}, max[3]={-1e30, -1e30, -1e30};
|
||||
float scale[3]={1.0f, 1.0f, 1.0f}, temp[3], xn;
|
||||
int i, texflag=0, flipnorm;
|
||||
BoundBox *bb;
|
||||
Mesh *me;
|
||||
Curve *cu;
|
||||
MetaBall *mb;
|
||||
Object *obt;
|
||||
|
||||
/* Calculate Texture space scale factor */
|
||||
if (ob->type == OB_MESH) {
|
||||
me=(Mesh *)(ob->data);
|
||||
if (me->bb == NULL) tex_space_mesh(me);
|
||||
bb=me->bb;
|
||||
texflag=me->texflag;
|
||||
}
|
||||
else if ((ob->type == OB_CURVE)||(ob->type == OB_SURF)||(ob->type == OB_FONT)) {
|
||||
cu=(Curve *)(ob->data);
|
||||
if (cu->bb == NULL) tex_space_curve(cu);
|
||||
bb=cu->bb;
|
||||
texflag=cu->texflag;
|
||||
}
|
||||
else if (ob->type == OB_MBALL) { /* Metaballs have bb but don't seem to use it */
|
||||
mb=(MetaBall *)(ob->data);
|
||||
if (ob->bb == NULL) ob=find_basis_mball(ob);
|
||||
if (ob->bb == NULL) tex_space_mball(ob);
|
||||
bb=ob->bb;
|
||||
texflag=mb->texflag;
|
||||
}
|
||||
else bb=ob->bb; /* Need to test? */
|
||||
|
||||
/* Relative scale of Data We reat amount of displacement */
|
||||
/* the same as other texture coords. Scale with data id AutoTexSpace is on. */
|
||||
if ( texflag & 1) { /* Bit 0 = Autotex */
|
||||
for(i=0; i<8; i++){ DO_MINMAX(bb->vec[i], min, max); }
|
||||
VecSubf(scale, max, min);
|
||||
printf("data scale=%f, %f, %f\n", scale[0], scale[1], scale[2]);
|
||||
}
|
||||
|
||||
|
||||
/* Object Size with parenting */
|
||||
obt=ob;
|
||||
while(obt){
|
||||
|
@ -3216,9 +3182,9 @@ void displace_render_vert(ShadeInput *shi, VertRen *vr, float *scale)
|
|||
//vr->co[0], vr->co[1], vr->co[2]);
|
||||
|
||||
/* 0.5 could become button once? */
|
||||
vr->co[0] += 0.25 * shi->displace[0] * scale[0] ;
|
||||
vr->co[1] += 0.25 * shi->displace[1] * scale[1] ;
|
||||
vr->co[2] += 0.25 * shi->displace[2] * scale[2] ;
|
||||
vr->co[0] += shi->displace[0] * scale[0] ;
|
||||
vr->co[1] += shi->displace[1] * scale[1] ;
|
||||
vr->co[2] += shi->displace[2] * scale[2] ;
|
||||
|
||||
//printf("after co=%f, %f, %f\n", vr->co[0], vr->co[1], vr->co[2]);
|
||||
|
||||
|
|
|
@ -1441,10 +1441,10 @@ static void world_panel_mapto(World *wrld)
|
|||
uiDefButS(block, ROW, B_MATPRV, "Add", 1182,130,41,19, &(mtex->blendtype), 9.0, (float)MTEX_ADD, 0, 0, "Sets texture to add the values or colour");
|
||||
uiDefButS(block, ROW, B_MATPRV, "Sub", 1226,130,40,19, &(mtex->blendtype), 9.0, (float)MTEX_SUB, 0, 0, "Sets texture to subtract the values or colour");
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 1087,50,179,19, &(mtex->colfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects colour values");
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 1087,30,179,19, &(mtex->norfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects normal values");
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 1087,10,179,19, &(mtex->varfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects other values");
|
||||
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 1087,50,179,19, &(mtex->colfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects colour values");
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 1087,30,179,19, &(mtex->norfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects normal values");
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 1087,10,179,19, &(mtex->varfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects other values");
|
||||
|
||||
}
|
||||
|
||||
static void world_panel_texture(World *wrld)
|
||||
|
@ -2137,9 +2137,10 @@ static void material_panel_map_to(Material *ma)
|
|||
uiDefButS(block, ROW, B_MATPRV, "Add", 1182,120,41,18, &(mtex->blendtype), 9.0, (float)MTEX_ADD, 0, 0, "Sets texture to add the values or colour");
|
||||
uiDefButS(block, ROW, B_MATPRV, "Sub", 1226,120,40,18, &(mtex->blendtype), 9.0, (float)MTEX_SUB, 0, 0, "Sets texture to subtract the values or colour");
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 1087,50,179,18, &(mtex->colfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects colour values");
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 1087,30,179,18, &(mtex->norfac), 0.0, 5.0, 0, 0, "Sets the amount the texture affects normal values");
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 1087,10,179,18, &(mtex->varfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects other values");
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Col ", 1087,70,179,18, &(mtex->colfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects colour values");
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Nor ", 1087,50,179,18, &(mtex->norfac), 0.0, 5.0, 0, 0, "Sets the amount the texture affects normal values");
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Var ", 1087,30,179,18, &(mtex->varfac), 0.0, 1.0, 0, 0, "Sets the amount the texture affects other values");
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "Disp ", 1087,10,179,19, &(mtex->dispfac), 0.0, 1.0, 0, 0, "Sets the amount the texture displaces the surface");
|
||||
uiBlockEndAlign(block);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue